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

@@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.EntitySystems
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(ContainerModified);
SubscribeLocalEvent<EntRemovedFromContainerMessage>(ContainerModified);
SubscribeLocalEvent<BuckleComponent, AttackHandMessage>(HandleAttackHand);
SubscribeLocalEvent<BuckleComponent, AttackHandEvent>(HandleAttackHand);
}
public override void Shutdown()
@@ -35,10 +35,10 @@ namespace Content.Server.GameObjects.EntitySystems
UnsubscribeLocalEvent<EntInsertedIntoContainerMessage>();
UnsubscribeLocalEvent<EntRemovedFromContainerMessage>();
UnsubscribeLocalEvent<BuckleComponent, AttackHandMessage>(HandleAttackHand);
UnsubscribeLocalEvent<BuckleComponent, AttackHandEvent>(HandleAttackHand);
}
private void HandleAttackHand(EntityUid uid, BuckleComponent component, AttackHandMessage args)
private void HandleAttackHand(EntityUid uid, BuckleComponent component, AttackHandEvent args)
{
args.Handled = component.TryUnbuckle(args.User);
}

View File

@@ -41,7 +41,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
public override void Initialize()
{
SubscribeNetworkEvent<DragDropMessage>(HandleDragDropMessage);
SubscribeNetworkEvent<DragDropRequestEvent>(HandleDragDropMessage);
CommandBinds.Builder
.Bind(EngineKeyFunctions.Use,
@@ -60,7 +60,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
base.Shutdown();
}
private void HandleDragDropMessage(DragDropMessage msg, EntitySessionEventArgs args)
private void HandleDragDropMessage(DragDropRequestEvent msg, EntitySessionEventArgs args)
{
var performer = args.SenderSession.AttachedEntity;
@@ -68,7 +68,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
if (!EntityManager.TryGetEntity(msg.Dropped, out var dropped)) return;
if (!EntityManager.TryGetEntity(msg.Target, out var target)) return;
var interactionArgs = new DragDropEventArgs(performer, msg.DropLocation, dropped, target);
var interactionArgs = new DragDropEvent(performer, msg.DropLocation, dropped, target);
// must be in range of both the target and the object they are drag / dropping
// Client also does this check but ya know we gotta validate it.
@@ -132,7 +132,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
private void InteractionActivate(IEntity user, IEntity used)
{
var activateMsg = new ActivateInWorldMessage(user, used);
var activateMsg = new ActivateInWorldEvent(user, used);
RaiseLocalEvent(used.Uid, activateMsg);
if (activateMsg.Handled)
{
@@ -404,7 +404,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
private async void InteractAfter(IEntity user, IEntity weapon, EntityCoordinates clickLocation, bool canReach)
{
var message = new AfterInteractMessage(user, weapon, null, clickLocation, canReach);
var message = new AfterInteractEvent(user, weapon, null, clickLocation, canReach);
RaiseLocalEvent(weapon.Uid, message);
if (message.Handled)
{
@@ -421,7 +421,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public async Task Interaction(IEntity user, IEntity weapon, IEntity attacked, EntityCoordinates clickLocation)
{
var attackMsg = new InteractUsingMessage(user, weapon, attacked, clickLocation);
var attackMsg = new InteractUsingEvent(user, weapon, attacked, clickLocation);
RaiseLocalEvent(attacked.Uid, attackMsg);
if (attackMsg.Handled)
return;
@@ -442,7 +442,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
}
var afterAtkMsg = new AfterInteractMessage(user, weapon, attacked, clickLocation, true);
var afterAtkMsg = new AfterInteractEvent(user, weapon, attacked, clickLocation, true);
RaiseLocalEvent(weapon.Uid, afterAtkMsg, false);
if (afterAtkMsg.Handled)
{
@@ -461,7 +461,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void Interaction(IEntity user, IEntity attacked)
{
var message = new AttackHandMessage(user, attacked);
var message = new AttackHandEvent(user, attacked);
RaiseLocalEvent(attacked.Uid, message);
if (message.Handled)
return;
@@ -514,7 +514,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
delayComponent.BeginDelay();
}
var useMsg = new UseInHandMessage(user, used);
var useMsg = new UseInHandEvent(user, used);
RaiseLocalEvent(used.Uid, useMsg);
if (useMsg.Handled)
{
@@ -552,7 +552,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void ThrownInteraction(IEntity user, IEntity thrown)
{
var throwMsg = new ThrownMessage(user, thrown);
var throwMsg = new ThrownEvent(user, thrown);
RaiseLocalEvent(thrown.Uid, throwMsg);
if (throwMsg.Handled)
{
@@ -575,7 +575,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void EquippedInteraction(IEntity user, IEntity equipped, EquipmentSlotDefines.Slots slot)
{
var equipMsg = new EquippedMessage(user, equipped, slot);
var equipMsg = new EquippedEvent(user, equipped, slot);
RaiseLocalEvent(equipped.Uid, equipMsg);
if (equipMsg.Handled)
{
@@ -597,7 +597,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void UnequippedInteraction(IEntity user, IEntity equipped, EquipmentSlotDefines.Slots slot)
{
var unequipMsg = new UnequippedMessage(user, equipped, slot);
var unequipMsg = new UnequippedEvent(user, equipped, slot);
RaiseLocalEvent(equipped.Uid, unequipMsg);
if (unequipMsg.Handled)
{
@@ -619,7 +619,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void EquippedHandInteraction(IEntity user, IEntity item, SharedHand hand)
{
var equippedHandMessage = new EquippedHandMessage(user, item, hand);
var equippedHandMessage = new EquippedHandEvent(user, item, hand);
RaiseLocalEvent(item.Uid, equippedHandMessage);
if (equippedHandMessage.Handled)
{
@@ -640,7 +640,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void UnequippedHandInteraction(IEntity user, IEntity item, SharedHand hand)
{
var unequippedHandMessage = new UnequippedHandMessage(user, item, hand);
var unequippedHandMessage = new UnequippedHandEvent(user, item, hand);
RaiseLocalEvent(item.Uid, unequippedHandMessage);
if (unequippedHandMessage.Handled)
{
@@ -673,7 +673,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void DroppedInteraction(IEntity user, IEntity item, bool intentional)
{
var dropMsg = new DroppedMessage(user, item, intentional);
var dropMsg = new DroppedEvent(user, item, intentional);
RaiseLocalEvent(item.Uid, dropMsg);
if (dropMsg.Handled)
{
@@ -697,7 +697,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void HandSelectedInteraction(IEntity user, IEntity item)
{
var handSelectedMsg = new HandSelectedMessage(user, item);
var handSelectedMsg = new HandSelectedEvent(user, item);
RaiseLocalEvent(item.Uid, handSelectedMsg);
if (handSelectedMsg.Handled)
{
@@ -719,7 +719,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public void HandDeselectedInteraction(IEntity user, IEntity item)
{
var handDeselectedMsg = new HandDeselectedMessage(user, item);
var handDeselectedMsg = new HandDeselectedEvent(user, item);
RaiseLocalEvent(item.Uid, handDeselectedMsg);
if (handDeselectedMsg.Handled)
{
@@ -741,7 +741,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// </summary>
public async void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, EntityCoordinates clickLocation)
{
var rangedMsg = new RangedInteractMessage(user, weapon, attacked, clickLocation);
var rangedMsg = new RangedInteractEvent(user, weapon, attacked, clickLocation);
RaiseLocalEvent(attacked.Uid, rangedMsg);
if (rangedMsg.Handled)
return;
@@ -759,7 +759,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
}
var afterAtkMsg = new AfterInteractMessage(user, weapon, attacked, clickLocation, false);
var afterAtkMsg = new AfterInteractEvent(user, weapon, attacked, clickLocation, false);
RaiseLocalEvent(weapon.Uid, afterAtkMsg);
if (afterAtkMsg.Handled)
return;
@@ -815,7 +815,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
}
var eventArgs = new AttackEventArgs(player, coordinates, wideAttack, targetUid);
var eventArgs = new AttackEvent(player, coordinates, wideAttack, targetUid);
// Verify player has a hand, and find what object he is currently holding in his active hand
if (player.TryGetComponent<IHandsComponent>(out var hands))

View File

@@ -22,7 +22,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<CloningPodComponent, ActivateInWorldMessage>(HandleActivate);
SubscribeLocalEvent<CloningPodComponent, ActivateInWorldEvent>(HandleActivate);
SubscribeLocalEvent<BeingClonedComponent, MindAddedMessage>(HandleMindAdded);
}
@@ -30,7 +30,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Shutdown();
UnsubscribeLocalEvent<CloningPodComponent, ActivateInWorldMessage>(HandleActivate);
UnsubscribeLocalEvent<CloningPodComponent, ActivateInWorldEvent>(HandleActivate);
UnsubscribeLocalEvent<BeingClonedComponent, MindAddedMessage>(HandleMindAdded);
}
@@ -46,7 +46,7 @@ namespace Content.Server.GameObjects.EntitySystems
mind?.UnVisit();
}
private void HandleActivate(EntityUid uid, CloningPodComponent component, ActivateInWorldMessage args)
private void HandleActivate(EntityUid uid, CloningPodComponent component, ActivateInWorldEvent args)
{
if (!component.Powered ||
!args.User.TryGetComponent(out ActorComponent? actor))

View File

@@ -18,21 +18,21 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<DisassembleOnActivateComponent, ActivateInWorldMessage>(HandleActivateInWorld);
SubscribeLocalEvent<DisassembleOnActivateComponent, ActivateInWorldEvent>(HandleActivateInWorld);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<DisassembleOnActivateComponent, ActivateInWorldMessage>(HandleActivateInWorld);
UnsubscribeLocalEvent<DisassembleOnActivateComponent, ActivateInWorldEvent>(HandleActivateInWorld);
}
private async void HandleActivateInWorld(EntityUid uid, DisassembleOnActivateComponent component, ActivateInWorldMessage args)
private async void HandleActivateInWorld(EntityUid uid, DisassembleOnActivateComponent component, ActivateInWorldEvent args)
{
if (string.IsNullOrEmpty(component.Prototype))
return;
if (!args.User.InRangeUnobstructed(args.Activated))
if (!args.User.InRangeUnobstructed(args.Target))
return;
if (component.DoAfterTime > 0 && TryGet<DoAfterSystem>(out var doAfterSystem))

View File

@@ -17,48 +17,48 @@ namespace Content.Server.GameObjects.EntitySystems.Janitorial
{
base.Initialize();
SubscribeLocalEvent<LightReplacerComponent, InteractUsingMessage>(HandleInteract);
SubscribeLocalEvent<LightReplacerComponent, AfterInteractMessage>(HandleAfterInteract);
SubscribeLocalEvent<LightReplacerComponent, InteractUsingEvent>(HandleInteract);
SubscribeLocalEvent<LightReplacerComponent, AfterInteractEvent>(HandleAfterInteract);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<LightReplacerComponent, InteractUsingMessage>(HandleInteract);
UnsubscribeLocalEvent<LightReplacerComponent, AfterInteractMessage>(HandleAfterInteract);
UnsubscribeLocalEvent<LightReplacerComponent, InteractUsingEvent>(HandleInteract);
UnsubscribeLocalEvent<LightReplacerComponent, AfterInteractEvent>(HandleAfterInteract);
}
private void HandleAfterInteract(EntityUid uid, LightReplacerComponent component, AfterInteractMessage eventArgs)
private void HandleAfterInteract(EntityUid uid, LightReplacerComponent component, AfterInteractEvent eventArgs)
{
// standard interaction checks
if (!ActionBlockerSystem.CanUse(eventArgs.User)) return;
if (!eventArgs.CanReach) return;
// behaviour will depends on target type
if (eventArgs.Attacked != null)
if (eventArgs.Target != null)
{
// replace broken light in fixture?
if (eventArgs.Attacked.TryGetComponent(out PoweredLightComponent? fixture))
if (eventArgs.Target.TryGetComponent(out PoweredLightComponent? fixture))
component.TryReplaceBulb(fixture, eventArgs.User);
// add new bulb to light replacer container?
else if (eventArgs.Attacked.TryGetComponent(out LightBulbComponent? bulb))
else if (eventArgs.Target.TryGetComponent(out LightBulbComponent? bulb))
component.TryInsertBulb(bulb, eventArgs.User, true);
}
}
private void HandleInteract(EntityUid uid, LightReplacerComponent component, InteractUsingMessage eventArgs)
private void HandleInteract(EntityUid uid, LightReplacerComponent component, InteractUsingEvent eventArgs)
{
// standard interaction checks
if (!ActionBlockerSystem.CanInteract(eventArgs.User)) return;
if (eventArgs.ItemInHand != null)
if (eventArgs.Used != null)
{
// want to insert a new light bulb?
if (eventArgs.ItemInHand.TryGetComponent(out LightBulbComponent? bulb))
if (eventArgs.Used.TryGetComponent(out LightBulbComponent? bulb))
component.TryInsertBulb(bulb, eventArgs.User, true);
// add bulbs from storage?
else if (eventArgs.ItemInHand.TryGetComponent(out ServerStorageComponent? storage))
else if (eventArgs.Used.TryGetComponent(out ServerStorageComponent? storage))
component.TryInsertBulb(storage, eventArgs.User);
}
}

View File

@@ -21,17 +21,17 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<SpawnAfterInteractComponent, AfterInteractMessage>(HandleAfterInteract);
SubscribeLocalEvent<SpawnAfterInteractComponent, AfterInteractEvent>(HandleAfterInteract);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<SpawnAfterInteractComponent, AfterInteractMessage>(HandleAfterInteract);
UnsubscribeLocalEvent<SpawnAfterInteractComponent, AfterInteractEvent>(HandleAfterInteract);
}
private async void HandleAfterInteract(EntityUid uid, SpawnAfterInteractComponent component, AfterInteractMessage args)
private async void HandleAfterInteract(EntityUid uid, SpawnAfterInteractComponent component, AfterInteractEvent args)
{
if (string.IsNullOrEmpty(component.Prototype))
return;