75 lines
2.8 KiB
C#
75 lines
2.8 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 DashColorMode = Celeste.Mod.AvaliSkin.AvaliSkinSettings.DashColorMode;
|
|
using SendReceive = Celeste.Mod.AvaliSkin.AvaliSkinSettings.SendReceive;
|
|
|
|
|
|
namespace Celeste.Mod.AvaliSkin {
|
|
public class AvaliConfig {
|
|
private static AvaliSkinSettings Settings => AvaliSkinModule.Settings;
|
|
|
|
public bool Enabled;
|
|
public DashColorMode DashColorMode;
|
|
public List<Color> DashColors = new List<Color>();
|
|
public Color LightBody;
|
|
public Color DarkBody;
|
|
|
|
|
|
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.DashColorMode) {
|
|
case DashColorMode.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 {
|
|
Logger.Log(LogLevel.Warn, "AvaliSkin", $"Player hair is missing!");
|
|
|
|
// If the player does have no hair, then just default to
|
|
// whatever preset... this only happens momentarily anyways
|
|
return this.DashColors[Math.Min(dashes, this.DashColors.Count - 1)];
|
|
}
|
|
|
|
case DashColorMode.ManualRGB: default:
|
|
return this.DashColors[Math.Min(dashes, this.DashColors.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);
|
|
}
|
|
}
|
|
}
|
|
}
|