Fix lasso buckle (#1246)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
DrSmugleaf
2020-07-02 23:36:06 +02:00
committed by GitHub
parent bc24a852f9
commit 0a8a383019
9 changed files with 86 additions and 30 deletions

View File

@@ -0,0 +1,23 @@
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
public class BuckleComponent : SharedBuckleComponent
{
private bool _buckled;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is BuckleComponentState buckle))
{
return;
}
_buckled = buckle.Buckled;
}
protected override bool Buckled => _buckled;
}
}

View File

@@ -116,7 +116,6 @@
"Utensil",
"UnarmedCombat",
"TimedSpawner",
"Buckle",
"Strap",
"NodeContainer",
"PowerSupplier",

View File

@@ -10,7 +10,6 @@ using Content.Shared.GameObjects.EntitySystems;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
@@ -22,17 +21,29 @@ using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Mobs
{
[RegisterComponent]
public class BuckleComponent : SharedBuckleComponent, IActionBlocker, IInteractHand, IEffectBlocker
public class BuckleComponent : SharedBuckleComponent, IInteractHand
{
#pragma warning disable 649
[Dependency] private readonly IEntitySystemManager _entitySystem;
[Dependency] private readonly IServerNotifyManager _notifyManager;
#pragma warning restore 649
[CanBeNull] private StrapComponent _buckledTo;
private int _size;
[ViewVariables, CanBeNull]
public StrapComponent BuckledTo { get; private set; }
public StrapComponent BuckledTo
{
get => _buckledTo;
private set
{
_buckledTo = value;
Dirty();
}
}
[ViewVariables]
protected override bool Buckled => BuckledTo != null;
[ViewVariables]
public int Size => _size;
@@ -42,9 +53,9 @@ namespace Content.Server.GameObjects.Components.Mobs
if (Owner.TryGetComponent(out ServerStatusEffectsComponent status))
{
status.ChangeStatusEffectIcon(StatusEffect.Buckled,
BuckledTo == null
? "/Textures/Mob/UI/Buckle/unbuckled.png"
: "/Textures/Mob/UI/Buckle/buckled.png");
Buckled
? "/Textures/Mob/UI/Buckle/buckled.png"
: "/Textures/Mob/UI/Buckle/unbuckled.png");
}
}
@@ -86,7 +97,7 @@ namespace Content.Server.GameObjects.Components.Mobs
return false;
}
if (BuckledTo != null)
if (Buckled)
{
_notifyManager.PopupMessage(Owner, user,
Loc.GetString(Owner == user
@@ -277,33 +288,22 @@ namespace Content.Server.GameObjects.Components.Mobs
BuckleStatus();
}
public override ComponentState GetComponentState()
{
return new BuckleComponentState(Buckled);
}
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
{
return TryUnbuckle(eventArgs.User);
}
bool IActionBlocker.CanMove()
{
return BuckledTo == null;
}
bool IActionBlocker.CanChangeDirection()
{
return BuckledTo == null;
}
bool IEffectBlocker.CanFall()
{
return BuckledTo == null;
}
[Verb]
private sealed class BuckleVerb : Verb<BuckleComponent>
{
protected override void GetData(IEntity user, BuckleComponent component, VerbData data)
{
if (!ActionBlockerSystem.CanInteract(user) ||
component.BuckledTo == null)
if (!ActionBlockerSystem.CanInteract(user) || !component.Buckled)
{
data.Visibility = VerbVisibility.Invisible;
return;

View File

@@ -69,7 +69,7 @@ namespace Content.Server.GameObjects.Components.Strap
/// The sum of the sizes of all the buckled entities in this strap
/// </summary>
[ViewVariables]
public int OccupiedSize { get; private set; }
private int OccupiedSize { get; set; }
public bool HasSpace(BuckleComponent buckle)
{

View File

@@ -2,6 +2,7 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Interfaces.GameObjects;

View File

@@ -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
{

View File

@@ -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;

View File

@@ -1,7 +1,7 @@
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
namespace Content.Shared.GameObjects.EntitySystems
{
/// <summary>
/// This interface gives components the ability to block certain effects

View File

@@ -60,6 +60,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=soundfonts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Spawner/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=stunnable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=underplating/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=uplink/@EntryIndexedValue">True</s:Boolean>