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>
This commit is contained in:
43
Content.Server/Security/Systems/DeployableBarrierSystem.cs
Normal file
43
Content.Server/Security/Systems/DeployableBarrierSystem.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user