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 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); }
private void TakeBlock(object obj) { global::World world = global::GameManager.Instance.World; object[] array = (object[])obj; int clrIdx = (int)array[0]; global::BlockValue blockValue = (global::BlockValue)array[1]; global::Vector3i vector3i = (global::Vector3i)array[2]; global::BlockValue block = world.GetBlock(vector3i); global::EntityPlayerLocal entityPlayerLocal = array[3] as global::EntityPlayerLocal; if (block.damage > 0) { global::GameManager.ShowTooltipWithAlert(entityPlayerLocal, global::Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied"); return; } if (block.type != blockValue.type) { global::GameManager.ShowTooltipWithAlert(entityPlayerLocal, global::Localization.Get("ttBlockMissingPickup", string.Empty), "ui_denied"); return; } global::TileEntityPowered tileEntityPowered = world.GetTileEntity(clrIdx, vector3i) as global::TileEntityPowered; if (tileEntityPowered != null && tileEntityPowered.IsUserAccessing()) { global::GameManager.ShowTooltipWithAlert(entityPlayerLocal, global::Localization.Get("ttCantPickupInUse", string.Empty), "ui_denied"); return; } // Remove TileEntity and wire base.OnBlockRemoved(world, (Chunk)world.GetChunkFromWorldPos(vector3i), vector3i, blockValue); global::LocalPlayerUI uiforPlayer = global::LocalPlayerUI.GetUIForPlayer(entityPlayerLocal); this.HandleTakeInternalItems(tileEntityPowered, uiforPlayer); global::ItemStack itemStack = new global::ItemStack(block.ToItemValue(), 1); if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack, true)) { uiforPlayer.xui.PlayerInventory.DropItem(itemStack); } world.SetBlockRPC(clrIdx, vector3i, global::BlockValue.Air); }
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 void TakeItemWithTimer(int _cIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, global::EntityAlive _player) { if (_blockValue.damage > 0) { global::GameManager.ShowTooltipWithAlert(_player as global::EntityPlayerLocal, global::Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied"); return; } global::LocalPlayerUI playerUI = (_player as global::EntityPlayerLocal).PlayerUI; playerUI.windowManager.Open("timer", true, false, true); global::XUiC_Timer xuiC_Timer = (global::XUiC_Timer)playerUI.xui.GetChildByType <global::XUiC_Timer>(); global::TimerEventData timerEventData = new global::TimerEventData(); timerEventData.Data = new object[] { _cIdx, _blockValue, _blockPos, _player }; timerEventData.Event += this.TakeBlock; xuiC_Timer.SetTimer(this.TakeDelay, timerEventData); }
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); }
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 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 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); }
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); }
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 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); }
// 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)); }
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); }