From dc853b6662cdb709e7031895fd9f461d1b113ea6 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Tue, 6 Aug 2024 00:42:53 +0300 Subject: [PATCH] SpawnSpell tweak (#393) * some refactor * Update flame_creation.yml --- .../MagicSpell/Spells/CP14SpellSpawnEntity.cs | 68 +++++++++++++++++++ .../Spells/CP14SpellSpawnEntityOnTarget.cs | 27 -------- .../Spells/CP14SpellSpawnEntityOnUser.cs | 21 ------ .../Entities/Actions/Spells/cure_wounds.yml | 6 +- .../Entities/Actions/Spells/earth_wall.yml | 6 +- .../Entities/Actions/Spells/fireball.yml | 3 +- .../Actions/Spells/flame_creation.yml | 3 +- .../Entities/Actions/Spells/ice_dagger.yml | 3 +- .../Entities/Actions/Spells/ice_floor.yml | 6 +- .../Entities/Actions/Spells/shadow_grab.yml | 11 ++- .../Entities/Actions/Spells/shadow_step.yml | 3 +- .../_CP14/Entities/Clothing/Rings/ring.yml | 4 +- 12 files changed, 98 insertions(+), 63 deletions(-) create mode 100644 Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntity.cs delete mode 100644 Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnTarget.cs delete mode 100644 Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnUser.cs diff --git a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntity.cs b/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntity.cs new file mode 100644 index 0000000000..b19cd48a41 --- /dev/null +++ b/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntity.cs @@ -0,0 +1,68 @@ +using Robust.Shared.Map; +using Robust.Shared.Prototypes; + +namespace Content.Shared._CP14.MagicSpell.Spells; + +public sealed partial class CP14SpellSpawnEntity : CP14SpellEffect +{ + [DataField] + public List Spawns = new(); + + [DataField] + public string Key = "target"; + + [DataField] + public bool TryParent = false; + + //Я сделал хуйню + public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args) + { + EntityCoordinates? targetPos = null; + EntityUid? targetEntity = null; + TransformComponent? transformComponent = null; + + var transform = entManager.System(); + switch (Key) + { + case "target": + targetPos = args.Position; + + if (args.Target is not null && entManager.TryGetComponent(args.Target, out transformComponent)) + { + targetPos = transformComponent.Coordinates; + targetEntity = args.Target; + } + + break; + case "user": + if (args.User is null || !entManager.TryGetComponent(args.User.Value, out transformComponent)) + return; + targetEntity = args.User; + targetPos = transformComponent.Coordinates; + break; + } + + + if (TryParent) + { + if (transformComponent is not null && targetEntity is not null) + { + foreach (var spawn in Spawns) + { + var s = entManager.SpawnAtPosition(spawn, transformComponent.Coordinates); + transform.SetParent(s, targetEntity.Value); + } + } + } + else + { + if (targetPos is not null) + { + foreach (var spawn in Spawns) + { + var s = entManager.SpawnAtPosition(spawn, targetPos.Value); + } + } + } + } +} diff --git a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnTarget.cs b/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnTarget.cs deleted file mode 100644 index 6545f85b7e..0000000000 --- a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnTarget.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Robust.Shared.Map; -using Robust.Shared.Prototypes; - -namespace Content.Shared._CP14.MagicSpell.Spells; - -public sealed partial class CP14SpellSpawnEntityOnTarget : CP14SpellEffect -{ - [DataField] - public List Spawns = new(); - - public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args) - { - EntityCoordinates? targetPoint = null; - if (args.Position is not null) - targetPoint = args.Position.Value; - else if (args.Target is not null && entManager.TryGetComponent(args.Target.Value, out var transformComponent)) - targetPoint = transformComponent.Coordinates; - - if (targetPoint is null) - return; - - foreach (var spawn in Spawns) - { - entManager.SpawnAtPosition(spawn, targetPoint.Value); - } - } -} diff --git a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnUser.cs b/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnUser.cs deleted file mode 100644 index 43b3cc34e5..0000000000 --- a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntityOnUser.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Robust.Shared.Map; -using Robust.Shared.Prototypes; - -namespace Content.Shared._CP14.MagicSpell.Spells; - -public sealed partial class CP14SpellSpawnEntityOnUser : CP14SpellEffect -{ - [DataField] - public List Spawns = new(); - - public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args) - { - if (args.User is null || !entManager.TryGetComponent(args.User.Value, out var transformComponent)) - return; - - foreach (var spawn in Spawns) - { - entManager.SpawnAtPosition(spawn, transformComponent.Coordinates); - } - } -} diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/cure_wounds.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/cure_wounds.yml index f48ebeb081..a8fe113df5 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/cure_wounds.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/cure_wounds.yml @@ -6,11 +6,13 @@ - type: CP14MagicEffect manaCost: 15 telegraphyEffects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectCureWounds effects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectCureWounds - !type:CP14SpellApplyEntityEffect diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/earth_wall.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/earth_wall.yml index 69b54713f3..a6699f47b7 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/earth_wall.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/earth_wall.yml @@ -6,11 +6,13 @@ - type: CP14MagicEffect manaCost: 15 telegraphyEffects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectEarthWall effects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14WallSpawnEarthWall - type: CP14MagicEffectVerbalAspect diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/fireball.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/fireball.yml index b2606a5e10..715983bb67 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/fireball.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/fireball.yml @@ -6,7 +6,8 @@ - type: CP14MagicEffect manaCost: 20 effects: - - !type:CP14SpellSpawnEntityOnUser + - !type:CP14SpellSpawnEntity + key: user spawns: - CP14ImpactEffectFireball - !type:CP14SpellProjectile diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/flame_creation.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/flame_creation.yml index 7b6a5b9174..9ed2fd5336 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/flame_creation.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/flame_creation.yml @@ -6,7 +6,8 @@ - type: CP14MagicEffect manaCost: 5 effects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectFlameCreation - !type:CP14SpellSpawnInHandEntity diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_dagger.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_dagger.yml index 3698e7e657..fa844850e6 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_dagger.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_dagger.yml @@ -6,7 +6,8 @@ - type: CP14MagicEffect manaCost: 15 effects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectIceDagger - !type:CP14SpellSpawnInHandEntity diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_floor.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_floor.yml index 2bc9e89dfe..a32d13b044 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_floor.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/ice_floor.yml @@ -6,11 +6,13 @@ - type: CP14MagicEffect manaCost: 10 telegraphyEffects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectIceFloor effects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14IceFloor - type: CP14MagicEffectVerbalAspect diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_grab.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_grab.yml index 8eec7fa9e9..b066c2d68d 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_grab.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_grab.yml @@ -6,16 +6,21 @@ - type: CP14MagicEffect manaCost: 10 telegraphyEffects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target + tryParent: true spawns: - CP14ImpactEffectShadowStep - - !type:CP14SpellSpawnEntityOnUser + - !type:CP14SpellSpawnEntity + key: user + tryParent: true spawns: - CP14ImpactEffectShadowGrab effects: - !type:CP14SpellThrowToUser throwPower: 10 - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectShadowStep - type: CP14MagicEffectSomaticAspect diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_step.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_step.yml index 36256346e5..c1e808a2b2 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_step.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/shadow_step.yml @@ -6,7 +6,8 @@ - type: CP14MagicEffect manaCost: 20 telegraphyEffects: - - !type:CP14SpellSpawnEntityOnTarget + - !type:CP14SpellSpawnEntity + key: target spawns: - CP14ImpactEffectShadowStep effects: diff --git a/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml b/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml index c3a88edd7f..a92c4397be 100644 --- a/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml +++ b/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml @@ -141,7 +141,7 @@ id: CP14ClothingRingEarthWall parent: CP14ClothingRingBase name: conductive ring - description: A standard mana-conductive ring that allows the user to heal physical injuries. + description: A standard mana-conductive ring that allows you to lift a piece of earthen wall. suffix: Earth wall components: - type: Sprite @@ -159,7 +159,7 @@ id: CP14ClothingRingIceFloor parent: CP14ClothingRingBase name: conductive ring - description: A standard mana-conductive ring that allows the user to heal physical injuries. + description: A standard mana-conductive ring that allows you to create slippery ice. suffix: Ice floor components: - type: Sprite