Content update for NetEntities (#18935)
This commit is contained in:
@@ -46,7 +46,7 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
|
||||
if (!_interactionSystem.InRangeUnobstructed(args.User, (EntityUid) args.Target))
|
||||
return;
|
||||
|
||||
var doAfterEventArgs = new DoAfterArgs(args.User, component.DoAfterTime, new AccessOverriderDoAfterEvent(), uid, target: args.Target, used: uid)
|
||||
var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.DoAfterTime, new AccessOverriderDoAfterEvent(), uid, target: args.Target, used: uid)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Server.Access.Systems
|
||||
return;
|
||||
|
||||
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons);
|
||||
UserInterfaceSystem.SetUiState(ui, state, args.Session);
|
||||
_uiSystem.SetUiState(ui, state, args.Session);
|
||||
}
|
||||
|
||||
private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args)
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class AddBodyPartCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "addbodypart";
|
||||
public string Description => "Adds a given entity to a containing body.";
|
||||
public string Help => "Usage: addbodypart <entity uid> <body uid> <part slot>";
|
||||
@@ -19,20 +21,21 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var childId))
|
||||
if (!NetEntity.TryParse(args[0], out var childNetId))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out var parentId))
|
||||
if (!NetEntity.TryParse(args[1], out var parentNetId))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
var childId = _entManager.GetEntity(childNetId);
|
||||
var parentId = _entManager.GetEntity(parentNetId);
|
||||
var bodySystem = _entManager.System<BodySystem>();
|
||||
|
||||
if (bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId))
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class AddEntityStorageCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "addstorage";
|
||||
public string Description => "Adds a given entity to a containing storage.";
|
||||
public string Help => "Usage: addstorage <entity uid> <storage uid>";
|
||||
@@ -20,24 +22,22 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entManager.TryGetEntity(entityUidNet, out var entityUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out var storageUid))
|
||||
if (!NetEntity.TryParse(args[1], out var storageUidNet) || !_entManager.TryGetEntity(storageUidNet, out var storageUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entityManager.HasComponent<EntityStorageComponent>(storageUid) &&
|
||||
entityManager.EntitySysManager.TryGetEntitySystem<EntityStorageSystem>(out var storageSys))
|
||||
if (_entManager.HasComponent<EntityStorageComponent>(storageUid) &&
|
||||
_entManager.EntitySysManager.TryGetEntitySystem<EntityStorageSystem>(out var storageSys))
|
||||
{
|
||||
storageSys.Insert(entityUid, storageUid);
|
||||
storageSys.Insert(entityUid.Value, storageUid.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class AddMechanismCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "addmechanism";
|
||||
public string Description => "Adds a given entity to a containing body.";
|
||||
public string Help => "Usage: addmechanism <entity uid> <bodypart uid>";
|
||||
@@ -19,20 +21,19 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var organId))
|
||||
if (!NetEntity.TryParse(args[0], out var organIdNet) || !_entManager.TryGetEntity(organIdNet, out var organId))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out var partId))
|
||||
if (!NetEntity.TryParse(args[1], out var partIdNet) || !_entManager.TryGetEntity(partIdNet, out var partId))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
var bodySystem = _entManager.System<BodySystem>();
|
||||
|
||||
if (bodySystem.AddOrganToFirstValidSlot(organId, partId))
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands;
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class AddPolymorphActionCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public string Command => "addpolymorphaction";
|
||||
|
||||
public string Description => Loc.GetString("add-polymorph-action-command-description");
|
||||
@@ -22,16 +24,15 @@ public sealed class AddPolymorphActionCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entityManager.TryGetEntity(entityUidNet, out var entityUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var polySystem = entityManager.EntitySysManager.GetEntitySystem<PolymorphSystem>();
|
||||
var polySystem = _entityManager.EntitySysManager.GetEntitySystem<PolymorphSystem>();
|
||||
|
||||
entityManager.EnsureComponent<PolymorphableComponent>(entityUid);
|
||||
polySystem.CreatePolymorphAction(args[1], entityUid);
|
||||
_entityManager.EnsureComponent<PolymorphableComponent>(entityUid.Value);
|
||||
polySystem.CreatePolymorphAction(args[1], entityUid.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class AddReagent : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protomanager = default!;
|
||||
|
||||
public string Command => "addreagent";
|
||||
public string Description => "Add (or remove) some amount of reagent from some solution.";
|
||||
public string Help => $"Usage: {Command} <target> <solution> <reagent> <quantity>";
|
||||
@@ -26,13 +29,13 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
shell.WriteLine($"Invalid entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
if (!_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
{
|
||||
shell.WriteLine($"Entity does not have any solutions.");
|
||||
return;
|
||||
@@ -46,7 +49,7 @@ namespace Content.Server.Administration.Commands
|
||||
}
|
||||
var solution = man.Solutions[args[1]];
|
||||
|
||||
if (!IoCManager.Resolve<IPrototypeManager>().HasIndex<ReagentPrototype>(args[2]))
|
||||
if (!_protomanager.HasIndex<ReagentPrototype>(args[2]))
|
||||
{
|
||||
shell.WriteLine($"Unknown reagent prototype");
|
||||
return;
|
||||
@@ -60,9 +63,9 @@ namespace Content.Server.Administration.Commands
|
||||
var quantity = FixedPoint2.New(MathF.Abs(quantityFloat));
|
||||
|
||||
if (quantityFloat > 0)
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddReagent(uid, solution, args[2], quantity, out var _);
|
||||
_entManager.System<SolutionContainerSystem>().TryAddReagent(uid.Value, solution, args[2], quantity, out _);
|
||||
else
|
||||
EntitySystem.Get<SolutionContainerSystem>().RemoveReagent(uid, solution, args[2], quantity);
|
||||
_entManager.System<SolutionContainerSystem>().RemoveReagent(uid.Value, solution, args[2], quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands;
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class ClearBluespaceLockerLinks : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public string Command => "clearbluespacelockerlinks";
|
||||
public string Description => "Removes the bluespace links of the given uid. Does not remove links this uid is the target of.";
|
||||
public string Help => "Usage: clearbluespacelockerlinks <storage uid>";
|
||||
@@ -19,15 +21,12 @@ public sealed class ClearBluespaceLockerLinks : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entityManager.TryGetEntity(entityUidNet, out var entityUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entityManager.TryGetComponent<BluespaceLockerComponent>(entityUid, out var originComponent))
|
||||
entityManager.RemoveComponent(entityUid, originComponent);
|
||||
_entityManager.RemoveComponent<BluespaceLockerComponent>(entityUid.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,28 +6,29 @@ namespace Content.Server.Administration.Commands;
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class DirtyCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "dirty";
|
||||
public string Description => "Marks all components on an entity as dirty, if not specified, dirties everything";
|
||||
public string Help => $"Usage: {Command} [entityUid]";
|
||||
|
||||
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
foreach (var entity in entityManager.GetEntities())
|
||||
foreach (var entity in _entManager.GetEntities())
|
||||
{
|
||||
DirtyAll(entityManager, entity);
|
||||
DirtyAll(_entManager, entity);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var parsedTarget))
|
||||
if (!NetEntity.TryParse(args[0], out var parsedTarget))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
DirtyAll(entityManager, parsedTarget);
|
||||
DirtyAll(_entManager, _entManager.GetEntity(parsedTarget));
|
||||
break;
|
||||
default:
|
||||
shell.WriteLine(Loc.GetString("shell-wrong-arguments-number"));
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands;
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class LinkBluespaceLocker : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "linkbluespacelocker";
|
||||
public string Description => "Links an entity, the target, to another as a bluespace locker target.";
|
||||
public string Help => "Usage: linkbluespacelocker <two-way link> <origin storage uid> <target storage uid>";
|
||||
@@ -19,44 +21,42 @@ public sealed class LinkBluespaceLocker : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Boolean.TryParse(args[0], out var bidirectional))
|
||||
if (!bool.TryParse(args[0], out var bidirectional))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-invalid-bool"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out var originUid))
|
||||
if (!NetEntity.TryParse(args[1], out var originUidNet) || !_entManager.TryGetEntity(originUidNet, out var originUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[2], out var targetUid))
|
||||
if (!NetEntity.TryParse(args[2], out var targetUidNet) || !_entManager.TryGetEntity(targetUidNet, out var targetUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entityManager.TryGetComponent<EntityStorageComponent>(originUid, out var originComponent))
|
||||
if (!_entManager.HasComponent<EntityStorageComponent>(originUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", originUid), ("componentName", nameof(EntityStorageComponent))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent<EntityStorageComponent>(targetUid, out var targetComponent))
|
||||
if (!_entManager.HasComponent<EntityStorageComponent>(targetUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", targetUid), ("componentName", nameof(EntityStorageComponent))));
|
||||
return;
|
||||
}
|
||||
|
||||
entityManager.EnsureComponent<BluespaceLockerComponent>(originUid, out var originBluespaceComponent);
|
||||
originBluespaceComponent.BluespaceLinks.Add(targetUid);
|
||||
entityManager.EnsureComponent<BluespaceLockerComponent>(targetUid, out var targetBluespaceComponent);
|
||||
_entManager.EnsureComponent<BluespaceLockerComponent>(originUid.Value, out var originBluespaceComponent);
|
||||
originBluespaceComponent.BluespaceLinks.Add(targetUid.Value);
|
||||
_entManager.EnsureComponent<BluespaceLockerComponent>(targetUid.Value, out var targetBluespaceComponent);
|
||||
if (bidirectional)
|
||||
{
|
||||
targetBluespaceComponent.BluespaceLinks.Add(originUid);
|
||||
targetBluespaceComponent.BluespaceLinks.Add(originUid.Value);
|
||||
}
|
||||
else if (targetBluespaceComponent.BluespaceLinks.Count == 0)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ public sealed class OSay : LocalizedCommands
|
||||
|
||||
var chatType = (InGameICChatType) Enum.Parse(typeof(InGameICChatType), args[1]);
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var source) || !_entityManager.EntityExists(source))
|
||||
if (!NetEntity.TryParse(args[0], out var sourceNet) || !_entityManager.TryGetEntity(sourceNet, out var source) || !_entityManager.EntityExists(source))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("osay-command-error-euid", ("arg", args[0])));
|
||||
return;
|
||||
@@ -56,7 +56,7 @@ public sealed class OSay : LocalizedCommands
|
||||
if (string.IsNullOrEmpty(message))
|
||||
return;
|
||||
|
||||
_entityManager.System<ChatSystem>().TrySendInGameICMessage(source, message, chatType, false);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{(shell.Player != null ? shell.Player.Name : "An administrator")} forced {_entityManager.ToPrettyString(source)} to {args[1]}: {message}");
|
||||
_entityManager.System<ChatSystem>().TrySendInGameICMessage(source.Value, message, chatType, false);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{(shell.Player != null ? shell.Player.Name : "An administrator")} forced {_entityManager.ToPrettyString(source.Value)} to {args[1]}: {message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class RemoveBodyPartCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "rmbodypart";
|
||||
public string Description => "Removes a given entity from it's containing body, if any.";
|
||||
public string Help => "Usage: rmbodypart <uid>";
|
||||
@@ -19,18 +21,17 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entManager.TryGetEntity(entityUidNet, out var entityUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
var bodySystem = _entManager.System<BodySystem>();
|
||||
|
||||
if (bodySystem.DropPart(entityUid))
|
||||
{
|
||||
shell.WriteLine($"Removed body part {entityManager.ToPrettyString(entityUid)}.");
|
||||
shell.WriteLine($"Removed body part {_entManager.ToPrettyString(entityUid.Value)}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class RemoveEntityStorageCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "rmstorage";
|
||||
public string Description => "Removes a given entity from it's containing storage, if any.";
|
||||
public string Help => "Usage: rmstorage <uid>";
|
||||
@@ -20,22 +22,23 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (!_entManager.EntitySysManager.TryGetEntitySystem<EntityStorageSystem>(out var entstorage))
|
||||
return;
|
||||
|
||||
if (!entityManager.EntitySysManager.TryGetEntitySystem<EntityStorageSystem>(out var entstorage)) return;
|
||||
if (!entityManager.TryGetComponent<TransformComponent>(entityUid, out var transform)) return;
|
||||
if (!_entManager.TryGetComponent<TransformComponent>(entityUid, out var transform))
|
||||
return;
|
||||
|
||||
var parent = transform.ParentUid;
|
||||
|
||||
if (entityManager.TryGetComponent<EntityStorageComponent>(parent, out var storage))
|
||||
if (_entManager.TryGetComponent<EntityStorageComponent>(parent, out var storage))
|
||||
{
|
||||
entstorage.Remove(entityUid, storage.Owner, storage);
|
||||
entstorage.Remove(entityUid.Value, storage.Owner, storage);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class RemoveMechanismCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "rmmechanism";
|
||||
public string Description => "Removes a given entity from it's containing bodypart, if any.";
|
||||
public string Help => "Usage: rmmechanism <uid>";
|
||||
@@ -19,18 +21,17 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
var bodySystem = _entManager.System<BodySystem>();
|
||||
|
||||
if (bodySystem.DropOrgan(entityUid))
|
||||
{
|
||||
shell.WriteLine($"Removed organ {entityManager.ToPrettyString(entityUid)}");
|
||||
shell.WriteLine($"Removed organ {_entManager.ToPrettyString(entityUid.Value)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class SetSolutionCapacity : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "setsolutioncapacity";
|
||||
public string Description => "Set the capacity (maximum volume) of some solution.";
|
||||
public string Help => $"Usage: {Command} <target> <solution> <new capacity>";
|
||||
@@ -21,13 +23,13 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet))
|
||||
{
|
||||
shell.WriteLine($"Invalid entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
if (!_entManager.TryGetEntity(uidNet, out var uid) || !_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
{
|
||||
shell.WriteLine($"Entity does not have any solutions.");
|
||||
return;
|
||||
@@ -54,7 +56,7 @@ namespace Content.Server.Administration.Commands
|
||||
}
|
||||
|
||||
var quantity = FixedPoint2.New(quantityFloat);
|
||||
EntitySystem.Get<SolutionContainerSystem>().SetCapacity(uid, solution, quantity);
|
||||
_entManager.System<SolutionContainerSystem>().SetCapacity(uid.Value, solution, quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class SetSolutionTemperature : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "setsolutiontemperature";
|
||||
public string Description => "Set the temperature of some solution.";
|
||||
public string Help => $"Usage: {Command} <target> <solution> <new temperature>";
|
||||
@@ -20,13 +22,13 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
shell.WriteLine($"Invalid entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
if (!_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
{
|
||||
shell.WriteLine($"Entity does not have any solutions.");
|
||||
return;
|
||||
@@ -52,7 +54,7 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().SetTemperature(uid, solution, quantity);
|
||||
_entManager.System<SolutionContainerSystem>().SetTemperature(uid.Value, solution, quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class SetSolutionThermalEnergy : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "setsolutionthermalenergy";
|
||||
public string Description => "Set the thermal energy of some solution.";
|
||||
public string Help => $"Usage: {Command} <target> <solution> <new thermal energy>";
|
||||
@@ -20,13 +22,13 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
shell.WriteLine($"Invalid entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
if (!_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man))
|
||||
{
|
||||
shell.WriteLine($"Entity does not have any solutions.");
|
||||
return;
|
||||
@@ -53,13 +55,14 @@ namespace Content.Server.Administration.Commands
|
||||
shell.WriteLine($"Cannot set the thermal energy of a solution with 0 heat capacity to a non-zero number.");
|
||||
return;
|
||||
}
|
||||
} else if(quantity <= 0.0f)
|
||||
}
|
||||
else if(quantity <= 0.0f)
|
||||
{
|
||||
shell.WriteLine($"Cannot set the thermal energy of a solution with heat capacity to a non-positive number.");
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().SetThermalEnergy(uid, solution, quantity);
|
||||
_entManager.System<SolutionContainerSystem>().SetThermalEnergy(uid.Value, solution, quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace Content.Server.Administration.Commands;
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
public sealed class VariantizeCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public string Command => "variantize";
|
||||
|
||||
public string Description => Loc.GetString("variantize-command-description");
|
||||
@@ -24,16 +27,13 @@ public sealed class VariantizeCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var euid))
|
||||
if (!NetEntity.TryParse(args[0], out var euidNet) || !_entManager.TryGetEntity(euidNet, out var euid))
|
||||
{
|
||||
shell.WriteError($"Failed to parse euid '{args[0]}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entMan.TryGetComponent(euid, out MapGridComponent? gridComp))
|
||||
if (!_entManager.TryGetComponent(euid, out MapGridComponent? gridComp))
|
||||
{
|
||||
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
||||
return;
|
||||
@@ -42,7 +42,7 @@ public sealed class VariantizeCommand : IConsoleCommand
|
||||
foreach (var tile in gridComp.GetAllTiles())
|
||||
{
|
||||
var def = tile.GetContentTileDefinition();
|
||||
var newTile = new Tile(tile.Tile.TypeId, tile.Tile.Flags, def.PickVariant(random));
|
||||
var newTile = new Tile(tile.Tile.TypeId, tile.Tile.Flags, def.PickVariant(_random));
|
||||
gridComp.SetTile(tile.GridIndices, newTile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Content.Server.Administration.Systems
|
||||
|
||||
var connected = session != null && session.Status is SessionStatus.Connected or SessionStatus.InGame;
|
||||
|
||||
return new PlayerInfo(name, entityName, identityName, startingRole, antag, session?.AttachedEntity, data.UserId,
|
||||
return new PlayerInfo(name, entityName, identityName, startingRole, antag, GetNetEntity(session?.AttachedEntity), data.UserId,
|
||||
connected, _roundActivePlayers.Contains(data.UserId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Administration.Systems;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration;
|
||||
@@ -30,13 +31,13 @@ namespace Content.Server.Administration.UI
|
||||
public override void Closed()
|
||||
{
|
||||
base.Closed();
|
||||
EntitySystem.Get<Systems.AdminVerbSystem>().OnEditSolutionsEuiClosed(Player);
|
||||
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player);
|
||||
}
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
var solutions = _entityManager.GetComponentOrNull<SolutionContainerManagerComponent>(Target)?.Solutions;
|
||||
return new EditSolutionsEuiState(Target, solutions);
|
||||
return new EditSolutionsEuiState(_entityManager.GetNetEntity(Target), solutions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Content.Server.Administration.UI
|
||||
public sealed class SetOutfitEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
private readonly EntityUid _target;
|
||||
|
||||
public SetOutfitEui(EntityUid entity)
|
||||
@@ -30,7 +31,7 @@ namespace Content.Server.Administration.UI
|
||||
{
|
||||
return new SetOutfitEuiState
|
||||
{
|
||||
TargetEntityId = _target
|
||||
TargetNetEntity = _entManager.GetNetEntity(_target)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed class AmeControllerSystem : EntitySystem
|
||||
return;
|
||||
|
||||
var state = GetUiState(uid, controller);
|
||||
UserInterfaceSystem.SetUiState(bui, state);
|
||||
_userInterfaceSystem.SetUiState(bui, state);
|
||||
}
|
||||
|
||||
private AmeControllerBoundUserInterfaceState GetUiState(EntityUid uid, AmeControllerComponent controller)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Server.Animals.Systems
|
||||
if (!Resolve(uid, ref udder))
|
||||
return;
|
||||
|
||||
var doargs = new DoAfterArgs(userUid, 5, new MilkingDoAfterEvent(), uid, uid, used: containerUid)
|
||||
var doargs = new DoAfterArgs(EntityManager, userUid, 5, new MilkingDoAfterEvent(), uid, uid, used: containerUid)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
|
||||
@@ -26,13 +26,13 @@ public sealed partial class AnomalySystem
|
||||
if (args.Length != 1)
|
||||
shell.WriteError("Argument length must be 1");
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid))
|
||||
return;
|
||||
|
||||
if (!TryComp<AnomalyComponent>(uid, out var anomaly))
|
||||
return;
|
||||
|
||||
DoAnomalyPulse(uid, anomaly);
|
||||
DoAnomalyPulse(uid.Value, anomaly);
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
@@ -41,13 +41,13 @@ public sealed partial class AnomalySystem
|
||||
if (args.Length != 1)
|
||||
shell.WriteError("Argument length must be 1");
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid))
|
||||
return;
|
||||
|
||||
if (!HasComp<AnomalyComponent>(uid))
|
||||
return;
|
||||
|
||||
StartSupercriticalEvent(uid);
|
||||
StartSupercriticalEvent(uid.Value);
|
||||
}
|
||||
|
||||
private CompletionResult GetAnomalyCompletion(IConsoleShell shell, string[] args)
|
||||
|
||||
@@ -79,7 +79,7 @@ public sealed partial class AnomalySystem
|
||||
if (!HasComp<AnomalyComponent>(target))
|
||||
return;
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid)
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid)
|
||||
{
|
||||
DistanceThreshold = 2f
|
||||
});
|
||||
|
||||
@@ -24,29 +24,27 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var euid))
|
||||
if (!NetEntity.TryParse(args[0], out var eNet) || !_entities.TryGetEntity(eNet, out var euid))
|
||||
{
|
||||
shell.WriteError($"Failed to parse euid '{args[0]}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entMan.HasComponent<MapGridComponent>(euid))
|
||||
if (!_entities.HasComponent<MapGridComponent>(euid))
|
||||
{
|
||||
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmos = entMan.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
||||
var atmos = _entities.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
||||
|
||||
if (atmos.HasAtmosphere(euid))
|
||||
if (atmos.HasAtmosphere(euid.Value))
|
||||
{
|
||||
shell.WriteLine("Grid already has an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
_entities.AddComponent<GridAtmosphereComponent>(euid);
|
||||
_entities.AddComponent<GridAtmosphereComponent>(euid.Value);
|
||||
|
||||
shell.WriteLine($"Added atmosphere to grid {euid}.");
|
||||
}
|
||||
|
||||
@@ -11,28 +11,34 @@ namespace Content.Server.Atmos.Commands
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class AddGasCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "addgas";
|
||||
public string Description => "Adds gas at a certain position.";
|
||||
public string Help => "addgas <X> <Y> <GridEid> <Gas> <moles>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 5) return;
|
||||
if (args.Length < 5)
|
||||
return;
|
||||
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !EntityUid.TryParse(args[2], out var euid)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId))
|
||||
|| !float.TryParse(args[4], out var moles)) return;
|
||||
if (!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !NetEntity.TryParse(args[2], out var netEnt)
|
||||
|| !_entManager.TryGetEntity(netEnt, out var euid)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId))
|
||||
|| !float.TryParse(args[4], out var moles))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.HasComponent<MapGridComponent>(euid))
|
||||
if (!_entManager.HasComponent<MapGridComponent>(euid))
|
||||
{
|
||||
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = entMan.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
||||
var atmosphereSystem = _entManager.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(euid, null, indices, true);
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace Content.Server.Atmos.Commands
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class DeleteGasCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public string Command => "deletegas";
|
||||
public string Description => "Removes all gases from a grid, or just of one type if specified.";
|
||||
public string Help => $"Usage: {Command} <GridId> <Gas> / {Command} <GridId> / {Command} <Gas> / {Command}";
|
||||
@@ -21,8 +24,6 @@ namespace Content.Server.Atmos.Commands
|
||||
EntityUid? gridId;
|
||||
Gas? gas = null;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
@@ -39,7 +40,7 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
gridId = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
|
||||
if (gridId == null)
|
||||
{
|
||||
@@ -51,7 +52,7 @@ namespace Content.Server.Atmos.Commands
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (!EntityUid.TryParse(args[0], out var number))
|
||||
if (!NetEntity.TryParse(args[0], out var numberEnt) || !_entManager.TryGetEntity(numberEnt, out var number))
|
||||
{
|
||||
// Argument is a gas
|
||||
if (player == null)
|
||||
@@ -66,7 +67,7 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
gridId = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
|
||||
if (gridId == null)
|
||||
{
|
||||
@@ -90,7 +91,7 @@ namespace Content.Server.Atmos.Commands
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!EntityUid.TryParse(args[0], out var first))
|
||||
if (!NetEntity.TryParse(args[0], out var firstNet) || !_entManager.TryGetEntity(firstNet, out var first))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer for a grid id.");
|
||||
return;
|
||||
@@ -119,15 +120,13 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out _))
|
||||
if (!_mapManager.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var atmosphereSystem = _entManager.System<AtmosphereSystem>();
|
||||
|
||||
var tiles = 0;
|
||||
var moles = 0f;
|
||||
@@ -136,7 +135,8 @@ namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
|
||||
{
|
||||
if (tile.Immutable) continue;
|
||||
if (tile.Immutable)
|
||||
continue;
|
||||
|
||||
tiles++;
|
||||
moles += tile.TotalMoles;
|
||||
@@ -148,7 +148,8 @@ namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
|
||||
{
|
||||
if (tile.Immutable) continue;
|
||||
if (tile.Immutable)
|
||||
continue;
|
||||
|
||||
tiles++;
|
||||
moles += tile.TotalMoles;
|
||||
|
||||
@@ -10,26 +10,33 @@ namespace Content.Server.Atmos.Commands
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class FillGas : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public string Command => "fillgas";
|
||||
public string Description => "Adds gas to all tiles in a grid.";
|
||||
public string Help => "fillgas <GridEid> <Gas> <moles>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 3) return;
|
||||
if(!EntityUid.TryParse(args[0], out var gridId)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
|
||||
|| !float.TryParse(args[2], out var moles)) return;
|
||||
if (args.Length < 3)
|
||||
return;
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
if (!NetEntity.TryParse(args[0], out var gridIdNet)
|
||||
|| !_entManager.TryGetEntity(gridIdNet, out var gridId)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
|
||||
|| !float.TryParse(args[2], out var moles))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mapMan.TryGetGrid(gridId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var atmosphereSystem = _entManager.System<AtmosphereSystem>();
|
||||
|
||||
foreach (var tile in atmosphereSystem.GetAllMixtures(grid.Owner, true))
|
||||
{
|
||||
|
||||
@@ -9,20 +9,28 @@ namespace Content.Server.Atmos.Commands
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class RemoveGasCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "removegas";
|
||||
public string Description => "Removes an amount of gases.";
|
||||
public string Help => "removegas <X> <Y> <GridId> <amount> <ratio>\nIf <ratio> is true, amount will be treated as the ratio of gas to be removed.";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 5) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !EntityUid.TryParse(args[2], out var id)
|
||||
|| !float.TryParse(args[3], out var amount)
|
||||
|| !bool.TryParse(args[4], out var ratio)) return;
|
||||
if (args.Length < 5)
|
||||
return;
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
if (!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !NetEntity.TryParse(args[2], out var idNet)
|
||||
|| !_entManager.TryGetEntity(idNet, out var id)
|
||||
|| !float.TryParse(args[3], out var amount)
|
||||
|| !bool.TryParse(args[4], out var ratio))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = _entManager.System<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(id, null, indices, true);
|
||||
|
||||
|
||||
@@ -10,17 +10,23 @@ namespace Content.Server.Atmos.Commands
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class SetAtmosTemperatureCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public string Command => "setatmostemp";
|
||||
public string Description => "Sets a grid's temperature (in kelvin).";
|
||||
public string Help => "Usage: setatmostemp <GridId> <Temperature>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 2) return;
|
||||
if(!EntityUid.TryParse(args[0], out var gridId)
|
||||
|| !float.TryParse(args[1], out var temperature)) return;
|
||||
if (args.Length < 2)
|
||||
return;
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
if (!_entManager.TryParseNetEntity(args[0], out var gridId)
|
||||
|| !float.TryParse(args[1], out var temperature))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
{
|
||||
@@ -28,13 +34,13 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
if (!gridId.Value.IsValid() || !_mapManager.TryGetGrid(gridId, out var gridComp))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var atmosphereSystem = _entManager.System<AtmosphereSystem>();
|
||||
|
||||
var tiles = 0;
|
||||
foreach (var tile in atmosphereSystem.GetAllMixtures(gridComp.Owner, true))
|
||||
|
||||
@@ -22,11 +22,17 @@ namespace Content.Server.Atmos.Commands
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 4) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !EntityUid.TryParse(args[2], out var gridId)
|
||||
|| !float.TryParse(args[3], out var temperature)) return;
|
||||
if (args.Length < 4)
|
||||
return;
|
||||
|
||||
if (!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !NetEntity.TryParse(args[2], out var gridIdNet)
|
||||
|| !_entities.TryGetEntity(gridIdNet, out var gridId)
|
||||
|| !float.TryParse(args[3], out var temperature))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
{
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
RaiseNetworkEvent(new AtmosDebugOverlayMessage(grid.Owner, baseTile, debugOverlayContent), session.ConnectedClient);
|
||||
RaiseNetworkEvent(new AtmosDebugOverlayMessage(GetNetEntity(grid.Owner), baseTile, debugOverlayContent), session.ConnectedClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public sealed partial class AtmosphereSystem
|
||||
|
||||
foreach (var arg in args)
|
||||
{
|
||||
if(!EntityUid.TryParse(arg, out var euid))
|
||||
if (!NetEntity.TryParse(arg, out var netEntity) || !TryGetEntity(netEntity, out var euid))
|
||||
{
|
||||
shell.WriteError($"Failed to parse euid '{arg}'.");
|
||||
return;
|
||||
@@ -85,7 +85,7 @@ public sealed partial class AtmosphereSystem
|
||||
continue;
|
||||
}
|
||||
|
||||
var transform = Transform(euid);
|
||||
var transform = Transform(euid.Value);
|
||||
|
||||
foreach (var (indices, tileMain) in gridAtmosphere.Tiles)
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
_userInterface.TrySendUiMessage(uid, GasAnalyzerUiKey.Key,
|
||||
new GasAnalyzerUserMessage(gasMixList.ToArray(),
|
||||
component.Target != null ? Name(component.Target.Value) : string.Empty,
|
||||
component.Target ?? EntityUid.Invalid,
|
||||
GetNetEntity(component.Target) ?? NetEntity.Invalid,
|
||||
deviceFlipped));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
public void UpdateUserInterface(GasTankComponent component, bool initialUpdate = false)
|
||||
{
|
||||
var internals = GetInternalsComponent(component);
|
||||
_ui.TrySetUiState(component.Owner, SharedGasTankUiKey.Key,
|
||||
new GasTankBoundUserInterfaceState
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ using Robust.Server.Player;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Threading;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -36,15 +35,15 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
[Robust.Shared.IoC.Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Robust.Shared.IoC.Dependency] private readonly ChunkingSystem _chunkingSys = default!;
|
||||
|
||||
private readonly Dictionary<IPlayerSession, Dictionary<EntityUid, HashSet<Vector2i>>> _lastSentChunks = new();
|
||||
private readonly Dictionary<IPlayerSession, Dictionary<NetEntity, HashSet<Vector2i>>> _lastSentChunks = new();
|
||||
|
||||
// Oh look its more duplicated decal system code!
|
||||
private ObjectPool<HashSet<Vector2i>> _chunkIndexPool =
|
||||
new DefaultObjectPool<HashSet<Vector2i>>(
|
||||
new DefaultPooledObjectPolicy<HashSet<Vector2i>>(), 64);
|
||||
private ObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>> _chunkViewerPool =
|
||||
new DefaultObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>>(
|
||||
new DefaultPooledObjectPolicy<Dictionary<EntityUid, HashSet<Vector2i>>>(), 64);
|
||||
private ObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>> _chunkViewerPool =
|
||||
new DefaultObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>>(
|
||||
new DefaultPooledObjectPolicy<Dictionary<NetEntity, HashSet<Vector2i>>>(), 64);
|
||||
|
||||
/// <summary>
|
||||
/// Overlay update interval, in seconds.
|
||||
@@ -294,22 +293,21 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick)
|
||||
{
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool);
|
||||
var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, _chunkIndexPool, _chunkViewerPool);
|
||||
var previouslySent = _lastSentChunks[playerSession];
|
||||
|
||||
var ev = new GasOverlayUpdateEvent();
|
||||
|
||||
foreach (var (grid, oldIndices) in previouslySent)
|
||||
foreach (var (netGrid, oldIndices) in previouslySent)
|
||||
{
|
||||
// Mark the whole grid as stale and flag for removal.
|
||||
if (!chunksInRange.TryGetValue(grid, out var chunks))
|
||||
if (!chunksInRange.TryGetValue(netGrid, out var chunks))
|
||||
{
|
||||
previouslySent.Remove(grid);
|
||||
previouslySent.Remove(netGrid);
|
||||
|
||||
// If grid was deleted then don't worry about sending it to the client.
|
||||
if (_mapManager.IsGrid(grid))
|
||||
ev.RemovedChunks[grid] = oldIndices;
|
||||
if (!TryGetEntity(netGrid, out var gridId) || !_mapManager.IsGrid(gridId.Value))
|
||||
ev.RemovedChunks[netGrid] = oldIndices;
|
||||
else
|
||||
{
|
||||
oldIndices.Clear();
|
||||
@@ -330,19 +328,19 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if (old.Count == 0)
|
||||
_chunkIndexPool.Return(old);
|
||||
else
|
||||
ev.RemovedChunks.Add(grid, old);
|
||||
ev.RemovedChunks.Add(netGrid, old);
|
||||
}
|
||||
|
||||
foreach (var (grid, gridChunks) in chunksInRange)
|
||||
foreach (var (netGrid, gridChunks) in chunksInRange)
|
||||
{
|
||||
// Not all grids have atmospheres.
|
||||
if (!TryComp(grid, out GasTileOverlayComponent? overlay))
|
||||
if (!TryGetEntity(netGrid, out var grid) || !TryComp(grid, out GasTileOverlayComponent? overlay))
|
||||
continue;
|
||||
|
||||
List<GasOverlayChunk> dataToSend = new();
|
||||
ev.UpdatedChunks[grid] = dataToSend;
|
||||
ev.UpdatedChunks[netGrid] = dataToSend;
|
||||
|
||||
previouslySent.TryGetValue(grid, out var previousChunks);
|
||||
previouslySent.TryGetValue(netGrid, out var previousChunks);
|
||||
|
||||
foreach (var index in gridChunks)
|
||||
{
|
||||
@@ -359,7 +357,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
dataToSend.Add(value);
|
||||
}
|
||||
|
||||
previouslySent[grid] = gridChunks;
|
||||
previouslySent[netGrid] = gridChunks;
|
||||
if (previousChunks != null)
|
||||
{
|
||||
previousChunks.Clear();
|
||||
|
||||
@@ -96,7 +96,7 @@ public sealed class BeamSystem : SharedBeamSystem
|
||||
|
||||
var distanceLength = distanceCorrection.Length();
|
||||
|
||||
var beamVisualizerEvent = new BeamVisualizerEvent(ent, distanceLength, userAngle, bodyState, shader);
|
||||
var beamVisualizerEvent = new BeamVisualizerEvent(GetNetEntity(ent), distanceLength, userAngle, bodyState, shader);
|
||||
RaiseNetworkEvent(beamVisualizerEvent);
|
||||
|
||||
if (controller != null)
|
||||
@@ -119,7 +119,7 @@ public sealed class BeamSystem : SharedBeamSystem
|
||||
beamSpawnPos = beamSpawnPos.Offset(calculatedDistance.Normalized());
|
||||
var newEnt = Spawn(prototype, beamSpawnPos);
|
||||
|
||||
var ev = new BeamVisualizerEvent(newEnt, distanceLength, userAngle, bodyState, shader);
|
||||
var ev = new BeamVisualizerEvent(GetNetEntity(newEnt), distanceLength, userAngle, bodyState, shader);
|
||||
RaiseNetworkEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace Content.Server.Body.Commands
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
sealed class AddHandCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
[ValidatePrototypeId<EntityPrototype>]
|
||||
public const string DefaultHandPrototype = "LeftHandHuman";
|
||||
|
||||
@@ -25,9 +29,6 @@ namespace Content.Server.Body.Commands
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
EntityUid entity;
|
||||
EntityUid hand;
|
||||
|
||||
@@ -48,21 +49,21 @@ namespace Content.Server.Body.Commands
|
||||
}
|
||||
|
||||
entity = player.AttachedEntity.Value;
|
||||
hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
hand = _entManager.SpawnEntity(DefaultHandPrototype, _entManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (EntityUid.TryParse(args[0], out var uid))
|
||||
if (NetEntity.TryParse(args[0], out var uidNet) && _entManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
if (!entityManager.EntityExists(uid))
|
||||
if (!_entManager.EntityExists(uid))
|
||||
{
|
||||
shell.WriteLine($"No entity found with uid {uid}");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = uid;
|
||||
hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
entity = uid.Value;
|
||||
hand = _entManager.SpawnEntity(DefaultHandPrototype, _entManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -79,34 +80,34 @@ namespace Content.Server.Body.Commands
|
||||
}
|
||||
|
||||
entity = player.AttachedEntity.Value;
|
||||
hand = entityManager.SpawnEntity(args[0], entityManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
hand = _entManager.SpawnEntity(args[0], _entManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var netEnt) || !_entManager.TryGetEntity(netEnt, out var uid))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity uid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(uid))
|
||||
if (!_entManager.EntityExists(uid))
|
||||
{
|
||||
shell.WriteLine($"No entity exists with uid {uid}.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = uid;
|
||||
entity = uid.Value;
|
||||
|
||||
if (!prototypeManager.HasIndex<EntityPrototype>(args[1]))
|
||||
if (!_protoManager.HasIndex<EntityPrototype>(args[1]))
|
||||
{
|
||||
shell.WriteLine($"No hand entity exists with id {args[1]}.");
|
||||
return;
|
||||
}
|
||||
|
||||
hand = entityManager.SpawnEntity(args[1], entityManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
hand = _entManager.SpawnEntity(args[1], _entManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -117,22 +118,21 @@ namespace Content.Server.Body.Commands
|
||||
}
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(entity, out BodyComponent? body) || body.Root == null)
|
||||
if (!_entManager.TryGetComponent(entity, out BodyComponent? body) || body.Root == null)
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
var text = $"You have no body{(_random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
shell.WriteLine(text);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(hand, out BodyPartComponent? part))
|
||||
if (!_entManager.TryGetComponent(hand, out BodyPartComponent? part))
|
||||
{
|
||||
shell.WriteLine($"Hand entity {hand} does not have a {nameof(BodyPartComponent)} component.");
|
||||
return;
|
||||
}
|
||||
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
var bodySystem = _entManager.System<BodySystem>();
|
||||
|
||||
var attachAt = bodySystem.GetBodyChildrenOfType(entity, BodyPartType.Arm, body).FirstOrDefault();
|
||||
if (attachAt == default)
|
||||
@@ -142,11 +142,11 @@ namespace Content.Server.Body.Commands
|
||||
|
||||
if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, hand, attachAt.Component, part))
|
||||
{
|
||||
shell.WriteError($"Couldn't create a slot with id {slotId} on entity {entityManager.ToPrettyString(entity)}");
|
||||
shell.WriteError($"Couldn't create a slot with id {slotId} on entity {_entManager.ToPrettyString(entity)}");
|
||||
return;
|
||||
}
|
||||
|
||||
shell.WriteLine($"Added hand to entity {entityManager.GetComponent<MetaDataComponent>(entity).EntityName}");
|
||||
shell.WriteLine($"Added hand to entity {_entManager.GetComponent<MetaDataComponent>(entity).EntityName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Content.Server.Body.Commands
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class AttachBodyPartCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "attachbodypart";
|
||||
public string Description => "Attaches a body part to you or someone else.";
|
||||
public string Help => $"{Command} <partEntityUid> / {Command} <entityUid> <partEntityUid>";
|
||||
@@ -19,10 +21,9 @@ namespace Content.Server.Body.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
EntityUid bodyId;
|
||||
EntityUid partUid;
|
||||
EntityUid? partUid;
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
@@ -39,7 +40,7 @@ namespace Content.Server.Body.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out partUid))
|
||||
if (!NetEntity.TryParse(args[0], out var partNet) || !_entManager.TryGetEntity(partNet, out partUid))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity uid.");
|
||||
return;
|
||||
@@ -49,53 +50,53 @@ namespace Content.Server.Body.Commands
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (!EntityUid.TryParse(args[0], out var entityUid))
|
||||
if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity uid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out partUid))
|
||||
if (!NetEntity.TryParse(args[1], out partNet) || !_entManager.TryGetEntity(partNet, out partUid))
|
||||
{
|
||||
shell.WriteLine($"{args[1]} is not a valid entity uid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(entityUid))
|
||||
if (!_entManager.EntityExists(entityUid))
|
||||
{
|
||||
shell.WriteLine($"{entityUid} is not a valid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
bodyId = entityUid;
|
||||
bodyId = entityUid.Value;
|
||||
break;
|
||||
default:
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(bodyId, out BodyComponent? body))
|
||||
if (!_entManager.TryGetComponent(bodyId, out BodyComponent? body))
|
||||
{
|
||||
shell.WriteLine($"Entity {entityManager.GetComponent<MetaDataComponent>(bodyId).EntityName} with uid {bodyId} does not have a {nameof(BodyComponent)}.");
|
||||
shell.WriteLine($"Entity {_entManager.GetComponent<MetaDataComponent>(bodyId).EntityName} with uid {bodyId} does not have a {nameof(BodyComponent)}.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(partUid))
|
||||
if (!_entManager.EntityExists(partUid))
|
||||
{
|
||||
shell.WriteLine($"{partUid} is not a valid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(partUid, out BodyPartComponent? part))
|
||||
if (!_entManager.TryGetComponent(partUid, out BodyPartComponent? part))
|
||||
{
|
||||
shell.WriteLine($"Entity {entityManager.GetComponent<MetaDataComponent>(partUid).EntityName} with uid {args[0]} does not have a {nameof(BodyPartComponent)}.");
|
||||
shell.WriteLine($"Entity {_entManager.GetComponent<MetaDataComponent>(partUid.Value).EntityName} with uid {args[0]} does not have a {nameof(BodyPartComponent)}.");
|
||||
return;
|
||||
}
|
||||
|
||||
var bodySystem = entityManager.System<BodySystem>();
|
||||
var bodySystem = _entManager.System<BodySystem>();
|
||||
if (bodySystem.BodyHasChild(bodyId, partUid, body, part))
|
||||
{
|
||||
shell.WriteLine($"Body part {entityManager.GetComponent<MetaDataComponent>(partUid).EntityName} with uid {partUid} is already attached to entity {entityManager.GetComponent<MetaDataComponent>(bodyId).EntityName} with uid {bodyId}");
|
||||
shell.WriteLine($"Body part {_entManager.GetComponent<MetaDataComponent>(partUid.Value).EntityName} with uid {partUid} is already attached to entity {_entManager.GetComponent<MetaDataComponent>(bodyId).EntityName} with uid {bodyId}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,12 +114,12 @@ namespace Content.Server.Body.Commands
|
||||
|
||||
if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, partUid, attachAt.Component, part))
|
||||
{
|
||||
shell.WriteError($"Could not create slot {slotId} on entity {entityManager.ToPrettyString(bodyId)}");
|
||||
shell.WriteError($"Could not create slot {slotId} on entity {_entManager.ToPrettyString(bodyId)}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
shell.WriteLine($"Attached part {entityManager.ToPrettyString(partUid)} to {entityManager.ToPrettyString(bodyId)}");
|
||||
shell.WriteLine($"Attached part {_entManager.ToPrettyString(partUid.Value)} to {_entManager.ToPrettyString(bodyId)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed class InternalsSystem : EntitySystem
|
||||
var isUser = user == target;
|
||||
var delay = !isUser ? internals.Delay : 1.0f;
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(user, delay, new InternalsDoAfterEvent(), target, target: target)
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, delay, new InternalsDoAfterEvent(), target, target: target)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed class BotanySwabSystem : EntitySystem
|
||||
if (args.Target == null || !args.CanReach || !HasComp<PlantHolderComponent>(args.Target))
|
||||
return;
|
||||
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, swab.SwabDelay, new BotanySwabDoAfterEvent(), uid, target: args.Target, used: uid)
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, swab.SwabDelay, new BotanySwabDoAfterEvent(), uid, target: args.Target, used: uid)
|
||||
{
|
||||
Broadcast = true,
|
||||
BreakOnTargetMove = true,
|
||||
|
||||
@@ -8,8 +8,9 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
|
||||
{
|
||||
public override void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null)
|
||||
{
|
||||
if (!Resolve(euid, ref component, false)) return;
|
||||
if (!Resolve(euid, ref component, false))
|
||||
return;
|
||||
|
||||
RaiseNetworkEvent(new CameraKickEvent(euid, kickback), euid);
|
||||
RaiseNetworkEvent(new CameraKickEvent(GetNetEntity(euid), kickback), euid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
||||
{
|
||||
if (_timing.CurTime > component.EffectCooldown)
|
||||
{
|
||||
RaiseNetworkEvent(new PlayBoxEffectMessage(uid, component.Mover.Value));
|
||||
RaiseNetworkEvent(new PlayBoxEffectMessage(GetNetEntity(uid), GetNetEntity(component.Mover.Value)));
|
||||
_audio.PlayPvs(component.EffectSound, uid);
|
||||
component.EffectCooldown = _timing.CurTime + component.CooldownDuration;
|
||||
}
|
||||
|
||||
@@ -215,13 +215,15 @@ namespace Content.Server.Cargo.Systems
|
||||
!TryComp<StationBankAccountComponent>(station, out var bankAccount)) return;
|
||||
|
||||
if (_uiSystem.TryGetUi(consoleUid, CargoConsoleUiKey.Orders, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new CargoConsoleInterfaceState(
|
||||
{
|
||||
_uiSystem.SetUiState(bui, new CargoConsoleInterfaceState(
|
||||
MetaData(station.Value).EntityName,
|
||||
GetOutstandingOrderCount(orderDatabase),
|
||||
orderDatabase.Capacity,
|
||||
bankAccount.Balance,
|
||||
orderDatabase.Orders
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private void ConsolePopup(ICommonSession session, string text)
|
||||
|
||||
@@ -95,12 +95,12 @@ public sealed partial class CargoSystem
|
||||
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
|
||||
if (Transform(uid).GridUid is not EntityUid gridUid)
|
||||
{
|
||||
UserInterfaceSystem.SetUiState(bui,
|
||||
_uiSystem.SetUiState(bui,
|
||||
new CargoPalletConsoleInterfaceState(0, 0, false));
|
||||
return;
|
||||
}
|
||||
GetPalletGoods(gridUid, out var toSell, out var amount);
|
||||
UserInterfaceSystem.SetUiState(bui,
|
||||
_uiSystem.SetUiState(bui,
|
||||
new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true));
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public sealed partial class CargoSystem
|
||||
var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty;
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, CargoConsoleUiKey.Shuttle, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState(
|
||||
_uiSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState(
|
||||
station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"),
|
||||
string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName,
|
||||
orders
|
||||
@@ -324,7 +324,7 @@ public sealed partial class CargoSystem
|
||||
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
|
||||
if (Transform(uid).GridUid is not EntityUid gridUid)
|
||||
{
|
||||
UserInterfaceSystem.SetUiState(bui,
|
||||
_uiSystem.SetUiState(bui,
|
||||
new CargoPalletConsoleInterfaceState(0, 0, false));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public sealed class PricingSystem : EntitySystem
|
||||
|
||||
foreach (var gid in args)
|
||||
{
|
||||
if (!EntityUid.TryParse(gid, out var gridId) || !gridId.IsValid())
|
||||
if (!EntityManager.TryParseNetEntity(gid, out var gridId) || !gridId.Value.IsValid())
|
||||
{
|
||||
shell.WriteError($"Invalid grid ID \"{gid}\".");
|
||||
continue;
|
||||
@@ -90,7 +90,7 @@ public sealed class PricingSystem : EntitySystem
|
||||
|
||||
if (!TryComp<BodyComponent>(uid, out var body) || !TryComp<MobStateComponent>(uid, out var state))
|
||||
{
|
||||
Logger.ErrorS("pricing", $"Tried to get the mob price of {ToPrettyString(uid)}, which has no {nameof(BodyComponent)} and no {nameof(MobStateComponent)}.");
|
||||
Log.Error($"Tried to get the mob price of {ToPrettyString(uid)}, which has no {nameof(BodyComponent)} and no {nameof(MobStateComponent)}.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.PDA;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Server.Containers;
|
||||
@@ -6,7 +9,6 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Content.Server.CartridgeLoader;
|
||||
|
||||
@@ -14,8 +16,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
{
|
||||
[Dependency] private readonly ContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
|
||||
private const string ContainerName = "program-container";
|
||||
[Dependency] private readonly PdaSystem _pda = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -29,6 +30,66 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
SubscribeLocalEvent<CartridgeLoaderComponent, CartridgeUiMessage>(OnUiMessage);
|
||||
}
|
||||
|
||||
public IReadOnlyList<EntityUid> GetInstalled(EntityUid uid, ContainerManagerComponent? comp = null)
|
||||
{
|
||||
if (_containerSystem.TryGetContainer(uid, InstalledContainerId, out var container, comp))
|
||||
return container.ContainedEntities;
|
||||
|
||||
return Array.Empty<EntityUid>();
|
||||
}
|
||||
|
||||
public bool TryGetProgram<T>(
|
||||
EntityUid uid,
|
||||
[NotNullWhen(true)] out EntityUid? programUid,
|
||||
[NotNullWhen(true)] out T? program,
|
||||
bool installedOnly = false,
|
||||
CartridgeLoaderComponent? loader = null,
|
||||
ContainerManagerComponent? containerManager = null)
|
||||
{
|
||||
program = default;
|
||||
programUid = null;
|
||||
|
||||
if (!_containerSystem.TryGetContainer(uid, InstalledContainerId, out var container, containerManager))
|
||||
return false;
|
||||
|
||||
foreach (var prog in container.ContainedEntities)
|
||||
{
|
||||
if (!TryComp(prog, out program))
|
||||
continue;
|
||||
|
||||
programUid = prog;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (installedOnly)
|
||||
return false;
|
||||
|
||||
if (!Resolve(uid, ref loader) || !TryComp(loader.CartridgeSlot.Item, out program))
|
||||
return false;
|
||||
|
||||
programUid = loader.CartridgeSlot.Item;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryGetProgram<T>(
|
||||
EntityUid uid,
|
||||
[NotNullWhen(true)] out EntityUid? programUid,
|
||||
bool installedOnly = false,
|
||||
CartridgeLoaderComponent? loader = null,
|
||||
ContainerManagerComponent? containerManager = null)
|
||||
{
|
||||
return TryGetProgram<T>(uid, out programUid, out _, installedOnly, loader, containerManager);
|
||||
}
|
||||
|
||||
public bool HasProgram<T>(
|
||||
EntityUid uid,
|
||||
bool installedOnly = false,
|
||||
CartridgeLoaderComponent? loader = null,
|
||||
ContainerManagerComponent? containerManager = null)
|
||||
{
|
||||
return TryGetProgram<T>(uid, out _, out _, installedOnly, loader, containerManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the cartridge loaders ui state.
|
||||
/// </summary>
|
||||
@@ -37,16 +98,17 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// and use this method to update its state so the cartridge loaders state can be added to it.
|
||||
/// </remarks>
|
||||
/// <seealso cref="PDA.PdaSystem.UpdatePdaUserInterface"/>
|
||||
public void UpdateUiState(EntityUid loaderUid, CartridgeLoaderUiState state, IPlayerSession? session = default!, CartridgeLoaderComponent? loader = default!)
|
||||
public void UpdateUiState(EntityUid loaderUid, IPlayerSession? session, CartridgeLoaderComponent? loader)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
|
||||
state.ActiveUI = loader.ActiveProgram;
|
||||
state.Programs = GetAvailablePrograms(loaderUid, loader);
|
||||
if (!_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
|
||||
return;
|
||||
|
||||
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
|
||||
UserInterfaceSystem.SetUiState(ui, state, session);
|
||||
var programs = GetAvailablePrograms(loaderUid, loader);
|
||||
var state = new CartridgeLoaderUiState(programs, GetNetEntity(loader.ActiveProgram));
|
||||
_userInterfaceSystem.SetUiState(ui, state, session);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +128,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
return;
|
||||
|
||||
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui))
|
||||
UserInterfaceSystem.SetUiState(ui, state, session);
|
||||
_userInterfaceSystem.SetUiState(ui, state, session);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,21 +137,18 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <param name="uid">The cartridge loaders uid</param>
|
||||
/// <param name="loader">The cartridge loader component</param>
|
||||
/// <returns>A list of all the available program entity ids</returns>
|
||||
public List<EntityUid> GetAvailablePrograms(EntityUid uid, CartridgeLoaderComponent? loader = default!)
|
||||
public List<NetEntity> GetAvailablePrograms(EntityUid uid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(uid, ref loader))
|
||||
return new List<EntityUid>();
|
||||
return new List<NetEntity>();
|
||||
|
||||
//Don't count a cartridge that has already been installed as available to avoid confusion
|
||||
if (loader.CartridgeSlot.HasItem && TryFindInstalled(Prototype(loader.CartridgeSlot.Item!.Value)?.ID, loader, out _))
|
||||
return loader.InstalledPrograms;
|
||||
var available = GetNetEntityList(GetInstalled(uid));
|
||||
|
||||
var available = new List<EntityUid>();
|
||||
available.AddRange(loader.InstalledPrograms);
|
||||
|
||||
if (loader.CartridgeSlot.HasItem)
|
||||
available.Add(loader.CartridgeSlot.Item!.Value);
|
||||
if (loader.CartridgeSlot.Item is not { } cartridge)
|
||||
return available;
|
||||
|
||||
// TODO exclude duplicate programs. Or something I dunno I CBF fixing this mess.
|
||||
available.Add(GetNetEntity(cartridge));
|
||||
return available;
|
||||
}
|
||||
|
||||
@@ -102,11 +161,13 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <returns>Whether installing the cartridge was successful</returns>
|
||||
public bool InstallCartridge(EntityUid loaderUid, EntityUid cartridgeUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader) || loader.InstalledPrograms.Count >= loader.DiskSpace)
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return false;
|
||||
|
||||
//This will eventually be replaced by serializing and deserializing the cartridge to copy it when something needs
|
||||
//the data on the cartridge to carry over when installing
|
||||
|
||||
// For anyone stumbling onto this: Do not do this or I will cut you.
|
||||
var prototypeId = Prototype(cartridgeUid)?.ID;
|
||||
return prototypeId != null && InstallProgram(loaderUid, prototypeId, loader: loader);
|
||||
}
|
||||
@@ -121,16 +182,16 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <returns>Whether installing the cartridge was successful</returns>
|
||||
public bool InstallProgram(EntityUid loaderUid, string prototype, bool deinstallable = true, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader) || loader.InstalledPrograms.Count >= loader.DiskSpace)
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return false;
|
||||
|
||||
if (!_containerSystem.TryGetContainer(loaderUid, ContainerName, out var container))
|
||||
if (!_containerSystem.TryGetContainer(loaderUid, InstalledContainerId, out var container))
|
||||
return false;
|
||||
|
||||
//Prevent installing cartridges that have already been installed
|
||||
if (TryFindInstalled(prototype, loader, out _))
|
||||
if (container.Count >= loader.DiskSpace)
|
||||
return false;
|
||||
|
||||
// TODO cancel duplicate program installations
|
||||
var ev = new ProgramInstallationAttempt(loaderUid, prototype);
|
||||
RaiseLocalEvent(ref ev);
|
||||
|
||||
@@ -138,32 +199,15 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
return false;
|
||||
|
||||
var installedProgram = Spawn(prototype, new EntityCoordinates(loaderUid, 0, 0));
|
||||
container?.Insert(installedProgram);
|
||||
container.Insert(installedProgram);
|
||||
|
||||
UpdateCartridgeInstallationStatus(installedProgram, deinstallable ? InstallationStatus.Installed : InstallationStatus.Readonly);
|
||||
loader.InstalledPrograms.Add(installedProgram);
|
||||
|
||||
RaiseLocalEvent(installedProgram, new CartridgeAddedEvent(loaderUid));
|
||||
UpdateUserInterfaceState(loaderUid, loader);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls a program using its prototype
|
||||
/// </summary>
|
||||
/// <param name="loaderUid">The cartridge loader uid</param>
|
||||
/// <param name="prototype">The prototype name of the program to be uninstalled</param>
|
||||
/// <param name="loader">The cartridge loader component</param>
|
||||
/// <returns>Whether uninstalling the program was successful</returns>
|
||||
public bool UninstallProgram(EntityUid loaderUid, string prototype, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return false;
|
||||
|
||||
return TryFindInstalled(prototype, loader, out var programUid) &&
|
||||
UninstallProgram(loaderUid, programUid.Value, loader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls a program using its uid
|
||||
/// </summary>
|
||||
@@ -173,14 +217,16 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <returns>Whether uninstalling the program was successful</returns>
|
||||
public bool UninstallProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!)
|
||||
{
|
||||
if (!Resolve(loaderUid, ref loader) || !ContainsCartridge(programUid, loader, true))
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return false;
|
||||
|
||||
if (!GetInstalled(loaderUid).Contains(programUid))
|
||||
return false;
|
||||
|
||||
if (loader.ActiveProgram == programUid)
|
||||
loader.ActiveProgram = null;
|
||||
|
||||
loader.BackgroundPrograms.Remove(programUid);
|
||||
loader.InstalledPrograms.Remove(programUid);
|
||||
EntityManager.QueueDeleteEntity(programUid);
|
||||
UpdateUserInterfaceState(loaderUid, loader);
|
||||
return true;
|
||||
@@ -194,7 +240,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
|
||||
if (!ContainsCartridge(programUid, loader))
|
||||
if (!HasProgram(loaderUid, programUid, loader))
|
||||
return;
|
||||
|
||||
if (loader.ActiveProgram.HasValue)
|
||||
@@ -215,7 +261,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
|
||||
if (!ContainsCartridge(programUid, loader) || loader.ActiveProgram != programUid)
|
||||
if (!HasProgram(loaderUid, programUid, loader) || loader.ActiveProgram != programUid)
|
||||
return;
|
||||
|
||||
if (!loader.BackgroundPrograms.Contains(programUid))
|
||||
@@ -236,7 +282,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
|
||||
if (!ContainsCartridge(cartridgeUid, loader))
|
||||
if (!HasProgram(loaderUid, cartridgeUid, loader))
|
||||
return;
|
||||
|
||||
if (loader.ActiveProgram != cartridgeUid)
|
||||
@@ -253,7 +299,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
if (!Resolve(loaderUid, ref loader))
|
||||
return;
|
||||
|
||||
if (!ContainsCartridge(cartridgeUid, loader))
|
||||
if (!HasProgram(loaderUid, cartridgeUid, loader))
|
||||
return;
|
||||
|
||||
if (loader.ActiveProgram != cartridgeUid)
|
||||
@@ -264,12 +310,18 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
|
||||
protected override void OnItemInserted(EntityUid uid, CartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID != InstalledContainerId && args.Container.ID != loader.CartridgeSlot.ID)
|
||||
return;
|
||||
|
||||
RaiseLocalEvent(args.Entity, new CartridgeAddedEvent(uid));
|
||||
base.OnItemInserted(uid, loader, args);
|
||||
}
|
||||
|
||||
protected override void OnItemRemoved(EntityUid uid, CartridgeLoaderComponent loader, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID != InstalledContainerId && args.Container.ID != loader.CartridgeSlot.ID)
|
||||
return;
|
||||
|
||||
var deactivate = loader.BackgroundPrograms.Remove(args.Entity);
|
||||
|
||||
if (loader.ActiveProgram == args.Entity)
|
||||
@@ -283,6 +335,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
|
||||
RaiseLocalEvent(args.Entity, new CartridgeRemovedEvent(uid));
|
||||
base.OnItemRemoved(uid, loader, args);
|
||||
|
||||
_pda.UpdatePdaUi(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -290,6 +344,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// </summary>
|
||||
private void OnMapInit(EntityUid uid, CartridgeLoaderComponent component, MapInitEvent args)
|
||||
{
|
||||
// TODO remove this and use container fill.
|
||||
foreach (var prototype in component.PreinstalledPrograms)
|
||||
{
|
||||
InstallProgram(uid, prototype, deinstallable: false);
|
||||
@@ -308,19 +363,21 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
|
||||
private void OnLoaderUiMessage(EntityUid loaderUid, CartridgeLoaderComponent component, CartridgeLoaderUiMessage message)
|
||||
{
|
||||
var cartridge = GetEntity(message.CartridgeUid);
|
||||
|
||||
switch (message.Action)
|
||||
{
|
||||
case CartridgeUiMessageAction.Activate:
|
||||
ActivateProgram(loaderUid, message.CartridgeUid, component);
|
||||
ActivateProgram(loaderUid, cartridge, component);
|
||||
break;
|
||||
case CartridgeUiMessageAction.Deactivate:
|
||||
DeactivateProgram(loaderUid, message.CartridgeUid, component);
|
||||
DeactivateProgram(loaderUid, cartridge, component);
|
||||
break;
|
||||
case CartridgeUiMessageAction.Install:
|
||||
InstallCartridge(loaderUid, message.CartridgeUid, component);
|
||||
InstallCartridge(loaderUid, cartridge, component);
|
||||
break;
|
||||
case CartridgeUiMessageAction.Uninstall:
|
||||
UninstallProgram(loaderUid, message.CartridgeUid, component);
|
||||
UninstallProgram(loaderUid, cartridge, component);
|
||||
break;
|
||||
case CartridgeUiMessageAction.UIReady:
|
||||
if (component.ActiveProgram.HasValue)
|
||||
@@ -337,7 +394,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
private void OnUiMessage(EntityUid uid, CartridgeLoaderComponent component, CartridgeUiMessage args)
|
||||
{
|
||||
var cartridgeEvent = args.MessageEvent;
|
||||
cartridgeEvent.LoaderUid = uid;
|
||||
cartridgeEvent.LoaderUid = GetNetEntity(uid);
|
||||
|
||||
RelayEvent(component, cartridgeEvent, true);
|
||||
}
|
||||
@@ -367,24 +424,6 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a program by its prototype name in the list of installed programs
|
||||
/// </summary>
|
||||
private bool TryFindInstalled(string? prototype, CartridgeLoaderComponent loader, [NotNullWhen(true)] out EntityUid? programUid)
|
||||
{
|
||||
foreach (var program in loader.InstalledPrograms)
|
||||
{
|
||||
if (Prototype(program)?.ID == prototype)
|
||||
{
|
||||
programUid = program;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
programUid = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut for updating the loaders user interface state without passing in a subtype of <see cref="CartridgeLoaderUiState"/>
|
||||
/// like the <see cref="PDA.PdaSystem"/> does when updating its ui state
|
||||
@@ -392,7 +431,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
/// <seealso cref="PDA.PdaSystem.UpdatePdaUserInterface"/>
|
||||
private void UpdateUserInterfaceState(EntityUid loaderUid, CartridgeLoaderComponent loader)
|
||||
{
|
||||
UpdateUiState(loaderUid, new CartridgeLoaderUiState(), null, loader);
|
||||
UpdateUiState(loaderUid, null, loader);
|
||||
}
|
||||
|
||||
private void UpdateCartridgeInstallationStatus(EntityUid cartridgeUid, InstallationStatus installationStatus, CartridgeComponent? cartridgeComponent = default!)
|
||||
@@ -400,13 +439,13 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
|
||||
if (Resolve(cartridgeUid, ref cartridgeComponent))
|
||||
{
|
||||
cartridgeComponent.InstallationStatus = installationStatus;
|
||||
Dirty(cartridgeComponent);
|
||||
Dirty(cartridgeUid, cartridgeComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ContainsCartridge(EntityUid cartridgeUid, CartridgeLoaderComponent loader, bool onlyInstalled = false)
|
||||
private bool HasProgram(EntityUid loader, EntityUid program, CartridgeLoaderComponent component)
|
||||
{
|
||||
return !onlyInstalled && loader.CartridgeSlot.Item?.Equals(cartridgeUid) == true || loader.InstalledPrograms.Contains(cartridgeUid);
|
||||
return component.CartridgeSlot.Item == program || GetInstalled(loader).Contains(program);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.CartridgeLoader.Cartridges;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.CartridgeLoader.Cartridges;
|
||||
@@ -41,7 +42,7 @@ public sealed class CrewManifestCartridgeSystem : EntitySystem
|
||||
/// </remarks>
|
||||
private void OnUiMessage(EntityUid uid, CrewManifestCartridgeComponent component, CartridgeMessageEvent args)
|
||||
{
|
||||
UpdateUiState(uid, args.LoaderUid, component);
|
||||
UpdateUiState(uid, GetEntity(args.LoaderUid), component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,14 +79,17 @@ public sealed class CrewManifestCartridgeSystem : EntitySystem
|
||||
{
|
||||
_unsecureViewersAllowed = unsecureViewersAllowed;
|
||||
|
||||
var allCartridgeLoaders = AllEntityQuery<CartridgeLoaderComponent>();
|
||||
|
||||
while (allCartridgeLoaders.MoveNext(out EntityUid loaderUid, out CartridgeLoaderComponent? comp))
|
||||
var allCartridgeLoaders = AllEntityQuery<CartridgeLoaderComponent, ContainerManagerComponent>();
|
||||
while (allCartridgeLoaders.MoveNext(out var loaderUid, out var comp, out var cont))
|
||||
{
|
||||
if (_unsecureViewersAllowed)
|
||||
_cartridgeLoader?.InstallProgram(loaderUid, CartridgePrototypeName, false, comp);
|
||||
else
|
||||
_cartridgeLoader?.UninstallProgram(loaderUid, CartridgePrototypeName, comp);
|
||||
{
|
||||
_cartridgeLoader.InstallProgram(loaderUid, CartridgePrototypeName, false, comp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cartridgeLoader.TryGetProgram<CrewManifestCartridgeComponent>(loaderUid, out var program, true, comp, cont))
|
||||
_cartridgeLoader.UninstallProgram(loaderUid, program.Value, comp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public sealed class NotekeeperCartridgeSystem : EntitySystem
|
||||
component.Notes.Remove(message.Note);
|
||||
}
|
||||
|
||||
UpdateUiState(uid, args.LoaderUid, component);
|
||||
UpdateUiState(uid, GetEntity(args.LoaderUid), component);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public sealed class CharacterInfoSystem : EntitySystem
|
||||
private void OnRequestCharacterInfoEvent(RequestCharacterInfoEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (!args.SenderSession.AttachedEntity.HasValue
|
||||
|| args.SenderSession.AttachedEntity != msg.EntityUid)
|
||||
|| args.SenderSession.AttachedEntity != GetEntity(msg.NetEntity))
|
||||
return;
|
||||
|
||||
var entity = args.SenderSession.AttachedEntity.Value;
|
||||
@@ -51,6 +51,6 @@ public sealed class CharacterInfoSystem : EntitySystem
|
||||
briefing = _roles.MindGetBriefing(mindId);
|
||||
}
|
||||
|
||||
RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing), args.SenderSession);
|
||||
RaiseNetworkEvent(new CharacterInfoEvent(GetNetEntity(entity), jobTitle, conditions, briefing), args.SenderSession);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Content.Server.Chat.Managers
|
||||
|
||||
public void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0)
|
||||
{
|
||||
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
|
||||
var msg = new ChatMessage(channel, message, wrappedMessage, _entityManager.GetNetEntity(source), hideChat, colorOverride, audioPath, audioVolume);
|
||||
_netManager.ServerSendMessage(new MsgChatMessage() { Message = msg }, client);
|
||||
|
||||
if (!recordReplay)
|
||||
@@ -260,7 +260,7 @@ namespace Content.Server.Chat.Managers
|
||||
|
||||
public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, List<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||
{
|
||||
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
|
||||
var msg = new ChatMessage(channel, message, wrappedMessage, _entityManager.GetNetEntity(source), hideChat, colorOverride, audioPath, audioVolume);
|
||||
_netManager.ServerSendToMany(new MsgChatMessage() { Message = msg }, clients);
|
||||
|
||||
if (!recordReplay)
|
||||
@@ -290,7 +290,7 @@ namespace Content.Server.Chat.Managers
|
||||
|
||||
public void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
|
||||
{
|
||||
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
|
||||
var msg = new ChatMessage(channel, message, wrappedMessage, _entityManager.GetNetEntity(source), hideChat, colorOverride, audioPath, audioVolume);
|
||||
_netManager.ServerSendToAll(new MsgChatMessage() { Message = msg });
|
||||
|
||||
if (!recordReplay)
|
||||
|
||||
@@ -484,7 +484,7 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
_chatManager.ChatMessageToOne(ChatChannel.Whisper, obfuscatedMessage, wrappedUnknownMessage, source, false, session.ConnectedClient);
|
||||
}
|
||||
|
||||
_replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, source, MessageRangeHideChatForReplay(range)));
|
||||
_replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, GetNetEntity(source), MessageRangeHideChatForReplay(range)));
|
||||
|
||||
var ev = new EntitySpokeEvent(source, message, channel, obfuscatedMessage);
|
||||
RaiseLocalEvent(source, ev, true);
|
||||
@@ -651,7 +651,7 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
_chatManager.ChatMessageToOne(channel, message, wrappedMessage, source, entHideChat, session.ConnectedClient);
|
||||
}
|
||||
|
||||
_replay.RecordServerMessage(new ChatMessage(channel, message, wrappedMessage, source, MessageRangeHideChatForReplay(range)));
|
||||
_replay.RecordServerMessage(new ChatMessage(channel, message, wrappedMessage, GetNetEntity(source), MessageRangeHideChatForReplay(range)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -259,7 +259,7 @@ public sealed partial class ChemistrySystem
|
||||
_adminLogger.Add(LogType.Ingestion, $"{EntityManager.ToPrettyString(user):user} is attempting to inject themselves with a solution {SolutionContainerSystem.ToPrettyString(solution):solution}.");
|
||||
}
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(user, actualDelay, new InjectorDoAfterEvent(), injector, target: target, used: injector)
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, actualDelay, new InjectorDoAfterEvent(), injector, target: target, used: injector)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
|
||||
@@ -20,11 +20,14 @@ public sealed class ChunkingSystem : EntitySystem
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
private EntityQuery<TransformComponent> _xformQuery;
|
||||
|
||||
private Box2 _baseViewBounds;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_xformQuery = GetEntityQuery<TransformComponent>();
|
||||
_configurationManager.OnValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged, true);
|
||||
}
|
||||
|
||||
@@ -36,16 +39,15 @@ public sealed class ChunkingSystem : EntitySystem
|
||||
|
||||
private void OnPvsRangeChanged(float value) => _baseViewBounds = Box2.UnitCentered.Scale(value);
|
||||
|
||||
public Dictionary<EntityUid, HashSet<Vector2i>> GetChunksForSession(
|
||||
public Dictionary<NetEntity, HashSet<Vector2i>> GetChunksForSession(
|
||||
IPlayerSession session,
|
||||
int chunkSize,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
ObjectPool<HashSet<Vector2i>> indexPool,
|
||||
ObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>> viewerPool,
|
||||
ObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>> viewerPool,
|
||||
float? viewEnlargement = null)
|
||||
{
|
||||
var viewers = GetSessionViewers(session);
|
||||
var chunks = GetChunksForViewers(viewers, chunkSize, indexPool, viewerPool, viewEnlargement ?? chunkSize, xformQuery);
|
||||
var chunks = GetChunksForViewers(viewers, chunkSize, indexPool, viewerPool, viewEnlargement ?? chunkSize);
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@@ -65,37 +67,38 @@ public sealed class ChunkingSystem : EntitySystem
|
||||
return viewers;
|
||||
}
|
||||
|
||||
private Dictionary<EntityUid, HashSet<Vector2i>> GetChunksForViewers(
|
||||
private Dictionary<NetEntity, HashSet<Vector2i>> GetChunksForViewers(
|
||||
HashSet<EntityUid> viewers,
|
||||
int chunkSize,
|
||||
ObjectPool<HashSet<Vector2i>> indexPool,
|
||||
ObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>> viewerPool,
|
||||
float viewEnlargement,
|
||||
EntityQuery<TransformComponent> xformQuery)
|
||||
ObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>> viewerPool,
|
||||
float viewEnlargement)
|
||||
{
|
||||
Dictionary<EntityUid, HashSet<Vector2i>> chunks = viewerPool.Get();
|
||||
var chunks = viewerPool.Get();
|
||||
DebugTools.Assert(chunks.Count == 0);
|
||||
|
||||
foreach (var viewerUid in viewers)
|
||||
{
|
||||
if (!xformQuery.TryGetComponent(viewerUid, out var xform))
|
||||
if (!_xformQuery.TryGetComponent(viewerUid, out var xform))
|
||||
{
|
||||
Log.Error($"Player has deleted viewer entities? Viewers: {string.Join(", ", viewers.Select(x => ToPrettyString(x)))}");
|
||||
Log.Error($"Player has deleted viewer entities? Viewers: {string.Join(", ", viewers.Select(ToPrettyString))}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var pos = _transform.GetWorldPosition(xform, xformQuery);
|
||||
var pos = _transform.GetWorldPosition(xform);
|
||||
var bounds = _baseViewBounds.Translated(pos).Enlarged(viewEnlargement);
|
||||
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID, bounds, true))
|
||||
{
|
||||
if (!chunks.TryGetValue(grid.Owner, out var set))
|
||||
var netGrid = GetNetEntity(grid.Owner);
|
||||
|
||||
if (!chunks.TryGetValue(netGrid, out var set))
|
||||
{
|
||||
chunks[grid.Owner] = set = indexPool.Get();
|
||||
chunks[netGrid] = set = indexPool.Get();
|
||||
DebugTools.Assert(set.Count == 0);
|
||||
}
|
||||
|
||||
var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid.Owner, xformQuery).TransformBox(bounds), chunkSize);
|
||||
var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid.Owner).TransformBox(bounds), chunkSize);
|
||||
|
||||
while (enumerator.MoveNext(out var indices))
|
||||
{
|
||||
|
||||
@@ -128,7 +128,7 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
if (climbing.IsClimbing)
|
||||
return true;
|
||||
|
||||
var args = new DoAfterArgs(user, comp.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove)
|
||||
var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Content.Server.Cloning
|
||||
}
|
||||
|
||||
var newState = GetUserInterfaceState(consoleComponent);
|
||||
UserInterfaceSystem.SetUiState(ui, newState);
|
||||
_uiSystem.SetUiState(ui, newState);
|
||||
}
|
||||
|
||||
public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null)
|
||||
|
||||
@@ -38,7 +38,7 @@ public sealed class CommsHackerSystem : SharedCommsHackerSystem
|
||||
if (!_gloves.AbilityCheck(uid, args, out var target))
|
||||
return;
|
||||
|
||||
var doAfterArgs = new DoAfterArgs(uid, comp.Delay, new TerrorDoAfterEvent(), target: target, used: uid, eventTarget: uid)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, uid, comp.Delay, new TerrorDoAfterEvent(), target: target, used: uid, eventTarget: uid)
|
||||
{
|
||||
BreakOnDamage = true,
|
||||
BreakOnUserMove = true,
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Content.Server.Communications
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
@@ -151,7 +152,7 @@ namespace Content.Server.Communications
|
||||
}
|
||||
|
||||
if (comp.UserInterface is not null)
|
||||
UserInterfaceSystem.SetUiState(comp.UserInterface, new CommunicationsConsoleInterfaceState(
|
||||
_uiSystem.SetUiState(comp.UserInterface, new CommunicationsConsoleInterfaceState(
|
||||
CanAnnounce(comp),
|
||||
CanCallOrRecall(comp),
|
||||
levels,
|
||||
|
||||
@@ -43,7 +43,7 @@ public sealed class ConfigurationSystem : EntitySystem
|
||||
private void UpdateUi(EntityUid uid, ConfigurationComponent component)
|
||||
{
|
||||
if (_uiSystem.TryGetUi(uid, ConfigurationUiKey.Key, out var ui))
|
||||
UserInterfaceSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config));
|
||||
_uiSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config));
|
||||
}
|
||||
|
||||
private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args)
|
||||
|
||||
@@ -10,8 +10,11 @@ using Robust.Shared.Map;
|
||||
namespace Content.Server.Construction.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
sealed class FixRotationsCommand : IConsoleCommand
|
||||
public sealed class FixRotationsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => "fixrotations";
|
||||
public string Description => "Sets the rotation of all occluders, low walls and windows to south.";
|
||||
@@ -20,9 +23,8 @@ namespace Content.Server.Construction.Commands
|
||||
public void Execute(IConsoleShell shell, string argsOther, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid? gridId;
|
||||
var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
|
||||
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
@@ -36,7 +38,7 @@ namespace Content.Server.Construction.Commands
|
||||
gridId = xformQuery.GetComponent(playerEntity).GridUid;
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id))
|
||||
{
|
||||
shell.WriteError($"{args[0]} is not a valid entity.");
|
||||
return;
|
||||
@@ -49,25 +51,24 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.WriteError($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(grid.Owner))
|
||||
if (!_entManager.EntityExists(grid.Owner))
|
||||
{
|
||||
shell.WriteError($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var changed = 0;
|
||||
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
|
||||
var tagSystem = _entManager.EntitySysManager.GetEntitySystem<TagSystem>();
|
||||
|
||||
foreach (var child in xformQuery.GetComponent(grid.Owner).ChildEntities)
|
||||
{
|
||||
if (!entityManager.EntityExists(child))
|
||||
if (!_entManager.EntityExists(child))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -76,14 +77,14 @@ namespace Content.Server.Construction.Commands
|
||||
|
||||
// Occluders should only count if the state of it right now is enabled.
|
||||
// This prevents issues with edge firelocks.
|
||||
if (entityManager.TryGetComponent<OccluderComponent>(child, out var occluder))
|
||||
if (_entManager.TryGetComponent<OccluderComponent>(child, out var occluder))
|
||||
{
|
||||
valid |= occluder.Enabled;
|
||||
}
|
||||
// low walls & grilles
|
||||
valid |= entityManager.HasComponent<SharedCanBuildWindowOnTopComponent>(child);
|
||||
valid |= _entManager.HasComponent<SharedCanBuildWindowOnTopComponent>(child);
|
||||
// cables
|
||||
valid |= entityManager.HasComponent<CableComponent>(child);
|
||||
valid |= _entManager.HasComponent<CableComponent>(child);
|
||||
// anything else that might need this forced
|
||||
valid |= tagSystem.HasTag(child, "ForceFixRotations");
|
||||
// override
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace Content.Server.Construction.Commands;
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
sealed class TileReplaceCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDef = default!;
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => "tilereplace";
|
||||
public string Description => "Replaces one tile with another.";
|
||||
@@ -17,7 +21,6 @@ sealed class TileReplaceCommand : IConsoleCommand
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid? gridId;
|
||||
string tileIdA;
|
||||
string tileIdB;
|
||||
@@ -31,12 +34,13 @@ sealed class TileReplaceCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
gridId = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
tileIdA = args[0];
|
||||
tileIdB = args[1];
|
||||
break;
|
||||
case 3:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
if (!NetEntity.TryParse(args[0], out var idNet) ||
|
||||
!_entManager.TryGetEntity(idNet, out var id))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity.");
|
||||
return;
|
||||
@@ -51,18 +55,16 @@ sealed class TileReplaceCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
var tileA = tileDefinitionManager[tileIdA];
|
||||
var tileB = tileDefinitionManager[tileIdB];
|
||||
var tileA = _tileDef[tileIdA];
|
||||
var tileB = _tileDef[tileIdB];
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(grid.Owner))
|
||||
if (!_entManager.EntityExists(grid.Owner))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
|
||||
@@ -11,6 +11,10 @@ namespace Content.Server.Construction.Commands
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
sealed class TileWallsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => "tilewalls";
|
||||
public string Description => "Puts an underplating tile below every wall on a grid.";
|
||||
@@ -25,7 +29,6 @@ namespace Content.Server.Construction.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid? gridId;
|
||||
|
||||
switch (args.Length)
|
||||
@@ -37,10 +40,10 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
gridId = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity.");
|
||||
return;
|
||||
@@ -53,27 +56,25 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(grid.Owner))
|
||||
if (!_entManager.EntityExists(grid.Owner))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
|
||||
var underplating = tileDefinitionManager[TilePrototypeId];
|
||||
var tagSystem = _entManager.EntitySysManager.GetEntitySystem<TagSystem>();
|
||||
var underplating = _tileDefManager[TilePrototypeId];
|
||||
var underplatingTile = new Tile(underplating.TileId);
|
||||
var changed = 0;
|
||||
foreach (var child in entityManager.GetComponent<TransformComponent>(grid.Owner).ChildEntities)
|
||||
foreach (var child in _entManager.GetComponent<TransformComponent>(grid.Owner).ChildEntities)
|
||||
{
|
||||
if (!entityManager.EntityExists(child))
|
||||
if (!_entManager.EntityExists(child))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -83,7 +84,7 @@ namespace Content.Server.Construction.Commands
|
||||
continue;
|
||||
}
|
||||
|
||||
var childTransform = entityManager.GetComponent<TransformComponent>(child);
|
||||
var childTransform = _entManager.GetComponent<TransformComponent>(child);
|
||||
|
||||
if (!childTransform.Anchored)
|
||||
{
|
||||
@@ -91,7 +92,7 @@ namespace Content.Server.Construction.Commands
|
||||
}
|
||||
|
||||
var tile = grid.GetTileRef(childTransform.Coordinates);
|
||||
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
||||
var tileDef = (ContentTileDefinition) _tileDefManager[tile.Tile.TypeId];
|
||||
|
||||
if (tileDef.ID == TilePrototypeId)
|
||||
{
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace Content.Server.Construction
|
||||
return null;
|
||||
}
|
||||
|
||||
var doAfterArgs = new DoAfterArgs(user, doAfterTime, new AwaitedDoAfterEvent(), null)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, user, doAfterTime, new AwaitedDoAfterEvent(), null)
|
||||
{
|
||||
BreakOnDamage = true,
|
||||
BreakOnTargetMove = false,
|
||||
@@ -432,9 +432,11 @@ namespace Content.Server.Construction
|
||||
_beingBuilt[args.SenderSession] = newSet;
|
||||
}
|
||||
|
||||
var location = GetCoordinates(ev.Location);
|
||||
|
||||
foreach (var condition in constructionPrototype.Conditions)
|
||||
{
|
||||
if (!condition.Condition(user, ev.Location, ev.Angle.GetCardinalDir()))
|
||||
if (!condition.Condition(user, location, ev.Angle.GetCardinalDir()))
|
||||
{
|
||||
Cleanup();
|
||||
return;
|
||||
@@ -453,7 +455,7 @@ namespace Content.Server.Construction
|
||||
return;
|
||||
}
|
||||
|
||||
var mapPos = ev.Location.ToMap(EntityManager);
|
||||
var mapPos = location.ToMap(EntityManager);
|
||||
var predicate = GetPredicate(constructionPrototype.CanBuildInImpassable, mapPos);
|
||||
|
||||
if (!_interactionSystem.InRangeUnobstructed(user, mapPos, predicate: predicate))
|
||||
@@ -515,11 +517,11 @@ namespace Content.Server.Construction
|
||||
var xform = Transform(structure);
|
||||
var wasAnchored = xform.Anchored;
|
||||
xform.Anchored = false;
|
||||
xform.Coordinates = ev.Location;
|
||||
xform.Coordinates = GetCoordinates(ev.Location);
|
||||
xform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero;
|
||||
xform.Anchored = wasAnchored;
|
||||
|
||||
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack, structure));
|
||||
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack, GetNetEntity(structure)));
|
||||
_adminLogger.Add(LogType.Construction, LogImpact.Low, $"{ToPrettyString(user):player} has turned a {ev.PrototypeName} construction ghost into {ToPrettyString(structure)} at {Transform(structure).Coordinates}");
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Content.Server.Construction
|
||||
interactDoAfter.User,
|
||||
interactDoAfter.Used!.Value,
|
||||
uid,
|
||||
interactDoAfter.ClickLocation);
|
||||
GetCoordinates(interactDoAfter.ClickLocation));
|
||||
|
||||
doAfterState = DoAfterState.Completed;
|
||||
}
|
||||
@@ -281,9 +281,9 @@ namespace Content.Server.Construction
|
||||
// If we still haven't completed this step's DoAfter...
|
||||
if (doAfterState == DoAfterState.None && insertStep.DoAfter > 0)
|
||||
{
|
||||
var doAfterEv = new ConstructionInteractDoAfterEvent(interactUsing);
|
||||
var doAfterEv = new ConstructionInteractDoAfterEvent(EntityManager, interactUsing);
|
||||
|
||||
var doAfterEventArgs = new DoAfterArgs(interactUsing.User, step.DoAfter, doAfterEv, uid, uid, interactUsing.Used)
|
||||
var doAfterEventArgs = new DoAfterArgs(EntityManager, interactUsing.User, step.DoAfter, doAfterEv, uid, uid, interactUsing.Used)
|
||||
{
|
||||
BreakOnDamage = false,
|
||||
BreakOnTargetMove = true,
|
||||
@@ -367,7 +367,7 @@ namespace Content.Server.Construction
|
||||
uid,
|
||||
TimeSpan.FromSeconds(toolInsertStep.DoAfter),
|
||||
new [] { toolInsertStep.Tool },
|
||||
new ConstructionInteractDoAfterEvent(interactUsing),
|
||||
new ConstructionInteractDoAfterEvent(EntityManager, interactUsing),
|
||||
out var doAfter);
|
||||
|
||||
return result && doAfter != null ? HandleResult.DoAfter : HandleResult.False;
|
||||
|
||||
@@ -170,7 +170,7 @@ public sealed class PartExchangerSystem : EntitySystem
|
||||
|
||||
component.AudioStream = _audio.PlayPvs(component.ExchangeSound, uid);
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.ExchangeDuration, new ExchangerDoAfterEvent(), uid, target: args.Target, used: uid)
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ExchangeDuration, new ExchangerDoAfterEvent(), uid, target: args.Target, used: uid)
|
||||
{
|
||||
BreakOnDamage = true,
|
||||
BreakOnUserMove = true
|
||||
|
||||
@@ -99,7 +99,7 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
if (component.UserInterface?.SubscribedSessions.Contains(actor.PlayerSession) == true)
|
||||
{
|
||||
// Tell the user interface the selected stuff
|
||||
UserInterfaceSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
|
||||
_uiSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class CrewManifestSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
OpenEui(message.Id, sessionCast);
|
||||
OpenEui(GetEntity(message.Id), sessionCast);
|
||||
}
|
||||
|
||||
// Not a big fan of this one. Rebuilds the crew manifest every time
|
||||
@@ -213,15 +213,7 @@ public sealed class CrewManifestSystem : EntitySystem
|
||||
}
|
||||
|
||||
entries.Entries = entries.Entries.OrderBy(e => e.JobTitle).ThenBy(e => e.Name).ToList();
|
||||
|
||||
if (_cachedEntries.ContainsKey(station))
|
||||
{
|
||||
_cachedEntries[station] = entries;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cachedEntries.Add(station, entries);
|
||||
}
|
||||
_cachedEntries[station] = entries;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +239,7 @@ public sealed class CrewManifestCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !_entityManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity UID.");
|
||||
return;
|
||||
@@ -261,7 +253,7 @@ public sealed class CrewManifestCommand : IConsoleCommand
|
||||
|
||||
var crewManifestSystem = _entityManager.System<CrewManifestSystem>();
|
||||
|
||||
crewManifestSystem.OpenEui(uid, session);
|
||||
crewManifestSystem.OpenEui(uid.Value, session);
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Content.Server.Damage.Commands
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class GodModeCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "godmode";
|
||||
public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes.";
|
||||
public string Help => $"Usage: {Command} / {Command} <entityUid>";
|
||||
@@ -19,8 +21,6 @@ namespace Content.Server.Damage.Commands
|
||||
var player = shell.Player as IPlayerSession;
|
||||
EntityUid entity;
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
@@ -39,29 +39,29 @@ namespace Content.Server.Damage.Commands
|
||||
entity = player.AttachedEntity.Value;
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} isn't a valid entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(id))
|
||||
if (!_entManager.EntityExists(id))
|
||||
{
|
||||
shell.WriteLine($"No entity found with id {id}.");
|
||||
return;
|
||||
}
|
||||
|
||||
entity = id;
|
||||
entity = id.Value;
|
||||
break;
|
||||
default:
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
var godmodeSystem = EntitySystem.Get<SharedGodmodeSystem>();
|
||||
var godmodeSystem = _entManager.System<SharedGodmodeSystem>();
|
||||
var enabled = godmodeSystem.ToggleGodmode(entity);
|
||||
|
||||
var name = entityManager.GetComponent<MetaDataComponent>(entity).EntityName;
|
||||
var name = _entManager.GetComponent<MetaDataComponent>(entity).EntityName;
|
||||
|
||||
shell.WriteLine(enabled
|
||||
? $"Enabled godmode for entity {name} with id {entity}"
|
||||
|
||||
@@ -13,15 +13,13 @@ namespace Content.Server.Damage.Commands
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
sealed class DamageCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public string Command => "damage";
|
||||
public string Description => Loc.GetString("damage-command-description");
|
||||
public string Help => Loc.GetString("damage-command-help", ("command", Command));
|
||||
|
||||
private readonly IPrototypeManager _prototypeManager = default!;
|
||||
public DamageCommand() {
|
||||
_prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
@@ -75,28 +73,27 @@ namespace Content.Server.Damage.Commands
|
||||
func = (entity, ignoreResistances) =>
|
||||
{
|
||||
var damage = new DamageSpecifier(damageGroup, amount);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(entity, damage, ignoreResistances);
|
||||
_entManager.System<DamageableSystem>().TryChangeDamage(entity, damage, ignoreResistances);
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
// Fall back to DamageType
|
||||
else if (_prototypeManager.TryIndex<DamageTypePrototype>(args[0], out var damageType))
|
||||
|
||||
if (_prototypeManager.TryIndex<DamageTypePrototype>(args[0], out var damageType))
|
||||
{
|
||||
func = (entity, ignoreResistances) =>
|
||||
{
|
||||
var damage = new DamageSpecifier(damageType, amount);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(entity, damage, ignoreResistances);
|
||||
_entManager.System<DamageableSystem>().TryChangeDamage(entity, damage, ignoreResistances);
|
||||
};
|
||||
return true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("damage-command-error-type", ("arg", args[0])));
|
||||
func = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
shell.WriteLine(Loc.GetString("damage-command-error-type", ("arg", args[0])));
|
||||
func = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
@@ -107,11 +104,11 @@ namespace Content.Server.Damage.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
EntityUid target;
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid? target;
|
||||
|
||||
if (args.Length == 4)
|
||||
{
|
||||
if (!EntityUid.TryParse(args[3], out target) || !entMan.EntityExists(target))
|
||||
if (!_entManager.TryParseNetEntity(args[3], out target) || !_entManager.EntityExists(target))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("damage-command-error-euid", ("arg", args[3])));
|
||||
return;
|
||||
@@ -127,7 +124,7 @@ namespace Content.Server.Damage.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryParseDamageArgs(shell, target, args, out var damageFunc))
|
||||
if (!TryParseDamageArgs(shell, target.Value, args, out var damageFunc))
|
||||
return;
|
||||
|
||||
bool ignoreResistances;
|
||||
@@ -144,7 +141,7 @@ namespace Content.Server.Damage.Commands
|
||||
ignoreResistances = false;
|
||||
}
|
||||
|
||||
damageFunc(target, ignoreResistances);
|
||||
damageFunc(target.Value, ignoreResistances);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace Content.Server.Decals.Commands
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
public sealed class AddDecalCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
|
||||
public string Command => "adddecal";
|
||||
public string Description => "Creates a decal on the map";
|
||||
public string Help => $"{Command} <id> <x position> <y position> <gridId> [angle=<angle> zIndex=<zIndex> color=<color>]";
|
||||
@@ -23,7 +27,7 @@ namespace Content.Server.Decals.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IPrototypeManager>().HasIndex<DecalPrototype>(args[0]))
|
||||
if (!_protoManager.HasIndex<DecalPrototype>(args[0]))
|
||||
{
|
||||
shell.WriteError($"Cannot find decalprototype '{args[0]}'.");
|
||||
}
|
||||
@@ -40,8 +44,9 @@ namespace Content.Server.Decals.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
if (!EntityUid.TryParse(args[3], out var gridIdRaw) || !mapManager.TryGetGrid(gridIdRaw, out var grid))
|
||||
if (!NetEntity.TryParse(args[3], out var gridIdNet) ||
|
||||
!_entManager.TryGetEntity(gridIdNet, out var gridIdRaw) ||
|
||||
!_mapManager.TryGetGrid(gridIdRaw, out var grid))
|
||||
{
|
||||
shell.WriteError($"Failed parsing gridId '{args[3]}'.");
|
||||
return;
|
||||
@@ -101,7 +106,7 @@ namespace Content.Server.Decals.Commands
|
||||
}
|
||||
}
|
||||
|
||||
if(EntitySystem.Get<DecalSystem>().TryAddDecal(args[0], coordinates, out var uid, color, rotation, zIndex))
|
||||
if (_entManager.System<DecalSystem>().TryAddDecal(args[0], coordinates, out var uid, color, rotation, zIndex))
|
||||
{
|
||||
shell.WriteLine($"Successfully created decal {uid}.");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace Content.Server.Decals;
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
public sealed class EditDecalCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public string Command => "editdecal";
|
||||
public string Description => "Edits a decal.";
|
||||
public string Help => $@"{Command} <gridId> <uid> <mode>\n
|
||||
@@ -28,7 +31,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var gridId))
|
||||
if (!NetEntity.TryParse(args[0], out var gridIdNet) || !_entManager.TryGetEntity(gridIdNet, out var gridId))
|
||||
{
|
||||
shell.WriteError($"Failed parsing gridId '{args[3]}'.");
|
||||
return;
|
||||
@@ -40,13 +43,13 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IMapManager>().GridExists(gridId))
|
||||
if (!_mapManager.GridExists(gridId))
|
||||
{
|
||||
shell.WriteError($"No grid with gridId {gridId} exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
var decalSystem = EntitySystem.Get<DecalSystem>();
|
||||
var decalSystem = _entManager.System<DecalSystem>();
|
||||
switch (args[2].ToLower())
|
||||
{
|
||||
case "position":
|
||||
@@ -62,7 +65,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decalSystem.SetDecalPosition(gridId, uid, new(gridId, new Vector2(x, y))))
|
||||
if (!decalSystem.SetDecalPosition(gridId.Value, uid, new(gridId.Value, new Vector2(x, y))))
|
||||
{
|
||||
shell.WriteError("Failed changing decalposition.");
|
||||
}
|
||||
@@ -80,7 +83,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decalSystem.SetDecalColor(gridId, uid, color))
|
||||
if (!decalSystem.SetDecalColor(gridId.Value, uid, color))
|
||||
{
|
||||
shell.WriteError("Failed changing decal color.");
|
||||
}
|
||||
@@ -92,7 +95,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decalSystem.SetDecalId(gridId, uid, args[3]))
|
||||
if (!decalSystem.SetDecalId(gridId.Value, uid, args[3]))
|
||||
{
|
||||
shell.WriteError("Failed changing decal id.");
|
||||
}
|
||||
@@ -110,7 +113,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decalSystem.SetDecalRotation(gridId, uid, Angle.FromDegrees(degrees)))
|
||||
if (!decalSystem.SetDecalRotation(gridId.Value, uid, Angle.FromDegrees(degrees)))
|
||||
{
|
||||
shell.WriteError("Failed changing decal rotation.");
|
||||
}
|
||||
@@ -128,7 +131,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decalSystem.SetDecalZIndex(gridId, uid, zIndex))
|
||||
if (!decalSystem.SetDecalZIndex(gridId.Value, uid, zIndex))
|
||||
{
|
||||
shell.WriteError("Failed changing decal zIndex.");
|
||||
}
|
||||
@@ -146,7 +149,7 @@ Possible modes are:\n
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decalSystem.SetDecalCleanable(gridId, uid, cleanable))
|
||||
if (!decalSystem.SetDecalCleanable(gridId.Value, uid, cleanable))
|
||||
{
|
||||
shell.WriteError("Failed changing decal cleanable flag.");
|
||||
}
|
||||
|
||||
@@ -2,12 +2,16 @@ using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using SQLitePCL;
|
||||
|
||||
namespace Content.Server.Decals.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
public sealed class RemoveDecalCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public string Command => "rmdecal";
|
||||
public string Description => "removes a decal";
|
||||
public string Help => $"{Command} <uid> <gridId>";
|
||||
@@ -25,14 +29,16 @@ namespace Content.Server.Decals.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out var rawGridId) ||
|
||||
!IoCManager.Resolve<IMapManager>().GridExists(rawGridId))
|
||||
if (!NetEntity.TryParse(args[1], out var rawGridIdNet) ||
|
||||
!_entManager.TryGetEntity(rawGridIdNet, out var rawGridId) ||
|
||||
!_mapManager.GridExists(rawGridId))
|
||||
{
|
||||
shell.WriteError("Failed parsing gridId.");
|
||||
return;
|
||||
}
|
||||
|
||||
var decalSystem = EntitySystem.Get<DecalSystem>();
|
||||
if (decalSystem.RemoveDecal(rawGridId, uid))
|
||||
var decalSystem = _entManager.System<DecalSystem>();
|
||||
if (decalSystem.RemoveDecal(rawGridId.Value, uid))
|
||||
{
|
||||
shell.WriteLine($"Successfully removed decal {uid}.");
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,7 +13,6 @@ using Robust.Server.Player;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Threading;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -34,8 +32,8 @@ namespace Content.Server.Decals
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
private readonly Dictionary<EntityUid, HashSet<Vector2i>> _dirtyChunks = new();
|
||||
private readonly Dictionary<IPlayerSession, Dictionary<EntityUid, HashSet<Vector2i>>> _previousSentChunks = new();
|
||||
private readonly Dictionary<NetEntity, HashSet<Vector2i>> _dirtyChunks = new();
|
||||
private readonly Dictionary<IPlayerSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
|
||||
private static readonly Vector2 _boundsMinExpansion = new(0.01f, 0.01f);
|
||||
private static readonly Vector2 _boundsMaxExpansion = new(1.01f, 1.01f);
|
||||
|
||||
@@ -44,9 +42,9 @@ namespace Content.Server.Decals
|
||||
new DefaultObjectPool<HashSet<Vector2i>>(
|
||||
new DefaultPooledObjectPolicy<HashSet<Vector2i>>(), 64);
|
||||
|
||||
private ObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>> _chunkViewerPool =
|
||||
new DefaultObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>>(
|
||||
new DefaultPooledObjectPolicy<Dictionary<EntityUid, HashSet<Vector2i>>>(), 64);
|
||||
private ObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>> _chunkViewerPool =
|
||||
new DefaultObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>>(
|
||||
new DefaultPooledObjectPolicy<Dictionary<NetEntity, HashSet<Vector2i>>>(), 64);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -203,10 +201,12 @@ namespace Content.Server.Decals
|
||||
if (!_adminManager.HasAdminFlag(session, AdminFlags.Spawn))
|
||||
return;
|
||||
|
||||
if (!ev.Coordinates.IsValid(EntityManager))
|
||||
var coordinates = GetCoordinates(ev.Coordinates);
|
||||
|
||||
if (!coordinates.IsValid(EntityManager))
|
||||
return;
|
||||
|
||||
if (!TryAddDecal(ev.Decal, ev.Coordinates, out _))
|
||||
if (!TryAddDecal(ev.Decal, coordinates, out _))
|
||||
return;
|
||||
|
||||
if (eventArgs.SenderSession.AttachedEntity != null)
|
||||
@@ -230,10 +230,12 @@ namespace Content.Server.Decals
|
||||
if (!_adminManager.HasAdminFlag(session, AdminFlags.Spawn))
|
||||
return;
|
||||
|
||||
if (!ev.Coordinates.IsValid(EntityManager))
|
||||
var coordinates = GetCoordinates(ev.Coordinates);
|
||||
|
||||
if (!coordinates.IsValid(EntityManager))
|
||||
return;
|
||||
|
||||
var gridId = ev.Coordinates.GetGridUid(EntityManager);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
|
||||
if (gridId == null)
|
||||
return;
|
||||
@@ -256,8 +258,9 @@ namespace Content.Server.Decals
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DirtyChunk(EntityUid id, Vector2i chunkIndices, DecalChunk chunk)
|
||||
protected override void DirtyChunk(EntityUid uid, Vector2i chunkIndices, DecalChunk chunk)
|
||||
{
|
||||
var id = GetNetEntity(uid);
|
||||
chunk.LastModified = _timing.CurTick;
|
||||
if(!_dirtyChunks.ContainsKey(id))
|
||||
_dirtyChunks[id] = new HashSet<Vector2i>();
|
||||
@@ -409,8 +412,8 @@ namespace Content.Server.Decals
|
||||
|
||||
foreach (var ent in _dirtyChunks.Keys)
|
||||
{
|
||||
if (TryComp(ent, out DecalGridComponent? decals))
|
||||
Dirty(decals);
|
||||
if (TryGetEntity(ent, out var uid) && TryComp(uid, out DecalGridComponent? decals))
|
||||
Dirty(uid.Value, decals);
|
||||
}
|
||||
|
||||
if (!PvsEnabled)
|
||||
@@ -431,8 +434,7 @@ namespace Content.Server.Decals
|
||||
|
||||
public void UpdatePlayer(IPlayerSession player)
|
||||
{
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool);
|
||||
var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, _chunkIndexPool, _chunkViewerPool);
|
||||
var staleChunks = _chunkViewerPool.Get();
|
||||
var previouslySent = _previousSentChunks[player];
|
||||
|
||||
@@ -440,16 +442,16 @@ namespace Content.Server.Decals
|
||||
// Then, remove them from previousSentChunks (for stuff like grids out of range)
|
||||
// and also mark them as stale for networking.
|
||||
|
||||
foreach (var (gridId, oldIndices) in previouslySent)
|
||||
foreach (var (netGrid, oldIndices) in previouslySent)
|
||||
{
|
||||
// Mark the whole grid as stale and flag for removal.
|
||||
if (!chunksInRange.TryGetValue(gridId, out var chunks))
|
||||
if (!chunksInRange.TryGetValue(netGrid, out var chunks))
|
||||
{
|
||||
previouslySent.Remove(gridId);
|
||||
previouslySent.Remove(netGrid);
|
||||
|
||||
// Was the grid deleted?
|
||||
if (MapManager.IsGrid(gridId))
|
||||
staleChunks[gridId] = oldIndices;
|
||||
if (!TryGetEntity(netGrid, out var gridId) || !MapManager.IsGrid(gridId.Value))
|
||||
staleChunks[netGrid] = oldIndices;
|
||||
else
|
||||
{
|
||||
// If grid was deleted then don't worry about telling the client to delete the chunk.
|
||||
@@ -465,7 +467,9 @@ namespace Content.Server.Decals
|
||||
// Get individual stale chunks.
|
||||
foreach (var chunk in oldIndices)
|
||||
{
|
||||
if (chunks.Contains(chunk)) continue;
|
||||
if (chunks.Contains(chunk))
|
||||
continue;
|
||||
|
||||
elmo.Add(chunk);
|
||||
}
|
||||
|
||||
@@ -475,16 +479,16 @@ namespace Content.Server.Decals
|
||||
continue;
|
||||
}
|
||||
|
||||
staleChunks.Add(gridId, elmo);
|
||||
staleChunks.Add(netGrid, elmo);
|
||||
}
|
||||
|
||||
var updatedChunks = _chunkViewerPool.Get();
|
||||
foreach (var (gridId, gridChunks) in chunksInRange)
|
||||
foreach (var (netGrid, gridChunks) in chunksInRange)
|
||||
{
|
||||
var newChunks = _chunkIndexPool.Get();
|
||||
_dirtyChunks.TryGetValue(gridId, out var dirtyChunks);
|
||||
_dirtyChunks.TryGetValue(netGrid, out var dirtyChunks);
|
||||
|
||||
if (!previouslySent.TryGetValue(gridId, out var previousChunks))
|
||||
if (!previouslySent.TryGetValue(netGrid, out var previousChunks))
|
||||
newChunks.UnionWith(gridChunks);
|
||||
else
|
||||
{
|
||||
@@ -498,19 +502,19 @@ namespace Content.Server.Decals
|
||||
_chunkIndexPool.Return(previousChunks);
|
||||
}
|
||||
|
||||
previouslySent[gridId] = gridChunks;
|
||||
previouslySent[netGrid] = gridChunks;
|
||||
|
||||
if (newChunks.Count == 0)
|
||||
_chunkIndexPool.Return(newChunks);
|
||||
else
|
||||
updatedChunks[gridId] = newChunks;
|
||||
updatedChunks[netGrid] = newChunks;
|
||||
}
|
||||
|
||||
//send all gridChunks to client
|
||||
SendChunkUpdates(player, updatedChunks, staleChunks);
|
||||
}
|
||||
|
||||
private void ReturnToPool(Dictionary<EntityUid, HashSet<Vector2i>> chunks)
|
||||
private void ReturnToPool(Dictionary<NetEntity, HashSet<Vector2i>> chunks)
|
||||
{
|
||||
foreach (var (_, previous) in chunks)
|
||||
{
|
||||
@@ -524,12 +528,14 @@ namespace Content.Server.Decals
|
||||
|
||||
private void SendChunkUpdates(
|
||||
IPlayerSession session,
|
||||
Dictionary<EntityUid, HashSet<Vector2i>> updatedChunks,
|
||||
Dictionary<EntityUid, HashSet<Vector2i>> staleChunks)
|
||||
Dictionary<NetEntity, HashSet<Vector2i>> updatedChunks,
|
||||
Dictionary<NetEntity, HashSet<Vector2i>> staleChunks)
|
||||
{
|
||||
var updatedDecals = new Dictionary<EntityUid, Dictionary<Vector2i, DecalChunk>>();
|
||||
foreach (var (gridId, chunks) in updatedChunks)
|
||||
var updatedDecals = new Dictionary<NetEntity, Dictionary<Vector2i, DecalChunk>>();
|
||||
foreach (var (netGrid, chunks) in updatedChunks)
|
||||
{
|
||||
var gridId = GetEntity(netGrid);
|
||||
|
||||
var collection = ChunkCollection(gridId);
|
||||
if (collection == null)
|
||||
continue;
|
||||
@@ -542,7 +548,7 @@ namespace Content.Server.Decals
|
||||
? chunk
|
||||
: new());
|
||||
}
|
||||
updatedDecals[gridId] = gridChunks;
|
||||
updatedDecals[netGrid] = gridChunks;
|
||||
}
|
||||
|
||||
if (updatedDecals.Count != 0 || staleChunks.Count != 0)
|
||||
|
||||
@@ -40,7 +40,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
|
||||
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui))
|
||||
{
|
||||
UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label,
|
||||
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label,
|
||||
TimeSpan.FromSeconds(component.Delay).Minutes.ToString("D2"),
|
||||
TimeSpan.FromSeconds(component.Delay).Seconds.ToString("D2"),
|
||||
component.CanEditLabel,
|
||||
@@ -60,7 +60,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
|
||||
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui))
|
||||
{
|
||||
UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
|
||||
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
|
||||
TimeSpan.FromSeconds(signalTimer.Delay).Minutes.ToString("D2"),
|
||||
TimeSpan.FromSeconds(signalTimer.Delay).Seconds.ToString("D2"),
|
||||
signalTimer.CanEditLabel,
|
||||
|
||||
@@ -473,7 +473,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
return;
|
||||
|
||||
if (_uiSystem.OpenUi(bui, actor.PlayerSession))
|
||||
UserInterfaceSystem.SetUiState(bui, new DeviceListUserInterfaceState(
|
||||
_uiSystem.SetUiState(bui, new DeviceListUserInterfaceState(
|
||||
_deviceListSystem.GetDeviceList(configurator.ActiveDeviceList.Value)
|
||||
.Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet()
|
||||
));
|
||||
@@ -505,7 +505,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, NetworkConfiguratorUiKey.List, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new NetworkConfiguratorUserInterfaceState(devices));
|
||||
_uiSystem.SetUiState(bui, new NetworkConfiguratorUserInterfaceState(devices));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -177,7 +177,7 @@ public sealed class MailingUnitSystem : EntitySystem
|
||||
|
||||
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag);
|
||||
if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, state);
|
||||
_userInterfaceSystem.SetUiState(bui, state);
|
||||
}
|
||||
|
||||
private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args)
|
||||
|
||||
@@ -325,8 +325,9 @@ namespace Content.Server.Disposal.Tube
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key, out var bui))
|
||||
UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(tagger.Tag));
|
||||
if (_uiSystem.TryGetUi(uid, DisposalTaggerUiKey.Key, out var bui))
|
||||
_uiSystem.SetUiState(bui,
|
||||
new DisposalTaggerUserInterfaceState(tagger.Tag));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -335,11 +336,11 @@ namespace Content.Server.Disposal.Tube
|
||||
/// <returns>Returns a <see cref="SharedDisposalRouterComponent.DisposalRouterUserInterfaceState"/></returns>
|
||||
private void UpdateRouterUserInterface(EntityUid uid, DisposalRouterComponent router)
|
||||
{
|
||||
var bui = _uiSystem.GetUiOrNull(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key);
|
||||
var bui = _uiSystem.GetUiOrNull(uid, DisposalTaggerUiKey.Key);
|
||||
if (router.Tags.Count <= 0)
|
||||
{
|
||||
if (bui is not null)
|
||||
UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(""));
|
||||
_uiSystem.SetUiState(bui, new DisposalTaggerUserInterfaceState(""));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,7 +355,7 @@ namespace Content.Server.Disposal.Tube
|
||||
taglist.Remove(taglist.Length - 2, 2);
|
||||
|
||||
if (bui is not null)
|
||||
UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(taglist.ToString()));
|
||||
_uiSystem.SetUiState(bui, new DisposalTaggerUserInterfaceState(taglist.ToString()));
|
||||
}
|
||||
|
||||
private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Content.Server.Disposal
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
if (!NetEntity.TryParse(args[0], out var idNet) || !_entities.TryGetEntity(idNet, out var id))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("shell-invalid-entity-uid",("uid", args[0])));
|
||||
return;
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.Disposal
|
||||
return;
|
||||
}
|
||||
|
||||
_entities.System<DisposalTubeSystem>().PopupDirections(id, tube, player.AttachedEntity.Value);
|
||||
_entities.System<DisposalTubeSystem>().PopupDirections(id.Value, tube, player.AttachedEntity.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
if (!Resolve(uid, ref holder))
|
||||
return false;
|
||||
|
||||
if (!holder.Container.CanInsert(toInsert))
|
||||
if (!_containerSystem.CanInsert(toInsert, holder.Container))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
|
||||
component.NextFlush,
|
||||
component.Powered,
|
||||
component.Engaged,
|
||||
component.RecentlyEjected);
|
||||
GetNetEntityList(component.RecentlyEjected));
|
||||
}
|
||||
|
||||
private void OnUnpaused(EntityUid uid, SharedDisposalUnitComponent component, ref EntityUnpausedEvent args)
|
||||
@@ -499,7 +499,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
|
||||
|
||||
// Can't check if our target AND disposals moves currently so we'll just check target.
|
||||
// if you really want to check if disposals moves then add a predicate.
|
||||
var doAfterArgs = new DoAfterArgs(userId.Value, delay, new DisposalDoAfterEvent(), unitId, target: toInsertId, used: unitId)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, userId.Value, delay, new DisposalDoAfterEvent(), unitId, target: toInsertId, used: unitId)
|
||||
{
|
||||
BreakOnDamage = true,
|
||||
BreakOnTargetMove = true,
|
||||
@@ -753,10 +753,10 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
|
||||
|
||||
public override bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity)
|
||||
{
|
||||
if (!base.CanInsert(uid, component, entity) || component is not SharedDisposalUnitComponent serverComp)
|
||||
if (!base.CanInsert(uid, component, entity))
|
||||
return false;
|
||||
|
||||
return serverComp.Container.CanInsert(entity);
|
||||
return _containerSystem.CanInsert(entity, component.Container);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,6 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem
|
||||
{
|
||||
public override void RaiseEffect(Color color, List<EntityUid> entities, Filter filter)
|
||||
{
|
||||
RaiseNetworkEvent(new ColorFlashEffectEvent(color, entities), filter);
|
||||
RaiseNetworkEvent(new ColorFlashEffectEvent(color, GetNetEntityList(entities)), filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.Electrocution
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class ElectrocuteCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "electrocute";
|
||||
public string Description => Loc.GetString("electrocute-command-description");
|
||||
public string Help => $"{Command} <uid> <seconds> <damage>";
|
||||
@@ -24,15 +26,15 @@ namespace Content.Server.Electrocution
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid) || !entityManager.EntityExists(uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) ||
|
||||
!_entManager.TryGetEntity(uidNet, out var uid) ||
|
||||
!_entManager.EntityExists(uid))
|
||||
{
|
||||
shell.WriteError($"Invalid entity specified!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>().CanApplyEffect(uid, ElectrocutionStatusEffect))
|
||||
if (!_entManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>().CanApplyEffect(uid.Value, ElectrocutionStatusEffect))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("electrocute-command-entity-cannot-be-electrocuted"));
|
||||
return;
|
||||
@@ -48,8 +50,8 @@ namespace Content.Server.Electrocution
|
||||
damage = 10;
|
||||
}
|
||||
|
||||
entityManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>()
|
||||
.TryDoElectrocution(uid, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true);
|
||||
_entManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>()
|
||||
.TryDoElectrocution(uid.Value, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Content.Server.Engineering.EntitySystems
|
||||
|
||||
if (component.DoAfterTime > 0 && TryGet<SharedDoAfterSystem>(out var doAfterSystem))
|
||||
{
|
||||
var doAfterArgs = new DoAfterArgs(user, component.DoAfterTime, new AwaitedDoAfterEvent(), null)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, user, component.DoAfterTime, new AwaitedDoAfterEvent(), null)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Content.Server.Engineering.EntitySystems
|
||||
|
||||
if (component.DoAfterTime > 0)
|
||||
{
|
||||
var doAfterArgs = new DoAfterArgs(args.User, component.DoAfterTime, new AwaitedDoAfterEvent(), null)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.DoAfterTime, new AwaitedDoAfterEvent(), null)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
};
|
||||
|
||||
@@ -98,7 +98,7 @@ public sealed partial class EnsnareableSystem
|
||||
var freeTime = user == target ? component.BreakoutTime : component.FreeTime;
|
||||
var breakOnMove = !component.CanMoveBreakout;
|
||||
|
||||
var doAfterEventArgs = new DoAfterArgs(user, freeTime, new EnsnareableDoAfterEvent(), target, target: target, used: ensnare)
|
||||
var doAfterEventArgs = new DoAfterArgs(EntityManager, user, freeTime, new EnsnareableDoAfterEvent(), target, target: target, used: ensnare)
|
||||
{
|
||||
BreakOnUserMove = breakOnMove,
|
||||
BreakOnTargetMove = breakOnMove,
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Content.Server.Examine
|
||||
verbs = _verbSystem.GetLocalVerbs(target, player, typeof(ExamineVerb));
|
||||
|
||||
var ev = new ExamineSystemMessages.ExamineInfoResponseMessage(
|
||||
target, 0, message, verbs?.ToList(), centerAtCursor
|
||||
GetNetEntity(target), 0, message, verbs?.ToList(), centerAtCursor
|
||||
);
|
||||
|
||||
RaiseNetworkEvent(ev, session.ConnectedClient);
|
||||
@@ -49,29 +49,30 @@ namespace Content.Server.Examine
|
||||
var player = (IPlayerSession) eventArgs.SenderSession;
|
||||
var session = eventArgs.SenderSession;
|
||||
var channel = player.ConnectedClient;
|
||||
var entity = GetEntity(request.NetEntity);
|
||||
|
||||
if (session.AttachedEntity is not {Valid: true} playerEnt
|
||||
|| !EntityManager.EntityExists(request.EntityUid))
|
||||
|| !EntityManager.EntityExists(entity))
|
||||
{
|
||||
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(
|
||||
request.EntityUid, request.Id, _entityNotFoundMessage), channel);
|
||||
request.NetEntity, request.Id, _entityNotFoundMessage), channel);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanExamine(playerEnt, request.EntityUid))
|
||||
if (!CanExamine(playerEnt, entity))
|
||||
{
|
||||
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(
|
||||
request.EntityUid, request.Id, _entityOutOfRangeMessage, knowTarget: false), channel);
|
||||
request.NetEntity, request.Id, _entityOutOfRangeMessage, knowTarget: false), channel);
|
||||
return;
|
||||
}
|
||||
|
||||
SortedSet<Verb>? verbs = null;
|
||||
if (request.GetVerbs)
|
||||
verbs = _verbSystem.GetLocalVerbs(request.EntityUid, playerEnt, typeof(ExamineVerb));
|
||||
verbs = _verbSystem.GetLocalVerbs(entity, playerEnt, typeof(ExamineVerb));
|
||||
|
||||
var text = GetExamineText(request.EntityUid, player.AttachedEntity);
|
||||
var text = GetExamineText(entity, player.AttachedEntity);
|
||||
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(
|
||||
request.EntityUid, request.Id, text, verbs?.ToList()), channel);
|
||||
request.NetEntity, request.Id, text, verbs?.ToList()), channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,12 +331,12 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
var (area, iterationIntensity, spaceData, gridData, spaceMatrix) = results.Value;
|
||||
|
||||
Logger.Info($"Generated explosion preview with {area} tiles in {stopwatch.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Info($"Generated explosion preview with {area} tiles in {stopwatch.Elapsed.TotalMilliseconds}ms");
|
||||
|
||||
Dictionary<EntityUid, Dictionary<int, List<Vector2i>>> tileLists = new();
|
||||
Dictionary<NetEntity, Dictionary<int, List<Vector2i>>> tileLists = new();
|
||||
foreach (var (grid, data) in gridData)
|
||||
{
|
||||
tileLists.Add(grid, data.TileLists);
|
||||
tileLists.Add(GetNetEntity(grid), data.TileLists);
|
||||
}
|
||||
|
||||
return new ExplosionVisualsState(
|
||||
|
||||
@@ -15,12 +15,18 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
private void OnGetState(EntityUid uid, ExplosionVisualsComponent component, ref ComponentGetState args)
|
||||
{
|
||||
Dictionary<NetEntity, Dictionary<int, List<Vector2i>>> tileLists = new();
|
||||
foreach (var (grid, data) in component.Tiles)
|
||||
{
|
||||
tileLists.Add(GetNetEntity(grid), data);
|
||||
}
|
||||
|
||||
args.State = new ExplosionVisualsState(
|
||||
component.Epicenter,
|
||||
component.ExplosionType,
|
||||
component.Intensity,
|
||||
component.SpaceTiles,
|
||||
component.Tiles,
|
||||
tileLists,
|
||||
component.SpaceMatrix,
|
||||
component.SpaceTileSize);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
if (user != null)
|
||||
{
|
||||
// Check if entity is bomb/mod. grenade/etc
|
||||
if (_container.TryGetContainer(uid, "payload", out IContainer? container) &&
|
||||
if (_container.TryGetContainer(uid, "payload", out BaseContainer? container) &&
|
||||
container.ContainedEntities.Count > 0 &&
|
||||
TryComp(container.ContainedEntities[0], out ChemicalPayloadComponent? chemicalPayloadComponent))
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ public sealed class AdminFaxEui : BaseEui
|
||||
var entries = new List<AdminFaxEntry>();
|
||||
while (faxes.MoveNext(out var uid, out var fax, out var device))
|
||||
{
|
||||
entries.Add(new AdminFaxEntry(uid, fax.FaxName, device.Address));
|
||||
entries.Add(new AdminFaxEntry(_entityManager.GetNetEntity(uid), fax.FaxName, device.Address));
|
||||
}
|
||||
return new AdminFaxEuiState(entries);
|
||||
}
|
||||
@@ -49,14 +49,14 @@ public sealed class AdminFaxEui : BaseEui
|
||||
!_entityManager.HasComponent<GhostComponent>(Player.AttachedEntity.Value))
|
||||
return;
|
||||
|
||||
_followerSystem.StartFollowingEntity(Player.AttachedEntity.Value, followData.TargetFax);
|
||||
_followerSystem.StartFollowingEntity(Player.AttachedEntity.Value, _entityManager.GetEntity(followData.TargetFax));
|
||||
break;
|
||||
}
|
||||
case AdminFaxEuiMsg.Send sendData:
|
||||
{
|
||||
var printout = new FaxPrintout(sendData.Content, sendData.Title, null, sendData.StampState,
|
||||
new() { new StampDisplayInfo { StampedName = sendData.From, StampedColor = sendData.StampColor } });
|
||||
_faxSystem.Receive(sendData.Target, printout);
|
||||
_faxSystem.Receive(_entityManager.GetEntity(sendData.Target), printout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
_audioSystem.PlayPvs(component.PlungerSound, uid);
|
||||
|
||||
|
||||
var doAfterArgs = new DoAfterArgs(args.User, component.UnclogDuration, new DrainDoAfterEvent(),uid, args.Target, args.Used)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.UnclogDuration, new DrainDoAfterEvent(),uid, args.Target, args.Used)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
|
||||
@@ -79,7 +79,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
|
||||
data.Add(new PuddleDebugOverlayData(pos, vol));
|
||||
}
|
||||
|
||||
RaiseNetworkEvent(new PuddleOverlayDebugMessage(gridUid, data.ToArray()));
|
||||
RaiseNetworkEvent(new PuddleOverlayDebugMessage(GetNetEntity(gridUid), data.ToArray()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public sealed partial class PuddleSystem
|
||||
{
|
||||
verb.Act = () =>
|
||||
{
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, component.SpillDelay ?? 0, new SpillDoAfterEvent(), uid, target: uid)
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.SpillDelay ?? 0, new SpillDoAfterEvent(), uid, target: uid)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Content.Server.Forensics
|
||||
{
|
||||
var ev = new ForensicPadDoAfterEvent(sample);
|
||||
|
||||
var doAfterEventArgs = new DoAfterArgs(user, pad.ScanDelay, ev, used, target: target, used: used)
|
||||
var doAfterEventArgs = new DoAfterArgs(EntityManager, user, pad.ScanDelay, ev, used, target: target, used: used)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Content.Server.Forensics
|
||||
/// </remarks>
|
||||
private void StartScan(EntityUid uid, ForensicScannerComponent component, EntityUid user, EntityUid target)
|
||||
{
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(user, component.ScanDelay, new ForensicScannerDoAfterEvent(), uid, target: target, used: uid)
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.ScanDelay, new ForensicScannerDoAfterEvent(), uid, target: target, used: uid)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
@@ -107,7 +107,7 @@ namespace Content.Server.Forensics
|
||||
var verb = new UtilityVerb()
|
||||
{
|
||||
Act = () => StartScan(uid, component, args.User, args.Target),
|
||||
IconEntity = uid,
|
||||
IconEntity = GetNetEntity(uid),
|
||||
Text = Loc.GetString("forensic-scanner-verb-text"),
|
||||
Message = Loc.GetString("forensic-scanner-verb-message")
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Content.Server.GameTicking.Commands
|
||||
[AnyCommand]
|
||||
sealed class JoinGameCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public string Command => "joingame";
|
||||
@@ -36,9 +37,8 @@ namespace Content.Server.GameTicking.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var ticker = EntitySystem.Get<GameTicker>();
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
var stationJobs = EntitySystem.Get<StationJobsSystem>();
|
||||
var ticker = _entManager.System<GameTicker>();
|
||||
var stationJobs = _entManager.System<StationJobsSystem>();
|
||||
|
||||
if (ticker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) && status == PlayerGameStatus.JoinedGame)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace Content.Server.GameTicking.Commands
|
||||
shell.WriteError(Loc.GetString("shell-argument-must-be-number"));
|
||||
}
|
||||
|
||||
var station = new EntityUid(sid);
|
||||
var station = _entManager.GetEntity(new NetEntity(sid));
|
||||
var jobPrototype = _prototypeManager.Index<JobPrototype>(id);
|
||||
if(stationJobs.TryGetJobSlot(station, jobPrototype, out var slots) == false || slots == 0)
|
||||
{
|
||||
|
||||
@@ -247,10 +247,10 @@ public sealed partial class GameTicker
|
||||
|
||||
foreach (var rule in args)
|
||||
{
|
||||
if (!EntityUid.TryParse(rule, out var ruleEnt))
|
||||
if (!NetEntity.TryParse(rule, out var ruleEntNet) || !TryGetEntity(ruleEntNet, out var ruleEnt))
|
||||
continue;
|
||||
|
||||
EndGameRule(ruleEnt);
|
||||
EndGameRule(ruleEnt.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace Content.Server.GameTicking
|
||||
PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)",
|
||||
// Character name takes precedence over current entity name
|
||||
PlayerICName = playerIcName,
|
||||
PlayerEntityUid = entity,
|
||||
PlayerNetEntity = GetNetEntity(entity),
|
||||
Role = antag
|
||||
? roles.First(role => role.Antagonist).Name
|
||||
: roles.FirstOrDefault().Name ?? Loc.GetString("game-ticker-unknown-role"),
|
||||
|
||||
@@ -66,18 +66,18 @@ public sealed class GatewaySystem : EntitySystem
|
||||
|
||||
private void UpdateUserInterface(EntityUid uid, GatewayComponent comp)
|
||||
{
|
||||
var destinations = new List<(EntityUid, String, TimeSpan, bool)>();
|
||||
var destinations = new List<(NetEntity, String, TimeSpan, bool)>();
|
||||
foreach (var destUid in comp.Destinations)
|
||||
{
|
||||
var dest = Comp<GatewayDestinationComponent>(destUid);
|
||||
if (!dest.Enabled)
|
||||
continue;
|
||||
|
||||
destinations.Add((destUid, dest.Name, dest.NextReady, HasComp<PortalComponent>(destUid)));
|
||||
destinations.Add((GetNetEntity(destUid), dest.Name, dest.NextReady, HasComp<PortalComponent>(destUid)));
|
||||
}
|
||||
|
||||
GetDestination(uid, out var current);
|
||||
var state = new GatewayBoundUserInterfaceState(destinations, current, comp.NextClose, comp.LastOpen);
|
||||
var state = new GatewayBoundUserInterfaceState(destinations, GetNetEntity(current), comp.NextClose, comp.LastOpen);
|
||||
_ui.TrySetUiState(uid, GatewayUiKey.Key, state);
|
||||
}
|
||||
|
||||
@@ -89,15 +89,17 @@ public sealed class GatewaySystem : EntitySystem
|
||||
private void OnOpenPortal(EntityUid uid, GatewayComponent comp, GatewayOpenPortalMessage args)
|
||||
{
|
||||
// can't link if portal is already open on either side, the destination is invalid or on cooldown
|
||||
var desto = GetEntity(args.Destination);
|
||||
|
||||
if (HasComp<PortalComponent>(uid) ||
|
||||
HasComp<PortalComponent>(args.Destination) ||
|
||||
!TryComp<GatewayDestinationComponent>(args.Destination, out var dest) ||
|
||||
HasComp<PortalComponent>(desto) ||
|
||||
!TryComp<GatewayDestinationComponent>(desto, out var dest) ||
|
||||
!dest.Enabled ||
|
||||
_timing.CurTime < dest.NextReady)
|
||||
return;
|
||||
|
||||
// TODO: admin log???
|
||||
OpenPortal(uid, comp, args.Destination, dest);
|
||||
OpenPortal(uid, comp, desto, dest);
|
||||
}
|
||||
|
||||
private void OpenPortal(EntityUid uid, GatewayComponent comp, EntityUid dest, GatewayDestinationComponent destComp)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user