Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -4,10 +4,8 @@ using Content.Server.Body.Systems;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.Magic.Components;
|
||||
using Content.Server.Magic.Events;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Coordinates.Helpers;
|
||||
using Content.Shared.DoAfter;
|
||||
@@ -15,6 +13,7 @@ using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Magic;
|
||||
using Content.Shared.Magic.Events;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Spawners.Components;
|
||||
@@ -22,11 +21,8 @@ using Content.Shared.Storage;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Manager.Exceptions;
|
||||
|
||||
namespace Content.Server.Magic;
|
||||
|
||||
@@ -38,7 +34,6 @@ public sealed class MagicSystem : EntitySystem
|
||||
[Dependency] private readonly ISerializationManager _seriMan = default!;
|
||||
[Dependency] private readonly IComponentFactory _compFact = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly DoorBoltSystem _boltsSystem = default!;
|
||||
[Dependency] private readonly BodySystem _bodySystem = default!;
|
||||
@@ -81,23 +76,9 @@ public sealed class MagicSystem : EntitySystem
|
||||
private void OnInit(EntityUid uid, SpellbookComponent component, ComponentInit args)
|
||||
{
|
||||
//Negative charges means the spell can be used without it running out.
|
||||
foreach (var (id, charges) in component.WorldSpells)
|
||||
foreach (var (id, charges) in component.SpellActions)
|
||||
{
|
||||
var spell = new WorldTargetAction(_prototypeManager.Index<WorldTargetActionPrototype>(id));
|
||||
_actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
|
||||
component.Spells.Add(spell);
|
||||
}
|
||||
|
||||
foreach (var (id, charges) in component.InstantSpells)
|
||||
{
|
||||
var spell = new InstantAction(_prototypeManager.Index<InstantActionPrototype>(id));
|
||||
_actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
|
||||
component.Spells.Add(spell);
|
||||
}
|
||||
|
||||
foreach (var (id, charges) in component.EntitySpells)
|
||||
{
|
||||
var spell = new EntityTargetAction(_prototypeManager.Index<EntityTargetActionPrototype>(id));
|
||||
var spell = Spawn(id);
|
||||
_actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
|
||||
component.Spells.Add(spell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user