Pulled item interaction fix (#34587)
This commit is contained in:
@@ -46,6 +46,8 @@ public abstract class SharedVirtualItemSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<VirtualItemComponent, BeforeRangedInteractEvent>(OnBeforeRangedInteract);
|
||||
SubscribeLocalEvent<VirtualItemComponent, GettingInteractedWithAttemptEvent>(OnGettingInteractedWithAttemptEvent);
|
||||
|
||||
SubscribeLocalEvent<VirtualItemComponent, GetUsedEntityEvent>(OnGetUsedEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -81,6 +83,23 @@ public abstract class SharedVirtualItemSystem : EntitySystem
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnGetUsedEntity(Entity<VirtualItemComponent> ent, ref GetUsedEntityEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
// if the user is holding the real item the virtual item points to,
|
||||
// we allow them to use it in the interaction
|
||||
foreach (var hand in _handsSystem.EnumerateHands(args.User))
|
||||
{
|
||||
if (hand.HeldEntity == ent.Comp.BlockingEntity)
|
||||
{
|
||||
args.Used = ent.Comp.BlockingEntity;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Hands
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user