Content update for NetEntities (#18935)

This commit is contained in:
metalgearsloth
2023-09-11 09:42:41 +10:00
committed by GitHub
parent 389c8d1a2c
commit 5a0fc68be2
526 changed files with 3058 additions and 2215 deletions

View File

@@ -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}.");
}

View File

@@ -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.");
}

View File

@@ -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;