Fix lasso buckle (#1246)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -1,13 +1,44 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs
|
||||
{
|
||||
public class SharedBuckleComponent : Component
|
||||
public abstract class SharedBuckleComponent : Component, IActionBlocker, IEffectBlocker
|
||||
{
|
||||
public sealed override string Name => "Buckle";
|
||||
|
||||
public sealed override uint? NetID => ContentNetIDs.BUCKLE;
|
||||
|
||||
protected abstract bool Buckled { get; }
|
||||
|
||||
bool IActionBlocker.CanMove()
|
||||
{
|
||||
return !Buckled;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanChangeDirection()
|
||||
{
|
||||
return !Buckled;
|
||||
}
|
||||
|
||||
bool IEffectBlocker.CanFall()
|
||||
{
|
||||
return !Buckled;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class BuckleComponentState : ComponentState
|
||||
{
|
||||
public BuckleComponentState(bool buckled) : base(ContentNetIDs.BUCKLE)
|
||||
{
|
||||
Buckled = buckled;
|
||||
}
|
||||
|
||||
public bool Buckled { get; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum BuckleVisuals
|
||||
{
|
||||
|
||||
@@ -56,8 +56,9 @@
|
||||
public const uint THIRST = 1050;
|
||||
|
||||
public const uint FLASHABLE = 1051;
|
||||
public const uint PROJECTILE = 1052;
|
||||
public const uint THROWN_ITEM = 1053;
|
||||
public const uint BUCKLE = 1052;
|
||||
public const uint PROJECTILE = 1053;
|
||||
public const uint THROWN_ITEM = 1054;
|
||||
|
||||
// Net IDs for integration tests.
|
||||
public const uint PREDICTION_TEST = 10001;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components the ability to block certain effects
|
||||
/// from affecting the owning entity. For actions see <see cref="IActionBlocker"/>
|
||||
/// </summary>
|
||||
public interface IEffectBlocker
|
||||
{
|
||||
bool CanFall() => true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Utility methods to check if an effect is allowed to affect a specific entity.
|
||||
/// For actions see <see cref="ActionBlockerSystem"/>
|
||||
/// </summary>
|
||||
public class EffectBlockerSystem : EntitySystem
|
||||
{
|
||||
public static bool CanFall(IEntity entity)
|
||||
{
|
||||
var canFall = true;
|
||||
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
||||
{
|
||||
canFall &= blocker.CanFall(); // Sets var to false if false
|
||||
}
|
||||
|
||||
return canFall;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user