|
| 1 | +using MiraAPI.GameOptions; |
| 2 | +using MiraAPI.Modifiers.Types; |
| 3 | +using MiraAPI.Utilities; |
| 4 | +using NewMod.Options.Modifiers; |
| 5 | +using UnityEngine; |
| 6 | + |
| 7 | +namespace NewMod.Modifiers |
| 8 | +{ |
| 9 | + public class FalseFormModifier : TimedModifier |
| 10 | + { |
| 11 | + public override string ModifierName => "FalseForm"; |
| 12 | + public override bool AutoStart => |
| 13 | + OptionGroupSingleton<FalseFormModifierOptions>.Instance.EnableModifier; |
| 14 | + public override float Duration => |
| 15 | + (int)OptionGroupSingleton<FalseFormModifierOptions>.Instance.FalseFormDuration; |
| 16 | + public override bool ShowInFreeplay => true; |
| 17 | + public override bool HideOnUi => false; |
| 18 | + public override bool RemoveOnComplete => true; |
| 19 | + private float timer; |
| 20 | + private AppearanceBackup oldAppearance; |
| 21 | + public override void OnActivate() |
| 22 | + { |
| 23 | + oldAppearance = new AppearanceBackup |
| 24 | + { |
| 25 | + PlayerName = Player.Data.PlayerName, |
| 26 | + HatId = Player.Data.DefaultOutfit.HatId, |
| 27 | + SkinId = Player.Data.DefaultOutfit.SkinId, |
| 28 | + PetId = Player.Data.DefaultOutfit.PetId, |
| 29 | + ColorId = Player.Data.DefaultOutfit.ColorId |
| 30 | + }; |
| 31 | + } |
| 32 | + public override bool? CanVent() |
| 33 | + { |
| 34 | + return Player.Data.Role.CanVent; |
| 35 | + } |
| 36 | + public override string GetDescription() |
| 37 | + { |
| 38 | + return ModifierName |
| 39 | + + $"\nYour appearance changes every {OptionGroupSingleton<FalseFormModifierOptions>.Instance.FalseFormAppearanceTimer.Value} seconds."; |
| 40 | + } |
| 41 | + |
| 42 | + public override void FixedUpdate() |
| 43 | + { |
| 44 | + base.FixedUpdate(); |
| 45 | + |
| 46 | + timer += Time.fixedDeltaTime; |
| 47 | + |
| 48 | + if (timer >= OptionGroupSingleton<FalseFormModifierOptions>.Instance.FalseFormAppearanceTimer.Value) |
| 49 | + { |
| 50 | + Player.RpcSetName(Helpers.RandomString(5)); |
| 51 | + Player.RpcSetColor((byte)Random.Range(0, Palette.PlayerColors.Count)); |
| 52 | + Player.RpcSetHat(HatManager.Instance.AllHats[Random.Range(0, HatManager.Instance.allHats.Count)].ProductId); |
| 53 | + Player.RpcSetSkin(HatManager.Instance.AllSkins[Random.Range(0, HatManager.Instance.allSkins.Count)].ProductId); |
| 54 | + Player.RpcSetPet(HatManager.Instance.AllPets[Random.Range(0, HatManager.Instance.allPets.Count)].ProductId); |
| 55 | + } |
| 56 | + } |
| 57 | + public override void OnDeactivate() |
| 58 | + { |
| 59 | + if (OptionGroupSingleton<FalseFormModifierOptions>.Instance.RevertAppearance) |
| 60 | + { |
| 61 | + Player.RpcSetName(oldAppearance.PlayerName); |
| 62 | + Player.RpcSetColor((byte)oldAppearance.ColorId); |
| 63 | + Player.RpcSetHat(oldAppearance.HatId); |
| 64 | + Player.RpcSetSkin(oldAppearance.SkinId); |
| 65 | + Player.RpcSetPet(oldAppearance.PetId); |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + class AppearanceBackup |
| 70 | + { |
| 71 | + public string PlayerName; |
| 72 | + public string HatId, SkinId, PetId; |
| 73 | + public int ColorId; |
| 74 | + } |
| 75 | +} |
0 commit comments