Blast doors & shutters (#4822)

This commit is contained in:
mirrorcult
2021-10-10 03:43:50 -07:00
committed by GitHub
parent 72d30724c4
commit 9b4e495c95
32 changed files with 325 additions and 37 deletions

View File

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

View File

@@ -0,0 +1,10 @@
using Robust.Shared.GameObjects;
namespace Content.Server.Doors.Components
{
[RegisterComponent]
public class ToggleDoorOnTriggerComponent : Component
{
public override string Name => "ToggleDoorOnTrigger";
}
}