SpawnSpell tweak (#393)

* some refactor

* Update flame_creation.yml
This commit is contained in:
Ed
2024-08-06 00:42:53 +03:00
committed by GitHub
parent 37e0ffa173
commit dc853b6662
12 changed files with 98 additions and 63 deletions

View File

@@ -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<EntProtoId> 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<SharedTransformSystem>();
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);
}
}
}
}
}

View File

@@ -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<EntProtoId> 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<TransformComponent>(args.Target.Value, out var transformComponent))
targetPoint = transformComponent.Coordinates;
if (targetPoint is null)
return;
foreach (var spawn in Spawns)
{
entManager.SpawnAtPosition(spawn, targetPoint.Value);
}
}
}

View File

@@ -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<EntProtoId> Spawns = new();
public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args)
{
if (args.User is null || !entManager.TryGetComponent<TransformComponent>(args.User.Value, out var transformComponent))
return;
foreach (var spawn in Spawns)
{
entManager.SpawnAtPosition(spawn, transformComponent.Coordinates);
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -6,7 +6,8 @@
- type: CP14MagicEffect
manaCost: 20
effects:
- !type:CP14SpellSpawnEntityOnUser
- !type:CP14SpellSpawnEntity
key: user
spawns:
- CP14ImpactEffectFireball
- !type:CP14SpellProjectile

View File

@@ -6,7 +6,8 @@
- type: CP14MagicEffect
manaCost: 5
effects:
- !type:CP14SpellSpawnEntityOnTarget
- !type:CP14SpellSpawnEntity
key: target
spawns:
- CP14ImpactEffectFlameCreation
- !type:CP14SpellSpawnInHandEntity

View File

@@ -6,7 +6,8 @@
- type: CP14MagicEffect
manaCost: 15
effects:
- !type:CP14SpellSpawnEntityOnTarget
- !type:CP14SpellSpawnEntity
key: target
spawns:
- CP14ImpactEffectIceDagger
- !type:CP14SpellSpawnInHandEntity

View File

@@ -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

View File

@@ -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

View File

@@ -6,7 +6,8 @@
- type: CP14MagicEffect
manaCost: 20
telegraphyEffects:
- !type:CP14SpellSpawnEntityOnTarget
- !type:CP14SpellSpawnEntity
key: target
spawns:
- CP14ImpactEffectShadowStep
effects:

View File

@@ -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