45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using CustomPlayerEffects;
|
|
using LabApi.Features.Wrappers;
|
|
using Mirror;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using Logger = LabApi.Features.Console.Logger;
|
|
|
|
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<ReferenceHub>().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;
|
|
};
|
|
}
|
|
} |