Files
tbd-station-14/Content.Server/Security/Systems/DeployableBarrierSystem.cs
Alex Evgrashin 8408c1128f Add security barriers (#4458)
* Add sprites

* Lock system now raises lock toggle events

* Add prototype and barrier system

* Toggle lock on click

* Barrier blocks bullets (like a real wall)

* Barrier now destroyable

* Fancy visualzer and lighting. Also unlock by default

* Deleted comma

* Ignored components?

* Update Resources/Prototypes/Entities/Objects/Specific/Security/barrier.yml

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Update Resources/Prototypes/Entities/Objects/Specific/Security/barrier.yml

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Toggle Lock no longer handled

* Made it much easier to move through airlocks

Co-authored-by: Swept <sweptwastaken@protonmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2021-08-23 02:32:24 +10:00

44 lines
1.5 KiB
C#

using Content.Server.Lock;
using Content.Server.Storage.Components;
using Content.Shared.Security;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using System;
namespace Content.Server.Security.Systems
{
public class DeployableBarrierSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DeployableBarrierComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<DeployableBarrierComponent, LockToggledEvent>(OnLockToggled);
}
private void OnStartup(EntityUid uid, DeployableBarrierComponent component, ComponentStartup args)
{
if (!component.Owner.TryGetComponent(out LockComponent? lockComponent))
return;
ToggleBarrierDeploy(component, lockComponent.Locked);
}
private void OnLockToggled(EntityUid uid, DeployableBarrierComponent component, LockToggledEvent args)
{
ToggleBarrierDeploy(component, args.Locked);
}
private void ToggleBarrierDeploy(DeployableBarrierComponent component, bool isDeployed)
{
component.Owner.Transform.Anchored = isDeployed;
if (!component.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent))
return;
var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle;
appearanceComponent.SetData(DeployableBarrierVisuals.State, state);
}
}
}