Пример #1
0
 public bool shouldCartInteract(EntityMinecart cart)
 {
     return
         (this.minecart == null && // There is no Minecart already here
          cart.position == this.pos &&
          !cart.inventory.isFull());
 }
Пример #2
0
    public override void placeIntoWorld(World world, BuildAreaHighlighter highlight, Position pos, Rotation rotation)
    {
        EntityMinecart minecart = (EntityMinecart)world.entities.spawn(pos, 2); // Minecart id.
        Rotation       trackRot = world.getCellState(pos).rotation;

        minecart.rotation = rotation.axis == EnumAxis.Y ? trackRot : trackRot.opposite();

        // Incrase stat.
        world.statManager.minecartsPlaced.increase(1);
    }
Пример #3
0
    public override bool deposit(Item item)
    {
        bool addedItem = this.minecart.inventory.addItem(item);

        if (this.minecart.inventory.isFull())
        {
            this.minecart.release();
            this.minecart = null;
        }

        return(addedItem);
    }
Пример #4
0
    //private float tripTimer;

    public override void onUpdate()
    {
        base.onUpdate();

        //this.tripTimer -= Time.deltaTime;
        //if(this.tripTimer <= 0) {
        //    this.dirty();
        //    this.isTripped = false;
        //}
        if (this.tripper != null && this.tripper.position != this.pos)
        {
            this.tripper = null;
        }
    }
Пример #5
0
    public void setTripped(EntityMinecart cart)
    {
        if (this.tripper == null || (this.tripper != cart))
        {
            this.tripper   = cart;
            this.isTripped = !this.isTripped;
            this.dirty();

            CellBehaviorLever.alertNeighborsOfFlip(this);
        }

        /*
         * this.tripTimer = 0.1f;
         * if(!this.isTripped) {
         *  this.isTripped = true;
         *  this.dirty();
         * }
         */
    }