// 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);
    }
예제 #2
0
    // 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);
    }