/// <summary> /// Spawns a stack of a certain stack type. See <see cref="StackPrototype"/>. /// </summary> public EntityUid Spawn(int amount, StackPrototype prototype, EntityCoordinates spawnPosition) { // Set the output result parameter to the new stack entity... var entity = Spawn(prototype.Spawn, spawnPosition); var stack = Comp <StackComponent>(entity); // And finally, set the correct amount! SetCount(entity, amount, stack); return(entity); }
/// <summary> /// Spawns a stack of a certain stack type. See <see cref="StackPrototype"/>. /// </summary> public IEntity Spawn(int amount, StackPrototype prototype, EntityCoordinates spawnPosition) { // Set the output result parameter to the new stack entity... var entity = EntityManager.SpawnEntity(prototype.Spawn, spawnPosition); var stack = ComponentManager.GetComponent <StackComponent>(entity.Uid); // And finally, set the correct amount! SetCount(entity.Uid, stack, amount); return(entity); }
public static IEntity SpawnStack(StackPrototype stack, int amount, EntityCoordinates coordinates, IEntityManager?entityManager = null) { entityManager ??= IoCManager.Resolve <IEntityManager>(); // TODO: Add more. string prototype = stack.Spawn ?? 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); }