make dragons breathe fire (#26746)
* add ActionGun system * add RepeatingTrigger * dragons breath projectile, repeatedly explodes * give dragon fire breathing action, fireproof it * oop * oop 2 * prevent troll * proper repeating thing * pro * webedit ops * realops --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Weapons.Ranged.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Lets you shoot a gun using an action.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(ActionGunSystem))]
|
||||
public sealed partial class ActionGunComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Action to create, must use <see cref="ActionGunShootEvent"/>.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public EntProtoId Action = string.Empty;
|
||||
|
||||
[DataField]
|
||||
public EntityUid? ActionEntity;
|
||||
|
||||
/// <summary>
|
||||
/// Prototype of gun entity to spawn.
|
||||
/// Deleted when this component is removed.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public EntProtoId GunProto = string.Empty;
|
||||
|
||||
[DataField]
|
||||
public EntityUid? Gun;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action event for <see cref="ActionGunComponent"/> to shoot at a position.
|
||||
/// </summary>
|
||||
public sealed partial class ActionGunShootEvent : WorldTargetActionEvent;
|
||||
41
Content.Shared/Weapons/Ranged/Systems/ActionGunSystem.cs
Normal file
41
Content.Shared/Weapons/Ranged/Systems/ActionGunSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
|
||||
namespace Content.Shared.Weapons.Ranged.Systems;
|
||||
|
||||
public sealed class ActionGunSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly SharedGunSystem _gun = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ActionGunComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<ActionGunComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<ActionGunComponent, ActionGunShootEvent>(OnShoot);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<ActionGunComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ent.Comp.Action))
|
||||
return;
|
||||
|
||||
_actions.AddAction(ent, ref ent.Comp.ActionEntity, ent.Comp.Action);
|
||||
ent.Comp.Gun = Spawn(ent.Comp.GunProto);
|
||||
}
|
||||
|
||||
private void OnShutdown(Entity<ActionGunComponent> ent, ref ComponentShutdown args)
|
||||
{
|
||||
if (ent.Comp.Gun is {} gun)
|
||||
QueueDel(gun);
|
||||
}
|
||||
|
||||
private void OnShoot(Entity<ActionGunComponent> ent, ref ActionGunShootEvent args)
|
||||
{
|
||||
if (TryComp<GunComponent>(ent.Comp.Gun, out var gun))
|
||||
_gun.AttemptShoot(ent, ent.Comp.Gun.Value, gun, args.Target);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user