Inline Prototype
This commit is contained in:
@@ -3,6 +3,7 @@ using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
var id = args[0].ToLower();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var entities = entityManager.GetEntities().Where(e => e.Prototype?.ID.ToLower() == id);
|
||||
var entities = entityManager.GetEntities().Where(e => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e.Uid).EntityPrototype?.ID.ToLower() == id);
|
||||
var i = 0;
|
||||
|
||||
foreach (var entity in entities)
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
@@ -52,12 +53,12 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
foreach (var entity in entitiesWithAllComponents)
|
||||
{
|
||||
if (entity.Prototype == null)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
entityIds.Add(entity.Prototype.ID);
|
||||
entityIds.Add(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype.ID);
|
||||
}
|
||||
|
||||
if (entityIds.Count == 0)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
foreach (var entity in entityManager.GetEntities())
|
||||
{
|
||||
if (checkPrototype && entity.Prototype != prototype || entity.Prototype == null)
|
||||
if (checkPrototype && IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype != prototype || IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
foreach (var component in entity.GetAllComponents())
|
||||
{
|
||||
if (entity.Prototype.Components.ContainsKey(component.Name))
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype.Components.ContainsKey(component.Name))
|
||||
continue;
|
||||
|
||||
entityManager.RemoveComponent(entity.Uid, component);
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Content.Server.Chemistry.Components
|
||||
/// </summary>
|
||||
public void Spread()
|
||||
{
|
||||
if (Owner.Prototype == null)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype == null)
|
||||
{
|
||||
Logger.Error("AreaEffectComponent needs its owner to be spawned by a prototype.");
|
||||
return;
|
||||
@@ -83,7 +83,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return;
|
||||
}
|
||||
|
||||
var newEffect = IoCManager.Resolve<IEntityManager>().SpawnEntity(Owner.Prototype.ID, grid.DirectionToGrid(coords, dir));
|
||||
var newEffect = IoCManager.Resolve<IEntityManager>().SpawnEntity(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype.ID, grid.DirectionToGrid(coords, dir));
|
||||
|
||||
if (!newEffect.TryGetComponent(out SolutionAreaEffectComponent? effectComponent))
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Content.Server.Construction.Commands
|
||||
continue;
|
||||
}
|
||||
|
||||
var prototype = childEntity.Prototype;
|
||||
var prototype = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(childEntity.Uid).EntityPrototype;
|
||||
while (true)
|
||||
{
|
||||
if (prototype?.Parent == null)
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.Stack;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
@@ -66,7 +67,7 @@ namespace Content.Server.Construction.Components
|
||||
|
||||
if (!_boardContainer.Insert(board))
|
||||
{
|
||||
throw new Exception($"Couldn't insert board with prototype {BoardPrototype} to machine with prototype {Owner.Prototype?.ID ?? "N/A"}!");
|
||||
throw new Exception($"Couldn't insert board with prototype {BoardPrototype} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}!");
|
||||
}
|
||||
|
||||
if (!board.TryGetComponent<MachineBoardComponent>(out var machineBoard))
|
||||
@@ -81,7 +82,7 @@ namespace Content.Server.Construction.Components
|
||||
var p = entityManager.SpawnEntity(MachinePartComponent.Prototypes[part], Owner.Transform.Coordinates);
|
||||
|
||||
if (!partContainer.Insert(p))
|
||||
throw new Exception($"Couldn't insert machine part of type {part} to machine with prototype {Owner.Prototype?.ID ?? "N/A"}!");
|
||||
throw new Exception($"Couldn't insert machine part of type {part} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ namespace Content.Server.Construction.Components
|
||||
var stack = EntitySystem.Get<StackSystem>().Spawn(amount, stackType, Owner.Transform.Coordinates);
|
||||
|
||||
if (!partContainer.Insert(IoCManager.Resolve<IEntityManager>().GetEntity(stack)))
|
||||
throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {Owner.Prototype?.ID ?? "N/A"}");
|
||||
throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}");
|
||||
}
|
||||
|
||||
foreach (var (compName, info) in machineBoard.ComponentRequirements)
|
||||
@@ -100,7 +101,7 @@ namespace Content.Server.Construction.Components
|
||||
var c = entityManager.SpawnEntity(info.DefaultPrototype, Owner.Transform.Coordinates);
|
||||
|
||||
if(!partContainer.Insert(c))
|
||||
throw new Exception($"Couldn't insert machine component part with default prototype '{compName}' to machine with prototype {Owner.Prototype?.ID ?? "N/A"}");
|
||||
throw new Exception($"Couldn't insert machine component part with default prototype '{compName}' to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ namespace Content.Server.Construction.Components
|
||||
var c = entityManager.SpawnEntity(info.DefaultPrototype, Owner.Transform.Coordinates);
|
||||
|
||||
if(!partContainer.Insert(c))
|
||||
throw new Exception($"Couldn't insert machine component part with default prototype '{tagName}' to machine with prototype {Owner.Prototype?.ID ?? "N/A"}");
|
||||
throw new Exception($"Couldn't insert machine component part with default prototype '{tagName}' to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetCurrentGraph(uid, construction) is not {} graph)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {construction.Owner.Prototype?.ID}'s construction component has an invalid graph specified.");
|
||||
_sawmill.Warning($"Prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(construction.Owner.Uid).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetNodeFromGraph(graph, construction.Node) is not {} node)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {construction.Owner.Prototype?.ID}'s construction component has an invalid node specified.");
|
||||
_sawmill.Warning($"Prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(construction.Owner.Uid).EntityPrototype?.ID}'s construction component has an invalid node specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {construction.Owner.Prototype?.ID}'s construction component has an invalid edge index specified.");
|
||||
_sawmill.Warning($"Prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(construction.Owner.Uid).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {construction.Owner.Prototype?.ID}'s construction component has an invalid target node specified.");
|
||||
_sawmill.Warning($"Prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(construction.Owner.Uid).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Containers
|
||||
{
|
||||
@@ -11,7 +14,7 @@ namespace Content.Server.Containers
|
||||
{
|
||||
foreach (var entity in container.ContainedEntities)
|
||||
{
|
||||
if (entity.Prototype?.ID == prototypeId) total++;
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype?.ID == prototypeId) total++;
|
||||
if(!entity.TryGetComponent<ContainerManagerComponent>(out var component)) continue;
|
||||
total += component.CountPrototypeOccurencesRecursive(prototypeId);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems
|
||||
{
|
||||
@@ -328,7 +329,7 @@ namespace Content.Server.Fluids.EntitySystems
|
||||
}
|
||||
|
||||
puddle ??= () =>
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(puddleComponent.Owner.Prototype?.ID,
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(puddleComponent.Owner.Uid).EntityPrototype?.ID,
|
||||
mapGrid.DirectionToGrid(coords, direction))
|
||||
.GetComponent<PuddleComponent>();
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -74,7 +76,8 @@ namespace Content.Server.GameTicking.Commands
|
||||
shell.ExecuteCommand($"addmap {mapId} false");
|
||||
shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
|
||||
|
||||
if (player.AttachedEntity?.Prototype?.ID != "AdminObserver")
|
||||
IEntity? tempQualifier = player.AttachedEntity;
|
||||
if ((tempQualifier != null ? IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(tempQualifier.Uid).EntityPrototype : null)?.ID != "AdminObserver")
|
||||
shell.ExecuteCommand("aghost");
|
||||
|
||||
shell.ExecuteCommand($"tp 0 0 {mapId}");
|
||||
|
||||
@@ -29,6 +29,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -311,18 +312,18 @@ namespace Content.Server.Kitchen.Components
|
||||
var solidsDict = new Dictionary<string, int>();
|
||||
foreach (var item in _storage.ContainedEntities)
|
||||
{
|
||||
if (item.Prototype == null)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (solidsDict.ContainsKey(item.Prototype.ID))
|
||||
if (solidsDict.ContainsKey(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype.ID))
|
||||
{
|
||||
solidsDict[item.Prototype.ID]++;
|
||||
solidsDict[IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype.ID]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
solidsDict.Add(item.Prototype.ID, 1);
|
||||
solidsDict.Add(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype.ID, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,12 +451,12 @@ namespace Content.Server.Kitchen.Components
|
||||
{
|
||||
foreach (var item in _storage.ContainedEntities)
|
||||
{
|
||||
if (item.Prototype == null)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.Prototype.ID == recipeSolid.Key)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype.ID == recipeSolid.Key)
|
||||
{
|
||||
_storage.Remove(item);
|
||||
item.Delete();
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Content.Server.Stack
|
||||
// Get a prototype ID to spawn the new entity. Null is also valid, although it should rarely be picked...
|
||||
var prototype = _prototypeManager.TryIndex<StackPrototype>(stack.StackTypeId, out var stackType)
|
||||
? stackType.Spawn
|
||||
: stack.Owner.Prototype?.ID;
|
||||
: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(stack.Owner.Uid).EntityPrototype?.ID;
|
||||
|
||||
// Try to remove the amount of things we want to split from the original stack...
|
||||
if (!Use(uid, amount, stack))
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
else
|
||||
{
|
||||
projectile =
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(baseProjectile.Prototype?.ID, baseProjectile.Transform.Coordinates);
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(baseProjectile.Uid).EntityPrototype?.ID, baseProjectile.Transform.Coordinates);
|
||||
}
|
||||
|
||||
firedProjectiles[i] = projectile.Uid;
|
||||
|
||||
Reference in New Issue
Block a user