Modular landmines (#8351)

This commit is contained in:
Kara
2022-06-01 01:39:06 -07:00
committed by GitHub
parent 19778cc664
commit da07d91895
14 changed files with 190 additions and 28 deletions

View File

@@ -24,6 +24,7 @@ namespace Content.Server.Destructible
[Dependency] public readonly ConstructionSystem ConstructionSystem = default!;
[Dependency] public readonly ExplosionSystem ExplosionSystem = default!;
[Dependency] public readonly StackSystem StackSystem = default!;
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
[Dependency] public readonly IComponentFactory ComponentFactory = default!;

View File

@@ -0,0 +1,10 @@
namespace Content.Server.Destructible.Thresholds.Behaviors;
[DataDefinition]
public sealed class TriggerBehavior : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system)
{
system.TriggerSystem.Trigger(owner);
}
}

View File

@@ -12,6 +12,7 @@ using Robust.Shared.Player;
using Content.Shared.Sound;
using Content.Shared.Trigger;
using Content.Shared.Database;
using Content.Shared.Explosion;
using Content.Shared.Interaction;
namespace Content.Server.Explosion.EntitySystems
@@ -60,6 +61,7 @@ namespace Content.Server.Explosion.EntitySystems
private void HandleExplodeTrigger(EntityUid uid, ExplodeOnTriggerComponent component, TriggerEvent args)
{
_explosions.TriggerExplosive(uid, user: args.User);
args.Handled = true;
}
#region Flash
@@ -67,12 +69,14 @@ namespace Content.Server.Explosion.EntitySystems
{
// TODO Make flash durations sane ffs.
_flashSystem.FlashArea(uid, args.User, component.Range, component.Duration * 1000f);
args.Handled = true;
}
#endregion
private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args)
{
EntityManager.QueueDeleteEntity(uid);
args.Handled = true;
}
private void OnTriggerCollide(EntityUid uid, TriggerOnCollideComponent component, StartCollideEvent args)
@@ -84,12 +88,14 @@ namespace Content.Server.Explosion.EntitySystems
private void OnActivate(EntityUid uid, TriggerOnActivateComponent component, ActivateInWorldEvent args)
{
Trigger(component.Owner, args.User);
args.Handled = true;
}
public void Trigger(EntityUid trigger, EntityUid? user = null)
public bool Trigger(EntityUid trigger, EntityUid? user = null)
{
var triggerEvent = new TriggerEvent(trigger, user);
EntityManager.EventBus.RaiseLocalEvent(trigger, triggerEvent);
return triggerEvent.Handled;
}
public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay , float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound, AudioParams beepParams)

View File

@@ -20,5 +20,7 @@ public sealed class GhostKickUserOnTriggerSystem : EntitySystem
_ghostKickManager.DoDisconnect(
actor.PlayerSession.ConnectedClient,
"Tripped over a kick mine, crashed through the fourth wall");
args.Handled = true;
}
}

View File

@@ -3,5 +3,6 @@
[RegisterComponent]
public sealed class LandMineComponent : Component
{
[DataField("deleteOnActivate")]
public bool DeleteOnActivate = true;
}

View File

@@ -27,14 +27,16 @@ public sealed class LandMineSystem : EntitySystem
private void HandleTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredEvent args)
{
_popupSystem.PopupCoordinates(
Loc.GetString("land-mine-triggered", ("mine", uid)),
Transform(uid).Coordinates,
Filter.Entities(args.Tripper));
if (_trigger.Trigger(uid, args.Tripper))
{
_popupSystem.PopupCoordinates(
Loc.GetString("land-mine-triggered", ("mine", uid)),
Transform(uid).Coordinates,
Filter.Entities(args.Tripper));
}
_trigger.Trigger(uid, args.Tripper);
QueueDel(uid);
if (component.DeleteOnActivate)
QueueDel(uid);
}
}

View File

@@ -1,8 +1,10 @@
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Payload.Components;
using Content.Shared.Tag;
using Robust.Shared.Containers;
@@ -27,22 +29,34 @@ public sealed class PayloadSystem : EntitySystem
SubscribeLocalEvent<PayloadTriggerComponent, TriggerEvent>(OnTriggerTriggered);
SubscribeLocalEvent<PayloadCaseComponent, EntInsertedIntoContainerMessage>(OnEntityInserted);
SubscribeLocalEvent<PayloadCaseComponent, EntRemovedFromContainerMessage>(OnEntityRemoved);
SubscribeLocalEvent<PayloadCaseComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<ChemicalPayloadComponent, TriggerEvent>(HandleChemicalPayloadTrigger);
}
public IEnumerable<EntityUid> GetAllPayloads(EntityUid uid, ContainerManagerComponent? contMan=null)
{
if (!Resolve(uid, ref contMan, false))
yield break;
foreach (var container in contMan.Containers.Values)
{
foreach (var entity in container.ContainedEntities)
{
if (_tagSystem.HasTag(entity, "Payload"))
yield return entity;
}
}
}
private void OnCaseTriggered(EntityUid uid, PayloadCaseComponent component, TriggerEvent args)
{
if (!TryComp(uid, out ContainerManagerComponent? contMan))
return;
// Pass trigger event onto all contained payloads. Payload capacity configurable by construction graphs.
foreach (var container in contMan.Containers.Values)
foreach (var ent in GetAllPayloads(uid, contMan))
{
foreach (var entity in container.ContainedEntities)
{
if (_tagSystem.HasTag(entity, "Payload"))
RaiseLocalEvent(entity, args, false);
}
RaiseLocalEvent(ent, args, false);
}
}
@@ -106,6 +120,24 @@ public sealed class PayloadSystem : EntitySystem
trigger.GrantedComponents.Clear();
}
private void OnExamined(EntityUid uid, PayloadCaseComponent component, ExaminedEvent args)
{
if (!args.IsInDetailsRange)
{
args.PushMarkup(Loc.GetString("payload-case-not-close-enough", ("ent", uid)));
return;
}
if (GetAllPayloads(uid).Any())
{
args.PushMarkup(Loc.GetString("payload-case-has-payload", ("ent", uid)));
}
else
{
args.PushMarkup(Loc.GetString("payload-case-does-not-have-payload", ("ent", uid)));
}
}
private void HandleChemicalPayloadTrigger(EntityUid uid, ChemicalPayloadComponent component, TriggerEvent args)
{
if (component.BeakerSlotA.Item is not EntityUid beakerA
@@ -135,5 +167,7 @@ public sealed class PayloadSystem : EntitySystem
_solutionSystem.TryAddSolution(beakerB, solutionB, tmpSol);
solutionA.MaxVolume -= solutionB.MaxVolume;
_solutionSystem.UpdateChemicals(beakerA, solutionA, false);
args.Handled = true;
}
}

