Example #1
0
        /// <summary>
        /// Standard right click funtion, it get the top left corner of the tile and see if there is a generator tile entity.
        /// If there is one, it will show how much energy it has generated, otherwise it will return an error.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="j"></param>
        public override void RightClick(int i, int j)
        {
            GeneratorTileEntity tileEntity = ExampleTEMod.GetTileEntity(i, j) as GeneratorTileEntity;

            if (tileEntity != null)
            {
                Main.NewText(tileEntity.GetEnergyStored(null) + "/" + tileEntity.GetMaxEnergyStorage(null) + " TE");
            }
        }
        /// <summary>
        /// Standard right click funtion, it get the top left corner of the tile and see if there is a generator tile entity.
        /// If there is one, it will show how much energy it has generated, otherwise it will return an error.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="j"></param>
        public override void RightClick(int i, int j)
        {
            Tile tile = Main.tile[i, j];

            int left = i - (tile.frameX / 18);
            int top  = j - (tile.frameY / 18);

            int index = mod.GetTileEntity <GeneratorTileEntity>().Find(left, top);

            if (index == -1)
            {
                Main.NewText("An error happened");
                return;
            }

            GeneratorTileEntity tileEntity = TileEntity.ByID[index] as GeneratorTileEntity;

            Main.NewText(tileEntity.EnergyContainer.GetCurrentEnergy() + "/" + tileEntity.EnergyContainer.MaxEnergy + " TE");
        }