Rename and clean up interaction events (#4044)

* Rename and clean up interaction events

* Fix hand equip events
This commit is contained in:
ShadowCommander
2021-05-22 21:06:40 -07:00
committed by GitHub
parent d97021d3a0
commit acb102f978
62 changed files with 273 additions and 240 deletions

View File

@@ -38,22 +38,22 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when an entity is activated in the world.
/// </summary>
[PublicAPI]
public class ActivateInWorldMessage : HandledEntityEventArgs
public class ActivateInWorldEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that activated the world entity.
/// Entity that activated the target world entity.
/// </summary>
public IEntity User { get; }
/// <summary>
/// Entity that was activated in the world.
/// </summary>
public IEntity Activated { get; }
public IEntity Target { get; }
public ActivateInWorldMessage(IEntity user, IEntity activated)
public ActivateInWorldEvent(IEntity user, IEntity target)
{
User = user;
Activated = activated;
Target = target;
}
}
}

View File

@@ -51,22 +51,22 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when clicking on another object and no attack event was handled.
/// </summary>
[PublicAPI]
public class AfterInteractMessage : HandledEntityEventArgs
public class AfterInteractEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that triggered the attack.
/// Entity that triggered the interaction.
/// </summary>
public IEntity User { get; }
/// <summary>
/// Entity that the User attacked with.
/// Entity that the user used to interact.
/// </summary>
public IEntity ItemInHand { get; set; }
public IEntity Used { get; }
/// <summary>
/// Entity that was attacked. This can be null if the attack did not click on an entity.
/// Entity that was interacted on. This can be null if the attack did not click on an entity.
/// </summary>
public IEntity? Attacked { get; }
public IEntity? Target { get; }
/// <summary>
/// Location that the user clicked outside of their interaction range.
@@ -79,13 +79,13 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public bool CanReach { get; }
public AfterInteractMessage(IEntity user, IEntity itemInHand, IEntity? attacked,
public AfterInteractEvent(IEntity user, IEntity used, IEntity? target,
EntityCoordinates clickLocation, bool canReach)
{
User = user;
Attacked = attacked;
Used = used;
Target = target;
ClickLocation = clickLocation;
ItemInHand = itemInHand;
CanReach = canReach;
}
}

View File

@@ -15,15 +15,43 @@ namespace Content.Shared.Interfaces.GameObjects.Components
{
// Redirects to ClickAttack by default.
[Obsolete("WideAttack")]
bool WideAttack(AttackEventArgs eventArgs) => ClickAttack(eventArgs);
bool WideAttack(AttackEvent eventArgs) => ClickAttack(eventArgs);
[Obsolete("Use ClickAttack instead")]
bool ClickAttack(AttackEventArgs eventArgs);
bool ClickAttack(AttackEvent eventArgs);
}
public class AttackEventArgs : EntityEventArgs
/// <summary>
/// Raised when a target entity is attacked by a user.
/// </summary>
public class AttackEvent : EntityEventArgs
{
public AttackEventArgs(IEntity user, EntityCoordinates clickLocation, bool wideAttack, EntityUid target = default)
/// <summary>
/// Entity that triggered the attack.
/// </summary>
public IEntity User { get; }
/// <summary>
/// The original location that was clicked by the user.
/// </summary>
public EntityCoordinates ClickLocation { get; }
/// <summary>
/// Indicates whether the attack creates a swing attack or attacks the target entity directly.
/// </summary>
public bool WideAttack { get; }
/// <summary>
/// UID of the entity that was attacked.
/// </summary>
public EntityUid Target { get; }
/// <summary>
/// Entity that was attacked.
/// </summary>
public IEntity? TargetEntity { get; }
public AttackEvent(IEntity user, EntityCoordinates clickLocation, bool wideAttack, EntityUid target = default)
{
User = user;
ClickLocation = clickLocation;
@@ -33,11 +61,5 @@ namespace Content.Shared.Interfaces.GameObjects.Components
IoCManager.Resolve<IEntityManager>().TryGetEntity(Target, out var targetEntity);
TargetEntity = targetEntity;
}
public IEntity User { get; }
public EntityCoordinates ClickLocation { get; }
public bool WideAttack { get; }
public EntityUid Target { get; }
public IEntity? TargetEntity { get; }
}
}

View File

@@ -18,7 +18,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
/// <param name="eventArgs"></param>
/// <returns>true if <see cref="eventArgs"/> is valid, false otherwise.</returns>
bool CanDragDropOn(DragDropEventArgs eventArgs);
bool CanDragDropOn(DragDropEvent eventArgs);
/// <summary>
/// Invoked server-side when another entity is being dragged and dropped
@@ -30,6 +30,6 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// true if an interaction occurred and no further interaction should
/// be processed for this drop.
/// </returns>
bool DragDropOn(DragDropEventArgs eventArgs);
bool DragDropOn(DragDropEvent eventArgs);
}
}

