Refactor MeleeWeaponComponent and related comps to be ECS (#4133)

* move everything to MeleeWeaponSystem

* refactor MeleeChemicalInjector

* hypospray and flash refactor

* stunbaton refactor

* bugfixes

* flash afterinteract

* resolve issues

* props

* playing the slots

* MeleeInteractEvent + bugfixes

* spear can actually use MeleeChemicalInjector
This commit is contained in:
mirrorcult
2021-06-05 00:20:52 -07:00
committed by GitHub
parent 3fa00d27df
commit f744b655b8
20 changed files with 895 additions and 750 deletions

View File

@@ -817,7 +817,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click
return;
}
// In a container where the target entity is not the container's owner
if (player.TryGetContainer(out var playerContainer) &&
(!EntityManager.TryGetEntity(targetUid, out var target) ||
@@ -832,8 +831,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
}
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))
{
@@ -841,35 +838,18 @@ namespace Content.Server.GameObjects.EntitySystems.Click
if (item != null)
{
RaiseLocalEvent(item.Uid, eventArgs, false);
foreach (var attackComponent in item.GetAllComponents<IAttack>())
{
if (wideAttack ? attackComponent.WideAttack(eventArgs) : attackComponent.ClickAttack(eventArgs))
return;
}
if(wideAttack)
RaiseLocalEvent(item.Uid, new WideAttackEvent(item, player, coordinates), false);
else
RaiseLocalEvent(item.Uid, new ClickAttackEvent(item, player, coordinates, targetUid), false);
}
else
{
// We pick up items if our hand is empty, even if we're in combat mode.
if (EntityManager.TryGetEntity(targetUid, out var targetEnt))
{
if (targetEnt.HasComponent<ItemComponent>())
{
Interaction(player, targetEnt);
return;
}
}
if (!EntityManager.TryGetEntity(targetUid, out var targetEnt) || !targetEnt.HasComponent<ItemComponent>()) return;
Interaction(player, targetEnt);
}
}
RaiseLocalEvent(player.Uid, eventArgs);
foreach (var attackComponent in player.GetAllComponents<IAttack>())
{
if (wideAttack)
attackComponent.WideAttack(eventArgs);
else
attackComponent.ClickAttack(eventArgs);
}
}
}
}