79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Celeste.Mod.CelesteNet.Client;
|
|
using Celeste.Mod.CelesteNet.Client.Entities;
|
|
using Celeste.Mod.CelesteNet.DataTypes;
|
|
|
|
using ColorChoice = Celeste.Mod.AvaliSkin.AvaliSkinSettings.ColorChoice;
|
|
using ColorMode = Celeste.Mod.AvaliSkin.AvaliSkinSettings.ColorMode;
|
|
using SendReceive = Celeste.Mod.AvaliSkin.AvaliSkinSettings.SendReceive;
|
|
|
|
|
|
namespace Celeste.Mod.AvaliSkin {
|
|
public class AvaliConfig {
|
|
private static AvaliSkinSettings Settings => AvaliSkinModule.Settings;
|
|
|
|
public bool Enabled;
|
|
public ColorMode ColorMode;
|
|
public List<ColorChoice> ManualPreset = new List<ColorChoice>();
|
|
public List<Color> ManualRGB = new List<Color>();
|
|
|
|
|
|
public bool IsEnabled(Player player) {
|
|
return Enabled;
|
|
}
|
|
|
|
public bool IsEnabled(Ghost ghost) {
|
|
return Settings.EnableCelesteNet
|
|
&& (
|
|
(Enabled && (
|
|
Settings.CelesteNetSync == SendReceive.SendReceive
|
|
|| Settings.CelesteNetSync == SendReceive.Receive
|
|
))
|
|
|| Settings.CelesteNetEveryoneHasSkin
|
|
);
|
|
}
|
|
|
|
// Check sprite.Scene != null && sprite.Entity != null && sprite.Entity is Player player
|
|
// before calling this
|
|
public Color GetColor(Player player) {
|
|
int dashes = player.Dashes;
|
|
switch (this.ColorMode) {
|
|
case ColorMode.ExternalDash:
|
|
// Infrequently, it's possible for the player to momentarily have no hair.
|
|
if (player.Hair != null && player.Sprite.HairCount > 0) {
|
|
return player.Hair.GetHairColor(0);
|
|
} else {
|
|
// If the player does have no hair, then just default to
|
|
// whatever preset... this only happens momentarily anyways
|
|
return ColorUtil.SettingToColor(
|
|
ManualPreset[Math.Min(dashes, ManualPreset.Count - 1)]
|
|
);
|
|
}
|
|
|
|
case ColorMode.ManualRGB:
|
|
return ManualRGB[Math.Min(dashes, ManualRGB.Count - 1)];
|
|
|
|
case ColorMode.ManualPreset: default:
|
|
return ColorUtil.SettingToColor(
|
|
ManualPreset[Math.Min(dashes, ManualPreset.Count - 1)]
|
|
);
|
|
}
|
|
}
|
|
|
|
// Check sprite.Scene != null && sprite.Entity != null && sprite.Entity is Ghost
|
|
// before calling this
|
|
public Color GetColor(Ghost ghost) {
|
|
// Infrequently, it's possible for the ghost to momentarily have no hair.
|
|
if (ghost.Hair != null && ghost.Sprite.HairCount > 0) {
|
|
return ghost.Hair.GetHairColor(0);
|
|
} else {
|
|
// todo: wtf???
|
|
return new Color(0, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|