Пример #1
0
        protected override void OnDestroy(int x, int y, Inventory inv)
        {
            base.OnDestroy(x, y, inv);
            if (entityCage != null)
            {
                entityCage.Release();
                EntityManager.RemoveEntity(entityCage);
            }

            entityCage = null;
        }
Пример #2
0
        internal override void Update(int x, int y)
        {
            if (entityCage == null)
            {
                entityCage = new EntityCage(new Vector2(x, y + 1));
                EntityManager.AddEntity(entityCage);
            }

            if (cooldown == null)
            {
                cooldown = new CooldownTimer(100);
            }

            BoundedFloat buffer = new BoundedFloat(0, 0, cost);

            CachePowerLevels();

            if (powerinL + powerinR + powerinD >= buffer.max)
            {
                BoundedFloat.MoveVals(ref powerinL, ref buffer, powerinL);
                BoundedFloat.MoveVals(ref powerinR, ref buffer, powerinR);
                BoundedFloat.MoveVals(ref powerinD, ref buffer, powerinD);
            }

            EmptyInputs();

            if (buffer.IsFull())
            {
                state = true;
                if (cooldown.Ready())
                {
                    Spawn(x, y);
                    cooldown.Reset();
                }
            }
            else
            {
                state = false;
            }

            Terrain.TileAt(x, y).enumId = state ? TileID.EntitySpawnerOn : TileID.EntitySpawnerOff;
        }