Blast doors & shutters (#4822)
This commit is contained in:
@@ -107,6 +107,12 @@ namespace Content.Server.Doors.Components
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("bumpOpen")]
|
||||
public bool BumpOpen = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door will open when it is activated or clicked.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("clickOpen")]
|
||||
public bool ClickOpen = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door starts open when it's first loaded from prototype. A door won't start open if its prototype is also welded shut.
|
||||
/// Handled in Startup().
|
||||
@@ -164,6 +170,12 @@ namespace Content.Server.Doors.Components
|
||||
[DataField("denySound")]
|
||||
public SoundSpecifier? DenySound;
|
||||
|
||||
/// <summary>
|
||||
/// Should this door automatically close if its been open for too long?
|
||||
/// </summary>
|
||||
[DataField("autoClose")]
|
||||
public bool AutoClose;
|
||||
|
||||
/// <summary>
|
||||
/// Default time that the door should take to pry open.
|
||||
/// </summary>
|
||||
@@ -238,6 +250,9 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!ClickOpen)
|
||||
return;
|
||||
|
||||
DoorClickShouldActivateEvent ev = new DoorClickShouldActivateEvent(eventArgs);
|
||||
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
|
||||
if (ev.Handled)
|
||||
@@ -255,9 +270,15 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
#region Opening
|
||||
|
||||
public void TryOpen(IEntity user)
|
||||
public void TryOpen(IEntity? user=null)
|
||||
{
|
||||
if (CanOpenByEntity(user))
|
||||
if (user == null)
|
||||
{
|
||||
// a machine opened it or something, idk
|
||||
Open();
|
||||
return;
|
||||
}
|
||||
else if (CanOpenByEntity(user))
|
||||
{
|
||||
Open();
|
||||
|
||||
@@ -384,9 +405,9 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
#region Closing
|
||||
|
||||
public void TryClose(IEntity user)
|
||||
public void TryClose(IEntity? user=null)
|
||||
{
|
||||
if (!CanCloseByEntity(user))
|
||||
if (user != null && !CanCloseByEntity(user))
|
||||
{
|
||||
Deny();
|
||||
return;
|
||||
@@ -610,6 +631,9 @@ namespace Content.Server.Doors.Components
|
||||
if (State != DoorState.Open)
|
||||
return;
|
||||
|
||||
if (!AutoClose)
|
||||
return;
|
||||
|
||||
var autoev = new BeforeDoorAutoCloseEvent();
|
||||
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, autoev, false);
|
||||
if (autoev.Cancelled)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Doors.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ToggleDoorOnTriggerComponent : Component
|
||||
{
|
||||
public override string Name => "ToggleDoorOnTrigger";
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.Flash;
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Doors;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -43,6 +45,7 @@ namespace Content.Server.Explosion
|
||||
SubscribeLocalEvent<SoundOnTriggerComponent, TriggerEvent>(HandleSoundTrigger);
|
||||
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
|
||||
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
|
||||
SubscribeLocalEvent<ToggleDoorOnTriggerComponent, TriggerEvent>(HandleDoorTrigger);
|
||||
}
|
||||
|
||||
#region Explosions
|
||||
@@ -89,6 +92,25 @@ namespace Content.Server.Explosion
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
|
||||
private void HandleDoorTrigger(EntityUid uid, ToggleDoorOnTriggerComponent component, TriggerEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<ServerDoorComponent>(uid, out var door))
|
||||
{
|
||||
switch (door.State)
|
||||
{
|
||||
case SharedDoorComponent.DoorState.Open:
|
||||
door.Close();
|
||||
break;
|
||||
case SharedDoorComponent.DoorState.Closed:
|
||||
door.Open();
|
||||
break;
|
||||
case SharedDoorComponent.DoorState.Closing:
|
||||
case SharedDoorComponent.DoorState.Opening:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCollide(EntityUid uid, TriggerOnCollideComponent component, StartCollideEvent args)
|
||||
{
|
||||
Trigger(component.Owner);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.MachineLinking.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class TriggerOnSignalReceivedComponent : Component
|
||||
{
|
||||
public override string Name => "TriggerOnSignalReceived";
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SignalButtonSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Content.Server.MachineLinking.System
|
||||
if (!IsInRange(component, link.ReceiverComponent)) continue;
|
||||
|
||||
RaiseLocalEvent(link.ReceiverComponent.Owner.Uid,
|
||||
new SignalReceivedEvent(link.Receiverport.Name, args.Value));
|
||||
new SignalReceivedEvent(link.Receiverport.Name, args.Value), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using Content.Server.Explosion;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
{
|
||||
public class TriggerOnSignalReceivedSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly TriggerSystem _trigger = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<TriggerOnSignalReceivedComponent, SignalReceivedEvent>(OnSignalReceived);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, TriggerOnSignalReceivedComponent component, SignalReceivedEvent args)
|
||||
{
|
||||
_trigger.Trigger(EntityManager.GetEntity(uid));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user