View File

@@ -23,7 +23,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// The information about the drag, such as who is doing it.
/// </param>
/// <returns>True if the drag should be initiated, false otherwise.</returns>
bool CanStartDrag(StartDragDropEventArgs args)
bool CanStartDrag(StartDragDropEvent args)
{
return true;
}
@@ -39,7 +39,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// True if target is a valid target to be dropped on by this component's
/// entity, false otherwise.
/// </returns>
bool CanDrop(CanDropEventArgs args);
bool CanDrop(CanDropEvent args);
/// <summary>
/// Invoked when this component's entity is being dropped on another.
@@ -52,73 +52,74 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// True if an interaction occurred and no further interaction should
/// be processed for this drop, false otherwise.
/// </returns>
bool Drop(DragDropEventArgs args)
bool Drop(DragDropEvent args)
{
return false;
}
}
public class StartDragDropEventArgs : EntityEventArgs
public class StartDragDropEvent : EntityEventArgs
{
/// <summary>
/// Creates a new instance of <see cref="StartDragDropEventArgs"/>.
/// </summary>
/// <param name="user">The entity doing the drag and drop.</param>
/// <param name="dragged">The entity that is being dragged and dropped.</param>
public StartDragDropEventArgs(IEntity user, IEntity dragged)
{
User = user;
Dragged = dragged;
}
/// <summary>
/// The entity doing the drag and drop.
/// Entity doing the drag and drop.
/// </summary>
public IEntity User { get; }
/// <summary>
/// The entity that is being dragged.
/// Entity that is being dragged.
/// </summary>
public IEntity Dragged { get; }
/// <summary>
/// Creates a new instance of <see cref="StartDragDropEvent"/>.
/// </summary>
/// <param name="user">The entity doing the drag and drop.</param>
/// <param name="dragged">The entity that is being dragged and dropped.</param>
public StartDragDropEvent(IEntity user, IEntity dragged)
{
User = user;
Dragged = dragged;
}
}
public class CanDropEventArgs : StartDragDropEventArgs
public class CanDropEvent : StartDragDropEvent
{
/// <summary>
/// Creates a new instance of <see cref="CanDropEventArgs"/>.
/// The entity that <see cref="StartDragDropEvent.Dragged"/>
/// is being dropped onto.
/// </summary>
public IEntity Target { get; }
/// <summary>
/// Creates a new instance of <see cref="CanDropEvent"/>.
/// </summary>
/// <param name="user">The entity doing the drag and drop.</param>
/// <param name="dragged">The entity that is being dragged and dropped.</param>
/// <param name="target">The entity that <see cref="dropped"/> is being dropped onto.</param>
public CanDropEventArgs(IEntity user, IEntity dragged, IEntity target) : base(user, dragged)
public CanDropEvent(IEntity user, IEntity dragged, IEntity target) : base(user, dragged)
{
Target = target;
}
/// <summary>
/// The entity that <see cref="StartDragDropEventArgs.Dragged"/>
/// is being dropped onto.
/// </summary>
public IEntity Target { get; }
}
public class DragDropEventArgs : CanDropEventArgs
public class DragDropEvent : CanDropEvent
{
/// <summary>
/// Creates a new instance of <see cref="DragDropEventArgs"/>.
/// The location where <see cref="StartDragDropEvent.Dragged"/>
/// is being dropped.
/// </summary>
public EntityCoordinates DropLocation { get; }
/// <summary>
/// Creates a new instance of <see cref="DragDropEvent"/>.
/// </summary>
/// <param name="user">The entity doing the drag and drop.</param>
/// <param name="dropLocation">The location where <see cref="dropped"/> is being dropped.</param>
/// <param name="dragged">The entity that is being dragged and dropped.</param>
/// <param name="target">The entity that <see cref="dropped"/> is being dropped onto.</param>
public DragDropEventArgs(IEntity user, EntityCoordinates dropLocation, IEntity dragged, IEntity target) : base(user, dragged, target)
public DragDropEvent(IEntity user, EntityCoordinates dropLocation, IEntity dragged, IEntity target) : base(user, dragged, target)
{
DropLocation = dropLocation;
}
/// <summary>
/// The location where <see cref="StartDragDropEventArgs.Dragged"/>
/// is being dropped.
/// </summary>
public EntityCoordinates DropLocation { get; }
}
}

View File

