Upgradeable machines. (#2675)

* Start work on upgradeable machines.

* Upgradeable machines work

* Component requirements for upgradeable machines

* Better container handling

* Remember to not push submodule updates in your PRs, kids!

* Refresh parts after building a machine.

* NetSync false

* Address some reviews, fix some bugs

* Nullable stackhelpers dependencies

* Use container helper method to delete all entities in containers

* Nullable string in AddContainer

* Better examine for machine frame and construction in general

* Machine breakage

* Nullable node

* nullable GraphPrototype

* Re-save saltern for autolathe parts

* Fix SaveLoadSave
This commit is contained in:
Vera Aguilera Puerto
2020-12-03 22:49:00 +01:00
committed by GitHub
parent ba2bdec13b
commit c3341132c5
36 changed files with 5270 additions and 3703 deletions

View File

@@ -0,0 +1,63 @@
#nullable enable
using System;
using Content.Server.GameObjects.Components.Stack;
using Content.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.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.Phoron:
prototype = "PhoronStack1";
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;
}
}
}