public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { if (_blockValue.damage > 0) { GameManager.ShowTooltipWithAlert(_player as EntityPlayerLocal, Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied"); } else { LocalPlayerUI playerUi = (_player as EntityPlayerLocal).PlayerUI; playerUi.windowManager.Open("timer", true, false, true); XUiC_Timer childByType = playerUi.xui.GetChildByType <XUiC_Timer>(); TimerEventData _eventData = new TimerEventData { Data = new object[4] { _cIdx, _blockValue, _blockPos, _player } }; _eventData.Event += new TimerEventHandler(this.EventData_Event); childByType.SetTimer(_takeDelay, _eventData); } }
// Displays the UI for the timer, calling TakeTarget when its done. public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { LocalPlayerUI playerUI = (_player as EntityPlayerLocal).PlayerUI; playerUI.windowManager.Open("timer", true, false, true); XUiC_Timer xuiC_Timer = (XUiC_Timer)playerUI.xui.GetChildByType <XUiC_Timer>(); TimerEventData timerEventData = new TimerEventData(); timerEventData.Data = new object[] { _cIdx, _blockValue, _blockPos, _player }; timerEventData.Event += this.TakeTarget; float newTakeTime = this.fTakeDelay; // If the entity is holding a crow bar or hammer, then reduce the take time. if (_player.inventory.holdingItem.Name == "CrowBar" || _player.inventory.holdingItem.Name == "meleeToolClawHammer") { // Make sure the item can still be used if (_player.inventory.holdingItemItemValue.MaxUseTimes > 0) { // Bump the Use time by one. global::ItemValue itemValue = _player.inventory.holdingItemItemValue; // Calculate the degradation value. itemValue.UseTimes += (int)EffectManager.GetValue(PassiveEffects.DegradationPerUse, itemValue, 1f, _player, null, default(FastTags), true, true, true, true); _player.inventory.holdingItemData.itemValue = itemValue; // Automatically reduce the take delay by half if you have a crow bar or claw hammer. newTakeTime = (this.fTakeDelay / 2); float blockDamage = EffectManager.GetValue(PassiveEffects.BlockDamage, null, 1f, _player, null, default(FastTags), true, true, true, true); Debug.Log("Block Damage is: " + blockDamage); // Don't divde by 0, but take it as a full timer, since it's level 0. if (blockDamage == 0f) { newTakeTime = newTakeTime * 1f; } else { newTakeTime = newTakeTime * blockDamage; } } } xuiC_Timer.SetTimer(newTakeTime, timerEventData); }
// Displays the UI for the timer, calling TakeTarget when its done. public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { LocalPlayerUI playerUI = (_player as EntityPlayerLocal).PlayerUI; playerUI.windowManager.Open("timer", true, false, true); XUiC_Timer xuiC_Timer = (XUiC_Timer)playerUI.xui.GetChildByType <XUiC_Timer>(); TimerEventData timerEventData = new TimerEventData(); timerEventData.Data = new object[] { _cIdx, _blockValue, _blockPos, _player }; timerEventData.Event += this.TakeTarget; float newTakeTime = this.fTakeDelay; // If the entity is holding a crow bar or hammer, then reduce the take time. if (_player.inventory.holdingItem.Name == "CrowBar" || _player.inventory.holdingItem.Name == "clawHammer") { // Make sure the item can still be used if (_player.inventory.holdingItemItemValue.MaxUseTimes > 0) { // Bump the Use time by one. global::ItemValue itemValue = _player.inventory.holdingItemItemValue; itemValue.UseTimes += global::AttributeBase.GetVal <global::AttributeDegradationRate>(itemValue, 1); _player.inventory.holdingItemData.itemValue = itemValue; // Automatically reduce the take delay by half if you have a crow bar or claw hammer. newTakeTime = (this.fTakeDelay / 2); Skill tmpSkill = (_player as EntityPlayerLocal).Skills.GetSkillByName("Breaking And Entering"); // Don't divde by 0, but take it as a full timer, since it's level 0. if (tmpSkill.Level == 0) { newTakeTime = newTakeTime / 1f; } else { newTakeTime = newTakeTime / tmpSkill.Level; } } } xuiC_Timer.SetTimer(newTakeTime, timerEventData); }
// We want to give the user the ability to pick up the blocks too, but the loot containers don't support that directly. public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { #region TakeItemWithTimer if (_blockValue.damage > 0) { GameManager.ShowTooltipWithAlert(_player as EntityPlayerLocal, Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied"); return; } LocalPlayerUI playerUI = (_player as EntityPlayerLocal).PlayerUI; playerUI.windowManager.Open("timer", true, false, true); XUiC_Timer childByType = playerUI.xui.GetChildByType <XUiC_Timer>(); TimerEventData timerEventData = new TimerEventData(); timerEventData.Data = new object[] { _cIdx, _blockValue, _blockPos, _player }; timerEventData.Event += this.EventData_Event; childByType.SetTimer(this.TakeDelay, timerEventData); #endregion }