Patched Actions Rework (#6899)

* Rejig Actions

* fix merge errors

* lambda-b-gon

* fix PAI, add innate actions

* Revert "fix PAI, add innate actions"

This reverts commit 4b501ac083e979e31ebd98d7b98077e0dbdd344b.

* Just fix by making nullable.

if only require: true actually did something somehow.

* Make AddActions() ensure an actions component

and misc comments

* misc cleanup

* Limit range even when not checking for obstructions

* remove old guardian code

* rename function and make EntityUid nullable

* fix magboot bug

* fix action search menu

* make targeting toggle all equivalent actions

* fix combat popups (enabling <-> disabling)

* fix networking

* Allow action locking

* prevent telepathy
This commit is contained in:
Leon Friedrich
2022-02-26 18:24:08 +13:00
committed by GitHub
parent d32f884157
commit ff7d4ed9f6
135 changed files with 3156 additions and 5166 deletions

View File

@@ -24,14 +24,74 @@ public sealed class InteractionOutlineSystem : EntitySystem
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
public bool Enabled = true;
/// <summary>
/// Whether to currently draw the outline. The outline may be temporarily disabled by other systems
/// </summary>
private bool _enabled = true;
/// <summary>
/// Whether to draw the outline at all. Overrides <see cref="_enabled"/>.
/// </summary>
private bool _cvarEnabled = true;
private EntityUid? _lastHoveredEntity;
public override void Initialize()
{
base.Initialize();
_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
}
public override void Shutdown()
{
base.Shutdown();
_configManager.UnsubValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
}
public void SetCvarEnabled(bool cvarEnabled)
{
_cvarEnabled = cvarEnabled;
// clear last hover if required:
if (_cvarEnabled)
return;
if (_lastHoveredEntity == null || Deleted(_lastHoveredEntity))
return;
if (TryComp(_lastHoveredEntity, out InteractionOutlineComponent? outline))
outline.OnMouseLeave();
}
public void SetEnabled(bool enabled)
{
if (enabled == _enabled)
return;
_enabled = enabled;
// clear last hover if required:
if (enabled)
return;
if (_lastHoveredEntity == null || Deleted(_lastHoveredEntity))
return;
if (TryComp(_lastHoveredEntity, out InteractionOutlineComponent? outline))
outline.OnMouseLeave();
}
public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);
if (!_enabled || !_cvarEnabled)
return;
// If there is no local player, there is no session, and therefore nothing to do here.
var localPlayer = _playerManager.LocalPlayer;
if (localPlayer == null)
@@ -81,16 +141,6 @@ public sealed class InteractionOutlineSystem : EntitySystem
InteractionOutlineComponent? outline;
if (!Enabled || !_configManager.GetCVar(CCVars.OutlineEnabled))
{
if (entityToClick != null && TryComp(entityToClick, out outline))
{
outline.OnMouseLeave(); //Prevent outline remains from persisting post command.
}
return;
}
if (entityToClick == _lastHoveredEntity)
{
if (entityToClick != null && TryComp(entityToClick, out outline))