Spikes fix reopened (#3203)

* DoAfter, dead and stun check, DragDropOn

* Not ignored anymore

* Copied comment deleted

* Herbert's an ass

* Woops

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
komunre
2021-02-18 14:49:50 +07:00
committed by GitHub
parent eadcb3a296
commit 77c8fc5b42
4 changed files with 157 additions and 43 deletions

View File

@@ -0,0 +1,42 @@
#nullable enable
using Content.Shared.GameObjects.Components.Mobs.State;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Kitchen
{
public abstract class SharedKitchenSpikeComponent : Component, IDragDropOn
{
public override string Name => "KitchenSpike";
[ViewVariables]
protected float SpikeDelay;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref SpikeDelay, "delay", 10.0f);
}
bool IDragDropOn.CanDragDropOn(DragDropEventArgs eventArgs)
{
if (!eventArgs.Dragged.TryGetComponent<IMobStateComponent>(out var state))
{
return false;
}
// TODO: Wouldn't we just need the CanMove check?
if (state.IsDead() || state.IsCritical() || state.IsIncapacitated() || !ActionBlockerSystem.CanMove(eventArgs.Dragged))
{
return true;
}
return false;
}
public abstract bool DragDropOn(DragDropEventArgs eventArgs);
}
}