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:
@@ -25,8 +25,6 @@ public partial class MobStateSystem : EntitySystem
|
||||
_sawmill = _logManager.GetSawmill("MobState");
|
||||
base.Initialize();
|
||||
SubscribeEvents();
|
||||
SubscribeLocalEvent<MobStateComponent, ComponentGetState>(OnGetComponentState);
|
||||
SubscribeLocalEvent<MobStateComponent, ComponentHandleState>(OnHandleComponentState);
|
||||
}
|
||||
|
||||
#region Public API
|
||||
@@ -100,24 +98,5 @@ public partial class MobStateSystem : EntitySystem
|
||||
|
||||
#region Private Implementation
|
||||
|
||||
private void OnHandleComponentState(EntityUid uid, MobStateComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not MobStateComponentState state)
|
||||
return;
|
||||
|
||||
component.CurrentState = state.CurrentState;
|
||||
|
||||
if (!component.AllowedStates.SetEquals(state.AllowedStates))
|
||||
{
|
||||
component.AllowedStates.Clear();
|
||||
component.AllowedStates.UnionWith(state.AllowedStates);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetComponentState(EntityUid uid, MobStateComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new MobStateComponentState(component.CurrentState, component.AllowedStates);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user