WIP refactor v3
This commit is contained in:
parent
ccaf44d50b
commit
43f66370f3
@ -1,5 +1,4 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.Remoting.Messaging;
|
|
||||||
using CustomPlayerEffects;
|
using CustomPlayerEffects;
|
||||||
using HintServiceMeow.Core.Models.Hints;
|
using HintServiceMeow.Core.Models.Hints;
|
||||||
using Interactables.Interobjects.DoorUtils;
|
using Interactables.Interobjects.DoorUtils;
|
||||||
@ -418,22 +417,13 @@ public class NegromancerShadowHandler : CustomClassHandler
|
|||||||
{
|
{
|
||||||
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
||||||
{
|
{
|
||||||
|
base.HandleSpawn(player,config,random);
|
||||||
|
|
||||||
player.MaxHealth = 1000;
|
player.MaxHealth = 1000;
|
||||||
player.MaxHumeShield = 0;
|
player.MaxHumeShield = 0;
|
||||||
player.HumeShield = 0;
|
player.HumeShield = 0;
|
||||||
|
|
||||||
player.EnableEffect<MovementBoost>(10, float.PositiveInfinity);
|
player.EnableEffect<MovementBoost>(10, float.PositiveInfinity);
|
||||||
|
|
||||||
const string customInfo = "<color=#A0A0A0>Shadow</color>";
|
|
||||||
if (!Player.ValidateCustomInfo(customInfo, out var reason))
|
|
||||||
{
|
|
||||||
Logger.Error($"Invalid custom info for Shadow: {reason}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.CustomInfo = customInfo;
|
|
||||||
player.InfoArea |= PlayerInfoArea.CustomInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,12 +443,32 @@ public interface ICustomClassHandler
|
|||||||
|
|
||||||
public abstract class CustomClassHandler: ICustomClassHandler
|
public abstract class CustomClassHandler: ICustomClassHandler
|
||||||
{
|
{
|
||||||
public abstract void HandleSpawn(Player player, CustomClassConfig config, Random random);
|
public virtual void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
||||||
|
{
|
||||||
|
var info = config.FullCustomInfo;
|
||||||
|
|
||||||
public virtual void HandleEscape(Player player, CustomClassConfig config)
|
if (!Player.ValidateCustomInfo(info, out var reason))
|
||||||
|
{
|
||||||
|
Logger.Error($"[{GetType().Name}] Invalid custom info: {reason}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.CustomInfo = info;
|
||||||
|
player.InfoArea |= PlayerInfoArea.CustomInfo;
|
||||||
|
|
||||||
|
SendSpawnMessage(player, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void HandleEscape(Player player, CustomClassConfig config)
|
||||||
{
|
{
|
||||||
//Intentionally left blank
|
//Intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void SendSpawnMessage(Player player, CustomClassConfig config)
|
||||||
|
{
|
||||||
|
if (config.Name.IsEmpty()) return;
|
||||||
|
player.SendBroadcast($"You are a {config.FullCustomInfo}!", CustomClasses.BroadcastDuration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum JanitorSpawn
|
public enum JanitorSpawn
|
||||||
@ -617,7 +627,7 @@ public class ShadowStepperHandler : CustomClassHandler
|
|||||||
player.SendBroadcast("You're a <color=#000000>ShadowStepper</color>!", CustomClasses.BroadcastDuration);
|
player.SendBroadcast("You're a <color=#000000>ShadowStepper</color>!", CustomClasses.BroadcastDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleEscape(Player player, CustomClassConfig config)
|
protected override void HandleEscape(Player player, CustomClassConfig config)
|
||||||
{
|
{
|
||||||
base.HandleEscape(player, config);
|
base.HandleEscape(player, config);
|
||||||
|
|
||||||
@ -638,6 +648,7 @@ public abstract class SimpleAddItemHandler : CustomClassHandler
|
|||||||
{
|
{
|
||||||
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
||||||
{
|
{
|
||||||
|
base.HandleSpawn(player,config,random);
|
||||||
foreach (var spawnItem in config.Items)
|
foreach (var spawnItem in config.Items)
|
||||||
{
|
{
|
||||||
player.AddItem(spawnItem, ItemAddReason.StartingItem);
|
player.AddItem(spawnItem, ItemAddReason.StartingItem);
|
||||||
@ -842,6 +853,11 @@ public abstract class CustomClassConfig
|
|||||||
/// The required role for this class to be considered.
|
/// The required role for this class to be considered.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual RoleTypeId RequiredRole { get; set; } = RoleTypeId.ClassD;
|
public virtual RoleTypeId RequiredRole { get; set; } = RoleTypeId.ClassD;
|
||||||
|
|
||||||
|
public virtual string Name { get; init; } = string.Empty;
|
||||||
|
public virtual string Color { get; init; } = "#FFFFFF";
|
||||||
|
|
||||||
|
public string FullCustomInfo => $"<color={Color}>{Name}</color>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -932,9 +948,9 @@ public sealed class FlashMasterConfig : CustomClassConfig
|
|||||||
public sealed class NegromancerConfig : CustomClassConfig
|
public sealed class NegromancerConfig : CustomClassConfig
|
||||||
{
|
{
|
||||||
public override double ChancePerPlayer { get; set; } = 0.0;
|
public override double ChancePerPlayer { get; set; } = 0.0;
|
||||||
public override int MaxSpawns { get; set; } = 1;
|
|
||||||
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Scp049;
|
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Scp049;
|
||||||
public override ItemType[] Items { get; set; } = [];
|
public override string Name { get; init; } = "Shadowmancer";
|
||||||
|
public override string Color { get; init; } = "#A0A0A0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class NegromancerShadowConfig : CustomClassConfig
|
public sealed class NegromancerShadowConfig : CustomClassConfig
|
||||||
@ -942,7 +958,8 @@ public sealed class NegromancerShadowConfig : CustomClassConfig
|
|||||||
public override double ChancePerPlayer { get; set; } = 0.0;
|
public override double ChancePerPlayer { get; set; } = 0.0;
|
||||||
public override int MaxSpawns { get; set; } = int.MaxValue;
|
public override int MaxSpawns { get; set; } = int.MaxValue;
|
||||||
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Scp106;
|
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Scp106;
|
||||||
public override ItemType[] Items { get; set; } = [];
|
public override string Name { get; init; } = "Shadow";
|
||||||
|
public override string Color { get; init; } = "#A0A0A0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class BloodFueledConfig : CustomClassConfig
|
public sealed class BloodFueledConfig : CustomClassConfig
|
||||||
@ -950,7 +967,6 @@ public sealed class BloodFueledConfig : CustomClassConfig
|
|||||||
public override double ChancePerPlayer { get; set; } = 1.0;
|
public override double ChancePerPlayer { get; set; } = 1.0;
|
||||||
public override int MaxSpawns { get; set; } = int.MaxValue;
|
public override int MaxSpawns { get; set; } = int.MaxValue;
|
||||||
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Scp939;
|
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Scp939;
|
||||||
public override ItemType[] Items { get; set; } = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -12,19 +12,9 @@ namespace CustomClasses;
|
|||||||
|
|
||||||
public class NegromancerHandler : CustomClassHandler
|
public class NegromancerHandler : CustomClassHandler
|
||||||
{
|
{
|
||||||
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
protected override void SendSpawnMessage(Player player, CustomClassConfig config)
|
||||||
{
|
{
|
||||||
player.SendBroadcast("You are the <color=#6e2e99>Negromancer</color>! Revived players become your <color=#3c1361>Shadow</color>.", CustomClasses.BroadcastDuration);
|
player.SendBroadcast("You are the <color=#6e2e99>Negromancer</color>! Revived players become your <color=#3c1361>Shadow</color>.", CustomClasses.BroadcastDuration);
|
||||||
const string customInfo = "<color=#A0A0A0>Shadowmancer</color>";
|
|
||||||
if (!Player.ValidateCustomInfo(customInfo, out var reason))
|
|
||||||
{
|
|
||||||
Logger.Error($"Invalid custom info for Negromancer: {reason}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.CustomInfo = customInfo;
|
|
||||||
player.InfoArea |= PlayerInfoArea.CustomInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ using LabApi.Events.Handlers;
|
|||||||
using LabApi.Features.Permissions;
|
using LabApi.Features.Permissions;
|
||||||
using LabApi.Features.Wrappers;
|
using LabApi.Features.Wrappers;
|
||||||
using MEC;
|
using MEC;
|
||||||
using Mirror;
|
|
||||||
using PlayerRoles;
|
using PlayerRoles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using LightSourceToy = LabApi.Features.Wrappers.LightSourceToy;
|
using LightSourceToy = LabApi.Features.Wrappers.LightSourceToy;
|
||||||
@ -110,16 +109,6 @@ public class SerpentsHandManager
|
|||||||
public static void PreSpawn(Player player)
|
public static void PreSpawn(Player player)
|
||||||
{
|
{
|
||||||
player.SetRole(RoleTypeId.Tutorial, RoleChangeReason.RespawnMiniwave, RoleSpawnFlags.None);
|
player.SetRole(RoleTypeId.Tutorial, RoleChangeReason.RespawnMiniwave, RoleSpawnFlags.None);
|
||||||
const string customInfo = "<color=#32CD32>SerpentsHand</color>";
|
|
||||||
if (!Player.ValidateCustomInfo(customInfo, out var reason))
|
|
||||||
{
|
|
||||||
Logger.Error($"Invalid custom info for Serpents Hand: {reason}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.CustomInfo = customInfo;
|
|
||||||
player.InfoArea |= PlayerInfoArea.CustomInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<float> UpdateSerpentsHandHint()
|
public IEnumerator<float> UpdateSerpentsHandHint()
|
||||||
@ -244,6 +233,8 @@ public sealed class SerpentsHandConfig : CustomClassConfig
|
|||||||
public const float BaseChance = 90f;
|
public const float BaseChance = 90f;
|
||||||
|
|
||||||
public readonly Vector3[] SpawnLocations = [new(0.22f, 300.96f, -0.31f), new(123.921f, 288.792f, 20.929f)];
|
public readonly Vector3[] SpawnLocations = [new(0.22f, 300.96f, -0.31f), new(123.921f, 288.792f, 20.929f)];
|
||||||
|
public override string Color { get; init; } = "#32CD32";
|
||||||
|
public override string Name { get; init; } = "Serpents Hand";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SerpentsHandHandler : SimpleAddItemHandler
|
public class SerpentsHandHandler : SimpleAddItemHandler
|
||||||
|
Loading…
x
Reference in New Issue
Block a user