ВНИМАНИЕ!!! ОБНАРУЖЕНЫ УЛИТКИ!!! (#774)

This commit is contained in:
BIGZi0348
2024-11-11 09:54:23 +03:00
committed by Jabak
parent 0db0511a5e
commit e37a1758fc
31 changed files with 519 additions and 9 deletions

View File

@@ -14,9 +14,26 @@ public sealed class MobStateActionsSystem : EntitySystem
public override void Initialize()
{
SubscribeLocalEvent<MobStateActionsComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<MobStateComponent, ComponentInit>(OnMobStateComponentInit); // WD ahead of wizden
}
private void OnMobStateChanged(EntityUid uid, MobStateActionsComponent component, MobStateChangedEvent args)
{
ComposeActions(uid, component, args.NewMobState); // WD ahead of wizden
}
private void OnMobStateComponentInit(EntityUid uid, MobStateComponent component, ComponentInit args) // WD ahead of wizden
{
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) // WD ahead of wizden
{
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)