Mobs auto state handlers (#26957)

* Autogenerate MobStateComponentState

* changed CurrentState to DataField, updated DataField attribute for AllowedStates

* Update Content.Shared/Mobs/Components/MobStateComponent.cs

* Update Content.Shared/Mobs/Components/MobStateComponent.cs

---------

Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Alfred Baumann
2024-04-17 12:00:05 +02:00
committed by GitHub
parent e2341c0089
commit 5b8468c9d8
2 changed files with 6 additions and 36 deletions

View File

@@ -13,30 +13,21 @@ namespace Content.Shared.Mobs.Components
/// </summary>
[RegisterComponent]
[NetworkedComponent]
[AutoGenerateComponentState]
[Access(typeof(MobStateSystem), typeof(MobThresholdSystem))]
public sealed partial class MobStateComponent : Component
{
//default mobstate is always the lowest state level
[ViewVariables] public MobState CurrentState { get; set; } = MobState.Alive;
[AutoNetworkedField, ViewVariables]
public MobState CurrentState { get; set; } = MobState.Alive;
[DataField("allowedStates")] public HashSet<MobState> AllowedStates = new()
[DataField]
[AutoNetworkedField]
public HashSet<MobState> AllowedStates = new()
{
MobState.Alive,
MobState.Critical,
MobState.Dead
};
}
[Serializable, NetSerializable]
public sealed class MobStateComponentState : ComponentState
{
public readonly MobState CurrentState;
public readonly HashSet<MobState> AllowedStates;
public MobStateComponentState(MobState currentState, HashSet<MobState> allowedStates)
{
CurrentState = currentState;
AllowedStates = allowedStates;
}
}
}