public override global::BlockActivationCommand[] GetBlockActivationCommands(global::WorldBase _world, global::BlockValue _blockValue, int _clrIdx, global::Vector3i _blockPos, global::EntityAlive _entityFocusing)
    {
        bool flag = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);

        this.blockActivationCommand[0].enabled = (this.CanPickup && flag && this.TakeDelay > 0f);
        return(this.blockActivationCommand);
    }
Esempio n. 2
0
    public override string GetActivationText(global::WorldBase _world, global::BlockValue _blockValue, int _clrIdx, global::Vector3i _blockPos, global::EntityAlive _entityFocusing)
    {
        if (!_world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false))
        {
            return(string.Empty);
        }

        global::Block block     = global::Block.list[_blockValue.type];
        string        blockName = block.GetBlockName();

        return(string.Format(global::Localization.Get("pickupPrompt", string.Empty), global::Localization.Get(blockName, string.Empty)));
    }
    public override global::BlockActivationCommand[] GetBlockActivationCommands(global::WorldBase _world, global::BlockValue _blockValue,
                                                                                int _clrIdx, global::Vector3i _blockPos, global::EntityAlive _entityFocusing)
    {
        BlockActivationCommand[] returnVal = base.GetBlockActivationCommands(_world, _blockValue, _clrIdx, _blockPos, _entityFocusing);

        global::TileEntityVendingMachine tileEntityVendingMachine = _world.GetTileEntity(_clrIdx, _blockPos) as global::TileEntityVendingMachine;
        string @string = global::GamePrefs.GetString(global::EnumGamePrefs.PlayerId);

        returnVal[1].enabled = (this.CanPickup && _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false));

        return(returnVal);
    }
 public override void OnBlockRemoved(global::WorldBase world, global::Chunk _chunk, global::Vector3i _blockPos, global::BlockValue _blockValue)
 {
     if (_blockValue.damage > 0)
     {
         // Only remove TileEntity and wire when block is removed because it's destroyed, not when picked up by player, or upgraded to Fire version.
         // Removal of TileEntity and wire when player is picking it up is done in TakeBlock()
         base.OnBlockRemoved(world, (Chunk)world.GetChunkFromWorldPos(_blockPos), _blockPos, _blockValue);
     }
     else
     {
         this.shape.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
     }
 }
    public override bool OnBlockActivated(int _indexInBlockActivationCommands, global::WorldBase _world, int _cIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, global::EntityAlive _player)
    {
        global::BlockValue block = _world.GetBlock(_blockPos.x, _blockPos.y - 1, _blockPos.z);

        if (global::Block.list[block.type].HasTag(global::BlockTags.Door))
        {
            _blockPos = new global::Vector3i(_blockPos.x, _blockPos.y - 1, _blockPos.z);
            return(this.OnBlockActivated(_indexInBlockActivationCommands, _world, _cIdx, _blockPos, _blockValue, _player));
        }
        if (_indexInBlockActivationCommands != 0)
        {
            return(false);
        }

        this.TakeItemWithTimer2(_cIdx, _blockPos, _blockValue, _player);
        return(true);
    }
    public bool PlantUpdateTick(global::WorldBase _world, int _clrIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, System.Random _rnd)
    {
        // The first few ticks, random is null, so don't do the check if its null.
        if (_rnd == null)
        {
            return(false);
        }
        if (!this.IsRandomlyTick && _bRandomTick)
        {
            _world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.GetTickRate());
            return(true);
        }

        global::ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];

        if (chunkCluster == null)
        {
            return(true);
        }

        if (this.IsRandomlyTick)
        {
            if ((float)_blockValue.meta3and2 < this.UpdateRate - 1f)
            {
                if (_rnd.Next(2) == 0)
                {
                    _blockValue.meta3and2 += 1;
                    _world.SetBlockRPC(_clrIdx, _blockPos, _blockValue);
                }


                return(true);
            }
            _blockValue.meta3and2 = 0;
        }

        if (this.IsRandomlyTick || _ticksIfLoaded <= this.GetTickRate())
        {
            DepleteFromBlock(_blockValue, _blockPos);
        }

        return(true);
    }
    public override bool OnBlockActivated(int _indexInBlockActivationCommands, global::WorldBase _world, int _cIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, global::EntityAlive _player)
    {
        global::BlockValue block = _world.GetBlock(_blockPos.x, _blockPos.y - 1, _blockPos.z);

        if (global::Block.list[block.type].HasTag(global::BlockTags.Door))
        {
            _blockPos = new global::Vector3i(_blockPos.x, _blockPos.y - 1, _blockPos.z);
            return(this.OnBlockActivated(_indexInBlockActivationCommands, _world, _cIdx, _blockPos, _blockValue, _player));
        }
        global::TileEntityVendingMachine tileEntityVendingMachine = _world.GetTileEntity(_cIdx, _blockPos) as global::TileEntityVendingMachine;

        if (tileEntityVendingMachine == null)
        {
            return(false);
        }
        global::LocalPlayerUI uiforPlayer = global::LocalPlayerUI.GetUIForPlayer(_player as global::EntityPlayerLocal);

        if (null != uiforPlayer)
        {
            switch (_indexInBlockActivationCommands)
            {
            case 0:
                return(this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player));

            case 1:
            {
                this.tmpPickupUiforPlayer = uiforPlayer;
                this.tmpPickupClrIdx      = _cIdx;
                this.tmpPickupBlockPos    = _blockPos;
                this.tmpPickupItemStack   = new global::ItemStack(_blockValue.ToItemValue(), 1);
                this.TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player);
                return(true);
            }

            case 2:
                uiforPlayer.windowManager.Open(global::GUIWindowKeypad.ID, true, false, true);
                global::NGuiKeypad.Instance.LockedItem = tileEntityVendingMachine;
                return(true);
            }
        }
        return(false);
    }
 public override string GetActivationText(global::WorldBase _world, global::BlockValue _blockValue, int _clrIdx, global::Vector3i _blockPos, global::EntityAlive _entityFocusing)
 {
     return("Press <E> to remove the wood from this block.");
 }
 public override string GetActivationText(global::WorldBase _world, global::BlockValue _blockValue, int _clrIdx, global::Vector3i _blockPos, global::EntityAlive _entityFocusing)
 {
     return(string.Format(Localization.Get("takeandreplace"), Localization.Get(_blockValue.Block.GetBlockName())));
     //    return "Press <E> to remove the wood from this block.";
 }
 public override void OnBlockRemoved(global::WorldBase world, global::Chunk _chunk, global::Vector3i _blockPos, global::BlockValue _blockValue)
 {
     base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
     Audio.Manager.BroadcastStop(_blockPos.ToVector3(), soundRepeat);
 }
