Fix more errors, client and server now build
This commit is contained in:
@@ -179,6 +179,7 @@ namespace Content.Client.AI
|
||||
{
|
||||
private readonly IEyeManager _eyeManager;
|
||||
private readonly IPlayerManager _playerManager;
|
||||
private readonly IEntityManager _entities;
|
||||
|
||||
// TODO: Add a box like the debug one and show the most recent path stuff
|
||||
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
||||
@@ -214,6 +215,7 @@ namespace Content.Client.AI
|
||||
_shader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>("unshaded").Instance();
|
||||
_eyeManager = IoCManager.Resolve<IEyeManager>();
|
||||
_playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
_entities = IoCManager.Resolve<IEntityManager>();
|
||||
}
|
||||
|
||||
#region Graph
|
||||
@@ -286,8 +288,8 @@ namespace Content.Client.AI
|
||||
|
||||
private void DrawCachedRegions(DrawingHandleScreen screenHandle, Box2 viewport)
|
||||
{
|
||||
var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (attachedEntity == default || !CachedRegions.TryGetValue(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).GridID, out var entityRegions))
|
||||
var transform = _entities.GetComponentOrNull<TransformComponent>(_playerManager.LocalPlayer?.ControlledEntity);
|
||||
if (transform == null || !CachedRegions.TryGetValue(transform.GridID, out var entityRegions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -305,7 +307,7 @@ namespace Content.Client.AI
|
||||
screenTile.X + 15.0f,
|
||||
screenTile.Y + 15.0f);
|
||||
|
||||
screenHandle.DrawRect(box, _cachedRegionColors[IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).GridID][region]);
|
||||
screenHandle.DrawRect(box, _cachedRegionColors[transform.GridID][region]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,7 +338,8 @@ namespace Content.Client.AI
|
||||
private void DrawRegions(DrawingHandleScreen screenHandle, Box2 viewport)
|
||||
{
|
||||
var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (attachedEntity == default || !Regions.TryGetValue(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).GridID, out var entityRegions))
|
||||
if (!_entities.TryGetComponent(attachedEntity, out TransformComponent? transform) ||
|
||||
!Regions.TryGetValue(transform.GridID, out var entityRegions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -356,7 +359,7 @@ namespace Content.Client.AI
|
||||
screenTile.X + 15.0f,
|
||||
screenTile.Y + 15.0f);
|
||||
|
||||
screenHandle.DrawRect(box, _regionColors[IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).GridID][chunk][region]);
|
||||
screenHandle.DrawRect(box, _regionColors[_entities.GetComponent<TransformComponent>(attachedEntity.Value).GridID][chunk][region]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Content.Client.Actions
|
||||
return new((in PointerInputCmdHandler.PointerInputCmdArgs args) =>
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == default ||
|
||||
if (playerEntity == null ||
|
||||
!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
|
||||
|
||||
actionsComponent.HandleHotbarKeybind(slot, args);
|
||||
@@ -98,8 +98,7 @@ namespace Content.Client.Actions
|
||||
return new((in PointerInputCmdHandler.PointerInputCmdArgs args) =>
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == default ||
|
||||
!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
|
||||
if (!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false;
|
||||
|
||||
actionsComponent.HandleChangeHotbarKeybind(hotbar, args);
|
||||
return true;
|
||||
@@ -110,8 +109,7 @@ namespace Content.Client.Actions
|
||||
private bool TargetingOnUse(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == default ||
|
||||
!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
|
||||
if (!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false;
|
||||
|
||||
return actionsComponent.TargetingOnUse(args);
|
||||
}
|
||||
@@ -119,8 +117,7 @@ namespace Content.Client.Actions
|
||||
private void ToggleActionsMenu()
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == default ||
|
||||
!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return;
|
||||
if (!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return;
|
||||
|
||||
actionsComponent.ToggleActionsMenu();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var tempQualifier = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = (tempQualifier != default ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier.Value) : null)?.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_gridData = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var tempQualifier = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = (tempQualifier != default ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier.Value) : null)?.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_gridData = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var tempQualifier = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = (tempQualifier != default ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier.Value) : null)?.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var tempQualifier = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = (tempQualifier != default ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier.Value) : null)?.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -90,13 +90,13 @@ namespace Content.Client.Audio
|
||||
_accumulator -= _cooldown;
|
||||
|
||||
var player = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (player == default)
|
||||
if (!EntityManager.TryGetComponent(player, out TransformComponent? playerManager))
|
||||
{
|
||||
ClearSounds();
|
||||
return;
|
||||
}
|
||||
|
||||
var coordinates = EntityManager.GetComponent<TransformComponent>(player.Value).Coordinates;
|
||||
var coordinates = playerManager.Coordinates;
|
||||
|
||||
foreach (var (comp, (stream, _)) in _playingSounds.ToArray())
|
||||
{
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace Content.Client.CharacterInterface
|
||||
|
||||
private void HandleOpenCharacterMenu()
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == default
|
||||
|| !EntityManager.TryGetComponent(_playerManager.LocalPlayer.ControlledEntity, out CharacterInterfaceComponent? characterInterface))
|
||||
if (!EntityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out CharacterInterfaceComponent? characterInterface))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,8 @@ namespace Content.Client.CombatMode
|
||||
|
||||
public bool IsInCombatMode()
|
||||
{
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (entity == default || !EntityManager.TryGetComponent(entity.Value, out CombatModeComponent? combatMode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return combatMode.IsInCombatMode;
|
||||
return EntityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out CombatModeComponent? combatMode) &&
|
||||
combatMode.IsInCombatMode;
|
||||
}
|
||||
|
||||
private void OnTargetingZoneChanged(TargetingZone obj)
|
||||
@@ -47,4 +42,8 @@ namespace Content.Client.CombatMode
|
||||
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetTargetZoneMessage(obj));
|
||||
}
|
||||
}
|
||||
|
||||
public static class A
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Content.Client.Instruments.UI
|
||||
var instrument = _owner.Instrument;
|
||||
|
||||
// If either the entity or component are null, return.
|
||||
if (instrumentEnt == default || instrument == default)
|
||||
if (instrumentEnt == null || instrument == null)
|
||||
return false;
|
||||
|
||||
// If we're a handheld instrument, we might be in a container. Get it just in case.
|
||||
|
||||
@@ -78,13 +78,13 @@ namespace Content.Client.Interactable
|
||||
bool popup = false)
|
||||
{
|
||||
var originEntity = origin.ControlledEntity;
|
||||
if (originEntity == default)
|
||||
if (originEntity == null)
|
||||
{
|
||||
// TODO: Take into account the player's camera position?
|
||||
return false;
|
||||
}
|
||||
|
||||
return SharedInteractionSystem.InRangeUnobstructed(originEntity, other, range, collisionMask, predicate,
|
||||
return SharedInteractionSystem.InRangeUnobstructed(originEntity.Value, other, range, collisionMask, predicate,
|
||||
ignoreInsideBlocker, popup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Content.Client.Storage
|
||||
{
|
||||
var controlledEntity = players.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (controlledEntity != default && entities.HasComponent<HandsComponent>(controlledEntity.Value))
|
||||
if (entities.HasComponent<HandsComponent>(controlledEntity))
|
||||
{
|
||||
#pragma warning disable 618
|
||||
StorageEntity.SendNetworkMessage(new InsertEntityMessage());
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.Client.Suspicion
|
||||
var viewport = _eyeManager.GetWorldViewport();
|
||||
|
||||
var ent = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (ent == default || _entityManager.TryGetComponent(ent.Value, out SuspicionRoleComponent? sus) != true)
|
||||
if (_entityManager.TryGetComponent(ent, out SuspicionRoleComponent? sus) != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Content.Client.Tabletop
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
// If there is no player entity, return
|
||||
if (_playerManager.LocalPlayer is not {ControlledEntity: var playerEntity}) return;
|
||||
if (_playerManager.LocalPlayer is not {ControlledEntity: { } playerEntity}) return;
|
||||
|
||||
if (StunnedOrNoHands(playerEntity))
|
||||
{
|
||||
@@ -167,7 +167,8 @@ namespace Content.Client.Tabletop
|
||||
private bool OnMouseDown(in PointerInputCmdArgs args)
|
||||
{
|
||||
// Return if no player entity
|
||||
if (_playerManager.LocalPlayer is not { ControlledEntity: var playerEntity}) return false;
|
||||
if (_playerManager.LocalPlayer is not {ControlledEntity: { } playerEntity})
|
||||
return false;
|
||||
|
||||
// Return if can not see table or stunned/no hands
|
||||
if (!CanSeeTable(playerEntity, _table) || StunnedOrNoHands(playerEntity))
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Content.Client.Weapons.Ranged
|
||||
}
|
||||
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (entity == default || !EntityManager.TryGetComponent(entity.Value, out SharedHandsComponent? hands))
|
||||
if (!EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
Assert.NotNull(local);
|
||||
var controlled = local.ControlledEntity;
|
||||
Assert.NotNull(controlled);
|
||||
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientAlertsComponent>(controlled);
|
||||
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientAlertsComponent>(controlled.Value);
|
||||
Assert.NotNull(alertsComponent);
|
||||
|
||||
// find the alertsui
|
||||
@@ -86,7 +86,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
Assert.NotNull(local);
|
||||
var controlled = local.ControlledEntity;
|
||||
Assert.NotNull(controlled);
|
||||
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientAlertsComponent>(controlled);
|
||||
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientAlertsComponent>(controlled.Value);
|
||||
Assert.NotNull(alertsComponent);
|
||||
|
||||
// find the alertsui
|
||||
|
||||
@@ -56,17 +56,17 @@ namespace Content.Server.Chat.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (mindComponent.OwnedEntity == default)
|
||||
if (mindComponent.OwnedEntity is not {Valid: true} owned)
|
||||
{
|
||||
shell.WriteError("You don't have an entity!");
|
||||
return;
|
||||
}
|
||||
|
||||
var emote = chatSanitizer.TrySanitizeOutSmilies(message, mindComponent.OwnedEntity.Value, out var sanitized, out var emoteStr);
|
||||
var emote = chatSanitizer.TrySanitizeOutSmilies(message, owned, out var sanitized, out var emoteStr);
|
||||
if (sanitized.Length != 0)
|
||||
chat.EntitySay(mindComponent.OwnedEntity.Value, sanitized);
|
||||
chat.EntitySay(owned, sanitized);
|
||||
if (emote)
|
||||
chat.EntityMe(mindComponent.OwnedEntity.Value, emoteStr!);
|
||||
chat.EntityMe(owned, emoteStr!);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Interaction.Components;
|
||||
@@ -42,7 +43,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
public bool TryDoInject(EntityUid? target, EntityUid user)
|
||||
{
|
||||
if (target == default || !EligibleEntity(target.Value))
|
||||
if (!EligibleEntity(target))
|
||||
return false;
|
||||
|
||||
string? msgFormat = null;
|
||||
@@ -110,7 +111,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(target.Value, targetSolution, removedSolution);
|
||||
|
||||
static bool EligibleEntity(EntityUid entity)
|
||||
static bool EligibleEntity([NotNullWhen(true)] EntityUid? entity)
|
||||
{
|
||||
// TODO: Does checking for BodyComponent make sense as a "can be hypospray'd" tag?
|
||||
// In SS13 the hypospray ONLY works on mobs, NOT beakers or anything else.
|
||||
|
||||
@@ -41,7 +41,8 @@ namespace Content.Server.GameTicking.Presets
|
||||
{
|
||||
var playerEntity = mind.OwnedEntity;
|
||||
|
||||
if (playerEntity != default && IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity.Value))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (entities.HasComponent<GhostComponent>(playerEntity))
|
||||
return false;
|
||||
|
||||
if (mind.VisitingEntity != default)
|
||||
@@ -62,7 +63,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
// (If the mob survives, that's a bug. Ghosting is kept regardless.)
|
||||
var canReturn = canReturnGlobal && mind.CharacterDeadPhysically;
|
||||
|
||||
if (playerEntity != default && canReturnGlobal && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity.Value, out MobStateComponent? mobState))
|
||||
if (canReturnGlobal && entities.TryGetComponent(playerEntity, out MobStateComponent? mobState))
|
||||
{
|
||||
if (mobState.IsCritical())
|
||||
{
|
||||
@@ -71,7 +72,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
//todo: what if they dont breathe lol
|
||||
//cry deeply
|
||||
DamageSpecifier damage = new(IoCManager.Resolve<IPrototypeManager>().Index<DamageTypePrototype>("Asphyxiation"), 200);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(playerEntity.Value, damage, true);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(playerEntity, damage, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +83,9 @@ namespace Content.Server.GameTicking.Presets
|
||||
// If all else fails, it'll default to the default entity prototype name, "observer".
|
||||
// However, that should rarely happen.
|
||||
if(!string.IsNullOrWhiteSpace(mind.CharacterName))
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ghost).EntityName = mind.CharacterName;
|
||||
entities.GetComponent<MetaDataComponent>(ghost).EntityName = mind.CharacterName;
|
||||
else if (!string.IsNullOrWhiteSpace(mind.Session?.Name))
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ghost).EntityName = mind.Session.Name;
|
||||
entities.GetComponent<MetaDataComponent>(ghost).EntityName = mind.Session.Name;
|
||||
|
||||
var ghostComponent = IoCManager.Resolve<IEntityManager>().GetComponent<GhostComponent>(ghost);
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
}
|
||||
|
||||
// Finally, it would be preferrable if they spawned as far away from other players as reasonably possible.
|
||||
if (mind.OwnedEntity != default && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
|
||||
if (mind.OwnedEntity != null && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
|
||||
{
|
||||
_entityManager.GetComponent<TransformComponent>(mind.OwnedEntity.Value).Coordinates = bestTarget;
|
||||
}
|
||||
|
||||
@@ -153,9 +153,7 @@ namespace Content.Server.Mind
|
||||
// (If being a borg or AI counts as dead, then this is highly likely, as it's still the same Mind for practical purposes.)
|
||||
|
||||
// This can be null if they're deleted (spike / brain nom)
|
||||
if (OwnedEntity == default)
|
||||
return true;
|
||||
var targetMobState = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity.Value);
|
||||
var targetMobState = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity);
|
||||
// This can be null if it's a brain (this happens very often)
|
||||
// Brains are the result of gibbing so should definitely count as dead
|
||||
if (targetMobState == null)
|
||||
@@ -184,7 +182,7 @@ namespace Content.Server.Mind
|
||||
role.Greet();
|
||||
|
||||
var message = new RoleAddedEvent(role);
|
||||
if (OwnedEntity != default)
|
||||
if (OwnedEntity != null)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnedEntity.Value, message);
|
||||
}
|
||||
@@ -210,7 +208,7 @@ namespace Content.Server.Mind
|
||||
|
||||
var message = new RoleRemovedEvent(role);
|
||||
|
||||
if (OwnedEntity != default)
|
||||
if (OwnedEntity != null)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnedEntity.Value, message);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
|
||||
private void AfterInteract(EntityUid uid, DrinkComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (args.Handled || args.Target == default)
|
||||
if (args.Handled || args.Target == null)
|
||||
return;
|
||||
|
||||
if (!_actionBlockerSystem.CanInteract(args.User) || !_actionBlockerSystem.CanUse(args.User))
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
/// </summary>
|
||||
private void OnFeedFood(EntityUid uid, FoodComponent foodComponent, AfterInteractEvent args)
|
||||
{
|
||||
if (args.Handled || args.Target == default)
|
||||
if (args.Handled || args.Target == null)
|
||||
return;
|
||||
|
||||
if (!_actionBlockerSystem.CanInteract(args.User) || !_actionBlockerSystem.CanUse(args.User))
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
/// </summary>
|
||||
private void OnAfterInteract(EntityUid uid, UtensilComponent component, AfterInteractEvent ev)
|
||||
{
|
||||
if (ev.Target == default)
|
||||
if (ev.Target == null)
|
||||
return;
|
||||
|
||||
if (TryUseUtensil(ev.User, ev.Target.Value, component))
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace Content.Server.Objectives.Conditions
|
||||
if (entity == default)
|
||||
return false;
|
||||
|
||||
return (IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(entity.Value)?.IsAlive() ?? false) && mc.Mind != mind;
|
||||
return entityMgr.TryGetComponent(entity, out MobStateComponent mobState) &&
|
||||
mobState.IsAlive() &&
|
||||
mc.Mind != mind;
|
||||
}).Select(mc => mc.Mind).ToList();
|
||||
return new KillRandomPersonCondition {Target = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)};
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.Verbs.Commands
|
||||
EntityUid playerEntity = default;
|
||||
if (!int.TryParse(args[0], out var intPlayerUid))
|
||||
{
|
||||
if (args[0] == "self" && shell.Player?.AttachedEntity != default)
|
||||
if (args[0] == "self" && shell.Player?.AttachedEntity != null)
|
||||
{
|
||||
playerEntity = shell.Player.AttachedEntity;
|
||||
}
|
||||
|
||||
@@ -140,9 +140,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
{
|
||||
for (var i = 0; i < Math.Max(10, rangedMagazine.ShotsLeft); i++)
|
||||
{
|
||||
var ammo = rangedMagazine.TakeAmmo();
|
||||
|
||||
if (!ammo.Valid)
|
||||
if (rangedMagazine.TakeAmmo() is not {Valid: true} ammo)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
public class RangedMagazineComponent : Component, IMapInit, IInteractUsing, IUse, IExamine
|
||||
#pragma warning restore 618
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public override string Name => "RangedMagazine";
|
||||
|
||||
private readonly Stack<EntityUid> _spawnedAmmo = new();
|
||||
@@ -77,7 +79,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||
if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||
{
|
||||
_appearanceComponent = appearanceComponent;
|
||||
}
|
||||
@@ -93,7 +95,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
|
||||
public bool TryInsertAmmo(EntityUid user, EntityUid ammo)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ammo, out AmmoComponent? ammoComponent))
|
||||
if (!_entities.TryGetComponent(ammo, out AmmoComponent? ammoComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -116,7 +118,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public EntityUid TakeAmmo()
|
||||
public EntityUid? TakeAmmo()
|
||||
{
|
||||
EntityUid ammo = default;
|
||||
// If anything's spawned use that first, otherwise use the fill prototype as a fallback (if we have spawn count left)
|
||||
@@ -128,7 +130,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
else if (_unspawnedCount > 0)
|
||||
{
|
||||
_unspawnedCount--;
|
||||
ammo = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
ammo = _entities.SpawnEntity(_fillPrototype, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
}
|
||||
|
||||
UpdateAppearance();
|
||||
@@ -142,21 +144,20 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out HandsComponent? handsComponent))
|
||||
if (!_entities.TryGetComponent(eventArgs.User, out HandsComponent? handsComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var ammo = TakeAmmo();
|
||||
if (ammo == null)
|
||||
if (TakeAmmo() is not {Valid: true} ammo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(ammo);
|
||||
var itemComponent = _entities.GetComponent<ItemComponent>(ammo);
|
||||
if (!handsComponent.CanPutInHand(itemComponent))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ammo).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(eventArgs.User).Coordinates;
|
||||
_entities.GetComponent<TransformComponent>(ammo).Coordinates = _entities.GetComponent<TransformComponent>(eventArgs.User).Coordinates;
|
||||
ServerRangedBarrelComponent.EjectCasing(ammo);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
if (MagazineContainer.ContainedEntity is {Valid: true} magazine)
|
||||
{
|
||||
count += IoCManager.Resolve<IEntityManager>().GetComponent<RangedMagazineComponent>(magazine).ShotsLeft;
|
||||
count += _entities.GetComponent<RangedMagazineComponent>(magazine).ShotsLeft;
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -73,7 +73,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
var count = 1;
|
||||
if (MagazineContainer.ContainedEntity is {Valid: true} magazine)
|
||||
{
|
||||
count += IoCManager.Resolve<IEntityManager>().GetComponent<RangedMagazineComponent>(magazine).Capacity;
|
||||
count += _entities.GetComponent<RangedMagazineComponent>(magazine).Capacity;
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -153,7 +153,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
{
|
||||
(int, int)? count = null;
|
||||
if (MagazineContainer.ContainedEntity is {Valid: true} magazine &&
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(magazine, out RangedMagazineComponent? rangedMagazineComponent))
|
||||
_entities.TryGetComponent(magazine, out RangedMagazineComponent? rangedMagazineComponent))
|
||||
{
|
||||
count = (rangedMagazineComponent.ShotsLeft, rangedMagazineComponent.Capacity);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
if (!existing && _magFillPrototype != null)
|
||||
{
|
||||
var magEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_magFillPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
var magEntity = _entities.SpawnEntity(_magFillPrototype, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
MagazineContainer.Insert(magEntity);
|
||||
}
|
||||
Dirty();
|
||||
@@ -205,7 +205,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
var entity = _chamberContainer.ContainedEntity ?? default;
|
||||
|
||||
Cycle();
|
||||
return entity != default ? IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(entity).TakeBullet(spawnAt) : null;
|
||||
return entity != default ? _entities.GetComponent<AmmoComponent>(entity).TakeBullet(spawnAt) : null;
|
||||
}
|
||||
|
||||
private void Cycle(bool manual = false)
|
||||
@@ -272,17 +272,16 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
public bool TryEjectChamber()
|
||||
{
|
||||
var chamberEntity = _chamberContainer.ContainedEntity;
|
||||
if (chamberEntity != null)
|
||||
if (_chamberContainer.ContainedEntity is {Valid: true} chamberEntity)
|
||||
{
|
||||
if (!_chamberContainer.Remove(chamberEntity.Value))
|
||||
if (!_chamberContainer.Remove(chamberEntity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(chamberEntity.Value);
|
||||
var ammoComponent = _entities.GetComponent<AmmoComponent>(chamberEntity);
|
||||
if (!ammoComponent.Caseless)
|
||||
{
|
||||
EjectCasing(chamberEntity.Value);
|
||||
EjectCasing(chamberEntity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -298,16 +297,15 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
// Try and pull a round from the magazine to replace the chamber if possible
|
||||
var magazine = MagazineContainer.ContainedEntity ?? default;
|
||||
var nextRound = magazine != default ? IoCManager.Resolve<IEntityManager>().GetComponent<RangedMagazineComponent>(magazine).TakeAmmo() : default;
|
||||
|
||||
if (nextRound == default)
|
||||
if (_entities.GetComponentOrNull<RangedMagazineComponent>(magazine)?.TakeAmmo() is not {Valid: true} nextRound)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_chamberContainer.Insert(nextRound);
|
||||
|
||||
if (_autoEjectMag && magazine != null && IoCManager.Resolve<IEntityManager>().GetComponent<RangedMagazineComponent>(magazine).ShotsLeft == 0)
|
||||
if (_autoEjectMag && magazine != null && _entities.GetComponent<RangedMagazineComponent>(magazine).ShotsLeft == 0)
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
|
||||
|
||||
@@ -337,9 +335,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
MagazineContainer.Remove(mag.Value);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent))
|
||||
if (_entities.TryGetComponent(user, out HandsComponent? handsComponent))
|
||||
{
|
||||
handsComponent.PutInHandOrDrop(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(mag.Value));
|
||||
handsComponent.PutInHandOrDrop(_entities.GetComponent<ItemComponent>(mag.Value));
|
||||
}
|
||||
|
||||
Dirty();
|
||||
@@ -348,7 +346,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
public bool CanInsertMagazine(EntityUid user, EntityUid magazine, bool quiet = true)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(magazine, out RangedMagazineComponent? magazineComponent))
|
||||
if (!_entities.TryGetComponent(magazine, out RangedMagazineComponent? magazineComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -402,7 +400,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
}
|
||||
|
||||
// Insert 1 ammo
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Using, out AmmoComponent? ammoComponent))
|
||||
if (_entities.TryGetComponent(eventArgs.Using, out AmmoComponent? ammoComponent))
|
||||
{
|
||||
if (!BoltOpen)
|
||||
{
|
||||
|
||||
@@ -223,8 +223,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
FireHitscan(shooter, hitscan, angle);
|
||||
}
|
||||
else if (_entities.HasComponent<ProjectileComponent>(projectile) &&
|
||||
ammo != default &&
|
||||
_entities.TryGetComponent(ammo.Value, out AmmoComponent? ammoComponent))
|
||||
_entities.TryGetComponent(ammo, out AmmoComponent? ammoComponent))
|
||||
{
|
||||
FireProjectiles(shooter, projectile, ammoComponent.ProjectilesFired, ammoComponent.EvenSpreadAngle, angle, ammoComponent.Velocity, ammo.Value);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Shared.CombatMode
|
||||
{
|
||||
var entity = eventArgs.SenderSession.AttachedEntity;
|
||||
|
||||
if (entity == null || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent))
|
||||
if (entity == default || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Content.Shared.Damage
|
||||
/// Returns a <see cref="DamageSpecifier"/> with information about the actual damage changes. This will be
|
||||
/// null if the user had no applicable components that can take damage.
|
||||
/// </returns>
|
||||
public DamageSpecifier? TryChangeDamage(EntityUid uid, DamageSpecifier damage, bool ignoreResistances = false,
|
||||
public DamageSpecifier? TryChangeDamage(EntityUid? uid, DamageSpecifier damage, bool ignoreResistances = false,
|
||||
bool interruptsDoAfters = true, bool logChange = false)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent<DamageableComponent>(uid, out var damageable))
|
||||
@@ -175,7 +175,7 @@ namespace Content.Shared.Damage
|
||||
}
|
||||
|
||||
var ev = new DamageModifyEvent(damage);
|
||||
RaiseLocalEvent(uid, ev, false);
|
||||
RaiseLocalEvent(uid.Value, ev, false);
|
||||
damage = ev.Damage;
|
||||
|
||||
if (damage.Empty)
|
||||
|
||||
Reference in New Issue
Block a user