IDs and access (#319)

* something about access

* Fixed deny animation
This commit is contained in:
DamianX
2019-09-01 22:57:22 +02:00
committed by Pieter-Jan Briers
parent 0329150109
commit f3b460c8b4
13 changed files with 205 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
using System;
using Content.Server.GameObjects.Components.Access;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Doors;
using Robust.Server.GameObjects;
@@ -26,6 +27,7 @@ namespace Content.Server.GameObjects
private static readonly TimeSpan CloseTime = TimeSpan.FromSeconds(1.2f);
private static readonly TimeSpan OpenTimeOne = TimeSpan.FromSeconds(0.3f);
private static readonly TimeSpan OpenTimeTwo = TimeSpan.FromSeconds(0.9f);
private static readonly TimeSpan DenyTime = TimeSpan.FromSeconds(0.45f);
public override void Initialize()
{
@@ -51,7 +53,7 @@ namespace Content.Server.GameObjects
}
else if (_state == DoorState.Closed)
{
Open();
TryOpen(eventArgs.User);
}
}
@@ -73,11 +75,24 @@ namespace Content.Server.GameObjects
return;
}
Open();
TryOpen(msg.Entity);
break;
}
}
public void TryOpen(IEntity user)
{
if (Owner.TryGetComponent(out AccessReader accessReader))
{
if (!accessReader.IsAllowed(user))
{
Deny();
return;
}
}
Open();
}
public void Open()
{
if (_state != DoorState.Closed)
@@ -120,6 +135,15 @@ namespace Content.Server.GameObjects
return true;
}
public void Deny()
{
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Deny);
Timer.Spawn(DenyTime, () =>
{
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closed);
});
}
private const float AUTO_CLOSE_DELAY = 5;
public void OnUpdate(float frameTime)
{