Predict inventory slot interactions. (#6033)

This commit is contained in:
Leon Friedrich
2022-01-30 13:50:10 +13:00
committed by GitHub
parent c465715273
commit 47e597ca47
9 changed files with 138 additions and 140 deletions

View File

@@ -70,12 +70,19 @@ namespace Content.Shared.Interaction
/// </summary>
public EntityCoordinates ClickLocation { get; }
public InteractUsingEvent(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation)
/// <summary>
/// If true, this prediction is also being predicted client-side. So care has to be taken to avoid audio
/// duplication.
/// </summary>
public bool Predicted { get; }
public InteractUsingEvent(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation, bool predicted = false)
{
User = user;
Used = used;
Target = target;
ClickLocation = clickLocation;
Predicted = predicted;
}
}
}

View File

@@ -532,7 +532,7 @@ namespace Content.Shared.Interaction
/// Finds components with the InteractUsing interface and calls their function
/// NOTE: Does not have an InRangeUnobstructed check
/// </summary>
public async Task InteractUsing(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation)
public async Task InteractUsing(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation, bool predicted = false)
{
if (!_actionBlockerSystem.CanInteract(user))
return;
@@ -541,7 +541,7 @@ namespace Content.Shared.Interaction
return;
// all interactions should only happen when in range / unobstructed, so no range check is needed
var interactUsingEvent = new InteractUsingEvent(user, used, target, clickLocation);
var interactUsingEvent = new InteractUsingEvent(user, used, target, clickLocation, predicted);
RaiseLocalEvent(target, interactUsingEvent);
if (interactUsingEvent.Handled)
return;