From: js6pak Date: Fri, 24 Nov 2023 17:35:33 +0000 (+0100) Subject: Implement MushroomMixupSabotage X-Git-Tag: v1.9.0~9 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=c6121eed498c34d38ba6ccc3a167946bb21a4430;p=rhonda%2Fimpostor.git Implement MushroomMixupSabotage --- diff --git a/src/Impostor.Api/Innersloth/Customization/PlayerOutfitType.cs b/src/Impostor.Api/Innersloth/Customization/PlayerOutfitType.cs index 55ba04c..17ed351 100644 --- a/src/Impostor.Api/Innersloth/Customization/PlayerOutfitType.cs +++ b/src/Impostor.Api/Innersloth/Customization/PlayerOutfitType.cs @@ -4,5 +4,7 @@ namespace Impostor.Api.Innersloth.Customization { Default, Shapeshifted, + HorseWrangler, + MushroomMixup, } } diff --git a/src/Impostor.Server/Net/Inner/Objects/ShipStatus/InnerFungleShipStatus.cs b/src/Impostor.Server/Net/Inner/Objects/ShipStatus/InnerFungleShipStatus.cs index a868d7c..571bb63 100644 --- a/src/Impostor.Server/Net/Inner/Objects/ShipStatus/InnerFungleShipStatus.cs +++ b/src/Impostor.Server/Net/Inner/Objects/ShipStatus/InnerFungleShipStatus.cs @@ -20,7 +20,7 @@ namespace Impostor.Server.Net.Inner.Objects.ShipStatus systems.Add(SystemTypes.Comms, new HudOverrideSystemType()); systems.Add(SystemTypes.Reactor, new ReactorSystemType()); systems.Add(SystemTypes.Doors, new DoorsSystemType(Doors)); - // systems.Add(SystemTypes.MushroomMixupSabotage, ); + systems.Add(SystemTypes.MushroomMixupSabotage, new MushroomMixupSabotageSystemType()); } } } diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MushroomMixupSabotageSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MushroomMixupSabotageSystemType.cs new file mode 100644 index 0000000..0055608 --- /dev/null +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MushroomMixupSabotageSystemType.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; + +namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus; + +public class MushroomMixupSabotageSystemType : ISystemType +{ + private readonly Dictionary _currentMixups = new(); + private State _currentState; + private float _currentSecondsUntilHeal; + + private enum State + { + Inactive, + JustTriggered, + IdleButMixedUp, + } + + public void Serialize(IMessageWriter writer, bool initialState) + { + writer.Write((byte)_currentState); + writer.Write(_currentSecondsUntilHeal); + + writer.WritePacked(_currentMixups.Count); + foreach (var (playerId, outfit) in _currentMixups) + { + writer.Write(playerId); + outfit.Serialize(writer); + } + } + + public void Deserialize(IMessageReader reader, bool initialState) + { + _currentState = (State)reader.ReadByte(); + _currentSecondsUntilHeal = reader.ReadSingle(); + + _currentMixups.Clear(); + var num = reader.ReadByte(); + for (var i = 0; i < num; i++) + { + var playerId = reader.ReadByte(); + var outfit = CondensedOutfit.Deserialize(reader); + + _currentMixups.Add(playerId, outfit); + } + } + + private readonly record struct CondensedOutfit( + byte HatIndex, + byte VisorIndex, + byte SkinIndex, + byte PetIndex, + byte ColorPlayerId + ) + { + public void Serialize(IMessageWriter writer) + { + writer.Write(ColorPlayerId); + writer.Write(HatIndex); + writer.Write(VisorIndex); + writer.Write(SkinIndex); + writer.Write(PetIndex); + } + + public static CondensedOutfit Deserialize(IMessageReader reader) + { + return new CondensedOutfit + { + ColorPlayerId = reader.ReadByte(), + HatIndex = reader.ReadByte(), + VisorIndex = reader.ReadByte(), + SkinIndex = reader.ReadByte(), + PetIndex = reader.ReadByte(), + }; + } + } +}