Ejemplo n.º 1
0
        public async Task PerformAction(IEntity entity, IEntity?user)
        {
            if (entity.Deleted || string.IsNullOrEmpty(Prototype))
            {
                return;
            }

            var entityManager = IoCManager.Resolve <IEntityManager>();
            var coordinates   = entity.Transform.Coordinates;

            if (EntityPrototypeHelpers.HasComponent <StackComponent>(Prototype))
            {
                var            _entity        = entityManager.SpawnEntity(Prototype, coordinates);
                StackComponent stackComponent = _entity.GetComponent <StackComponent>();

                stackComponent.Count = Math.Min(stackComponent.MaxCount, Amount);
            }
            else
            {
                for (var i = 0; i < Amount; i++)
                {
                    entityManager.SpawnEntity(Prototype, coordinates);
                }
            }
        }
Ejemplo n.º 2
0
        private void DoSpawn(IEntity owner, IRobustRandom random)
        {
            if (Spawn == null)
            {
                return;
            }

            foreach (var(key, value) in Spawn)
            {
                var count = value.Min >= value.Max
                    ? value.Min
                    : random.Next(value.Min, value.Max + 1);

                if (count == 0)
                {
                    continue;
                }

                if (EntityPrototypeHelpers.HasComponent <StackComponent>(key))
                {
                    var spawned = owner.EntityManager.SpawnEntity(key, owner.Transform.Coordinates);
                    var stack   = spawned.GetComponent <StackComponent>();
                    stack.Count = count;
                    spawned.RandomOffset(0.5f);
                }
                else
                {
                    for (var i = 0; i < count; i++)
                    {
                        var spawned = owner.EntityManager.SpawnEntity(key, owner.Transform.Coordinates);
                        spawned.RandomOffset(0.5f);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
        {
            if (SpawnOnDestroy == null || !eventArgs.IsSpawnWreck)
            {
                return;
            }
            foreach (var(key, value) in SpawnOnDestroy)
            {
                int count;
                if (value.Min >= value.Max)
                {
                    count = value.Min;
                }
                else
                {
                    count = _random.Next(value.Min, value.Max + 1);
                }

                if (count == 0)
                {
                    continue;
                }

                if (EntityPrototypeHelpers.HasComponent <StackComponent>(key))
                {
                    var spawned = Owner.EntityManager.SpawnEntity(key, Owner.Transform.Coordinates);
                    var stack   = spawned.GetComponent <StackComponent>();
                    stack.Count = count;
                    spawned.RandomOffset(0.5f);
                }
                else
                {
                    for (var i = 0; i < count; i++)
                    {
                        var spawned = Owner.EntityManager.SpawnEntity(key, Owner.Transform.Coordinates);
                        spawned.RandomOffset(0.5f);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void PerformAction(EntityUid uid, EntityUid?userUid, IEntityManager entityManager)
        {
            if (string.IsNullOrEmpty(Prototype))
            {
                return;
            }

            var coordinates = entityManager.GetComponent <TransformComponent>(uid).Coordinates;

            if (EntityPrototypeHelpers.HasComponent <StackComponent>(Prototype))
            {
                var stackEnt = entityManager.SpawnEntity(Prototype, coordinates);
                var stack    = entityManager.GetComponent <StackComponent>(stackEnt);
                entityManager.EntitySysManager.GetEntitySystem <StackSystem>().SetCount(stackEnt, Amount, stack);
            }
            else
            {
                for (var i = 0; i < Amount; i++)
                {
                    entityManager.SpawnEntity(Prototype, coordinates);
                }
            }
        }
Ejemplo n.º 5
0
        public async Task PerformAction(IEntity entity, IEntity?user)
        {
            if (entity.Deleted || string.IsNullOrEmpty(Prototype))
            {
                return;
            }

            var entityManager = IoCManager.Resolve <IEntityManager>();
            var coordinates   = entity.Transform.Coordinates;

            if (EntityPrototypeHelpers.HasComponent <StackComponent>(Prototype))
            {
                var stack = entityManager.SpawnEntity(Prototype, coordinates);
                stack.EntityManager.EventBus.RaiseLocalEvent(stack.Uid, new StackChangeCountEvent(Amount), false);
            }
            else
            {
                for (var i = 0; i < Amount; i++)
                {
                    entityManager.SpawnEntity(Prototype, coordinates);
                }
            }
        }
Ejemplo n.º 6
0
        public async Task PerformAction(IEntity entity, IEntity?user)
        {
            if (entity.Deleted || string.IsNullOrEmpty(Prototype))
            {
                return;
            }

            var entityManager = IoCManager.Resolve <IEntityManager>();
            var coordinates   = entity.Transform.Coordinates;

            if (EntityPrototypeHelpers.HasComponent <StackComponent>(Prototype))
            {
                var stackEnt = entityManager.SpawnEntity(Prototype, coordinates);
                var stack    = stackEnt.GetComponent <StackComponent>();
                EntitySystem.Get <StackSystem>().SetCount(stackEnt.Uid, stack, Amount);
            }
            else
            {
                for (var i = 0; i < Amount; i++)
                {
                    entityManager.SpawnEntity(Prototype, coordinates);
                }
            }
        }