Projectile spells + fireball spell (#9058)

* Projectile spells + fireball spell

* say it with some gumption
This commit is contained in:
Kara
2022-06-23 03:24:50 -07:00
committed by GitHub
parent d3233d90af
commit cc755a2051
29 changed files with 231 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
using Content.Shared.Actions;
using Content.Shared.Sound;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Magic.Events;
public sealed class ProjectileSpellEvent : WorldTargetActionEvent
{
/// <summary>
/// What entity should be spawned.
/// </summary>
[DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Prototype = default!;
/// <summary>
/// Gets the targeted spawn positions; may lead to multiple entities being spawned.
/// </summary>
[DataField("posData")] public MagicSpawnData Pos = new TargetCasterPos();
}

View File

@@ -4,7 +4,9 @@ using Content.Server.Decals;
using Content.Server.DoAfter;
using Content.Server.Doors.Components;
using Content.Server.Magic.Events;
using Content.Server.Popups;
using Content.Server.Spawners.Components;
using Content.Server.Weapon.Ranged.Systems;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Doors.Components;
@@ -33,6 +35,7 @@ public sealed class MagicSystem : EntitySystem
[Dependency] private readonly SharedDoorSystem _doorSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly GunSystem _gunSystem = default!;
public override void Initialize()
{
@@ -47,7 +50,7 @@ public sealed class MagicSystem : EntitySystem
SubscribeLocalEvent<TeleportSpellEvent>(OnTeleportSpell);
SubscribeLocalEvent<KnockSpellEvent>(OnKnockSpell);
SubscribeLocalEvent<WorldSpawnSpellEvent>(OnWorldSpawn);
SubscribeLocalEvent<ProjectileSpellEvent>(OnProjectileSpell);
}
private void OnInit(EntityUid uid, SpellbookComponent component, ComponentInit args)
@@ -142,6 +145,20 @@ public sealed class MagicSystem : EntitySystem
args.Handled = true;
}
private void OnProjectileSpell(ProjectileSpellEvent ev)
{
if (ev.Handled)
return;
var xform = Transform(ev.Performer);
foreach (var pos in GetSpawnPositions(xform, ev.Pos))
{
var ent = Spawn(ev.Prototype, pos.SnapToGrid(EntityManager, _mapManager));
_gunSystem.ShootProjectile(ent,ev.Target.Position - Transform(ent).MapPosition.Position, ev.Performer);
}
}
private List<EntityCoordinates> GetSpawnPositions(TransformComponent casterXform, MagicSpawnData data)
{
switch (data)

View File

@@ -154,7 +154,7 @@ public sealed partial class GunSystem : SharedGunSystem
}, false);
}
private void ShootProjectile(EntityUid uid, Vector2 direction, EntityUid? user = null)
public void ShootProjectile(EntityUid uid, Vector2 direction, EntityUid? user = null)
{
var physics = EnsureComp<PhysicsComponent>(uid);
physics.BodyStatus = BodyStatus.InAir;