2021-02-03 22:07:13 +00:00
|
|
|
#nullable enable
|
2020-07-27 00:54:32 +02:00
|
|
|
using System;
|
2019-11-13 17:37:46 -05:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-02-03 22:07:13 +00:00
|
|
|
using Robust.Shared.Map;
|
2019-11-13 17:37:46 -05:00
|
|
|
using Robust.Shared.Serialization;
|
2017-09-26 21:27:48 +02:00
|
|
|
|
2020-07-25 15:11:16 +02:00
|
|
|
namespace Content.Shared.GameObjects.Components.Items
|
2017-09-26 21:27:48 +02:00
|
|
|
{
|
2020-07-27 00:54:32 +02:00
|
|
|
public abstract class SharedHandsComponent : Component, ISharedHandsComponent
|
2017-09-26 21:27:48 +02:00
|
|
|
{
|
|
|
|
|
public sealed override string Name => "Hands";
|
|
|
|
|
public sealed override uint? NetID => ContentNetIDs.HANDS;
|
2020-12-13 14:28:20 -08:00
|
|
|
|
|
|
|
|
/// <returns>true if the item is in one of the hands</returns>
|
|
|
|
|
public abstract bool IsHolding(IEntity item);
|
2017-09-26 21:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-25 15:11:16 +02:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class SharedHand
|
|
|
|
|
{
|
|
|
|
|
public readonly int Index;
|
|
|
|
|
public readonly string Name;
|
|
|
|
|
public readonly EntityUid? EntityUid;
|
|
|
|
|
public readonly HandLocation Location;
|
2020-10-28 10:16:40 +01:00
|
|
|
public readonly bool Enabled;
|
2020-07-25 15:11:16 +02:00
|
|
|
|
2020-10-28 10:16:40 +01:00
|
|
|
public SharedHand(int index, string name, EntityUid? entityUid, HandLocation location, bool enabled)
|
2020-07-25 15:11:16 +02:00
|
|
|
{
|
|
|
|
|
Index = index;
|
|
|
|
|
Name = name;
|
|
|
|
|
EntityUid = entityUid;
|
|
|
|
|
Location = location;
|
2020-10-28 10:16:40 +01:00
|
|
|
Enabled = enabled;
|
2020-07-25 15:11:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 21:27:48 +02:00
|
|
|
// The IDs of the items get synced over the network.
|
2018-05-27 10:13:33 +02:00
|
|
|
[Serializable, NetSerializable]
|
2017-09-26 21:27:48 +02:00
|
|
|
public class HandsComponentState : ComponentState
|
|
|
|
|
{
|
2020-07-25 15:11:16 +02:00
|
|
|
public readonly SharedHand[] Hands;
|
2020-07-27 00:54:32 +02:00
|
|
|
public readonly string? ActiveIndex;
|
2017-09-26 21:27:48 +02:00
|
|
|
|
2020-07-27 00:54:32 +02:00
|
|
|
public HandsComponentState(SharedHand[] hands, string? activeIndex) : base(ContentNetIDs.HANDS)
|
2017-09-26 21:27:48 +02:00
|
|
|
{
|
|
|
|
|
Hands = hands;
|
2017-09-30 16:56:19 +02:00
|
|
|
ActiveIndex = activeIndex;
|
2017-09-26 21:27:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-22 06:11:38 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
2020-01-17 18:41:47 -08:00
|
|
|
/// A message that calls the use interaction on an item in hand, presumed for now the interaction will occur only on the active hand.
|
2018-04-22 06:11:38 -05:00
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2020-01-17 18:41:47 -08:00
|
|
|
public class UseInHandMsg : ComponentMessage
|
2018-04-22 06:11:38 -05:00
|
|
|
{
|
2020-01-17 18:41:47 -08:00
|
|
|
public UseInHandMsg()
|
2018-04-22 06:11:38 -05:00
|
|
|
{
|
|
|
|
|
Directed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-21 20:58:11 +01:00
|
|
|
|
2020-01-17 18:41:47 -08:00
|
|
|
/// <summary>
|
|
|
|
|
/// A message that calls the activate interaction on the item in Index.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class ActivateInHandMsg : ComponentMessage
|
|
|
|
|
{
|
|
|
|
|
public string Index { get; }
|
|
|
|
|
|
|
|
|
|
public ActivateInHandMsg(string index)
|
|
|
|
|
{
|
|
|
|
|
Directed = true;
|
|
|
|
|
Index = index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-21 20:58:11 +01:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class ClientAttackByInHandMsg : ComponentMessage
|
|
|
|
|
{
|
|
|
|
|
public string Index { get; }
|
|
|
|
|
|
|
|
|
|
public ClientAttackByInHandMsg(string index)
|
|
|
|
|
{
|
|
|
|
|
Directed = true;
|
|
|
|
|
Index = index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-31 17:49:18 -07:00
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class ClientChangedHandMsg : ComponentMessage
|
|
|
|
|
{
|
|
|
|
|
public string Index { get; }
|
|
|
|
|
|
|
|
|
|
public ClientChangedHandMsg(string index)
|
|
|
|
|
{
|
|
|
|
|
Directed = true;
|
|
|
|
|
Index = index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-25 15:11:16 +02:00
|
|
|
|
2020-10-28 10:16:40 +01:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class HandEnabledMsg : ComponentMessage
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
|
|
|
|
public HandEnabledMsg(string name)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class HandDisabledMsg : ComponentMessage
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
|
|
|
|
public HandDisabledMsg(string name)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-25 15:11:16 +02:00
|
|
|
public enum HandLocation : byte
|
|
|
|
|
{
|
|
|
|
|
Left,
|
|
|
|
|
Middle,
|
|
|
|
|
Right
|
|
|
|
|
}
|
2021-02-03 22:07:13 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Component message for displaying an animation of an entity flying towards the owner of a HandsComponent
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class AnimatePickupEntityMessage : ComponentMessage
|
|
|
|
|
{
|
|
|
|
|
public readonly EntityUid EntityId;
|
|
|
|
|
public readonly EntityCoordinates EntityPosition;
|
|
|
|
|
public AnimatePickupEntityMessage(EntityUid entity, EntityCoordinates entityPosition)
|
|
|
|
|
{
|
|
|
|
|
Directed = true;
|
|
|
|
|
EntityId = entity;
|
|
|
|
|
EntityPosition = entityPosition;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-26 21:27:48 +02:00
|
|
|
}
|