View File

@@ -40,6 +40,7 @@ namespace Content.Server.Sound
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
{
TryEmitSound(component);
args.Handled = true;
}
private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)

View File

@@ -0,0 +1,3 @@
payload-case-not-close-enough = You need to get closer to determine if {THE($ent)} has a payload installed.
payload-case-has-payload = {CAPITALIZE(THE($ent))} has a payload installed!
payload-case-does-not-have-payload = {CAPITALIZE(THE($ent))} does not have a payload installed.

View File

@@ -4,6 +4,8 @@
components:
- type: Clickable
- type: InteractionOutline
- type: Anchorable
- type: Pullable
- type: MovedByPressure
- type: Physics
bodyType: Static
@@ -18,9 +20,20 @@
layer:
- LowImpassable
- type: Sprite
drawdepth: FloorObjects
drawdepth: Items
sprite: Objects/Misc/uglymine.rsi
state: uglymine
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 50
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: LandMine
- type: StepTrigger
requiredTriggeredSpeed: 0
@@ -32,6 +45,19 @@
components:
- type: GhostKickUserOnTrigger
- type: entity
name: modular mine
description: This bad boy could be packing any number of dangers. Or a bike horn.
parent: BaseLandMine
id: LandMineModular
components:
- type: PayloadCase
- type: Construction
graph: ModularMineGraph
node: emptyCase
- type: LandMine
deleteOnActivate: false
- type: entity
name: explosive mine
parent: BaseLandMine

View File

@@ -1,3 +1,5 @@
# TODO probably needs a base grenade
- type: entity
name: explosive grenade
description: Grenade that creates a small but devastating explosion.
@@ -32,6 +34,7 @@
!type:DamageTrigger
damage: 10
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: ["Destruction"]
- type: Appearance
@@ -71,6 +74,7 @@
!type:DamageTrigger
damage: 10
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: ["Destruction"]
- type: Appearance
@@ -108,6 +112,7 @@
!type:DamageTrigger
damage: 10
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: ["Destruction"]
- type: Appearance
@@ -115,6 +120,7 @@
- type: TimerTriggerVisualizer
countdown_sound:
path: /Audio/Effects/minibombcountdown.ogg
- type: entity
name: the nuclear option
description: Please don't throw it, think of the children.
@@ -144,6 +150,7 @@
!type:DamageTrigger
damage: 50
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: ["Destruction"]
- type: Appearance
@@ -175,6 +182,7 @@
!type:DamageTrigger
damage: 50
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: Appearance

View File

@@ -0,0 +1,55 @@
- type: constructionGraph
id: ModularMineGraph
start: start
graph:
- node: start
edges:
- to: emptyCase
steps:
- material: Steel
amount: 5
doAfter: 1
- node: emptyCase
entity: LandMineModular
edges:
- to: wiredCase
steps:
- material: Cable
doAfter: 0.5
- node: wiredCase
entity: LandMineModular
actions:
- !type:PlaySound
sound: /Audio/Machines/button.ogg
edges:
- to: emptyCase
steps:
- tool: Cutting
doAfter: 0.5
completed:
- !type:SpawnPrototype
prototype: CableApcStack1
- to: mine
steps:
- tag: Payload
store: payload
name: Payload
doAfter: 0.5
- node: mine
actions:
- !type:PlaySound
sound: /Audio/Machines/button.ogg
- !type:AdminLog
message: "A mine was crafted"
edges:
- to: wiredCase
steps:
- tool: Prying
doAfter: 0.5
completed:
- !type:EmptyContainer
container: payload

View File

@@ -0,0 +1,25 @@
- type: construction
name: Modular Grenade
id: ModularGrenadeRecipe
graph: ModularGrenadeGraph
startNode: start
targetNode: grenade
category: Weapons
description: Construct a grenade using a trigger and a payload.
icon:
sprite: Objects/Weapons/Grenades/modular.rsi
state: complete
objectType: Item
- type: construction
name: Modular Mine
id: ModularMineRecipe
graph: ModularMineGraph
startNode: start
targetNode: mine
category: Weapons
description: Construct a landmine using a payload.
icon:
sprite: Objects/Misc/uglymine.rsi
state: uglymine
objectType: Item

View File

@@ -1,12 +0,0 @@
- type: construction
name: Modular Grenade
id: ModularGrenadeRecipe
graph: ModularGrenadeGraph
startNode: start
targetNode: grenade
category: Weapons
description: Construct a grenade using a trigger and a payload.
icon:
sprite: Objects/Weapons/Grenades/modular.rsi
state: complete
objectType: Item