Add Snails (#30765)
* add snails * scuffix * migrate * mo-grate * oopsied the ftls * Revert "oopsied the ftls" This reverts commit 0d3c6c17f31ec904679d6a48799cea71e77c1f99. * the curse of staging the wrong file, resolved. * Snoth * fix my dumbs * reviews 1 * anti space technology * salt hurty * spelling * Its a slotherhouse out here * sequencing * cooked snail * volfix * speed reversal
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Mobs.Components;
|
||||
|
||||
namespace Content.Shared.Mobs.Systems;
|
||||
@@ -14,9 +14,26 @@ public sealed class MobStateActionsSystem : EntitySystem
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<MobStateActionsComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
SubscribeLocalEvent<MobStateComponent, ComponentInit>(OnMobStateComponentInit);
|
||||
}
|
||||
|
||||
private void OnMobStateChanged(EntityUid uid, MobStateActionsComponent component, MobStateChangedEvent args)
|
||||
{
|
||||
ComposeActions(uid, component, args.NewMobState);
|
||||
}
|
||||
|
||||
private void OnMobStateComponentInit(EntityUid uid, MobStateComponent component, ComponentInit args)
|
||||
{
|
||||
if (!TryComp<MobStateActionsComponent>(uid, out var mobStateActionsComp))
|
||||
return;
|
||||
|
||||
ComposeActions(uid, mobStateActionsComp, component.CurrentState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds or removes actions from a mob based on mobstate.
|
||||
/// </summary>
|
||||
private void ComposeActions(EntityUid uid, MobStateActionsComponent component, MobState newMobState)
|
||||
{
|
||||
if (!TryComp<ActionsComponent>(uid, out var action))
|
||||
return;
|
||||
@@ -27,7 +44,7 @@ public sealed class MobStateActionsSystem : EntitySystem
|
||||
}
|
||||
component.GrantedActions.Clear();
|
||||
|
||||
if (!component.Actions.TryGetValue(args.NewMobState, out var toGrant))
|
||||
if (!component.Actions.TryGetValue(newMobState, out var toGrant))
|
||||
return;
|
||||
|
||||
foreach (var id in toGrant)
|
||||
|
||||
Reference in New Issue
Block a user