Verb predict (#5638)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.Access;
|
||||
using Content.Shared.Access.Systems;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Client.Access
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Access;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Access.SharedIdCardConsoleComponent;
|
||||
using static Content.Shared.Access.Components.SharedIdCardConsoleComponent;
|
||||
|
||||
namespace Content.Client.Access.UI
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Access.SharedIdCardConsoleComponent;
|
||||
using static Content.Shared.Access.Components.SharedIdCardConsoleComponent;
|
||||
|
||||
namespace Content.Client.Access.UI
|
||||
{
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace Content.Client.Entry
|
||||
"ResearchServer",
|
||||
"ResearchPointSource",
|
||||
"ResearchClient",
|
||||
"IdCard",
|
||||
"Access",
|
||||
"AccessReader",
|
||||
"IdCardConsole",
|
||||
@@ -155,7 +154,6 @@ namespace Content.Client.Entry
|
||||
"RefillableSolution",
|
||||
"DrainableSolution",
|
||||
"ExaminableSolution",
|
||||
"FitsInDispenser",
|
||||
"DrawableSolution",
|
||||
"InjectableSolution",
|
||||
"Barotrauma",
|
||||
@@ -295,7 +293,6 @@ namespace Content.Client.Entry
|
||||
"BatteryCharger",
|
||||
"UnpoweredFlashlight",
|
||||
"Uplink",
|
||||
"PDA",
|
||||
"SpawnItemsOnUse",
|
||||
"AmbientOnPowered",
|
||||
"Wieldable",
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Content.Client.Items.Managers
|
||||
}
|
||||
else if (args.Function == ContentKeyFunctions.AltActivateItemInWorld)
|
||||
{
|
||||
_entityManager.EntityNetManager?.SendSystemNetworkMessage(new InteractInventorySlotEvent(item, altInteract: true));
|
||||
_entityManager.RaisePredictiveEvent(new InteractInventorySlotEvent(item, altInteract: true));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
10
Content.Client/PDA/PDASystem.cs
Normal file
10
Content.Client/PDA/PDASystem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.PDA
|
||||
{
|
||||
public sealed class PDASystem : SharedPDASystem
|
||||
{
|
||||
// Nothing here. Have a lovely day.
|
||||
}
|
||||
}
|
||||
@@ -192,27 +192,43 @@ namespace Content.Client.Verbs
|
||||
/// Execute actions associated with the given verb.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Unless this is a client-exclusive verb, this will also tell the server to run the same verb. However, if the verb
|
||||
/// is disabled and has a tooltip, this function will only generate a pop-up-message instead of executing anything.
|
||||
/// Unless this is a client-exclusive verb, this will also tell the server to run the same verb.
|
||||
/// </remarks>
|
||||
public void ExecuteVerb(EntityUid target, Verb verb, VerbType verbType)
|
||||
{
|
||||
if (verb.Disabled)
|
||||
{
|
||||
if (verb.Message != null)
|
||||
_popupSystem.PopupCursor(verb.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
var user = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (user == null)
|
||||
return;
|
||||
|
||||
ExecuteVerb(verb, user.Value, target);
|
||||
|
||||
if (!verb.ClientExclusive)
|
||||
// is this verb actually valid?
|
||||
if (verb.Disabled)
|
||||
{
|
||||
RaiseNetworkEvent(new ExecuteVerbEvent(target, verb, verbType));
|
||||
// maybe send an informative pop-up message.
|
||||
if (!string.IsNullOrWhiteSpace(verb.Message))
|
||||
_popupSystem.PopupEntity(verb.Message, user.Value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (verb.ClientExclusive)
|
||||
// is this a client exclusive (gui) verb?
|
||||
ExecuteVerb(verb, user.Value, target);
|
||||
else
|
||||
EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb, verbType));
|
||||
}
|
||||
|
||||
public override void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bool forced = false)
|
||||
{
|
||||
// invoke any relevant actions
|
||||
verb.Act?.Invoke();
|
||||
|
||||
// Maybe raise a local event
|
||||
if (verb.ExecutionEventArgs != null)
|
||||
{
|
||||
if (verb.EventTarget.IsValid())
|
||||
RaiseLocalEvent(verb.EventTarget, verb.ExecutionEventArgs);
|
||||
else
|
||||
RaiseLocalEvent(verb.ExecutionEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user