Esempio n. 11
0
 public override bool OnBlockActivated(int _indexInBlockActivationCommands, global::WorldBase _world, int _cIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, global::EntityAlive _player)
 {
     this.TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player);
     return(true);
 }
 public override string GetActivationText(global::WorldBase _world, global::BlockValue _blockValue, int _clrIdx, global::Vector3i _blockPos, global::EntityAlive _entityFocusing)
 {
     // If this.CanPickup is enabled, we don't want to be bothered by the pickup text when in the middle of a blood moon
     return(string.Empty);
 }
Esempio n. 13
0
 // Call the PlantUpdate tick to control upgrades, and the base UpdateTick to allow water flow.
 public override bool UpdateTick(global::WorldBase world, int _clrIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, System.Random _rnd)
 {
     PlantUpdateTick(world, _clrIdx, _blockPos, _blockValue, _bRandomTick, _ticksIfLoaded, _rnd);
     return(base.UpdateTick(world, _clrIdx, _blockPos, _blockValue, _bRandomTick, _ticksIfLoaded, _rnd));
 }
Esempio n. 14
0
 public override void OnBlockRemoved(global::WorldBase world, global::Chunk _chunk, global::Vector3i _blockPos, global::BlockValue _blockValue)
 {
     // Don't remove TileEntity and wire when block is removed because it's destroyed, we keep it for the downgrade version of the block so wires stay connected
     this.shape.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
 }