Implement inflatable wall (#3703)

* Implement inflatable wall

* Actually block atmos

* Fix naming and add description

* Add requested changes

* Change prototype to field

* Refactor checks to use existing methods

* Fix PrototypeIdSerializer imports

* Fix mass in yaml
This commit is contained in:
ShadowCommander
2021-04-01 00:04:56 -07:00
committed by GitHub
parent a69e98dcdc
commit a98c0dadd4
17 changed files with 417 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Items.Storage;
@@ -131,7 +131,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
private void InteractionActivate(IEntity user, IEntity used)
{
var activateMsg = new ActivateInWorldMessage(user, used);
RaiseLocalEvent(activateMsg);
RaiseLocalEvent(used.Uid, activateMsg);
if (activateMsg.Handled)
{
return;

View File

@@ -0,0 +1,68 @@
using Content.Server.GameObjects.Components.Engineering;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems.DoAfter;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using System.Threading;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class DisassembleOnActivateSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DisassembleOnActivateComponent, ActivateInWorldMessage>(HandleActivateInWorld);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<DisassembleOnActivateComponent, ActivateInWorldMessage>(HandleActivateInWorld);
}
private async void HandleActivateInWorld(EntityUid uid, DisassembleOnActivateComponent component, ActivateInWorldMessage args)
{
if (string.IsNullOrEmpty(component.Prototype))
return;
if (!args.User.InRangeUnobstructed(args.Activated))
return;
if (component.DoAfterTime > 0 && TryGet<DoAfterSystem>(out var doAfterSystem))
{
var doAfterArgs = new DoAfterEventArgs(args.User, component.DoAfterTime, component.TokenSource.Token)
{
BreakOnUserMove = true,
BreakOnStun = true,
};
var result = await doAfterSystem.DoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished)
return;
component.TokenSource.Cancel();
}
if (component.Deleted || component.Owner.Deleted)
return;
var entity = EntityManager.SpawnEntity(component.Prototype, component.Owner.Transform.Coordinates);
if (args.User.TryGetComponent<HandsComponent>(out var hands)
&& entity.TryGetComponent<ItemComponent>(out var item))
{
hands.PutInHandOrDrop(item);
}
component.Owner.Delete();
return;
}
}
}

View File

@@ -0,0 +1,79 @@
#nullable enable
using Content.Server.GameObjects.Components.Engineering;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems.DoAfter;
using Content.Server.Utility;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Maps;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class SpawnAfterInteractSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SpawnAfterInteractComponent, AfterInteractMessage>(HandleAfterInteract);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<SpawnAfterInteractComponent, AfterInteractMessage>(HandleAfterInteract);
}
private async void HandleAfterInteract(EntityUid uid, SpawnAfterInteractComponent component, AfterInteractMessage args)
{
if (string.IsNullOrEmpty(component.Prototype))
return;
if (!args.ClickLocation.TryGetTileRef(out var tileRef, EntityManager, _mapManager))
return;
bool IsTileClear()
{
return tileRef.Value.Tile.IsEmpty == false && args.User.InRangeUnobstructed(args.ClickLocation, popup: true);
}
if (!IsTileClear())
return;
if (component.DoAfterTime > 0 && TryGet<DoAfterSystem>(out var doAfterSystem))
{
var doAfterArgs = new DoAfterEventArgs(args.User, component.DoAfterTime)
{
BreakOnUserMove = true,
BreakOnStun = true,
PostCheck = IsTileClear,
};
var result = await doAfterSystem.DoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished)
return;
}
if (component.Deleted || component.Owner.Deleted)
return;
StackComponent? stack = null;
if (component.RemoveOnInteract && component.Owner.TryGetComponent(out stack) && !stack.Use(1))
return;
EntityManager.SpawnEntity(component.Prototype, tileRef.Value.GridPosition(_mapManager));
if (component.RemoveOnInteract && stack == null && !component.Owner.Deleted)
component.Owner.Delete();
return;
}
}
}