* Engine namespace changes.
* Automated remove redundant using statements.
* Simplified Graphics namespace.
* Apparently the container system stores full type names in the map file.😞 This updates those names.
* API Changes to LocalizationManager.LoadCulture.
* Update submodule to v0.3.2
64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
#nullable enable
|
|
using System;
|
|
using Content.Server.GameObjects.Components.Stack;
|
|
using Content.Shared.GameObjects.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.Construction
|
|
{
|
|
public static class StackHelpers
|
|
{
|
|
/// <summary>
|
|
/// Spawns a stack of a specified type given an amount.
|
|
/// </summary>
|
|
public static IEntity SpawnStack(StackType stack, int amount, EntityCoordinates coordinates, IEntityManager? entityManager = null)
|
|
{
|
|
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
|
|
|
string prototype;
|
|
|
|
switch (stack)
|
|
{
|
|
case StackType.Metal:
|
|
prototype = "SteelSheet1";
|
|
break;
|
|
|
|
case StackType.Glass:
|
|
prototype = "GlassSheet1";
|
|
break;
|
|
|
|
case StackType.MetalRod:
|
|
prototype = "MetalRodStack1";
|
|
break;
|
|
|
|
case StackType.Plasma:
|
|
prototype = "PlasmaStack1";
|
|
break;
|
|
|
|
case StackType.Plasteel:
|
|
prototype = "PlasteelSheet1";
|
|
break;
|
|
|
|
case StackType.Cable:
|
|
prototype = "ApcExtensionCableStack1";
|
|
break;
|
|
|
|
// TODO: Add more.
|
|
|
|
default:
|
|
throw new ArgumentOutOfRangeException(nameof(stack),"Stack type doesn't have a prototype specified yet!");
|
|
}
|
|
|
|
var ent = entityManager.SpawnEntity(prototype, coordinates);
|
|
|
|
var stackComponent = ent.GetComponent<StackComponent>();
|
|
|
|
stackComponent.Count = Math.Min(amount, stackComponent.MaxCount);
|
|
|
|
return ent;
|
|
}
|
|
}
|
|
}
|