hands ECS (#7081)
This commit is contained in:
@@ -152,15 +152,10 @@ public sealed partial class GunSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TryComp(ammo, out ItemComponent? item))
|
||||
if (!_handsSystem.TryPickup(user, ammo, handsComp: handsComponent))
|
||||
{
|
||||
if (!handsComponent.CanPutInHand(item))
|
||||
{
|
||||
TryInsertAmmo(user, ammo, ammoBox);
|
||||
return false;
|
||||
}
|
||||
|
||||
handsComponent.PutInHand(item);
|
||||
TryInsertAmmo(user, ammo, ammoBox);
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateAmmoBoxAppearance(ammoBox.Owner, ammoBox);
|
||||
|
||||
@@ -36,7 +36,7 @@ public sealed partial class GunSystem
|
||||
{
|
||||
if (!TryComp(gun.Owner, out ServerRangedBarrelComponent? barrel)) return;
|
||||
|
||||
if (!TryComp(user, out HandsComponent? hands) || hands.GetActiveHand()?.HeldEntity != gun.Owner) return;
|
||||
if (!TryComp(user, out HandsComponent? hands) || hands.ActiveHand?.HeldEntity != gun.Owner) return;
|
||||
|
||||
if (!TryComp(user, out CombatModeComponent? combat) ||
|
||||
!combat.IsInCombatMode ||
|
||||
|
||||
@@ -28,8 +28,8 @@ public sealed partial class GunSystem
|
||||
if (args.Hands == null ||
|
||||
!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
!component.HasMagazine ||
|
||||
!_blocker.CanPickup(args.User))
|
||||
component.MagazineContainer.ContainedEntity is not EntityUid mag ||
|
||||
!_blocker.CanPickup(args.User, mag))
|
||||
return;
|
||||
|
||||
if (component.MagNeedsOpenBolt && !component.BoltOpen)
|
||||
@@ -37,7 +37,7 @@ public sealed partial class GunSystem
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Text = MetaData(component.MagazineContainer.ContainedEntity!.Value).EntityName,
|
||||
Text = MetaData(mag).EntityName,
|
||||
Category = VerbCategory.Eject,
|
||||
Act = () => RemoveMagazine(args.User, component)
|
||||
};
|
||||
@@ -325,10 +325,7 @@ public sealed partial class GunSystem
|
||||
component.MagazineContainer.Remove(mag.Value);
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner), component.SoundMagEject.GetSound(), component.Owner, AudioParams.Default.WithVolume(-2));
|
||||
|
||||
if (TryComp(user, out HandsComponent? handsComponent))
|
||||
{
|
||||
handsComponent.PutInHandOrDrop(EntityManager.GetComponent<SharedItemComponent>(mag.Value));
|
||||
}
|
||||
_handsSystem.PickupOrDrop(user, mag.Value);
|
||||
|
||||
component.Dirty(EntityManager);
|
||||
UpdateMagazineAppearance(component);
|
||||
|
||||
@@ -70,16 +70,8 @@ public sealed partial class GunSystem
|
||||
if (TakeAmmo(component) is not {Valid: true} ammo)
|
||||
return;
|
||||
|
||||
var itemComponent = EntityManager.GetComponent<SharedItemComponent>(ammo);
|
||||
if (!handsComponent.CanPutInHand(itemComponent))
|
||||
{
|
||||
Transform(ammo).Coordinates = Transform(args.User).Coordinates;
|
||||
EjectCasing(ammo);
|
||||
}
|
||||
else
|
||||
{
|
||||
handsComponent.PutInHand(itemComponent);
|
||||
}
|
||||
_handsSystem.PickupOrDrop(args.User, ammo, handsComp: handsComponent);
|
||||
EjectCasing(ammo);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -75,15 +75,10 @@ public sealed partial class GunSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var itemComponent = EntityManager.GetComponent<SharedItemComponent>(ammo.Value);
|
||||
if (!handsComponent.CanPutInHand(itemComponent))
|
||||
if (!_handsSystem.TryPickup(args.User, ammo.Value, handsComp: handsComponent))
|
||||
{
|
||||
EjectCasing(ammo.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
handsComponent.PutInHand(itemComponent);
|
||||
}
|
||||
|
||||
UpdateSpeedLoaderAppearance(component);
|
||||
args.Handled = true;
|
||||
|
||||
@@ -11,6 +11,7 @@ using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Camera;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Popups;
|
||||
@@ -47,6 +48,7 @@ public sealed partial class GunSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly StunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// How many sounds are allowed to be played on ejecting multiple casings.
|
||||
@@ -141,7 +143,7 @@ public sealed partial class GunSystem : EntitySystem
|
||||
return;
|
||||
|
||||
// TODO: Not exactly robust
|
||||
var gun = handsComponent.GetActiveHand()?.HeldEntity;
|
||||
var gun = handsComponent.ActiveHand?.HeldEntity;
|
||||
|
||||
if (gun == null || !TryComp(gun, out ServerRangedWeaponComponent? weapon))
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user