Predict inventory slot interactions. (#6033)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user