Fix errors
This commit is contained in:
@@ -18,6 +18,8 @@ namespace Content.Server.GameTicking.Commands
|
||||
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
|
||||
class MappingCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public string Command => "mapping";
|
||||
public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
|
||||
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
|
||||
@@ -76,9 +78,11 @@ namespace Content.Server.GameTicking.Commands
|
||||
shell.ExecuteCommand($"addmap {mapId} false");
|
||||
shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
|
||||
|
||||
EntityUid tempQualifier = player.AttachedEntity;
|
||||
if ((tempQualifier != null ? IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(tempQualifier).EntityPrototype : null)?.ID != "AdminObserver")
|
||||
if (player.AttachedEntity is {Valid: true} playerEntity &&
|
||||
_entities.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != "AdminObserver")
|
||||
{
|
||||
shell.ExecuteCommand("aghost");
|
||||
}
|
||||
|
||||
shell.ExecuteCommand($"tp 0 0 {mapId}");
|
||||
shell.RemoteExecuteCommand("showmarkers");
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace Content.Server.GameTicking
|
||||
if (mind.CharacterName != null)
|
||||
playerIcName = mind.CharacterName;
|
||||
else if (mind.CurrentEntity != null)
|
||||
playerIcName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.CurrentEntity).EntityName;
|
||||
playerIcName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.CurrentEntity.Value).EntityName;
|
||||
|
||||
var playerEndRoundInfo = new RoundEndMessageEvent.RoundEndPlayerInfo()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Content.Server.GameTicking.Presets
|
||||
/// </summary>
|
||||
public abstract class GamePreset
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public abstract bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false);
|
||||
public virtual string ModeTitle => "Sandbox";
|
||||
public virtual string Description => "Secret!";
|
||||
@@ -39,7 +41,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
{
|
||||
var playerEntity = mind.OwnedEntity;
|
||||
|
||||
if (playerEntity != default && IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity))
|
||||
if (playerEntity != default && IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity.Value))
|
||||
return false;
|
||||
|
||||
if (mind.VisitingEntity != default)
|
||||
@@ -47,7 +49,9 @@ namespace Content.Server.GameTicking.Presets
|
||||
mind.UnVisit();
|
||||
}
|
||||
|
||||
var position = (playerEntity != null ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(playerEntity) : null).Coordinates ?? EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
|
||||
var position = playerEntity is {Valid: true}
|
||||
? _entities.GetComponent<TransformComponent>(playerEntity.Value).Coordinates
|
||||
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
|
||||
// Ok, so, this is the master place for the logic for if ghosting is "too cheaty" to allow returning.
|
||||
// There's no reason at this time to move it to any other place, especially given that the 'side effects required' situations would also have to be moved.
|
||||
// + If CharacterDeadPhysically applies, we're physically dead. Therefore, ghosting OK, and we can return (this is critical for gibbing)
|
||||
@@ -58,7 +62,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 != null && canReturnGlobal && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity, out MobStateComponent? mobState))
|
||||
if (playerEntity != default && canReturnGlobal && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity.Value, out MobStateComponent? mobState))
|
||||
{
|
||||
if (mobState.IsCritical())
|
||||
{
|
||||
@@ -67,7 +71,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, damage, true);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(playerEntity.Value, damage, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Suspicion;
|
||||
using Content.Server.Suspicion.Roles;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Server.Traitor.Uplink.Account;
|
||||
using Content.Server.Traitor.Uplink.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Traitor.Uplink;
|
||||
using Robust.Server.Player;
|
||||
@@ -121,7 +117,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
|
||||
// try to place uplink
|
||||
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||
.AddUplink(mind.OwnedEntity, uplinkAccount))
|
||||
.AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,19 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.PDA;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Roles;
|
||||
using Content.Server.Traitor;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Server.Traitor.Uplink.Account;
|
||||
using Content.Server.Traitor.Uplink.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Traitor.Uplink;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
@@ -131,7 +126,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
accounts.AddNewAccount(uplinkAccount);
|
||||
|
||||
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||
.AddUplink(mind.OwnedEntity, uplinkAccount))
|
||||
.AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
|
||||
continue;
|
||||
|
||||
var traitorRole = new TraitorRole(mind);
|
||||
|
||||
@@ -80,50 +80,50 @@ namespace Content.Server.GameTicking.Presets
|
||||
|
||||
// Delete anything that may contain "dangerous" role-specific items.
|
||||
// (This includes the PDA, as everybody gets the captain PDA in this mode for true-all-access reasons.)
|
||||
if (mind.OwnedEntity != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(mind.OwnedEntity, out InventoryComponent? inventory))
|
||||
if (mind.OwnedEntity is {Valid: true} owned && _entityManager.TryGetComponent(owned, out InventoryComponent? inventory))
|
||||
{
|
||||
var victimSlots = new[] {EquipmentSlotDefines.Slots.IDCARD, EquipmentSlotDefines.Slots.BELT, EquipmentSlotDefines.Slots.BACKPACK};
|
||||
foreach (var slot in victimSlots)
|
||||
{
|
||||
if (inventory.TryGetSlotItem(slot, out ItemComponent? vItem))
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(vItem.Owner);
|
||||
_entityManager.DeleteEntity(vItem.Owner);
|
||||
}
|
||||
|
||||
// Replace their items:
|
||||
|
||||
// pda
|
||||
var newPDA = _entityManager.SpawnEntity(PDAPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates);
|
||||
inventory.Equip(EquipmentSlotDefines.Slots.IDCARD, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newPDA));
|
||||
var newPDA = _entityManager.SpawnEntity(PDAPrototypeName, _entityManager.GetComponent<TransformComponent>(owned).Coordinates);
|
||||
inventory.Equip(EquipmentSlotDefines.Slots.IDCARD, _entityManager.GetComponent<ItemComponent>(newPDA));
|
||||
|
||||
// belt
|
||||
var newTmp = _entityManager.SpawnEntity(BeltPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates);
|
||||
inventory.Equip(EquipmentSlotDefines.Slots.BELT, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newTmp));
|
||||
var newTmp = _entityManager.SpawnEntity(BeltPrototypeName, _entityManager.GetComponent<TransformComponent>(owned).Coordinates);
|
||||
inventory.Equip(EquipmentSlotDefines.Slots.BELT, _entityManager.GetComponent<ItemComponent>(newTmp));
|
||||
|
||||
// backpack
|
||||
newTmp = _entityManager.SpawnEntity(BackpackPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates);
|
||||
inventory.Equip(EquipmentSlotDefines.Slots.BACKPACK, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newTmp));
|
||||
newTmp = _entityManager.SpawnEntity(BackpackPrototypeName, _entityManager.GetComponent<TransformComponent>(owned).Coordinates);
|
||||
inventory.Equip(EquipmentSlotDefines.Slots.BACKPACK, _entityManager.GetComponent<ItemComponent>(newTmp));
|
||||
|
||||
// Like normal traitors, they need access to a traitor account.
|
||||
var uplinkAccount = new UplinkAccount(startingBalance, mind.OwnedEntity);
|
||||
var uplinkAccount = new UplinkAccount(startingBalance, owned);
|
||||
var accounts = _entityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
|
||||
accounts.AddNewAccount(uplinkAccount);
|
||||
|
||||
_entityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||
.AddUplink(mind.OwnedEntity, uplinkAccount, newPDA);
|
||||
.AddUplink(owned, uplinkAccount, newPDA);
|
||||
|
||||
_allOriginalNames[uplinkAccount] = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.OwnedEntity).EntityName;
|
||||
_allOriginalNames[uplinkAccount] = _entityManager.GetComponent<MetaDataComponent>(owned).EntityName;
|
||||
|
||||
// The PDA needs to be marked with the correct owner.
|
||||
var pda = IoCManager.Resolve<IEntityManager>().GetComponent<PDAComponent>(newPDA);
|
||||
var pda = _entityManager.GetComponent<PDAComponent>(newPDA);
|
||||
_entityManager.EntitySysManager.GetEntitySystem<PDASystem>()
|
||||
.SetOwner(pda, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.OwnedEntity).EntityName);
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<TraitorDeathMatchReliableOwnerTagComponent>(newPDA).UserId = mind.UserId;
|
||||
.SetOwner(pda, _entityManager.GetComponent<MetaDataComponent>(owned).EntityName);
|
||||
_entityManager.AddComponent<TraitorDeathMatchReliableOwnerTagComponent>(newPDA).UserId = mind.UserId;
|
||||
}
|
||||
|
||||
// Finally, it would be preferrable if they spawned as far away from other players as reasonably possible.
|
||||
if (mind.OwnedEntity != null && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
|
||||
if (mind.OwnedEntity != default && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates = bestTarget;
|
||||
_entityManager.GetComponent<TransformComponent>(mind.OwnedEntity.Value).Coordinates = bestTarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -151,7 +151,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
var avoidMeEntity = avoidMeMind.OwnedEntity;
|
||||
if (avoidMeEntity == null)
|
||||
continue;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(avoidMeEntity, out MobStateComponent? mobState))
|
||||
if (_entityManager.TryGetComponent(avoidMeEntity.Value, out MobStateComponent? mobState))
|
||||
{
|
||||
// Does have mob state component; if critical or dead, they don't really matter for spawn checks
|
||||
if (mobState.IsCritical() || mobState.IsDead())
|
||||
@@ -162,7 +162,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
// Doesn't have mob state component. Assume something interesting is going on and don't count this as someone to avoid.
|
||||
continue;
|
||||
}
|
||||
existingPlayerPoints.Add(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(avoidMeEntity).Coordinates);
|
||||
existingPlayerPoints.Add(_entityManager.GetComponent<TransformComponent>(avoidMeEntity.Value).Coordinates);
|
||||
}
|
||||
|
||||
// Iterate over each possible spawn point, comparing to the existing player points.
|
||||
@@ -176,18 +176,18 @@ namespace Content.Server.GameTicking.Presets
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
foreach (var entity in ents)
|
||||
{
|
||||
if (!atmosphereSystem.IsTileMixtureProbablySafe(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates))
|
||||
if (!atmosphereSystem.IsTileMixtureProbablySafe(_entityManager.GetComponent<TransformComponent>(entity).Coordinates))
|
||||
continue;
|
||||
|
||||
var distanceFromNearest = float.PositiveInfinity;
|
||||
foreach (var existing in existingPlayerPoints)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.TryDistance(_entityManager, existing, out var dist))
|
||||
if (_entityManager.GetComponent<TransformComponent>(entity).Coordinates.TryDistance(_entityManager, existing, out var dist))
|
||||
distanceFromNearest = Math.Min(distanceFromNearest, dist);
|
||||
}
|
||||
if (bestTargetDistanceFromNearest < distanceFromNearest)
|
||||
{
|
||||
bestTarget = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates;
|
||||
bestTarget = _entityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
bestTargetDistanceFromNearest = distanceFromNearest;
|
||||
foundATarget = true;
|
||||
}
|
||||
@@ -197,8 +197,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
|
||||
public override bool OnGhostAttempt(Mind.Mind mind, bool canReturnGlobal)
|
||||
{
|
||||
var entity = mind.OwnedEntity;
|
||||
if ((entity != null) && IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out MobStateComponent? mobState))
|
||||
if (mind.OwnedEntity is {Valid: true} entity && _entityManager.TryGetComponent(entity, out MobStateComponent? mobState))
|
||||
{
|
||||
if (mobState.IsCritical())
|
||||
{
|
||||
@@ -208,7 +207,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
}
|
||||
else if (!mobState.IsDead())
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<HandsComponent>(entity))
|
||||
if (_entityManager.HasComponent<HandsComponent>(entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Shared.CCVar;
|
||||
@@ -62,9 +60,8 @@ namespace Content.Server.GameTicking.Rules
|
||||
IPlayerSession? winner = null;
|
||||
foreach (var playerSession in _playerManager.ServerSessions)
|
||||
{
|
||||
var playerEntity = playerSession.AttachedEntity;
|
||||
if (playerEntity == null
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity, out MobStateComponent? state))
|
||||
if (playerSession.AttachedEntity is not {Valid: true} playerEntity
|
||||
|| !_entityManager.TryGetComponent(playerEntity, out MobStateComponent? state))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Doors;
|
||||
@@ -35,6 +33,7 @@ namespace Content.Server.GameTicking.Rules
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
[DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
|
||||
|
||||
@@ -90,9 +89,9 @@ namespace Content.Server.GameTicking.Rules
|
||||
|
||||
foreach (var playerSession in _playerManager.ServerSessions)
|
||||
{
|
||||
if (playerSession.AttachedEntity == null
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(playerSession.AttachedEntity, out MobStateComponent? mobState)
|
||||
|| !IoCManager.Resolve<IEntityManager>().HasComponent<SuspicionRoleComponent>(playerSession.AttachedEntity))
|
||||
if (playerSession.AttachedEntity is not {Valid: true} playerEntity
|
||||
|| !_entities.TryGetComponent(playerEntity, out MobStateComponent? mobState)
|
||||
|| !_entities.HasComponent<SuspicionRoleComponent>(playerEntity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user