Make more uids nullable (#5794)
This commit is contained in:
@@ -14,9 +14,6 @@ namespace Content.Client.Body.UI
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private BodyScannerDisplay? _display;
|
private BodyScannerDisplay? _display;
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
private EntityUid _entity;
|
|
||||||
|
|
||||||
public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { }
|
public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { }
|
||||||
|
|
||||||
protected override void Open()
|
protected override void Open()
|
||||||
@@ -43,7 +40,7 @@ namespace Content.Client.Body.UI
|
|||||||
throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner} at {entMan.GetComponent<TransformComponent>(Owner.Owner).MapPosition}");
|
throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner} at {entMan.GetComponent<TransformComponent>(Owner.Owner).MapPosition}");
|
||||||
}
|
}
|
||||||
|
|
||||||
_display?.UpdateDisplay(_entity);
|
_display?.UpdateDisplay(scannerState.Uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Content.Client.Body.UI
|
|||||||
{
|
{
|
||||||
public sealed class BodyScannerDisplay : SS14Window
|
public sealed class BodyScannerDisplay : SS14Window
|
||||||
{
|
{
|
||||||
private EntityUid _currentEntity;
|
private EntityUid? _currentEntity;
|
||||||
private SharedBodyPartComponent? _currentBodyPart;
|
private SharedBodyPartComponent? _currentBodyPart;
|
||||||
|
|
||||||
public BodyScannerDisplay(BodyScannerBoundUserInterface owner)
|
public BodyScannerDisplay(BodyScannerBoundUserInterface owner)
|
||||||
@@ -104,9 +104,6 @@ namespace Content.Client.Body.UI
|
|||||||
|
|
||||||
public void UpdateDisplay(EntityUid entity)
|
public void UpdateDisplay(EntityUid entity)
|
||||||
{
|
{
|
||||||
if(entity == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_currentEntity = entity;
|
_currentEntity = entity;
|
||||||
BodyPartList.Clear();
|
BodyPartList.Clear();
|
||||||
|
|
||||||
@@ -125,12 +122,7 @@ namespace Content.Client.Body.UI
|
|||||||
|
|
||||||
public void BodyPartOnItemSelected(ItemListSelectedEventArgs args)
|
public void BodyPartOnItemSelected(ItemListSelectedEventArgs args)
|
||||||
{
|
{
|
||||||
if (_currentEntity == null)
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBodyComponent>(_currentEntity, out var body))
|
||||||
return;
|
|
||||||
|
|
||||||
var body = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SharedBodyComponent>(_currentEntity);
|
|
||||||
|
|
||||||
if (body == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The entity that can be accessed by interacting with this element.
|
/// The entity that can be accessed by interacting with this element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityUid Entity;
|
public EntityUid? Entity;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How many entities are accessible through this element's sub-menus.
|
/// How many entities are accessible through this element's sub-menus.
|
||||||
@@ -28,7 +28,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
public readonly Label CountLabel;
|
public readonly Label CountLabel;
|
||||||
public readonly SpriteView EntityIcon = new() { OverrideDirection = Direction.South};
|
public readonly SpriteView EntityIcon = new() { OverrideDirection = Direction.South};
|
||||||
|
|
||||||
public EntityMenuElement(EntityUid entity = default)
|
public EntityMenuElement(EntityUid? entity = null)
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
LayoutContainer.SetGrowVertical(CountLabel, LayoutContainer.GrowDirection.Begin);
|
LayoutContainer.SetGrowVertical(CountLabel, LayoutContainer.GrowDirection.Begin);
|
||||||
|
|
||||||
Entity = entity;
|
Entity = entity;
|
||||||
if (Entity != default)
|
if (Entity != null)
|
||||||
{
|
{
|
||||||
Count = 1;
|
Count = 1;
|
||||||
CountLabel.Visible = false;
|
CountLabel.Visible = false;
|
||||||
@@ -51,7 +51,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
Entity = default;
|
Entity = null;
|
||||||
Count = 0;
|
Count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,23 +59,25 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
/// Update the icon and text of this element based on the given entity or this element's own entity if none
|
/// Update the icon and text of this element based on the given entity or this element's own entity if none
|
||||||
/// is provided.
|
/// is provided.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateEntity(EntityUid entity = default)
|
public void UpdateEntity(EntityUid? entity = null)
|
||||||
{
|
{
|
||||||
if (Entity != default && _entityManager.EntityExists(Entity) && !entity.Valid)
|
entity ??= Entity;
|
||||||
entity = Entity;
|
|
||||||
|
|
||||||
if (entity == default)
|
// check whether entity is null, invalid, or has been deleted.
|
||||||
|
// _entityManager.Deleted() implicitly checks all of these.
|
||||||
|
if (_entityManager.Deleted(entity))
|
||||||
{
|
{
|
||||||
Text = string.Empty;
|
Text = string.Empty;
|
||||||
|
EntityIcon.Sprite = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityIcon.Sprite = _entityManager.GetComponentOrNull<ISpriteComponent>(entity);
|
EntityIcon.Sprite = _entityManager.GetComponentOrNull<ISpriteComponent>(entity);
|
||||||
|
|
||||||
if (UserInterfaceManager.DebugMonitors.Visible)
|
if (UserInterfaceManager.DebugMonitors.Visible)
|
||||||
Text = $"{_entityManager.GetComponent<MetaDataComponent>(entity!).EntityName} ({entity})";
|
Text = _entityManager.ToPrettyString(entity.Value);
|
||||||
else
|
else
|
||||||
Text = _entityManager.GetComponent<MetaDataComponent>(entity!).EntityName;
|
Text = _entityManager.GetComponent<MetaDataComponent>(entity.Value).EntityName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,18 +101,16 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
|
|
||||||
// get an entity associated with this element
|
// get an entity associated with this element
|
||||||
var entity = entityElement.Entity;
|
var entity = entityElement.Entity;
|
||||||
if (!entity.Valid)
|
entity ??= GetFirstEntityOrNull(element.SubMenu);
|
||||||
{
|
|
||||||
entity = GetFirstEntityOrNull(element.SubMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.Valid)
|
// Deleted() automatically checks for null & existence.
|
||||||
|
if (_entityManager.Deleted(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// open verb menu?
|
// open verb menu?
|
||||||
if (args.Function == ContentKeyFunctions.OpenContextMenu)
|
if (args.Function == ContentKeyFunctions.OpenContextMenu)
|
||||||
{
|
{
|
||||||
_verbSystem.VerbMenu.OpenVerbMenu(entity);
|
_verbSystem.VerbMenu.OpenVerbMenu(entity.Value);
|
||||||
args.Handle();
|
args.Handle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -120,7 +118,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
// do examination?
|
// do examination?
|
||||||
if (args.Function == ContentKeyFunctions.ExamineEntity)
|
if (args.Function == ContentKeyFunctions.ExamineEntity)
|
||||||
{
|
{
|
||||||
_systemManager.GetEntitySystem<ExamineSystem>().DoExamine(entity);
|
_systemManager.GetEntitySystem<ExamineSystem>().DoExamine(entity.Value);
|
||||||
args.Handle();
|
args.Handle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -139,7 +137,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
|
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
|
||||||
|
|
||||||
var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId,
|
var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId,
|
||||||
BoundKeyState.Down, _entityManager.GetComponent<TransformComponent>(entity).Coordinates, args.PointerLocation, entity);
|
BoundKeyState.Down, _entityManager.GetComponent<TransformComponent>(entity.Value).Coordinates, args.PointerLocation, entity.Value);
|
||||||
|
|
||||||
var session = _playerManager.LocalPlayer?.Session;
|
var session = _playerManager.LocalPlayer?.Session;
|
||||||
if (session != null)
|
if (session != null)
|
||||||
@@ -314,7 +312,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
element.SubMenu.Dispose();
|
element.SubMenu.Dispose();
|
||||||
element.SubMenu = null;
|
element.SubMenu = null;
|
||||||
element.CountLabel.Visible = false;
|
element.CountLabel.Visible = false;
|
||||||
Elements[entity] = element;
|
Elements[entity.Value] = element;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the parent element, so that it's count and entity icon gets updated.
|
// update the parent element, so that it's count and entity icon gets updated.
|
||||||
@@ -326,17 +324,17 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recursively look through a sub-menu and return the first entity.
|
/// Recursively look through a sub-menu and return the first entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private EntityUid GetFirstEntityOrNull(ContextMenuPopup? menu)
|
private EntityUid? GetFirstEntityOrNull(ContextMenuPopup? menu)
|
||||||
{
|
{
|
||||||
if (menu == null)
|
if (menu == null)
|
||||||
return default;
|
return null;
|
||||||
|
|
||||||
foreach (var element in menu.MenuBody.Children)
|
foreach (var element in menu.MenuBody.Children)
|
||||||
{
|
{
|
||||||
if (element is not EntityMenuElement entityElement)
|
if (element is not EntityMenuElement entityElement)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (entityElement.Entity != default)
|
if (entityElement.Entity != null)
|
||||||
{
|
{
|
||||||
if (!_entityManager.Deleted(entityElement.Entity))
|
if (!_entityManager.Deleted(entityElement.Entity))
|
||||||
return entityElement.Entity;
|
return entityElement.Entity;
|
||||||
@@ -345,11 +343,11 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
|
|
||||||
// if the element has no entity, its a group of entities with another attached sub-menu.
|
// if the element has no entity, its a group of entities with another attached sub-menu.
|
||||||
var entity = GetFirstEntityOrNull(entityElement.SubMenu);
|
var entity = GetFirstEntityOrNull(entityElement.SubMenu);
|
||||||
if (entity != default)
|
if (entity != null)
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OpenSubMenu(ContextMenuElement element)
|
public override void OpenSubMenu(ContextMenuElement element)
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ namespace Content.Client.DoAfter
|
|||||||
|
|
||||||
if (doAfter.BreakOnTargetMove)
|
if (doAfter.BreakOnTargetMove)
|
||||||
{
|
{
|
||||||
if (EntityManager.EntityExists(doAfter.TargetUid) &&
|
if (!EntityManager.Deleted(doAfter.Target) &&
|
||||||
!Transform(doAfter.TargetUid).Coordinates.InRange(EntityManager, doAfter.TargetGrid,
|
!Transform(doAfter.Target.Value).Coordinates.InRange(EntityManager, doAfter.TargetGrid,
|
||||||
doAfter.MovementThreshold))
|
doAfter.MovementThreshold))
|
||||||
{
|
{
|
||||||
comp.Cancel(id, currentTime);
|
comp.Cancel(id, currentTime);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Content.Client.Popups
|
|||||||
PopupMessage(message, _eyeManager.CoordinatesToScreen(transform.Coordinates));
|
PopupMessage(message, _eyeManager.CoordinatesToScreen(transform.Coordinates));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PopupMessage(string message, ScreenCoordinates coordinates, EntityUid entity = default)
|
public void PopupMessage(string message, ScreenCoordinates coordinates, EntityUid? entity = null)
|
||||||
{
|
{
|
||||||
var label = new PopupLabel(_eyeManager, EntityManager)
|
var label = new PopupLabel(_eyeManager, EntityManager)
|
||||||
{
|
{
|
||||||
@@ -146,7 +146,7 @@ namespace Content.Client.Popups
|
|||||||
|
|
||||||
public float TimeLeft { get; private set; }
|
public float TimeLeft { get; private set; }
|
||||||
public Vector2 InitialPos { get; set; }
|
public Vector2 InitialPos { get; set; }
|
||||||
public EntityUid Entity { get; set; }
|
public EntityUid? Entity { get; set; }
|
||||||
|
|
||||||
public PopupLabel(IEyeManager eyeManager, IEntityManager entityManager)
|
public PopupLabel(IEyeManager eyeManager, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
@@ -161,9 +161,9 @@ namespace Content.Client.Popups
|
|||||||
{
|
{
|
||||||
TimeLeft += eventArgs.DeltaSeconds;
|
TimeLeft += eventArgs.DeltaSeconds;
|
||||||
|
|
||||||
var position = Entity == default
|
var position = Entity == null
|
||||||
? InitialPos
|
? InitialPos
|
||||||
: (_eyeManager.CoordinatesToScreen(_entityManager.GetComponent<TransformComponent>(Entity).Coordinates).Position / UIScale) - DesiredSize / 2;
|
: (_eyeManager.CoordinatesToScreen(_entityManager.GetComponent<TransformComponent>(Entity.Value).Coordinates).Position / UIScale) - DesiredSize / 2;
|
||||||
|
|
||||||
LayoutContainer.SetPosition(this, position - (0, 20 * (TimeLeft * TimeLeft + TimeLeft)));
|
LayoutContainer.SetPosition(this, position - (0, 20 * (TimeLeft * TimeLeft + TimeLeft)));
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
private IEventBus _eventBus => _entityManager.EventBus;
|
private IEventBus _eventBus => _entityManager.EventBus;
|
||||||
|
|
||||||
private EntityUid _lastHoveredEntity;
|
private EntityUid? _lastHoveredEntity;
|
||||||
|
|
||||||
private bool _outlineEnabled = true;
|
private bool _outlineEnabled = true;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ namespace Content.Client.Viewport
|
|||||||
// lead to extremely thick outlines in the other viewports. Fixing this probably requires changing how the
|
// lead to extremely thick outlines in the other viewports. Fixing this probably requires changing how the
|
||||||
// hover outline works, so that it only highlights the entity in a single viewport.
|
// hover outline works, so that it only highlights the entity in a single viewport.
|
||||||
|
|
||||||
EntityUid entityToClick = default;
|
EntityUid? entityToClick = null;
|
||||||
var renderScale = 1;
|
var renderScale = 1;
|
||||||
if (UserInterfaceManager.CurrentlyHovered is IViewportControl vp)
|
if (UserInterfaceManager.CurrentlyHovered is IViewportControl vp)
|
||||||
{
|
{
|
||||||
@@ -107,15 +107,15 @@ namespace Content.Client.Viewport
|
|||||||
}
|
}
|
||||||
|
|
||||||
var inRange = false;
|
var inRange = false;
|
||||||
if (localPlayer.ControlledEntity != default && entityToClick != default)
|
if (localPlayer.ControlledEntity != null && entityToClick != null)
|
||||||
{
|
{
|
||||||
inRange = localPlayer.InRangeUnobstructed(entityToClick, ignoreInsideBlocker: true);
|
inRange = localPlayer.InRangeUnobstructed(entityToClick.Value, ignoreInsideBlocker: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractionOutlineComponent? outline;
|
InteractionOutlineComponent? outline;
|
||||||
if(!_outlineEnabled || !ConfigurationManager.GetCVar(CCVars.OutlineEnabled))
|
if(!_outlineEnabled || !ConfigurationManager.GetCVar(CCVars.OutlineEnabled))
|
||||||
{
|
{
|
||||||
if(entityToClick != default && _entityManager.TryGetComponent(entityToClick, out outline))
|
if(entityToClick != null && _entityManager.TryGetComponent(entityToClick, out outline))
|
||||||
{
|
{
|
||||||
outline.OnMouseLeave(); //Prevent outline remains from persisting post command.
|
outline.OnMouseLeave(); //Prevent outline remains from persisting post command.
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
if (entityToClick == _lastHoveredEntity)
|
if (entityToClick == _lastHoveredEntity)
|
||||||
{
|
{
|
||||||
if (entityToClick != default && _entityManager.TryGetComponent(entityToClick, out outline))
|
if (entityToClick != null && _entityManager.TryGetComponent(entityToClick, out outline))
|
||||||
{
|
{
|
||||||
outline.UpdateInRange(inRange, renderScale);
|
outline.UpdateInRange(inRange, renderScale);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ namespace Content.Client.Viewport
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lastHoveredEntity != default && !_entityManager.Deleted(_lastHoveredEntity) &&
|
if (_lastHoveredEntity != null && !_entityManager.Deleted(_lastHoveredEntity) &&
|
||||||
_entityManager.TryGetComponent(_lastHoveredEntity, out outline))
|
_entityManager.TryGetComponent(_lastHoveredEntity, out outline))
|
||||||
{
|
{
|
||||||
outline.OnMouseLeave();
|
outline.OnMouseLeave();
|
||||||
@@ -140,16 +140,16 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
_lastHoveredEntity = entityToClick;
|
_lastHoveredEntity = entityToClick;
|
||||||
|
|
||||||
if (_lastHoveredEntity != default && _entityManager.TryGetComponent(_lastHoveredEntity, out outline))
|
if (_lastHoveredEntity != null && _entityManager.TryGetComponent(_lastHoveredEntity, out outline))
|
||||||
{
|
{
|
||||||
outline.OnMouseEnter(inRange, renderScale);
|
outline.OnMouseEnter(inRange, renderScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityUid GetEntityUnderPosition(MapCoordinates coordinates)
|
public EntityUid? GetEntityUnderPosition(MapCoordinates coordinates)
|
||||||
{
|
{
|
||||||
var entitiesUnderPosition = GetEntitiesUnderPosition(coordinates);
|
var entitiesUnderPosition = GetEntitiesUnderPosition(coordinates);
|
||||||
return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : default;
|
return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<EntityUid> GetEntitiesUnderPosition(EntityCoordinates coordinates)
|
public IList<EntityUid> GetEntitiesUnderPosition(EntityCoordinates coordinates)
|
||||||
@@ -257,7 +257,7 @@ namespace Content.Client.Viewport
|
|||||||
var funcId = InputManager.NetworkBindMap.KeyFunctionID(func);
|
var funcId = InputManager.NetworkBindMap.KeyFunctionID(func);
|
||||||
|
|
||||||
EntityCoordinates coordinates = default;
|
EntityCoordinates coordinates = default;
|
||||||
EntityUid entityToClick = default;
|
EntityUid? entityToClick = null;
|
||||||
if (args.Viewport is IViewportControl vp)
|
if (args.Viewport is IViewportControl vp)
|
||||||
{
|
{
|
||||||
var mousePosWorld = vp.ScreenToMap(kArgs.PointerLocation.Position);
|
var mousePosWorld = vp.ScreenToMap(kArgs.PointerLocation.Position);
|
||||||
@@ -269,7 +269,7 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
var message = new FullInputCmdMessage(Timing.CurTick, Timing.TickFraction, funcId, kArgs.State,
|
var message = new FullInputCmdMessage(Timing.CurTick, Timing.TickFraction, funcId, kArgs.State,
|
||||||
coordinates , kArgs.PointerLocation,
|
coordinates , kArgs.PointerLocation,
|
||||||
entityToClick);
|
entityToClick ?? default); // TODO make entityUid nullable
|
||||||
|
|
||||||
// client side command handlers will always be sent the local player session.
|
// client side command handlers will always be sent the local player session.
|
||||||
var session = PlayerManager.LocalPlayer?.Session;
|
var session = PlayerManager.LocalPlayer?.Session;
|
||||||
|
|||||||
@@ -64,10 +64,11 @@ namespace Content.Client.Wall.Components
|
|||||||
{
|
{
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
|
|
||||||
EntityUid tempQualifier = _overlayEntity;
|
// _overlayEntity is non-nullable as it is set on startup.
|
||||||
if (tempQualifier != null)
|
// Should also never be default but might as well check.
|
||||||
|
if (_overlayEntity.Valid)
|
||||||
{
|
{
|
||||||
_entMan.DeleteEntity(tempQualifier);
|
_entMan.DeleteEntity(_overlayEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace Content.Server.AI.LoadBalancer
|
|||||||
|
|
||||||
var entity = _request.Context.GetState<SelfState>().GetValue();
|
var entity = _request.Context.GetState<SelfState>().GetValue();
|
||||||
|
|
||||||
if (entity == null || !IoCManager.Resolve<IEntityManager>().HasComponent<AiControllerComponent>(entity))
|
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AiControllerComponent>(entity))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.ActionBlocker
|
|||||||
{
|
{
|
||||||
var self = context.GetState<SelfState>().GetValue();
|
var self = context.GetState<SelfState>().GetValue();
|
||||||
|
|
||||||
if (self == null || !EntitySystem.Get<ActionBlockerSystem>().CanMove(self))
|
if (!EntitySystem.Get<ActionBlockerSystem>().CanMove(self))
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.TryGetContainer(out var container))
|
if (target!.Value.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (entMan.TryGetComponent(container.Owner, out EntityStorageComponent? storageComponent))
|
if (entMan.TryGetComponent(container.Owner, out EntityStorageComponent? storageComponent))
|
||||||
{
|
{
|
||||||
@@ -43,12 +43,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers
|
|||||||
|
|
||||||
var owner = context.GetState<SelfState>().GetValue();
|
var owner = context.GetState<SelfState>().GetValue();
|
||||||
|
|
||||||
if (owner == null)
|
return EntitySystem.Get<AiReachableSystem>().CanAccess(owner, target.Value, SharedInteractionSystem.InteractionRange) ? 1.0f : 0.0f;
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EntitySystem.Get<AiReachableSystem>().CanAccess(owner, target, SharedInteractionSystem.InteractionRange) ? 1.0f : 0.0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
|||||||
|
|
||||||
if (target == null
|
if (target == null
|
||||||
|| IoCManager.Resolve<IEntityManager>().Deleted(target)
|
|| IoCManager.Resolve<IEntityManager>().Deleted(target)
|
||||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, DrinkComponent.DefaultSolutionName, out var drink))
|
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Value, DrinkComponent.DefaultSolutionName, out var drink))
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
|||||||
{
|
{
|
||||||
var owner = context.GetState<SelfState>().GetValue();
|
var owner = context.GetState<SelfState>().GetValue();
|
||||||
|
|
||||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out ThirstComponent? thirst))
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out ThirstComponent? thirst))
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
|||||||
{
|
{
|
||||||
var target = context.GetState<TargetEntityState>().GetValue();
|
var target = context.GetState<TargetEntityState>().GetValue();
|
||||||
|
|
||||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target, out var foodComp)
|
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target.Value, out var foodComp)
|
||||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, foodComp.SolutionName, out var food))
|
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Value, foodComp.SolutionName, out var food))
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
|||||||
{
|
{
|
||||||
var owner = context.GetState<SelfState>().GetValue();
|
var owner = context.GetState<SelfState>().GetValue();
|
||||||
|
|
||||||
if (owner == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out HungerComponent? hunger))
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out HungerComponent? hunger))
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ using Robust.Shared.GameObjects;
|
|||||||
namespace Content.Server.AI.WorldState.States.Combat
|
namespace Content.Server.AI.WorldState.States.Combat
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class WeaponEntityState : PlanningStateData<EntityUid>
|
public sealed class WeaponEntityState : PlanningStateData<EntityUid?>
|
||||||
{
|
{
|
||||||
// Similar to TargetEntity
|
// Similar to TargetEntity
|
||||||
public override string Name => "WeaponEntity";
|
public override string Name => "WeaponEntity";
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
Value = default;
|
Value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,18 +9,13 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
|||||||
/// AKA what's in active hand
|
/// AKA what's in active hand
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class EquippedEntityState : StateData<EntityUid>
|
public sealed class EquippedEntityState : StateData<EntityUid?>
|
||||||
{
|
{
|
||||||
public override string Name => "EquippedEntity";
|
public override string Name => "EquippedEntity";
|
||||||
|
|
||||||
public override EntityUid GetValue()
|
public override EntityUid? GetValue()
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<HandsComponent>(Owner)?.GetActiveHand?.Owner;
|
||||||
{
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
return handsComponent.GetActiveHand?.Owner ?? default;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ using Robust.Shared.GameObjects;
|
|||||||
namespace Content.Server.AI.WorldState.States.Movement
|
namespace Content.Server.AI.WorldState.States.Movement
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class MoveTargetState : PlanningStateData<EntityUid>
|
public sealed class MoveTargetState : PlanningStateData<EntityUid?>
|
||||||
{
|
{
|
||||||
public override string Name => "MoveTarget";
|
public override string Name => "MoveTarget";
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
Value = default;
|
Value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ namespace Content.Server.AI.WorldState.States
|
|||||||
/// Could be target item to equip, target to attack, etc.
|
/// Could be target item to equip, target to attack, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class TargetEntityState : PlanningStateData<EntityUid>
|
public sealed class TargetEntityState : PlanningStateData<EntityUid?>
|
||||||
{
|
{
|
||||||
public override string Name => "TargetEntity";
|
public override string Name => "TargetEntity";
|
||||||
|
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
Value = default;
|
Value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ namespace Content.Server.Body.Components
|
|||||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||||
|
|
||||||
public override string Name => "Internals";
|
public override string Name => "Internals";
|
||||||
[ViewVariables] public EntityUid GasTankEntity { get; set; }
|
[ViewVariables] public EntityUid? GasTankEntity { get; set; }
|
||||||
[ViewVariables] public EntityUid BreathToolEntity { get; set; }
|
[ViewVariables] public EntityUid? BreathToolEntity { get; set; }
|
||||||
|
|
||||||
public void DisconnectBreathTool()
|
public void DisconnectBreathTool()
|
||||||
{
|
{
|
||||||
var old = BreathToolEntity;
|
var old = BreathToolEntity;
|
||||||
BreathToolEntity = default;
|
BreathToolEntity = null;
|
||||||
|
|
||||||
if (old != default && _entMan.TryGetComponent(old, out BreathToolComponent? breathTool) )
|
if (_entMan.TryGetComponent(old, out BreathToolComponent? breathTool) )
|
||||||
{
|
{
|
||||||
breathTool.DisconnectInternals();
|
breathTool.DisconnectInternals();
|
||||||
DisconnectTank();
|
DisconnectTank();
|
||||||
@@ -28,7 +28,7 @@ namespace Content.Server.Body.Components
|
|||||||
|
|
||||||
public void ConnectBreathTool(EntityUid toolEntity)
|
public void ConnectBreathTool(EntityUid toolEntity)
|
||||||
{
|
{
|
||||||
if (BreathToolEntity != default && _entMan.TryGetComponent(BreathToolEntity, out BreathToolComponent? tool))
|
if (_entMan.TryGetComponent(BreathToolEntity, out BreathToolComponent? tool))
|
||||||
{
|
{
|
||||||
tool.DisconnectInternals();
|
tool.DisconnectInternals();
|
||||||
}
|
}
|
||||||
@@ -38,20 +38,20 @@ namespace Content.Server.Body.Components
|
|||||||
|
|
||||||
public void DisconnectTank()
|
public void DisconnectTank()
|
||||||
{
|
{
|
||||||
if (GasTankEntity != default && _entMan.TryGetComponent(GasTankEntity, out GasTankComponent? tank))
|
if (_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? tank))
|
||||||
{
|
{
|
||||||
tank.DisconnectFromInternals(Owner);
|
tank.DisconnectFromInternals(Owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
GasTankEntity = default;
|
GasTankEntity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryConnectTank(EntityUid tankEntity)
|
public bool TryConnectTank(EntityUid tankEntity)
|
||||||
{
|
{
|
||||||
if (BreathToolEntity == default)
|
if (BreathToolEntity == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GasTankEntity != default && _entMan.TryGetComponent(GasTankEntity, out GasTankComponent? tank))
|
if (_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? tank))
|
||||||
{
|
{
|
||||||
tank.DisconnectFromInternals(Owner);
|
tank.DisconnectFromInternals(Owner);
|
||||||
}
|
}
|
||||||
@@ -62,12 +62,10 @@ namespace Content.Server.Body.Components
|
|||||||
|
|
||||||
public bool AreInternalsWorking()
|
public bool AreInternalsWorking()
|
||||||
{
|
{
|
||||||
return BreathToolEntity != default &&
|
return _entMan.TryGetComponent(BreathToolEntity, out BreathToolComponent? breathTool) &&
|
||||||
GasTankEntity != default &&
|
|
||||||
_entMan.TryGetComponent(BreathToolEntity, out BreathToolComponent? breathTool) &&
|
|
||||||
breathTool.IsFunctional &&
|
breathTool.IsFunctional &&
|
||||||
_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? gasTank) &&
|
_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? gasTank) &&
|
||||||
gasTank.Air != default;
|
gasTank.Air != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,9 +291,6 @@ namespace Content.Server.Botany
|
|||||||
{
|
{
|
||||||
AddToDatabase();
|
AddToDatabase();
|
||||||
|
|
||||||
if (user == null)
|
|
||||||
return Enumerable.Empty<EntityUid>();
|
|
||||||
|
|
||||||
if (ProductPrototypes == null || ProductPrototypes.Count == 0 || Yield <= 0)
|
if (ProductPrototypes == null || ProductPrototypes.Count == 0 || Yield <= 0)
|
||||||
{
|
{
|
||||||
user.PopupMessageCursor(Loc.GetString("botany-harvest-fail-message"));
|
user.PopupMessageCursor(Loc.GetString("botany-harvest-fail-message"));
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ namespace Content.Server.Climbing.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == null || !_entities.HasComponent<ClimbingComponent>(dragged))
|
if (!_entities.HasComponent<ClimbingComponent>(dragged))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-climb");
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Content.Server.Clothing
|
|||||||
|
|
||||||
private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetActivationVerbsEvent args)
|
private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetActivationVerbsEvent args)
|
||||||
{
|
{
|
||||||
if (args.User == null || !args.CanAccess || !args.CanInteract)
|
if (!args.CanAccess || !args.CanInteract)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
|
|||||||
@@ -90,11 +90,6 @@ namespace Content.Server.Disposal.Unit.Components
|
|||||||
|
|
||||||
private bool PlayerCanUse(EntityUid player)
|
private bool PlayerCanUse(EntityUid player)
|
||||||
{
|
{
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||||
|
|
||||||
if (!actionBlocker.CanInteract(player) ||
|
if (!actionBlocker.CanInteract(player) ||
|
||||||
|
|||||||
@@ -275,19 +275,19 @@ namespace Content.Server.Doors.Components
|
|||||||
|
|
||||||
#region Opening
|
#region Opening
|
||||||
|
|
||||||
public void TryOpen(EntityUid user = default)
|
public void TryOpen(EntityUid? user = null)
|
||||||
{
|
{
|
||||||
var msg = new DoorOpenAttemptEvent();
|
var msg = new DoorOpenAttemptEvent();
|
||||||
_entMan.EventBus.RaiseLocalEvent(Owner, msg);
|
_entMan.EventBus.RaiseLocalEvent(Owner, msg);
|
||||||
|
|
||||||
if (msg.Cancelled) return;
|
if (msg.Cancelled) return;
|
||||||
|
|
||||||
if (!user.Valid)
|
if (user == null)
|
||||||
{
|
{
|
||||||
// a machine opened it or something, idk
|
// a machine opened it or something, idk
|
||||||
Open();
|
Open();
|
||||||
}
|
}
|
||||||
else if (CanOpenByEntity(user))
|
else if (CanOpenByEntity(user.Value))
|
||||||
{
|
{
|
||||||
Open();
|
Open();
|
||||||
|
|
||||||
@@ -422,14 +422,14 @@ namespace Content.Server.Doors.Components
|
|||||||
|
|
||||||
#region Closing
|
#region Closing
|
||||||
|
|
||||||
public void TryClose(EntityUid user = default)
|
public void TryClose(EntityUid? user = null)
|
||||||
{
|
{
|
||||||
var msg = new DoorCloseAttemptEvent();
|
var msg = new DoorCloseAttemptEvent();
|
||||||
_entMan.EventBus.RaiseLocalEvent(Owner, msg);
|
_entMan.EventBus.RaiseLocalEvent(Owner, msg);
|
||||||
|
|
||||||
if (msg.Cancelled) return;
|
if (msg.Cancelled) return;
|
||||||
|
|
||||||
if (user != default && !CanCloseByEntity(user))
|
if (user != null && !CanCloseByEntity(user.Value))
|
||||||
{
|
{
|
||||||
Deny();
|
Deny();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -99,12 +99,8 @@ namespace Content.Server.Hands.Components
|
|||||||
var source = @event.Source;
|
var source = @event.Source;
|
||||||
var target = @event.Target;
|
var target = @event.Target;
|
||||||
|
|
||||||
if (source != null)
|
|
||||||
{
|
|
||||||
SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f));
|
SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f));
|
||||||
|
|
||||||
if (target != null)
|
|
||||||
{
|
|
||||||
if (ActiveHand != null && Drop(ActiveHand, false))
|
if (ActiveHand != null && Drop(ActiveHand, false))
|
||||||
{
|
{
|
||||||
source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name: _entities.GetComponent<MetaDataComponent>(source).EntityName), ("disarmed", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name: _entities.GetComponent<MetaDataComponent>(source).EntityName), ("disarmed", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
@@ -115,8 +111,6 @@ namespace Content.Server.Hands.Components
|
|||||||
source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", Name: _entities.GetComponent<MetaDataComponent>(source).EntityName), ("shoved", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", Name: _entities.GetComponent<MetaDataComponent>(source).EntityName), ("shoved", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
// standard interaction checks
|
// standard interaction checks
|
||||||
if (!_blocker.CanInteract(eventArgs.User)) return;
|
if (!_blocker.CanInteract(eventArgs.User)) return;
|
||||||
|
|
||||||
if (eventArgs.Used != null)
|
|
||||||
{
|
|
||||||
var usedUid = eventArgs.Used;
|
var usedUid = eventArgs.Used;
|
||||||
|
|
||||||
// want to insert a new light bulb?
|
// want to insert a new light bulb?
|
||||||
@@ -78,7 +76,6 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
else if (EntityManager.TryGetComponent(usedUid, out ServerStorageComponent? storage))
|
else if (EntityManager.TryGetComponent(usedUid, out ServerStorageComponent? storage))
|
||||||
eventArgs.Handled = TryInsertBulbsFromStorage(uid, usedUid, eventArgs.User, component, storage);
|
eventArgs.Handled = TryInsertBulbsFromStorage(uid, usedUid, eventArgs.User, component, storage);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to replace a light bulb in <paramref name="fixtureUid"/>
|
/// Try to replace a light bulb in <paramref name="fixtureUid"/>
|
||||||
@@ -108,7 +105,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
(e) => EntityManager.GetComponentOrNull<LightBulbComponent>(e)?.Type == fixture.BulbType);
|
(e) => EntityManager.GetComponentOrNull<LightBulbComponent>(e)?.Type == fixture.BulbType);
|
||||||
|
|
||||||
// found bulb in inserted storage
|
// found bulb in inserted storage
|
||||||
if (bulb != null)
|
if (bulb.Valid) // FirstOrDefault can return default/invalid uid.
|
||||||
{
|
{
|
||||||
// try to remove it
|
// try to remove it
|
||||||
var hasRemoved = replacer.InsertedBulbs.Remove(bulb);
|
var hasRemoved = replacer.InsertedBulbs.Remove(bulb);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace Content.Server.PAI
|
|||||||
|
|
||||||
private void AddWipeVerb(EntityUid uid, PAIComponent pai, GetActivationVerbsEvent args)
|
private void AddWipeVerb(EntityUid uid, PAIComponent pai, GetActivationVerbsEvent args)
|
||||||
{
|
{
|
||||||
if (args.User == null || !args.CanAccess || !args.CanInteract)
|
if (!args.CanAccess || !args.CanInteract)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent<MindComponent>(uid, out var mind) && mind.HasMind)
|
if (EntityManager.TryGetComponent<MindComponent>(uid, out var mind) && mind.HasMind)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace Content.Server.PowerCell.Components
|
|||||||
/// <param name="user">(optional) the user to give the removed cell to.</param>
|
/// <param name="user">(optional) the user to give the removed cell to.</param>
|
||||||
/// <param name="playSound">Should <see cref="CellRemoveSound"/> be played upon removal?</param>
|
/// <param name="playSound">Should <see cref="CellRemoveSound"/> be played upon removal?</param>
|
||||||
/// <returns>The cell component of the entity that was removed, or null if removal failed.</returns>
|
/// <returns>The cell component of the entity that was removed, or null if removal failed.</returns>
|
||||||
public PowerCellComponent? EjectCell(EntityUid user, bool playSound = true)
|
public PowerCellComponent? EjectCell(EntityUid? user = null, bool playSound = true)
|
||||||
{
|
{
|
||||||
var cell = Cell;
|
var cell = Cell;
|
||||||
if (cell == null || !CanRemoveCell) return null;
|
if (cell == null || !CanRemoveCell) return null;
|
||||||
@@ -138,7 +138,7 @@ namespace Content.Server.PowerCell.Components
|
|||||||
{
|
{
|
||||||
if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent<ItemComponent>(cell.Owner)))
|
if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent<ItemComponent>(cell.Owner)))
|
||||||
{
|
{
|
||||||
_entities.GetComponent<TransformComponent>(cell.Owner).Coordinates = _entities.GetComponent<TransformComponent>(user).Coordinates;
|
_entities.GetComponent<TransformComponent>(cell.Owner).Coordinates = _entities.GetComponent<TransformComponent>(user.Value).Coordinates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -235,11 +235,8 @@ namespace Content.Server.RCD.Systems
|
|||||||
mode = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state
|
mode = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state
|
||||||
rcd.Mode = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
|
rcd.Mode = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
var msg = Loc.GetString("rcd-component-change-mode", ("mode", rcd.Mode.ToString()));
|
var msg = Loc.GetString("rcd-component-change-mode", ("mode", rcd.Mode.ToString()));
|
||||||
rcd.Owner.PopupMessage(user, msg); //Prints an overhead message above the RCD
|
rcd.Owner.PopupMessage(user, msg); //Prints an overhead message above the RCD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace Content.Server.Stack
|
|||||||
public EntityUid? Split(EntityUid uid, int amount, EntityCoordinates spawnPosition, SharedStackComponent? stack = null)
|
public EntityUid? Split(EntityUid uid, int amount, EntityCoordinates spawnPosition, SharedStackComponent? stack = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref stack))
|
if (!Resolve(uid, ref stack))
|
||||||
return default;
|
return null;
|
||||||
|
|
||||||
// Get a prototype ID to spawn the new entity. Null is also valid, although it should rarely be picked...
|
// Get a prototype ID to spawn the new entity. Null is also valid, although it should rarely be picked...
|
||||||
var prototype = _prototypeManager.TryIndex<StackPrototype>(stack.StackTypeId, out var stackType)
|
var prototype = _prototypeManager.TryIndex<StackPrototype>(stack.StackTypeId, out var stackType)
|
||||||
@@ -51,7 +51,7 @@ namespace Content.Server.Stack
|
|||||||
|
|
||||||
// Try to remove the amount of things we want to split from the original stack...
|
// Try to remove the amount of things we want to split from the original stack...
|
||||||
if (!Use(uid, amount, stack))
|
if (!Use(uid, amount, stack))
|
||||||
return default;
|
return null;
|
||||||
|
|
||||||
// Set the output parameter in the event instance to the newly split stack.
|
// Set the output parameter in the event instance to the newly split stack.
|
||||||
var entity = Spawn(prototype, spawnPosition);
|
var entity = Spawn(prototype, spawnPosition);
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ namespace Content.Server.Storage.Components
|
|||||||
if (lockers.Contains(Owner))
|
if (lockers.Contains(Owner))
|
||||||
lockers.Remove(Owner);
|
lockers.Remove(Owner);
|
||||||
|
|
||||||
var lockerEnt = _robustRandom.Pick(lockers);
|
if (lockers.Count == 0) return;
|
||||||
|
|
||||||
if (lockerEnt == null) return; // No valid lockers anywhere.
|
var lockerEnt = _robustRandom.Pick(lockers);
|
||||||
|
|
||||||
var locker = _entMan.GetComponent<EntityStorageComponent>(lockerEnt);
|
var locker = _entMan.GetComponent<EntityStorageComponent>(lockerEnt);
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var alreadySpawnedGroups = new List<string>();
|
var alreadySpawnedGroups = new List<string>();
|
||||||
EntityUid entityToPlaceInHands = default;
|
EntityUid? entityToPlaceInHands = null;
|
||||||
foreach (var storageItem in component.Items)
|
foreach (var storageItem in component.Items)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(storageItem.GroupId) &&
|
if (!string.IsNullOrEmpty(storageItem.GroupId) &&
|
||||||
@@ -57,10 +57,10 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
EntityManager.DeleteEntity(uid);
|
EntityManager.DeleteEntity(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityToPlaceInHands != default
|
if (entityToPlaceInHands != null
|
||||||
&& EntityManager.TryGetComponent<SharedHandsComponent?>(args.User, out var hands))
|
&& EntityManager.TryGetComponent<SharedHandsComponent?>(args.User, out var hands))
|
||||||
{
|
{
|
||||||
hands.TryPutInAnyHand(entityToPlaceInHands);
|
hands.TryPutInAnyHand(entityToPlaceInHands.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,18 +40,12 @@ namespace Content.Server.Stunnable
|
|||||||
var source = args.Source;
|
var source = args.Source;
|
||||||
var target = args.Target;
|
var target = args.Target;
|
||||||
|
|
||||||
if (source != null)
|
|
||||||
{
|
|
||||||
var knock = EntityManager.GetComponent<KnockedDownComponent>(uid);
|
var knock = EntityManager.GetComponent<KnockedDownComponent>(uid);
|
||||||
SoundSystem.Play(Filter.Pvs(source), knock.StunAttemptSound.GetSound(), source, AudioHelpers.WithVariation(0.025f));
|
SoundSystem.Play(Filter.Pvs(source), knock.StunAttemptSound.GetSound(), source, AudioHelpers.WithVariation(0.025f));
|
||||||
|
|
||||||
if (target != null)
|
|
||||||
{
|
|
||||||
// TODO: Use PopupSystem
|
// TODO: Use PopupSystem
|
||||||
source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", Name: EntityManager.GetComponent<MetaDataComponent>(source).EntityName), ("target", Name: EntityManager.GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", Name(source)), ("target", Name(target))));
|
||||||
source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", Name: EntityManager.GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", Name(target))));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_adminLogSystem.Add(LogType.DisarmedKnockdown, LogImpact.Medium, $"{ToPrettyString(args.Source):user} knocked down {ToPrettyString(args.Target):target}");
|
_adminLogSystem.Add(LogType.DisarmedKnockdown, LogImpact.Medium, $"{ToPrettyString(args.Source):user} knocked down {ToPrettyString(args.Target):target}");
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Content.Server.Verbs.Commands
|
|||||||
var verbSystem = EntitySystem.Get<SharedVerbSystem>();
|
var verbSystem = EntitySystem.Get<SharedVerbSystem>();
|
||||||
|
|
||||||
// get the 'player' entity (defaulting to command user, otherwise uses a uid)
|
// get the 'player' entity (defaulting to command user, otherwise uses a uid)
|
||||||
EntityUid playerEntity = default;
|
EntityUid? playerEntity = null;
|
||||||
if (!int.TryParse(args[0], out var intPlayerUid))
|
if (!int.TryParse(args[0], out var intPlayerUid))
|
||||||
{
|
{
|
||||||
if (args[0] == "self" && shell.Player?.AttachedEntity != null)
|
if (args[0] == "self" && shell.Player?.AttachedEntity != null)
|
||||||
@@ -54,7 +54,7 @@ namespace Content.Server.Verbs.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerEntity == default)
|
if (playerEntity == null)
|
||||||
{
|
{
|
||||||
shell.WriteError(Loc.GetString("invoke-verb-command-invalid-player-entity"));
|
shell.WriteError(Loc.GetString("invoke-verb-command-invalid-player-entity"));
|
||||||
return;
|
return;
|
||||||
@@ -68,14 +68,14 @@ namespace Content.Server.Verbs.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
var verbName = args[2].ToLowerInvariant();
|
var verbName = args[2].ToLowerInvariant();
|
||||||
var verbs = verbSystem.GetLocalVerbs(target, playerEntity, VerbType.All, true);
|
var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, VerbType.All, true);
|
||||||
|
|
||||||
if ((Enum.TryParse(typeof(VerbType), verbName, ignoreCase: true, out var vtype) &&
|
if ((Enum.TryParse(typeof(VerbType), verbName, ignoreCase: true, out var vtype) &&
|
||||||
vtype is VerbType key) &&
|
vtype is VerbType key) &&
|
||||||
verbs.TryGetValue(key, out var vset) &&
|
verbs.TryGetValue(key, out var vset) &&
|
||||||
vset.Any())
|
vset.Any())
|
||||||
{
|
{
|
||||||
verbSystem.ExecuteVerb(vset.First(), playerEntity, target, forced: true);
|
verbSystem.ExecuteVerb(vset.First(), playerEntity.Value, target, forced: true);
|
||||||
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verbName), ("target", target), ("player", playerEntity)));
|
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verbName), ("target", target), ("player", playerEntity)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ namespace Content.Server.Verbs.Commands
|
|||||||
{
|
{
|
||||||
if (verb.Text.ToLowerInvariant() == verbName)
|
if (verb.Text.ToLowerInvariant() == verbName)
|
||||||
{
|
{
|
||||||
verbSystem.ExecuteVerb(verb, playerEntity, target, forced: true);
|
verbSystem.ExecuteVerb(verb, playerEntity.Value, target, forced: true);
|
||||||
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verb.Text), ("target", target), ("player", playerEntity)));
|
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verb.Text), ("target", target), ("player", playerEntity)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
public EntityUid? TakeAmmo()
|
public EntityUid? TakeAmmo()
|
||||||
{
|
{
|
||||||
EntityUid ammo = default;
|
EntityUid? ammo = null;
|
||||||
// If anything's spawned use that first, otherwise use the fill prototype as a fallback (if we have spawn count left)
|
// If anything's spawned use that first, otherwise use the fill prototype as a fallback (if we have spawn count left)
|
||||||
if (_spawnedAmmo.TryPop(out var entity))
|
if (_spawnedAmmo.TryPop(out var entity))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -133,13 +133,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
|
|
||||||
if (powerCellEntity == null)
|
if (powerCellEntity == null)
|
||||||
{
|
{
|
||||||
return default;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var capacitor = _entities.GetComponent<BatteryComponent>(powerCellEntity.Value);
|
var capacitor = _entities.GetComponent<BatteryComponent>(powerCellEntity.Value);
|
||||||
if (capacitor.CurrentCharge < _lowerChargeLimit)
|
if (capacitor.CurrentCharge < _lowerChargeLimit)
|
||||||
{
|
{
|
||||||
return default;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can fire confirmed
|
// Can fire confirmed
|
||||||
@@ -149,7 +149,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
if (capacitor.UseCharge(chargeChange) < _lowerChargeLimit)
|
if (capacitor.UseCharge(chargeChange) < _lowerChargeLimit)
|
||||||
{
|
{
|
||||||
// Handling of funny exploding cells.
|
// Handling of funny exploding cells.
|
||||||
return default;
|
return null;
|
||||||
}
|
}
|
||||||
var energyRatio = chargeChange / _baseFireCost;
|
var energyRatio = chargeChange / _baseFireCost;
|
||||||
|
|
||||||
|
|||||||
@@ -193,19 +193,20 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
|
|
||||||
public override EntityUid? PeekAmmo()
|
public override EntityUid? PeekAmmo()
|
||||||
{
|
{
|
||||||
return BoltOpen ? default : _chamberContainer.ContainedEntity;
|
return BoltOpen ? null : _chamberContainer.ContainedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override EntityUid? TakeProjectile(EntityCoordinates spawnAt)
|
public override EntityUid? TakeProjectile(EntityCoordinates spawnAt)
|
||||||
{
|
{
|
||||||
if (BoltOpen)
|
if (BoltOpen)
|
||||||
{
|
{
|
||||||
return default;
|
return null;
|
||||||
}
|
}
|
||||||
var entity = _chamberContainer.ContainedEntity ?? default;
|
var entity = _chamberContainer.ContainedEntity;
|
||||||
|
|
||||||
Cycle();
|
Cycle();
|
||||||
return entity != default ? EntitySystem.Get<GunSystem>().TakeBullet(_entities.GetComponent<AmmoComponent>(entity), spawnAt) : null;
|
|
||||||
|
return entity != null ? EntitySystem.Get<GunSystem>().TakeBullet(_entities.GetComponent<AmmoComponent>(entity.Value), spawnAt) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Cycle(bool manual = false)
|
private void Cycle(bool manual = false)
|
||||||
@@ -296,7 +297,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try and pull a round from the magazine to replace the chamber if possible
|
// Try and pull a round from the magazine to replace the chamber if possible
|
||||||
var magazine = MagazineContainer.ContainedEntity ?? default;
|
var magazine = MagazineContainer.ContainedEntity;
|
||||||
|
|
||||||
if (_entities.GetComponentOrNull<RangedMagazineComponent>(magazine)?.TakeAmmo() is not {Valid: true} nextRound)
|
if (_entities.GetComponentOrNull<RangedMagazineComponent>(magazine)?.TakeAmmo() is not {Valid: true} nextRound)
|
||||||
{
|
{
|
||||||
@@ -305,11 +306,11 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
|
|
||||||
_chamberContainer.Insert(nextRound);
|
_chamberContainer.Insert(nextRound);
|
||||||
|
|
||||||
if (_autoEjectMag && magazine != null && _entities.GetComponent<RangedMagazineComponent>(magazine).ShotsLeft == 0)
|
if (_autoEjectMag && magazine != null && _entities.GetComponent<RangedMagazineComponent>(magazine.Value).ShotsLeft == 0)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
|
SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
|
||||||
|
|
||||||
MagazineContainer.Remove(magazine);
|
MagazineContainer.Remove(magazine.Value);
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
SendNetworkMessage(new MagazineAutoEjectMessage());
|
SendNetworkMessage(new MagazineAutoEjectMessage());
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
|
|||||||
@@ -151,9 +151,10 @@ namespace Content.Server.Wieldable
|
|||||||
|
|
||||||
private void OnItemWielded(EntityUid uid, WieldableComponent component, ItemWieldedEvent args)
|
private void OnItemWielded(EntityUid uid, WieldableComponent component, ItemWieldedEvent args)
|
||||||
{
|
{
|
||||||
if (args.User == default)
|
if (args.User == null)
|
||||||
return;
|
return;
|
||||||
if (!CanWield(uid, component, args.User) || component.Wielded)
|
|
||||||
|
if (!CanWield(uid, component, args.User.Value) || component.Wielded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent<ItemComponent>(uid, out var item))
|
if (EntityManager.TryGetComponent<ItemComponent>(uid, out var item))
|
||||||
@@ -171,16 +172,16 @@ namespace Content.Server.Wieldable
|
|||||||
|
|
||||||
for (var i = 0; i < component.FreeHandsRequired; i++)
|
for (var i = 0; i < component.FreeHandsRequired; i++)
|
||||||
{
|
{
|
||||||
_virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.User);
|
_virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.User.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
args.User.PopupMessage(Loc.GetString("wieldable-component-successful-wield",
|
args.User.Value.PopupMessage(Loc.GetString("wieldable-component-successful-wield",
|
||||||
("item", uid)));
|
("item", uid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnItemUnwielded(EntityUid uid, WieldableComponent component, ItemUnwieldedEvent args)
|
private void OnItemUnwielded(EntityUid uid, WieldableComponent component, ItemUnwieldedEvent args)
|
||||||
{
|
{
|
||||||
if (args.User == default)
|
if (args.User == null)
|
||||||
return;
|
return;
|
||||||
if (!component.Wielded)
|
if (!component.Wielded)
|
||||||
return;
|
return;
|
||||||
@@ -200,11 +201,11 @@ namespace Content.Server.Wieldable
|
|||||||
component.UnwieldSound.GetSound());
|
component.UnwieldSound.GetSound());
|
||||||
}
|
}
|
||||||
|
|
||||||
args.User.PopupMessage(Loc.GetString("wieldable-component-failed-wield",
|
args.User.Value.PopupMessage(Loc.GetString("wieldable-component-failed-wield",
|
||||||
("item", uid)));
|
("item", uid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_virtualItemSystem.DeleteInHandsMatching(args.User, uid);
|
_virtualItemSystem.DeleteInHandsMatching(args.User.Value, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnItemLeaveHand(EntityUid uid, WieldableComponent component, UnequippedHandEvent args)
|
private void OnItemLeaveHand(EntityUid uid, WieldableComponent component, UnequippedHandEvent args)
|
||||||
@@ -245,9 +246,9 @@ namespace Content.Server.Wieldable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ItemWieldedEvent : EntityEventArgs
|
public class ItemWieldedEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
public EntityUid User;
|
public EntityUid? User;
|
||||||
|
|
||||||
public ItemWieldedEvent(EntityUid user = default)
|
public ItemWieldedEvent(EntityUid? user = null)
|
||||||
{
|
{
|
||||||
User = user;
|
User = user;
|
||||||
}
|
}
|
||||||
@@ -275,13 +276,13 @@ namespace Content.Server.Wieldable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ItemUnwieldedEvent : EntityEventArgs
|
public class ItemUnwieldedEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
public EntityUid User;
|
public EntityUid? User;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the item is being forced to be unwielded, or if the player chose to unwield it themselves.
|
/// Whether the item is being forced to be unwielded, or if the player chose to unwield it themselves.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Force;
|
public bool Force;
|
||||||
|
|
||||||
public ItemUnwieldedEvent(EntityUid user = default, bool force=false)
|
public ItemUnwieldedEvent(EntityUid? user = null, bool force=false)
|
||||||
{
|
{
|
||||||
User = user;
|
User = user;
|
||||||
Force = force;
|
Force = force;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace Content.Shared.DoAfter
|
|||||||
|
|
||||||
public EntityCoordinates TargetGrid { get; }
|
public EntityCoordinates TargetGrid { get; }
|
||||||
|
|
||||||
public EntityUid TargetUid { get; }
|
public EntityUid? Target { get; }
|
||||||
|
|
||||||
public float Delay { get; }
|
public float Delay { get; }
|
||||||
|
|
||||||
@@ -63,7 +63,8 @@ namespace Content.Shared.DoAfter
|
|||||||
|
|
||||||
public float MovementThreshold { get; }
|
public float MovementThreshold { get; }
|
||||||
|
|
||||||
public ClientDoAfter(byte id, EntityCoordinates userGrid, EntityCoordinates targetGrid, TimeSpan startTime, float delay, bool breakOnUserMove, bool breakOnTargetMove, float movementThreshold, EntityUid targetUid = default)
|
public ClientDoAfter(byte id, EntityCoordinates userGrid, EntityCoordinates targetGrid, TimeSpan startTime,
|
||||||
|
float delay, bool breakOnUserMove, bool breakOnTargetMove, float movementThreshold, EntityUid? target = null)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
UserGrid = userGrid;
|
UserGrid = userGrid;
|
||||||
@@ -73,7 +74,7 @@ namespace Content.Shared.DoAfter
|
|||||||
BreakOnUserMove = breakOnUserMove;
|
BreakOnUserMove = breakOnUserMove;
|
||||||
BreakOnTargetMove = breakOnTargetMove;
|
BreakOnTargetMove = breakOnTargetMove;
|
||||||
MovementThreshold = movementThreshold;
|
MovementThreshold = movementThreshold;
|
||||||
TargetUid = targetUid;
|
Target = target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -650,7 +650,7 @@ namespace Content.Shared.Interaction
|
|||||||
/// <param name="used"></param>
|
/// <param name="used"></param>
|
||||||
public void TryUseInteraction(EntityUid user, EntityUid used, bool altInteract = false)
|
public void TryUseInteraction(EntityUid user, EntityUid used, bool altInteract = false)
|
||||||
{
|
{
|
||||||
if (user != null && used != null && _actionBlockerSystem.CanUse(user))
|
if (_actionBlockerSystem.CanUse(user))
|
||||||
{
|
{
|
||||||
if (altInteract)
|
if (altInteract)
|
||||||
AltInteract(user, used);
|
AltInteract(user, used);
|
||||||
@@ -820,7 +820,7 @@ namespace Content.Shared.Interaction
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TryDroppedInteraction(EntityUid user, EntityUid item)
|
public bool TryDroppedInteraction(EntityUid user, EntityUid item)
|
||||||
{
|
{
|
||||||
if (user == null || item == null || !_actionBlockerSystem.CanDrop(user)) return false;
|
if (!_actionBlockerSystem.CanDrop(user)) return false;
|
||||||
|
|
||||||
DroppedInteraction(user, item);
|
DroppedInteraction(user, item);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -64,15 +64,17 @@ namespace Content.Shared.Verbs
|
|||||||
// call ActionBlocker checks, just cache it for the verb request.
|
// call ActionBlocker checks, just cache it for the verb request.
|
||||||
var canInteract = force || _actionBlockerSystem.CanInteract(user);
|
var canInteract = force || _actionBlockerSystem.CanInteract(user);
|
||||||
|
|
||||||
EntityUid @using = default;
|
EntityUid? @using = null;
|
||||||
if (EntityManager.TryGetComponent(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user)))
|
if (TryComp(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user)))
|
||||||
{
|
{
|
||||||
hands.TryGetActiveHeldEntity(out @using);
|
// TODO Hands remove nullable (#5634)
|
||||||
|
hands.TryGetActiveHeldEntity(out var nonNullableUsing);
|
||||||
|
@using = nonNullableUsing;
|
||||||
|
|
||||||
// Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used".
|
// Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used".
|
||||||
// This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging
|
// This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging
|
||||||
// their sprite.
|
// their sprite.
|
||||||
if (@using != default && EntityManager.TryGetComponent<HandVirtualItemComponent?>(@using, out var pull))
|
if (@using != null && TryComp(@using, out HandVirtualItemComponent? pull))
|
||||||
{
|
{
|
||||||
@using = pull.BlockingEntity;
|
@using = pull.BlockingEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user