コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: StackSystem.cs プロジェクト: Vis13/space-station-14
        /// <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);
        }
コード例 #3
0
        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);
        }