Enable nullability in Content.Client (#3257)
* Enable nullability in Content.Client * Remove #nullable enable * Merge fixes * Remove Debug.Assert * Merge fixes * Fix build * Fix build
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.AI;
|
||||
@@ -20,7 +20,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI
|
||||
{
|
||||
private PathfindingDebugMode _modes = PathfindingDebugMode.None;
|
||||
private float _routeDuration = 4.0f; // How long before we remove a route from the overlay
|
||||
private DebugPathfindingOverlay _overlay;
|
||||
private DebugPathfindingOverlay? _overlay;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI
|
||||
if ((_modes & PathfindingDebugMode.Nodes) != 0 ||
|
||||
(_modes & PathfindingDebugMode.Route) != 0)
|
||||
{
|
||||
_overlay.AStarRoutes.Add(message);
|
||||
_overlay?.AStarRoutes.Add(message);
|
||||
Timer.Spawn(TimeSpan.FromSeconds(_routeDuration), () =>
|
||||
{
|
||||
if (_overlay == null) return;
|
||||
@@ -59,7 +59,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI
|
||||
if ((_modes & PathfindingDebugMode.Nodes) != 0 ||
|
||||
(_modes & PathfindingDebugMode.Route) != 0)
|
||||
{
|
||||
_overlay.JpsRoutes.Add(message);
|
||||
_overlay?.JpsRoutes.Add(message);
|
||||
Timer.Spawn(TimeSpan.FromSeconds(_routeDuration), () =>
|
||||
{
|
||||
if (_overlay == null) return;
|
||||
@@ -70,32 +70,31 @@ namespace Content.Client.GameObjects.EntitySystems.AI
|
||||
|
||||
private void HandleGraphMessage(SharedAiDebug.PathfindingGraphMessage message)
|
||||
{
|
||||
EnableOverlay();
|
||||
_overlay.UpdateGraph(message.Graph);
|
||||
EnableOverlay().UpdateGraph(message.Graph);
|
||||
}
|
||||
|
||||
private void HandleRegionsMessage(SharedAiDebug.ReachableChunkRegionsDebugMessage message)
|
||||
{
|
||||
EnableOverlay();
|
||||
_overlay.UpdateRegions(message.GridId, message.Regions);
|
||||
EnableOverlay().UpdateRegions(message.GridId, message.Regions);
|
||||
}
|
||||
|
||||
private void HandleCachedRegionsMessage(SharedAiDebug.ReachableCacheDebugMessage message)
|
||||
{
|
||||
EnableOverlay();
|
||||
_overlay.UpdateCachedRegions(message.GridId, message.Regions, message.Cached);
|
||||
EnableOverlay().UpdateCachedRegions(message.GridId, message.Regions, message.Cached);
|
||||
}
|
||||
|
||||
private void EnableOverlay()
|
||||
private DebugPathfindingOverlay EnableOverlay()
|
||||
{
|
||||
if (_overlay != null)
|
||||
{
|
||||
return;
|
||||
return _overlay;
|
||||
}
|
||||
|
||||
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||
_overlay = new DebugPathfindingOverlay {Modes = _modes};
|
||||
overlayManager.AddOverlay(_overlay);
|
||||
|
||||
return _overlay;
|
||||
}
|
||||
|
||||
private void DisableOverlay()
|
||||
@@ -125,7 +124,11 @@ namespace Content.Client.GameObjects.EntitySystems.AI
|
||||
{
|
||||
EnableOverlay();
|
||||
}
|
||||
_overlay.Modes = _modes;
|
||||
|
||||
if (_overlay != null)
|
||||
{
|
||||
_overlay.Modes = _modes;
|
||||
}
|
||||
|
||||
if (tooltip == PathfindingDebugMode.Graph)
|
||||
{
|
||||
@@ -153,7 +156,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI
|
||||
{
|
||||
DisableOverlay();
|
||||
}
|
||||
else
|
||||
else if (_overlay != null)
|
||||
{
|
||||
_overlay.Modes = _modes;
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
// delegate to the ActionsUI, simulating a click on it
|
||||
return new((in PointerInputCmdHandler.PointerInputCmdArgs args) =>
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false;
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>(out var actionsComponent)) return false;
|
||||
|
||||
actionsComponent.HandleHotbarKeybind(slot, args);
|
||||
return true;
|
||||
@@ -92,7 +92,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
// delegate to the ActionsUI, simulating a click on it
|
||||
return new((in PointerInputCmdHandler.PointerInputCmdArgs args) =>
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private bool TargetingOnUse(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false;
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private void ToggleActionsMenu()
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return;
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private void HandleOpenCharacterMenu()
|
||||
{
|
||||
if (_playerManager.LocalPlayer.ControlledEntity == null
|
||||
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out CharacterInterface characterInterface))
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == null
|
||||
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out CharacterInterface? characterInterface))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components.Doors;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
CommandBinds.Builder
|
||||
.Bind(ContentKeyFunctions.OpenInventoryMenu,
|
||||
InputCmdHandler.FromDelegate(s => HandleOpenInventoryMenu()))
|
||||
InputCmdHandler.FromDelegate(_ => HandleOpenInventoryMenu()))
|
||||
.Register<ClientInventorySystem>();
|
||||
}
|
||||
|
||||
@@ -34,14 +34,16 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private void HandleOpenInventoryMenu()
|
||||
{
|
||||
if (_playerManager.LocalPlayer.ControlledEntity == null
|
||||
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out ClientInventoryComponent clientInventory))
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == null
|
||||
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out ClientInventoryComponent? clientInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var menu = clientInventory.InterfaceController.Window;
|
||||
|
||||
if (menu == null) return;
|
||||
|
||||
if (menu.IsOpen)
|
||||
{
|
||||
if (menu.IsAtFront())
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
private void CombatModeToggled(ICommonSession session)
|
||||
private void CombatModeToggled(ICommonSession? session)
|
||||
{
|
||||
if (_gameTiming.IsFirstTimePredicted)
|
||||
{
|
||||
@@ -51,8 +51,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
public bool IsInCombatMode()
|
||||
{
|
||||
var entity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out CombatModeComponent combatMode))
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out CombatModeComponent? combatMode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components.Construction;
|
||||
using Content.Shared.Construction;
|
||||
@@ -104,7 +104,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
if (!entity.TryGetComponent<ConstructionGhostComponent>(out var ghostComp))
|
||||
return false;
|
||||
|
||||
TryStartConstruction(ghostComp.GhostID);
|
||||
TryStartConstruction(ghostComp.GhostId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
var ghost = EntityManager.SpawnEntity("constructionghost", loc);
|
||||
var comp = ghost.GetComponent<ConstructionGhostComponent>();
|
||||
comp.Prototype = prototype;
|
||||
comp.GhostID = _nextId++;
|
||||
comp.GhostId = _nextId++;
|
||||
ghost.Transform.LocalRotation = dir.ToAngle();
|
||||
_ghosts.Add(comp.GhostID, comp);
|
||||
_ghosts.Add(comp.GhostId, comp);
|
||||
var sprite = ghost.GetComponent<SpriteComponent>();
|
||||
sprite.Color = new Color(48, 255, 48, 128);
|
||||
sprite.AddBlankLayer(0); // There is no way to actually check if this already exists, so we blindly insert a new one
|
||||
@@ -154,6 +154,12 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
private void TryStartConstruction(int ghostId)
|
||||
{
|
||||
var ghost = _ghosts[ghostId];
|
||||
|
||||
if (ghost.Prototype == null)
|
||||
{
|
||||
throw new ArgumentException($"Can't start construction for a ghost with no prototype. Ghost id: {ghostId}");
|
||||
}
|
||||
|
||||
var transform = ghost.Owner.Transform;
|
||||
var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId);
|
||||
RaiseNetworkEvent(msg);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.State;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared.GameObjects.EntitySystemMessages;
|
||||
@@ -262,7 +260,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private bool OnUseMouseUp(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
if (_dragDropHelper.IsDragging == false)
|
||||
if (_dragDropHelper.IsDragging == false || _dragDropHelper.Dragged == null)
|
||||
{
|
||||
// haven't started the drag yet, quick mouseup, definitely treat it as a normal click by
|
||||
// replaying the original cmd
|
||||
@@ -329,7 +327,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
if (!draggable.CanDrop(dropArgs)) continue;
|
||||
|
||||
// tell the server about the drop attempt
|
||||
RaiseNetworkEvent(new DragDropMessage(args.Coordinates, _dragDropHelper.Dragged.Uid,
|
||||
RaiseNetworkEvent(new DragDropMessage(args.Coordinates, _dragDropHelper.Dragged!.Uid,
|
||||
entity.Uid));
|
||||
|
||||
draggable.Drop(dropArgs);
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
public const string StyleClassEntityTooltip = "entity-tooltip";
|
||||
|
||||
private Popup _examineTooltipOpen;
|
||||
private CancellationTokenSource _requestCancelTokenSource;
|
||||
private Popup? _examineTooltipOpen;
|
||||
private CancellationTokenSource? _requestCancelTokenSource;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -45,14 +45,14 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
private bool HandleExamine(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleExamine(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
if (!uid.IsValid() || !EntityManager.TryGetEntity(uid, out var examined))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (playerEntity == null || !CanExamine(playerEntity, examined))
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
panel.AddChild(vBox);
|
||||
var hBox = new HBoxContainer {SeparationOverride = 5};
|
||||
vBox.AddChild(hBox);
|
||||
if (entity.TryGetComponent(out ISpriteComponent sprite))
|
||||
if (entity.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
hBox.AddChild(new SpriteView {Sprite = sprite});
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
FormattedMessage message;
|
||||
if (entity.Uid.IsClientSide())
|
||||
{
|
||||
message = GetExamineText(entity, _playerManager.LocalPlayer.ControlledEntity);
|
||||
message = GetExamineText(entity, _playerManager.LocalPlayer?.ControlledEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
// This is simpler to implement. If you want to optimize it be my guest.
|
||||
var senderEnt = ev.Sender;
|
||||
if (senderEnt.IsValid() &&
|
||||
senderEnt.TryGetComponent(out IconSmoothComponent iconSmooth)
|
||||
senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth)
|
||||
&& iconSmooth.Running)
|
||||
{
|
||||
var snapGrid = senderEnt.GetComponent<SnapGridComponent>();
|
||||
@@ -114,7 +114,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
// As it stands now, it's totally possible for something to get queued twice.
|
||||
// Generation on the component is set after an update so we can cull updates that happened this generation.
|
||||
if (!entity.IsValid()
|
||||
|| !entity.TryGetComponent(out IconSmoothComponent smoothing)
|
||||
|| !entity.TryGetComponent(out IconSmoothComponent? smoothing)
|
||||
|| smoothing.UpdateGeneration == _generation)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public class InstrumentSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
public override void Initialize()
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private void PlayWeaponArc(PlayMeleeWeaponAnimationMessage msg)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(msg.ArcPrototype, out MeleeWeaponAnimationPrototype weaponArc))
|
||||
if (!_prototypeManager.TryIndex(msg.ArcPrototype, out MeleeWeaponAnimationPrototype? weaponArc))
|
||||
{
|
||||
Logger.Error("Tried to play unknown weapon arc prototype '{0}'", msg.ArcPrototype);
|
||||
return;
|
||||
@@ -63,8 +63,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
weaponArcAnimation.SetData(weaponArc, msg.Angle, attacker, msg.ArcFollowAttacker);
|
||||
|
||||
// Due to ISpriteComponent limitations, weapons that don't use an RSI won't have this effect.
|
||||
if (EntityManager.TryGetEntity(msg.Source, out var source) && msg.TextureEffect && source.TryGetComponent(out ISpriteComponent sourceSprite)
|
||||
&& sourceSprite.BaseRSI?.Path != null)
|
||||
if (EntityManager.TryGetEntity(msg.Source, out var source) &&
|
||||
msg.TextureEffect &&
|
||||
source.TryGetComponent(out ISpriteComponent? sourceSprite) &&
|
||||
sourceSprite.BaseRSI?.Path != null)
|
||||
{
|
||||
var sys = Get<EffectSystem>();
|
||||
var curTime = _gameTiming.CurTime;
|
||||
@@ -91,7 +93,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hitEntity.TryGetComponent(out ISpriteComponent sprite))
|
||||
if (!hitEntity.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
private InputSystem _inputSystem;
|
||||
private CombatModeSystem _combatModeSystem;
|
||||
private InputSystem _inputSystem = default!;
|
||||
private CombatModeSystem _combatModeSystem = default!;
|
||||
private bool _blocked;
|
||||
private int _shotCounter;
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
base.Initialize();
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
_inputSystem = EntitySystemManager.GetEntitySystem<InputSystem>();
|
||||
_combatModeSystem = EntitySystemManager.GetEntitySystem<CombatModeSystem>();
|
||||
_inputSystem = Get<InputSystem>();
|
||||
_combatModeSystem = Get<CombatModeSystem>();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -55,14 +55,14 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
return;
|
||||
}
|
||||
|
||||
var entity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out HandsComponent hands))
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out HandsComponent? hands))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var held = hands.ActiveHand;
|
||||
if (held == null || !held.TryGetComponent(out ClientRangedWeaponComponent weapon))
|
||||
if (held == null || !held.TryGetComponent(out ClientRangedWeaponComponent? weapon))
|
||||
{
|
||||
_blocked = true;
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
protected override bool OnDown(IEntity entity, bool playSound = true, bool dropItems = true, bool force = false)
|
||||
{
|
||||
if (!entity.TryGetComponent(out AppearanceComponent appearance))
|
||||
if (!entity.TryGetComponent(out AppearanceComponent? appearance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
protected override bool OnStand(IEntity entity)
|
||||
{
|
||||
if (!entity.TryGetComponent(out AppearanceComponent appearance)) return false;
|
||||
if (!entity.TryGetComponent(out AppearanceComponent? appearance)) return false;
|
||||
|
||||
appearance.TryGetData<RotationState>(RotationVisuals.RotationState, out var oldState);
|
||||
var newState = RotationState.Vertical;
|
||||
|
||||
@@ -65,12 +65,12 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
UpdateTile(grid, indices);
|
||||
}
|
||||
|
||||
private void MapManagerOnTileChanged(object sender, TileChangedEventArgs e)
|
||||
private void MapManagerOnTileChanged(object? sender, TileChangedEventArgs e)
|
||||
{
|
||||
UpdateTile(_mapManager.GetGrid(e.NewTile.GridIndex), e.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
private void MapManagerOnGridChanged(object sender, GridChangedEventArgs e)
|
||||
private void MapManagerOnGridChanged(object? sender, GridChangedEventArgs e)
|
||||
{
|
||||
foreach (var modified in e.Modified)
|
||||
{
|
||||
@@ -85,19 +85,19 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center))
|
||||
{
|
||||
var entity = snapGridComponent.Owner;
|
||||
if (!entity.TryGetComponent(out SubFloorHideComponent subFloorComponent))
|
||||
if (!entity.TryGetComponent(out SubFloorHideComponent? subFloorComponent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var enabled = EnableAll || !subFloorComponent.Running || tileDef.IsSubFloor;
|
||||
|
||||
if (entity.TryGetComponent(out ISpriteComponent spriteComponent))
|
||||
if (entity.TryGetComponent(out ISpriteComponent? spriteComponent))
|
||||
{
|
||||
spriteComponent.Visible = enabled;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out PhysicsComponent physicsComponent))
|
||||
if (entity.TryGetComponent(out PhysicsComponent? physicsComponent))
|
||||
{
|
||||
physicsComponent.CanCollide = enabled;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
|
||||
private ContextMenuPresenter _contextMenuPresenter;
|
||||
public event EventHandler<PointerInputCmdHandler.PointerInputCmdArgs> ToggleContextMenu;
|
||||
public event EventHandler<bool> ToggleContainerVisibility;
|
||||
public event EventHandler<PointerInputCmdHandler.PointerInputCmdArgs>? ToggleContextMenu;
|
||||
public event EventHandler<bool>? ToggleContainerVisibility;
|
||||
|
||||
private VerbPopup _currentVerbListRoot;
|
||||
private VerbPopup _currentGroupList;
|
||||
private ContextMenuPresenter _contextMenuPresenter = default!;
|
||||
private VerbPopup? _currentVerbListRoot;
|
||||
private VerbPopup? _currentGroupList;
|
||||
private EntityUid _currentEntity;
|
||||
|
||||
// TODO: Move presenter out of the system
|
||||
@@ -132,7 +132,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
var buttons = new Dictionary<string, List<ListedVerbData>>();
|
||||
var groupIcons = new Dictionary<string, SpriteSpecifier>();
|
||||
|
||||
var vBox = _currentVerbListRoot.List;
|
||||
var vBox = _currentVerbListRoot!.List;
|
||||
vBox.DisposeAllChildren();
|
||||
|
||||
// Local variable so that scope capture ensures this is the correct value.
|
||||
@@ -147,7 +147,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
groupIcons.Add(data.Category, data.CategoryIcon);
|
||||
}
|
||||
|
||||
list.Add(new ListedVerbData(data.Text, !data.Available, data.Key, entity.ToString(), () =>
|
||||
list.Add(new ListedVerbData(data.Text, !data.Available, data.Key, entity.ToString()!, () =>
|
||||
{
|
||||
RaiseNetworkEvent(new VerbSystemMessages.UseVerbMessage(curEntity, data.Key));
|
||||
CloseAllMenus();
|
||||
@@ -175,7 +175,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
groupIcons.Add(verbData.Category, verbData.CategoryIcon);
|
||||
}
|
||||
|
||||
list.Add(new ListedVerbData(verbData.Text, verbData.IsDisabled, verb.ToString(), entity.ToString(),
|
||||
list.Add(new ListedVerbData(verbData.Text, verbData.IsDisabled, verb.ToString()!, entity.ToString()!,
|
||||
() => verb.Activate(user, component), verbData.Icon));
|
||||
}
|
||||
|
||||
@@ -199,8 +199,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
groupIcons.Add(verbData.Category, verbData.CategoryIcon);
|
||||
}
|
||||
|
||||
list.Add(new ListedVerbData(verbData.Text, verbData.IsDisabled, globalVerb.ToString(),
|
||||
entity.ToString(),
|
||||
list.Add(new ListedVerbData(verbData.Text, verbData.IsDisabled, globalVerb.ToString()!,
|
||||
entity.ToString()!,
|
||||
() => globalVerb.Activate(user, entity), verbData.Icon));
|
||||
}
|
||||
|
||||
@@ -223,9 +223,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
first = false;
|
||||
|
||||
groupIcons.TryGetValue(category, out var icon);
|
||||
|
||||
vBox.AddChild(CreateCategoryButton(category, verbs, icon));
|
||||
if (groupIcons.TryGetValue(category, out var icon))
|
||||
{
|
||||
vBox.AddChild(CreateCategoryButton(category, verbs, icon));
|
||||
}
|
||||
}
|
||||
|
||||
if (buttons.ContainsKey(""))
|
||||
@@ -321,7 +322,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private IEntity GetUserEntity()
|
||||
{
|
||||
return _playerManager.LocalPlayer.ControlledEntity;
|
||||
return _playerManager.LocalPlayer!.ControlledEntity!;
|
||||
}
|
||||
|
||||
private sealed class VerbPopup : Popup
|
||||
@@ -343,13 +344,13 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
private readonly Label _label;
|
||||
private readonly TextureRect _icon;
|
||||
|
||||
public Texture Icon
|
||||
public Texture? Icon
|
||||
{
|
||||
get => _icon.Texture;
|
||||
set => _icon.Texture = value;
|
||||
}
|
||||
|
||||
public string Text
|
||||
public string? Text
|
||||
{
|
||||
get => _label.Text;
|
||||
set => _label.Text = value;
|
||||
@@ -389,19 +390,21 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
private static readonly TimeSpan HoverDelay = TimeSpan.FromSeconds(0.2);
|
||||
|
||||
private readonly VerbSystem _system;
|
||||
public List<ListedVerbData> VerbButtons { get; }
|
||||
|
||||
private readonly Label _label;
|
||||
private readonly TextureRect _icon;
|
||||
|
||||
private CancellationTokenSource _openCancel;
|
||||
private CancellationTokenSource? _openCancel;
|
||||
|
||||
public string Text
|
||||
public List<ListedVerbData> VerbButtons { get; }
|
||||
|
||||
public string? Text
|
||||
{
|
||||
get => _label.Text;
|
||||
set => _label.Text = value;
|
||||
}
|
||||
|
||||
public Texture Icon
|
||||
public Texture? Icon
|
||||
{
|
||||
get => _icon.Texture;
|
||||
set => _icon.Texture = value;
|
||||
@@ -509,11 +512,11 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
public bool Disabled { get; }
|
||||
public string VerbName { get; }
|
||||
public string OwnerName { get; }
|
||||
public SpriteSpecifier Icon { get; }
|
||||
public SpriteSpecifier? Icon { get; }
|
||||
public Action Action { get; }
|
||||
|
||||
public ListedVerbData(string text, bool disabled, string verbName, string ownerName,
|
||||
Action action, SpriteSpecifier icon)
|
||||
Action action, SpriteSpecifier? icon)
|
||||
{
|
||||
Text = text;
|
||||
Disabled = disabled;
|
||||
|
||||
Reference in New Issue
Block a user