Actions System + UI (#2710)
Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -6,8 +6,11 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when being activated in the world when the user
|
||||
/// is in range and has unobstructed access to the target entity (allows inside blockers).
|
||||
/// This interface gives components behavior when being activated (by default,
|
||||
/// this is done via the "E" key) when the user is in range and has unobstructed access to the target entity
|
||||
/// (allows inside blockers). This includes activating an object in the world as well as activating an
|
||||
/// object in inventory. Unlike IUse, this can be performed on entities that aren't in the active hand,
|
||||
/// even when the active hand is currently holding something else.
|
||||
/// </summary>
|
||||
public interface IActivate
|
||||
{
|
||||
|
||||
@@ -7,8 +7,9 @@ using Robust.Shared.Map;
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components a behavior when clicking on another object and no interaction occurs,
|
||||
/// at any range.
|
||||
/// This interface gives components a behavior when their entity is in the active hand, when
|
||||
/// clicking on another object and no interaction occurs, at any range. This includes
|
||||
/// clicking on an object in the world as well as clicking on an object in inventory.
|
||||
/// </summary>
|
||||
public interface IAfterInteract
|
||||
{
|
||||
|
||||
@@ -7,22 +7,35 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when their owner is put in an inventory slot.
|
||||
/// This interface gives components behavior when their entity is put in a non-hand inventory slot,
|
||||
/// regardless of where it came from. This includes moving the entity from a hand slot into a non-hand slot
|
||||
/// (which would also fire <see cref="IUnequippedHand"/>).
|
||||
///
|
||||
/// This DOES NOT fire when putting the entity into a hand slot (<see cref="IEquippedHand"/>), nor
|
||||
/// does it fire when putting the entity into held/equipped storage.
|
||||
/// </summary>
|
||||
public interface IEquipped
|
||||
{
|
||||
void Equipped(EquippedEventArgs eventArgs);
|
||||
}
|
||||
|
||||
public class EquippedEventArgs : EventArgs
|
||||
public abstract class UserEventArgs : EventArgs
|
||||
{
|
||||
public EquippedEventArgs(IEntity user, EquipmentSlotDefines.Slots slot)
|
||||
public IEntity User { get; }
|
||||
|
||||
protected UserEventArgs(IEntity user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
|
||||
public class EquippedEventArgs : UserEventArgs
|
||||
{
|
||||
public EquippedEventArgs(IEntity user, EquipmentSlotDefines.Slots slot) : base(user)
|
||||
{
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
public IEntity User { get; }
|
||||
public EquipmentSlotDefines.Slots Slot { get; }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.Components.Items;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when their entity is put in a hand inventory slot,
|
||||
/// even if it came from another hand slot (which would also fire <see cref="IUnequippedHand"/>).
|
||||
/// This includes moving the entity from a non-hand slot into a hand slot
|
||||
/// (which would also fire <see cref="IUnequipped"/>).
|
||||
/// </summary>
|
||||
public interface IEquippedHand
|
||||
{
|
||||
void EquippedHand(EquippedHandEventArgs eventArgs);
|
||||
}
|
||||
|
||||
public class EquippedHandEventArgs : UserEventArgs
|
||||
{
|
||||
public EquippedHandEventArgs(IEntity user, SharedHand hand) : base(user)
|
||||
{
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
public SharedHand Hand { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when putting the entity into a hand slot
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public class EquippedHandMessage : EntitySystemMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// If this message has already been "handled" by a previous system.
|
||||
/// </summary>
|
||||
public bool Handled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that equipped the item.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Item that was equipped.
|
||||
/// </summary>
|
||||
public IEntity Equipped { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Hand the item is going into.
|
||||
/// </summary>
|
||||
public SharedHand Hand { get; }
|
||||
|
||||
public EquippedHandMessage(IEntity user, IEntity equipped, SharedHand hand)
|
||||
{
|
||||
User = user;
|
||||
Equipped = equipped;
|
||||
Hand = hand;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,9 @@ using Robust.Shared.Map;
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when being clicked on by a user with an object in their hand
|
||||
/// who is in range and has unobstructed reach of the target entity (allows inside blockers).
|
||||
/// This interface gives components behavior when their entity is clicked on by a user with an object in their hand
|
||||
/// who is in range and has unobstructed reach of the target entity (allows inside blockers). This includes
|
||||
/// clicking on an object in the world as well as clicking on an object in inventory.
|
||||
/// </summary>
|
||||
public interface IInteractUsing
|
||||
{
|
||||
|
||||
@@ -7,22 +7,25 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when their owner is removed from an inventory slot.
|
||||
/// This interface gives components behavior when their entity is removed from a non-hand inventory slot,
|
||||
/// regardless of where it's going to. This includes moving the entity from a non-hand slot into a hand slot
|
||||
/// (which would also fire <see cref="IEquippedHand"/>).
|
||||
///
|
||||
/// This DOES NOT fire when removing the entity from a hand slot (<see cref="IUnequippedHand"/>), nor
|
||||
/// does it fire when removing the entity from held/equipped storage.
|
||||
/// </summary>
|
||||
public interface IUnequipped
|
||||
{
|
||||
void Unequipped(UnequippedEventArgs eventArgs);
|
||||
}
|
||||
|
||||
public class UnequippedEventArgs : EventArgs
|
||||
public class UnequippedEventArgs : UserEventArgs
|
||||
{
|
||||
public UnequippedEventArgs(IEntity user, EquipmentSlotDefines.Slots slot)
|
||||
public UnequippedEventArgs(IEntity user, EquipmentSlotDefines.Slots slot) : base(user)
|
||||
{
|
||||
User = user;
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
public IEntity User { get; }
|
||||
public EquipmentSlotDefines.Slots Slot { get; }
|
||||
}
|
||||
|
||||
@@ -43,19 +46,19 @@ namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
public IEntity User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Item that was equipped.
|
||||
/// Item that was unequipped.
|
||||
/// </summary>
|
||||
public IEntity Equipped { get; }
|
||||
public IEntity Unequipped { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Slot where the item was removed from.
|
||||
/// </summary>
|
||||
public EquipmentSlotDefines.Slots Slot { get; }
|
||||
|
||||
public UnequippedMessage(IEntity user, IEntity equipped, EquipmentSlotDefines.Slots slot)
|
||||
public UnequippedMessage(IEntity user, IEntity unequipped, EquipmentSlotDefines.Slots slot)
|
||||
{
|
||||
User = user;
|
||||
Equipped = equipped;
|
||||
Unequipped = unequipped;
|
||||
Slot = slot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.Components.Items;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when their entity is removed from a hand slot,
|
||||
/// even if it is going into another hand slot (which would also fire <see cref="IEquippedHand"/>).
|
||||
/// This includes moving the entity from a hand slot into a non-hand slot (which would also fire <see cref="IEquipped"/>).
|
||||
/// </summary>
|
||||
public interface IUnequippedHand
|
||||
{
|
||||
void UnequippedHand(UnequippedHandEventArgs eventArgs);
|
||||
}
|
||||
|
||||
public class UnequippedHandEventArgs : UserEventArgs
|
||||
{
|
||||
public UnequippedHandEventArgs(IEntity user, SharedHand hand) : base(user)
|
||||
{
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
public SharedHand Hand { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when removing the entity from an inventory slot.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public class UnequippedHandMessage : EntitySystemMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// If this message has already been "handled" by a previous system.
|
||||
/// </summary>
|
||||
public bool Handled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that equipped the item.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Item that was unequipped.
|
||||
/// </summary>
|
||||
public IEntity Unequipped { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Hand the item is removed from.
|
||||
/// </summary>
|
||||
public SharedHand Hand { get; }
|
||||
|
||||
public UnequippedHandMessage(IEntity user, IEntity unequipped, SharedHand hand)
|
||||
{
|
||||
User = user;
|
||||
Unequipped = unequipped;
|
||||
Hand = hand;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when using the entity in your hands
|
||||
/// This interface gives components behavior when using the entity in your active hand
|
||||
/// (done by clicking the entity in the active hand or pressing the keybind that defaults to Z).
|
||||
/// </summary>
|
||||
public interface IUse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user