using CustomPlayerEffects; using LabApi.Features.Wrappers; using Mirror; using PlayerRoles.FirstPersonControl; using UnityEngine; using UnityEngine.SceneManagement; using Logger = LabApi.Features.Console.Logger; using Random = System.Random; namespace CustomClasses; public abstract class CustomPlayerEffect : StatusEffectBase { private static bool _isLoaded; public Player Owner { get; private set; } = null!; protected override void Start() { Owner = Player.Get(Hub); base.Start(); } public override string ToString() => $"{GetType().Name}: Owner ({Owner}) - Intensity ({Intensity}) - Duration {Duration}"; internal static void Initialize() { SceneManager.sceneLoaded += (_, _) => { if (_isLoaded) return; _isLoaded = true; var playerEffects = NetworkManager.singleton.playerPrefab.GetComponent().playerEffectsController.effectsGameObject.transform; var type = typeof(DisableStaminaRegenEffect); if (!typeof(StatusEffectBase).IsAssignableFrom(type)) { Logger.Error($"[CustomPlayerEffect.Initialize] {type.FullName} is not a valid StatusEffectBase and thus could not be registered!"); return; } // register effect into prefab new GameObject(type.Name, type).transform.parent = playerEffects; }; } } public class DisableStaminaRegenEffect : CustomPlayerEffect, IStaminaModifier { public bool StaminaModifierActive => IsEnabled; public float StaminaUsageMultiplier => 1; public float StaminaRegenMultiplier => 0; public bool SprintingDisabled => false; public override EffectClassification Classification => EffectClassification.Negative; } public class BloodFueledManager { private readonly CustomClasses _plugin; public static bool IsBloodFueled(Player player) => player.CustomInfo.Contains("Blood Fueled"); public BloodFueledManager(CustomClasses plugin) { _plugin = plugin; } } public class BloodFueledHandler : CustomClassHandler { public override void HandleSpawn(Player player, CustomClassConfig config, Random random) { player.SendBroadcast("You are the Blood Fueled!", CustomClasses.BroadcastDuration); const string customInfo = "Blood Fueled"; if (!Player.ValidateCustomInfo(customInfo, out var reason)) { Logger.Error($"Invalid custom info for Blood Fueled: {reason}"); } else { player.CustomInfo = customInfo; player.InfoArea |= PlayerInfoArea.CustomInfo; } player.MaxHumeShield = 0; player.HumeShield = 0; player.MaxHealth = 3500; player.Health = 3500; player.EnableEffect(1, float.PositiveInfinity); } }