@@ -33,7 +33,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when an entity is dropped
/// </summary>
[PublicAPI]
public class DroppedMessage : HandledEntityEventArgs
public class DroppedEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that dropped the item.
@@ -50,7 +50,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public bool Intentional { get; }
public DroppedMessage(IEntity user, IEntity dropped, bool intentional)
public DroppedEvent(IEntity user, IEntity dropped, bool intentional)
{
User = user;
Dropped = dropped;

View File

@@ -43,10 +43,10 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when equipping the entity in an inventory slot.
/// Raised when equipping an entity in an inventory slot.
/// </summary>
[PublicAPI]
public class EquippedMessage : HandledEntityEventArgs
public class EquippedEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that equipped the item.
@@ -59,11 +59,11 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity Equipped { get; }
/// <summary>
/// Slot where the item was placed.
/// Slot that the item was placed into.
/// </summary>
public EquipmentSlotDefines.Slots Slot { get; }
public EquippedMessage(IEntity user, IEntity equipped, EquipmentSlotDefines.Slots slot)
public EquippedEvent(IEntity user, IEntity equipped, EquipmentSlotDefines.Slots slot)
{
User = user;
Equipped = equipped;

View File

@@ -31,10 +31,10 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when putting the entity into a hand slot
/// Raised when putting an entity into a hand slot
/// </summary>
[PublicAPI]
public class EquippedHandMessage : HandledEntityEventArgs
public class EquippedHandEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that equipped the item.
@@ -47,11 +47,11 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity Equipped { get; }
/// <summary>
/// Hand the item is going into.
/// Hand that the item was placed into.
/// </summary>
public SharedHand Hand { get; }
public EquippedHandMessage(IEntity user, IEntity equipped, SharedHand hand)
public EquippedHandEvent(IEntity user, IEntity equipped, SharedHand hand)
{
User = user;
Equipped = equipped;

View File

@@ -30,7 +30,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when an entity item in a hand is deselected.
/// </summary>
[PublicAPI]
public class HandDeselectedMessage : HandledEntityEventArgs
public class HandDeselectedEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that owns the deselected hand.
@@ -38,11 +38,11 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity User { get; }
/// <summary>
/// The item in question.
/// Item in the hand that was deselected.
/// </summary>
public IEntity Item { get; }
public HandDeselectedMessage(IEntity user, IEntity item)
public HandDeselectedEvent(IEntity user, IEntity item)
{
User = user;
Item = item;

View File

@@ -27,10 +27,10 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when an entity item in a hand is selected.
/// Raised when an item entity held by a hand is selected.
/// </summary>
[PublicAPI]
public class HandSelectedMessage : HandledEntityEventArgs
public class HandSelectedEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that owns the selected hand.
@@ -38,11 +38,11 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity User { get; }
/// <summary>
/// The item in question.
/// Item in the hand that was selected.
/// </summary>
public IEntity Item { get; }
public HandSelectedMessage(IEntity user, IEntity item)
public HandSelectedEvent(IEntity user, IEntity item)
{
User = user;
Item = item;

View File

@@ -31,27 +31,26 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity Target { get; }
}
/// <summary>
/// Raised when being clicked on or "attacked" by a user with an empty hand.
/// Raised when a target entity is interacted with by a user with an empty hand.
/// </summary>
[PublicAPI]
public class AttackHandMessage : HandledEntityEventArgs
public class AttackHandEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that triggered the attack.
/// Entity that triggered the interaction.
/// </summary>
public IEntity User { get; }
/// <summary>
/// Entity that was attacked.
/// Entity that was interacted on.
/// </summary>
public IEntity Attacked { get; }
public IEntity Target { get; }
public AttackHandMessage(IEntity user, IEntity attacked)
public AttackHandEvent(IEntity user, IEntity target)
{
User = user;
Attacked = attacked;
Target = target;
}
}
}

View File

@@ -45,36 +45,36 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when being clicked on or "attacked" by a user with an object in their hand
/// Raised when a target entity is interacted with by a user while holding an object in their hand.
/// </summary>
[PublicAPI]
public class InteractUsingMessage : HandledEntityEventArgs
public class InteractUsingEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that triggered the attack.
/// Entity that triggered the interaction.
/// </summary>
public IEntity User { get; }
/// <summary>
/// Entity that the User attacked with.
/// Entity that the user used to interact.
/// </summary>
public IEntity ItemInHand { get; }
public IEntity Used { get; }
/// <summary>
/// Entity that was attacked.
/// Entity that was interacted on.
/// </summary>
public IEntity Attacked { get; }
public IEntity Target { get; }
/// <summary>
/// The original location that was clicked by the user.
/// </summary>
public EntityCoordinates ClickLocation { get; }
public InteractUsingMessage(IEntity user, IEntity itemInHand, IEntity attacked, EntityCoordinates clickLocation)
public InteractUsingEvent(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation)
{
User = user;
ItemInHand = itemInHand;
Attacked = attacked;
Used = used;
Target = target;
ClickLocation = clickLocation;
}
}

View File

@@ -32,7 +32,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when an entity that was thrown lands.
/// </summary>
[PublicAPI]
public class LandMessage : HandledEntityEventArgs
public class LandEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that threw the item.
@@ -49,7 +49,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public EntityCoordinates LandLocation { get; }
public LandMessage(IEntity? user, IEntity thrown, EntityCoordinates landLocation)
public LandEvent(IEntity? user, IEntity thrown, EntityCoordinates landLocation)
{
User = user;
Thrown = thrown;

View File

@@ -36,37 +36,37 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when being clicked by objects outside the range of direct use.
/// Raised when an entity is interacted with that is out of the user entity's range of direct use.
/// </summary>
[PublicAPI]
public class RangedInteractMessage : HandledEntityEventArgs
public class RangedInteractEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that triggered the attack.
/// Entity that triggered the interaction.
/// </summary>
public IEntity User { get; }
/// <summary>
/// Entity that the User attacked with.
/// Entity that the user used to interact.
/// </summary>
public IEntity ItemInHand { get; set; }
public IEntity Used { get; }
/// <summary>
/// Entity that was attacked.
/// Entity that was interacted on.
/// </summary>
public IEntity Attacked { get; }
public IEntity Target { get; }
/// <summary>
/// Location that the user clicked outside of their interaction range.
/// </summary>
public EntityCoordinates ClickLocation { get; }
public RangedInteractMessage(IEntity user, IEntity itemInHand, IEntity attacked, EntityCoordinates clickLocation)
public RangedInteractEvent(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation)
{
User = user;
ItemInHand = itemInHand;
Used = used;
Target = target;
ClickLocation = clickLocation;
Attacked = attacked;
}
}
}

