action refactor proper ecs edition (#27422)

This commit is contained in:
deltanedas
2025-05-28 19:52:11 +00:00
committed by GitHub
parent a9f7cfbcb6
commit b3825dce97
111 changed files with 1995 additions and 2901 deletions

View File

@@ -4,6 +4,7 @@ using Content.Server.Inventory;
using Content.Server.Mind.Commands;
using Content.Server.Polymorph.Components;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Content.Shared.Buckle;
using Content.Shared.Coordinates;
using Content.Shared.Damage;
@@ -111,8 +112,8 @@ public sealed partial class PolymorphSystem : EntitySystem
if (_actions.AddAction(uid, ref component.Action, out var action, RevertPolymorphId))
{
action.EntityIcon = component.Parent;
action.UseDelay = TimeSpan.FromSeconds(component.Configuration.Delay);
_actions.SetEntityIcon((component.Action.Value, action), component.Parent);
_actions.SetUseDelay(component.Action.Value, TimeSpan.FromSeconds(component.Configuration.Delay));
}
}
@@ -397,20 +398,19 @@ public sealed partial class PolymorphSystem : EntitySystem
_metaData.SetEntityName(actionId.Value, Loc.GetString("polymorph-self-action-name", ("target", entProto.Name)), metaDataCache);
_metaData.SetEntityDescription(actionId.Value, Loc.GetString("polymorph-self-action-description", ("target", entProto.Name)), metaDataCache);
if (!_actions.TryGetActionData(actionId, out var baseAction))
if (_actions.GetAction(actionId) is not {} action)
return;
baseAction.Icon = new SpriteSpecifier.EntityPrototype(polyProto.Configuration.Entity);
if (baseAction is InstantActionComponent action)
action.Event = new PolymorphActionEvent(id);
_actions.SetIcon((action, action.Comp), new SpriteSpecifier.EntityPrototype(polyProto.Configuration.Entity));
_actions.SetEvent(action, new PolymorphActionEvent(id));
}
public void RemovePolymorphAction(ProtoId<PolymorphPrototype> id, Entity<PolymorphableComponent> target)
{
if (target.Comp.PolymorphActions == null)
if (target.Comp.PolymorphActions is not {} actions)
return;
if (target.Comp.PolymorphActions.TryGetValue(id, out var val))
_actions.RemoveAction(target, val);
if (actions.TryGetValue(id, out var action))
_actions.RemoveAction(target.Owner, action);
}
}