Fix guidebook examine not working in lobby (#17093)
This commit is contained in:
@@ -327,9 +327,9 @@ namespace Content.Client.Examine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoExamine(EntityUid entity, bool centeredOnCursor=true)
|
public void DoExamine(EntityUid entity, bool centeredOnCursor = true, EntityUid? userOverride = null)
|
||||||
{
|
{
|
||||||
var playerEnt = _playerManager.LocalPlayer?.ControlledEntity;
|
var playerEnt = userOverride ?? _playerManager.LocalPlayer?.ControlledEntity;
|
||||||
if (playerEnt == null)
|
if (playerEnt == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ public sealed partial class GuideEntityEmbed : BoxContainer, IDocumentTag
|
|||||||
// do examination?
|
// do examination?
|
||||||
if (args.Function == ContentKeyFunctions.ExamineEntity)
|
if (args.Function == ContentKeyFunctions.ExamineEntity)
|
||||||
{
|
{
|
||||||
_examineSystem.DoExamine(entity.Value);
|
_examineSystem.DoExamine(entity.Value,
|
||||||
|
userOverride: _guidebookSystem.GetGuidebookUser());
|
||||||
args.Handle();
|
args.Handle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Content.Shared.Tag;
|
|||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ public sealed class GuidebookSystem : EntitySystem
|
|||||||
public event Action<List<string>, List<string>?, string?, bool, string?>? OnGuidebookOpen;
|
public event Action<List<string>, List<string>?, string?, bool, string?>? OnGuidebookOpen;
|
||||||
public const string GuideEmbedTag = "GuideEmbeded";
|
public const string GuideEmbedTag = "GuideEmbeded";
|
||||||
|
|
||||||
|
private EntityUid _defaultUser;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -41,6 +44,23 @@ public sealed class GuidebookSystem : EntitySystem
|
|||||||
OnGuidebookControlsTestGetAlternateVerbs);
|
OnGuidebookControlsTestGetAlternateVerbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a user entity to use for verbs and examinations. If the player has no attached entity, this will use a
|
||||||
|
/// dummy client-side entity so that users can still use the guidebook when not attached to anything (e.g., in the
|
||||||
|
/// lobby)
|
||||||
|
/// </summary>
|
||||||
|
public EntityUid GetGuidebookUser()
|
||||||
|
{
|
||||||
|
var user = _playerManager.LocalPlayer!.ControlledEntity;
|
||||||
|
if (user != null)
|
||||||
|
return user.Value;
|
||||||
|
|
||||||
|
if (!Exists(_defaultUser))
|
||||||
|
_defaultUser = Spawn(null, MapCoordinates.Nullspace);
|
||||||
|
|
||||||
|
return _defaultUser;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnGetVerbs(EntityUid uid, GuideHelpComponent component, GetVerbsEvent<ExamineVerb> args)
|
private void OnGetVerbs(EntityUid uid, GuideHelpComponent component, GetVerbsEvent<ExamineVerb> args)
|
||||||
{
|
{
|
||||||
if (component.Guides.Count == 0 || _tags.HasTag(uid, GuideEmbedTag))
|
if (component.Guides.Count == 0 || _tags.HasTag(uid, GuideEmbedTag))
|
||||||
@@ -114,34 +134,26 @@ public sealed class GuidebookSystem : EntitySystem
|
|||||||
_audioSystem.PlayGlobal(speech.SpeechSounds, Filter.Local(), false, speech.AudioParams);
|
_audioSystem.PlayGlobal(speech.SpeechSounds, Filter.Local(), false, speech.AudioParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void FakeClientActivateInWorld(EntityUid activated)
|
public void FakeClientActivateInWorld(EntityUid activated)
|
||||||
{
|
{
|
||||||
var user = _playerManager.LocalPlayer!.ControlledEntity;
|
var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated);
|
||||||
if (user is null)
|
RaiseLocalEvent(activated, activateMsg);
|
||||||
return;
|
|
||||||
var activateMsg = new ActivateInWorldEvent(user.Value, activated);
|
|
||||||
RaiseLocalEvent(activated, activateMsg, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FakeClientAltActivateInWorld(EntityUid activated)
|
public void FakeClientAltActivateInWorld(EntityUid activated)
|
||||||
{
|
{
|
||||||
var user = _playerManager.LocalPlayer!.ControlledEntity;
|
|
||||||
if (user is null)
|
|
||||||
return;
|
|
||||||
// Get list of alt-interact verbs
|
// Get list of alt-interact verbs
|
||||||
var verbs = _verbSystem.GetLocalVerbs(activated, user.Value, typeof(AlternativeVerb));
|
var verbs = _verbSystem.GetLocalVerbs(activated, GetGuidebookUser(), typeof(AlternativeVerb), force: true);
|
||||||
|
|
||||||
if (!verbs.Any())
|
if (!verbs.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_verbSystem.ExecuteVerb(verbs.First(), user.Value, activated);
|
_verbSystem.ExecuteVerb(verbs.First(), GetGuidebookUser(), activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FakeClientUse(EntityUid activated)
|
public void FakeClientUse(EntityUid activated)
|
||||||
{
|
{
|
||||||
var user = _playerManager.LocalPlayer!.ControlledEntity ?? EntityUid.Invalid;
|
var activateMsg = new InteractHandEvent(GetGuidebookUser(), activated);
|
||||||
var activateMsg = new InteractHandEvent(user, activated);
|
RaiseLocalEvent(activated, activateMsg);
|
||||||
RaiseLocalEvent(activated, activateMsg, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ namespace Content.Client.Verbs
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verb.ClientExclusive)
|
if (verb.ClientExclusive || target.IsClientSide())
|
||||||
// is this a client exclusive (gui) verb?
|
// is this a client exclusive (gui) verb?
|
||||||
ExecuteVerb(verb, user.Value, target);
|
ExecuteVerb(verb, user.Value, target);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ namespace Content.Shared.Verbs
|
|||||||
public EntityUid EventTarget = EntityUid.Invalid;
|
public EntityUid EventTarget = EntityUid.Invalid;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If a verb is only defined client-side, this should be set to true.
|
/// Whether a verb is only defined client-side. Note that this has nothing to do with whether the target of
|
||||||
|
/// the verb is client-side
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If true, the client will not also ask the server to run this verb when executed locally. This just
|
/// If true, the client will not also ask the server to run this verb when executed locally. This just
|
||||||
|
|||||||
Reference in New Issue
Block a user