View File

@@ -38,7 +38,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
}
public class ThrowCollideMessage : HandledEntityEventArgs
public class ThrowCollideEvent : HandledEntityEventArgs
{
/// <summary>
/// The entity that threw <see cref="Thrown"/>.
@@ -55,7 +55,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public IEntity Target { get; }
public ThrowCollideMessage(IEntity? user, IEntity thrown, IEntity target)
public ThrowCollideEvent(IEntity? user, IEntity thrown, IEntity target)
{
User = user;
Thrown = thrown;

View File

@@ -30,7 +30,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when throwing the entity in your hands.
/// </summary>
[PublicAPI]
public class ThrownMessage : HandledEntityEventArgs
public class ThrownEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that threw the item.
@@ -42,7 +42,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public IEntity Thrown { get; }
public ThrownMessage(IEntity user, IEntity thrown)
public ThrownEvent(IEntity user, IEntity thrown)
{
User = user;
Thrown = thrown;

View File

@@ -33,10 +33,10 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when removing the entity from an inventory slot.
/// Raised when removing an entity from an inventory slot.
/// </summary>
[PublicAPI]
public class UnequippedMessage : HandledEntityEventArgs
public class UnequippedEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that equipped the item.
@@ -49,11 +49,11 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity Unequipped { get; }
/// <summary>
/// Slot where the item was removed from.
/// Slot that the item was removed from.
/// </summary>
public EquipmentSlotDefines.Slots Slot { get; }
public UnequippedMessage(IEntity user, IEntity unequipped, EquipmentSlotDefines.Slots slot)
public UnequippedEvent(IEntity user, IEntity unequipped, EquipmentSlotDefines.Slots slot)
{
User = user;
Unequipped = unequipped;

View File

@@ -30,10 +30,10 @@ namespace Content.Shared.Interfaces.GameObjects.Components
}
/// <summary>
/// Raised when removing the entity from an inventory slot.
/// Raised when removing an entity from an inventory slot.
/// </summary>
[PublicAPI]
public class UnequippedHandMessage : HandledEntityEventArgs
public class UnequippedHandEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity that equipped the item.
@@ -46,11 +46,11 @@ namespace Content.Shared.Interfaces.GameObjects.Components
public IEntity Unequipped { get; }
/// <summary>
/// Hand the item is removed from.
/// Hand that the item is removed from.
/// </summary>
public SharedHand Hand { get; }
public UnequippedHandMessage(IEntity user, IEntity unequipped, SharedHand hand)
public UnequippedHandEvent(IEntity user, IEntity unequipped, SharedHand hand)
{
User = user;
Unequipped = unequipped;

View File

@@ -34,7 +34,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// Raised when using the entity in your hands.
/// </summary>
[PublicAPI]
public class UseInHandMessage : HandledEntityEventArgs
public class UseInHandEvent : HandledEntityEventArgs
{
/// <summary>
/// Entity holding the item in their hand.
@@ -46,7 +46,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public IEntity Used { get; }
public UseInHandMessage(IEntity user, IEntity used)
public UseInHandEvent(IEntity user, IEntity used)
{
User = user;
Used = used;