Upload from upload_mods.ps1
This commit is contained in:
961
Scripts/ItemAction/ItemActionRepairRebirth.cs
Normal file
961
Scripts/ItemAction/ItemActionRepairRebirth.cs
Normal file
@@ -0,0 +1,961 @@
|
||||
using Audio;
|
||||
using Rebirth.RemoteCrafting;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class ItemActionRepairRebirth : ItemActionAttack
|
||||
{
|
||||
public override ItemActionData CreateModifierData(ItemInventoryData _invData, int _indexInEntityOfAction)
|
||||
{
|
||||
return new ItemActionRepairRebirth.InventoryDataRepair(_invData, _indexInEntityOfAction);
|
||||
}
|
||||
|
||||
public override void ReadFrom(DynamicProperties _props)
|
||||
{
|
||||
base.ReadFrom(_props);
|
||||
this.repairAmount = 0f;
|
||||
_props.ParseFloat("Repair_amount", ref this.repairAmount);
|
||||
this.hitCountOffset = 0f;
|
||||
_props.ParseFloat("Upgrade_hit_offset", ref this.hitCountOffset);
|
||||
this.repairActionSound = _props.GetString("Repair_action_sound");
|
||||
this.upgradeActionSound = _props.GetString("Upgrade_action_sound");
|
||||
this.allowedUpgradeItems = _props.GetString("Allowed_upgrade_items");
|
||||
this.restrictedUpgradeItems = _props.GetString("Restricted_upgrade_items");
|
||||
this.soundAnimActionSyncTimer = 0.3f;
|
||||
}
|
||||
|
||||
public override void StopHolding(ItemActionData _data)
|
||||
{
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_data).bUseStarted = false;
|
||||
this.bUpgradeCountChanged = false;
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_data.invData.holdingEntity as EntityPlayerLocal);
|
||||
if (uiforPlayer != null)
|
||||
{
|
||||
XUiC_FocusedBlockHealth.SetData(uiforPlayer, null, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StartHolding(ItemActionData _data)
|
||||
{
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_data).bUseStarted = false;
|
||||
this.bUpgradeCountChanged = false;
|
||||
}
|
||||
|
||||
public override void OnHoldingUpdate(ItemActionData _actionData)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 1");
|
||||
|
||||
if (_actionData.invData.hitInfo.bHitValid && _actionData.invData.hitInfo.hit.distanceSq > Constants.cDigAndBuildDistance * Constants.cDigAndBuildDistance)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 2");
|
||||
return;
|
||||
}
|
||||
EntityPlayerLocal entityPlayerLocal = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
if (entityPlayerLocal == null)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 3");
|
||||
return;
|
||||
}
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
||||
GUIWindowManager windowManager = uiforPlayer.windowManager;
|
||||
NGUIWindowManager nguiWindowManager = uiforPlayer.nguiWindowManager;
|
||||
if (windowManager.IsModalWindowOpen())
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 4");
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_actionData).bUseStarted = false;
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_actionData).repairType = ItemActionRepairRebirth.EnumRepairType.None;
|
||||
return;
|
||||
}
|
||||
if (_actionData.invData.holdingEntity != _actionData.invData.world.GetPrimaryPlayer())
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 5");
|
||||
return;
|
||||
}
|
||||
if (!((ItemActionRepairRebirth.InventoryDataRepair)_actionData).bUseStarted)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 6");
|
||||
return;
|
||||
}
|
||||
if (this.bUpgradeCountChanged)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 7");
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_actionData).upgradePerc = (float)this.blockUpgradeCount / (float)this.currentUpgradeInfo.Hits;
|
||||
if (this.blockUpgradeCount >= this.currentUpgradeInfo.Hits)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 8");
|
||||
if (this.RemoveRequiredResource(_actionData.invData))
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 9");
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate this.currentUpgradeInfo.ToBlock: " + this.currentUpgradeInfo.ToBlock);
|
||||
|
||||
BlockValue blockValue = Block.GetBlockValue(this.currentUpgradeInfo.ToBlock, false);
|
||||
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate blockValue: " + blockValue.Block.GetBlockName());
|
||||
|
||||
BlockValue block = _actionData.invData.world.GetBlock(this.blockTargetPos);
|
||||
blockValue.rotation = block.rotation;
|
||||
blockValue.meta = block.meta;
|
||||
QuestEventManager.Current.BlockUpgraded(this.currentUpgradeInfo.FromBlock, this.blockTargetPos);
|
||||
_actionData.invData.holdingEntity.MinEventContext.ItemActionData = _actionData;
|
||||
_actionData.invData.holdingEntity.MinEventContext.BlockValue = blockValue;
|
||||
_actionData.invData.holdingEntity.MinEventContext.Position = this.blockTargetPos.ToVector3();
|
||||
_actionData.invData.holdingEntity.FireEvent(MinEventTypes.onSelfUpgradedBlock, true);
|
||||
Block block2 = block.Block;
|
||||
block2.UpgradeBlock = blockValue;
|
||||
block.Block.UpgradeBlock = blockValue;
|
||||
block2.DamageBlock(_actionData.invData.world, this.blockTargetClrIdx, this.blockTargetPos, block, -1, _actionData.invData.holdingEntity.entityId, null, false, false);
|
||||
_actionData.invData.holdingEntity.Progression.AddLevelExp((int)(blockValue.Block.blockMaterial.Experience * (float)this.currentUpgradeInfo.ItemCount), "_xpFromUpgradeBlock", Progression.XPTypes.Upgrading, true);
|
||||
if (block2.UpgradeSound != null)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 10");
|
||||
_actionData.invData.holdingEntity.PlayOneShot(block2.UpgradeSound, false);
|
||||
}
|
||||
}
|
||||
this.blockUpgradeCount = 0;
|
||||
}
|
||||
if (this.currentUpgradeInfo.Sound.Length > 0)
|
||||
{
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 11");
|
||||
_actionData.invData.holdingEntity.PlayOneShot(this.currentUpgradeInfo.Sound, false);
|
||||
}
|
||||
this.bUpgradeCountChanged = false;
|
||||
return;
|
||||
}
|
||||
////Log.Out("ItemActionRepairRebirth-OnHoldingUpdate 12");
|
||||
this.ExecuteAction(_actionData, false);
|
||||
}
|
||||
|
||||
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction START");
|
||||
EntityPlayerLocal entityPlayerLocal = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
||||
if (_bReleased)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 1");
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_actionData).bUseStarted = false;
|
||||
((ItemActionRepairRebirth.InventoryDataRepair)_actionData).repairType = ItemActionRepairRebirth.EnumRepairType.None;
|
||||
return;
|
||||
}
|
||||
if (Time.time - _actionData.lastUseTime < this.Delay)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 2");
|
||||
return;
|
||||
}
|
||||
ItemInventoryData invData = _actionData.invData;
|
||||
if (invData.hitInfo.bHitValid && invData.hitInfo.hit.distanceSq > Constants.cDigAndBuildDistance * Constants.cDigAndBuildDistance)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 3");
|
||||
return;
|
||||
}
|
||||
if (EffectManager.GetValue(PassiveEffects.DisableItem, entityPlayerLocal.inventory.holdingItemItemValue, 0f, entityPlayerLocal, null, _actionData.invData.item.ItemTags, true, true, true, true, true, 1, false) > 0f)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 4");
|
||||
_actionData.lastUseTime = Time.time + 1f;
|
||||
Manager.PlayInsidePlayerHead("twitch_no_attack", -1, 0f, false);
|
||||
return;
|
||||
}
|
||||
_actionData.lastUseTime = Time.time;
|
||||
if (invData.hitInfo.bHitValid && _actionData.invData.world.IsWithinTraderArea(invData.hitInfo.hit.blockPos) && RebirthVariables.customProtectTraderArea)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 5");
|
||||
return;
|
||||
}
|
||||
if (invData.hitInfo.bHitValid && GameUtils.IsBlockOrTerrain(invData.hitInfo.tag))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 6");
|
||||
this.blockTargetPos = invData.hitInfo.hit.blockPos;
|
||||
this.blockTargetClrIdx = invData.hitInfo.hit.clrIdx;
|
||||
BlockValue block = invData.world.GetBlock(this.blockTargetPos);
|
||||
if (block.ischild)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 7");
|
||||
this.blockTargetPos = block.Block.multiBlockPos.GetParentPos(this.blockTargetPos, block);
|
||||
block = _actionData.invData.world.GetBlock(this.blockTargetPos);
|
||||
}
|
||||
if ((invData.itemValue.MaxUseTimes > 0 && invData.itemValue.UseTimes >= (float)invData.itemValue.MaxUseTimes) || (invData.itemValue.UseTimes == 0f && invData.itemValue.MaxUseTimes == 0))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 8");
|
||||
if (this.item.Properties.Values.ContainsKey(ItemClass.PropSoundJammed))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 9");
|
||||
Manager.PlayInsidePlayerHead(this.item.Properties.Values[ItemClass.PropSoundJammed], -1, 0f, false);
|
||||
}
|
||||
GameManager.ShowTooltip(entityPlayerLocal, "ttItemNeedsRepair");
|
||||
return;
|
||||
}
|
||||
ItemActionRepairRebirth.InventoryDataRepair inventoryDataRepair = (ItemActionRepairRebirth.InventoryDataRepair)_actionData;
|
||||
Block block2 = block.Block;
|
||||
if (block2.CanRepair(block))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 10");
|
||||
int num = Utils.FastMin((int)this.repairAmount, block.damage);
|
||||
float num2 = (float)num / (float)block2.MaxDamage;
|
||||
List<Block.SItemNameCount> list = block2.RepairItems;
|
||||
if (block2.RepairItemsMeshDamage != null && block2.shape.UseRepairDamageState(block))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 11");
|
||||
num = 1;
|
||||
num2 = 1f;
|
||||
list = block2.RepairItemsMeshDamage;
|
||||
}
|
||||
if (list == null)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 12");
|
||||
return;
|
||||
}
|
||||
if (inventoryDataRepair.lastHitPosition != this.blockTargetPos || inventoryDataRepair.lastHitBlockValue.type != block.type || inventoryDataRepair.lastRepairItems != list)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 13");
|
||||
inventoryDataRepair.lastHitPosition = this.blockTargetPos;
|
||||
inventoryDataRepair.lastHitBlockValue = block;
|
||||
inventoryDataRepair.lastRepairItems = list;
|
||||
inventoryDataRepair.lastRepairItemsPercents = new float[list.Count];
|
||||
}
|
||||
|
||||
inventoryDataRepair.blockDamagePerc = (float)block.damage / (float)block2.MaxDamage;
|
||||
EntityPlayerLocal entityPlayerLocal2 = inventoryDataRepair.invData.holdingEntity as EntityPlayerLocal;
|
||||
if (entityPlayerLocal2 == null)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 14");
|
||||
return;
|
||||
}
|
||||
inventoryDataRepair.repairType = ItemActionRepairRebirth.EnumRepairType.Repair;
|
||||
float resourceScale = block2.ResourceScale;
|
||||
bool flag = false;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
string itemName = list[i].ItemName;
|
||||
float num3 = (float)list[i].Count * num2 * resourceScale;
|
||||
if (inventoryDataRepair.lastRepairItemsPercents[i] <= 0f)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 15");
|
||||
int count = Utils.FastMax((int)num3, 1);
|
||||
ItemStack itemStack = new ItemStack(ItemClass.GetItem(itemName, false), count);
|
||||
if (!this.canRemoveRequiredItem(inventoryDataRepair.invData, itemStack))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 16");
|
||||
itemStack.count = 0;
|
||||
entityPlayerLocal2.AddUIHarvestingItem(itemStack, true);
|
||||
if (!flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 17");
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 18");
|
||||
return;
|
||||
}
|
||||
inventoryDataRepair.invData.holdingEntity.RightArmAnimationUse = true;
|
||||
float num4 = 0f;
|
||||
for (int j = 0; j < list.Count; j++)
|
||||
{
|
||||
float num5 = (float)list[j].Count * num2 * resourceScale;
|
||||
if (inventoryDataRepair.lastRepairItemsPercents[j] <= 0f)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 19");
|
||||
string itemName2 = list[j].ItemName;
|
||||
int num6 = Utils.FastMax((int)num5, 1);
|
||||
inventoryDataRepair.lastRepairItemsPercents[j] += (float)num6;
|
||||
inventoryDataRepair.lastRepairItemsPercents[j] -= num5;
|
||||
ItemStack itemStack2 = new ItemStack(ItemClass.GetItem(itemName2, false), num6);
|
||||
num4 += itemStack2.itemValue.ItemClass.MadeOfMaterial.Experience * (float)num6;
|
||||
this.removeRequiredItem(inventoryDataRepair.invData, itemStack2);
|
||||
itemStack2.count *= -1;
|
||||
entityPlayerLocal2.AddUIHarvestingItem(itemStack2, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 20");
|
||||
inventoryDataRepair.lastRepairItemsPercents[j] -= num5;
|
||||
}
|
||||
}
|
||||
if (this.repairActionSound != null && this.repairActionSound.Length > 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 21");
|
||||
invData.holdingEntity.PlayOneShot(this.repairActionSound, false);
|
||||
}
|
||||
else if (this.soundStart != null && this.soundStart.Length > 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 22");
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
if (invData.itemValue.MaxUseTimes > 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 23");
|
||||
invData.itemValue.UseTimes += 1f;
|
||||
}
|
||||
int num7 = block.Block.DamageBlock(invData.world, invData.hitInfo.hit.clrIdx, this.blockTargetPos, block, -num, invData.holdingEntity.entityId, null, false, false);
|
||||
inventoryDataRepair.bUseStarted = true;
|
||||
inventoryDataRepair.blockDamagePerc = (float)num7 / (float)block.Block.MaxDamage;
|
||||
inventoryDataRepair.invData.holdingEntity.MinEventContext.ItemActionData = inventoryDataRepair;
|
||||
inventoryDataRepair.invData.holdingEntity.MinEventContext.BlockValue = block;
|
||||
inventoryDataRepair.invData.holdingEntity.MinEventContext.Position = this.blockTargetPos.ToVector3();
|
||||
inventoryDataRepair.invData.holdingEntity.FireEvent(MinEventTypes.onSelfRepairBlock, true);
|
||||
entityPlayerLocal2.Progression.AddLevelExp((int)num4, "_xpFromRepairBlock", Progression.XPTypes.Repairing, true);
|
||||
return;
|
||||
}
|
||||
else if (this.isUpgradeItem)
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
bool isWithinTraderArea = ((World)_actionData.invData.world).GetTraderAreaAt(blockTargetPos) != null;
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction isWithinTraderArea: " + isWithinTraderArea);
|
||||
|
||||
if (optionProtectTrader && isWithinTraderArea)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantUpgradeHere"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 24");
|
||||
if (!this.CanRemoveRequiredResource(_actionData.invData, block))
|
||||
{
|
||||
string strUpgradeBlock = this.GetUpgradeItemName(block.Block);
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction this.currentUpgradeInfo.Item: " + this.currentUpgradeInfo.Item);
|
||||
if (strUpgradeBlock != null)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 25: " + strUpgradeBlock);
|
||||
ItemStack @is = new ItemStack(ItemClass.GetItem(strUpgradeBlock, false), 0);
|
||||
|
||||
if (_actionData.invData.holdingEntity.inventory.holdingItemItemValue.Modifications.Length != 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 26");
|
||||
for (int i = 0; i < _actionData.invData.holdingEntity.inventory.holdingItemItemValue.Modifications.Length; i++)
|
||||
{
|
||||
ItemValue itemValue = _actionData.invData.holdingEntity.inventory.holdingItemItemValue.Modifications[i];
|
||||
if (itemValue != null && itemValue.ItemClass != null)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 27");
|
||||
if (itemValue.ItemClass.GetItemName() == "modUpgradeExplConcrete")
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 28");
|
||||
@is = new ItemStack(ItemClass.GetItem("resourceResistantConcreteMix", false), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(_actionData.invData.holdingEntity as EntityPlayerLocal).AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
inventoryDataRepair.upgradePerc = 0f;
|
||||
return;
|
||||
}
|
||||
_actionData.invData.holdingEntity.RightArmAnimationUse = true;
|
||||
inventoryDataRepair.repairType = ItemActionRepairRebirth.EnumRepairType.Upgrade;
|
||||
if (this.blockTargetPos == this.lastBlockTargetPos)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 29");
|
||||
this.blockUpgradeCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 30");
|
||||
this.blockUpgradeCount = 1;
|
||||
}
|
||||
this.lastBlockTargetPos = this.blockTargetPos;
|
||||
this.bUpgradeCountChanged = true;
|
||||
inventoryDataRepair.bUseStarted = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-ExecuteAction 31");
|
||||
inventoryDataRepair.bUseStarted = false;
|
||||
inventoryDataRepair.repairType = ItemActionRepairRebirth.EnumRepairType.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float GetRepairAmount()
|
||||
{
|
||||
return this.repairAmount;
|
||||
}
|
||||
|
||||
private string GetUpgradeItemName(Block block)
|
||||
{
|
||||
string text = block.Properties.Values["UpgradeBlock.Item"];
|
||||
if (text != null && text.Length == 1 && text[0] == 'r')
|
||||
{
|
||||
text = block.RepairItems[0].ItemName;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private bool CanRemoveRequiredResource(ItemInventoryData data, BlockValue blockValue)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 1");
|
||||
Block block = blockValue.Block;
|
||||
string upgradeItemName = this.GetUpgradeItemName(block);
|
||||
bool flag = upgradeItemName != null && upgradeItemName.Length > 0;
|
||||
ItemActionRepairRebirth.UpgradeInfo upgradeInfo = default(ItemActionRepairRebirth.UpgradeInfo);
|
||||
upgradeInfo.FromBlock = block.GetBlockName();
|
||||
upgradeInfo.ToBlock = block.Properties.Values[Block.PropUpgradeBlockClassToBlock];
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource upgradeInfo.FromBlock: " + upgradeInfo.FromBlock);
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource upgradeInfo.ToBlock: " + upgradeInfo.ToBlock);
|
||||
|
||||
bool canUpgradeExplosiveConcrete = false;
|
||||
|
||||
if (data.holdingEntity.inventory.holdingItemItemValue.Modifications.Length != 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 2");
|
||||
for (int i = 0; i < data.holdingEntity.inventory.holdingItemItemValue.Modifications.Length; i++)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 3");
|
||||
ItemValue itemValue = data.holdingEntity.inventory.holdingItemItemValue.Modifications[i];
|
||||
if (itemValue != null && itemValue.ItemClass != null)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 4");
|
||||
if (blockValue.Block.GetBlockName().Contains("cobblestoneShapes"))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 5");
|
||||
if (itemValue.ItemClass.GetItemName() == "modUpgradeExplConcrete")
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 6");
|
||||
canUpgradeExplosiveConcrete = true;
|
||||
|
||||
string strUpgradeBlock = upgradeInfo.ToBlock.Replace("concrete", "ResistantConcrete");
|
||||
|
||||
upgradeInfo.ToBlock = strUpgradeBlock;
|
||||
upgradeInfo.ItemCount = 14;
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource upgradeInfo.ItemCount: " + upgradeInfo.ItemCount);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (blockValue.Block.GetBlockName().Contains("concreteShapes"))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 7");
|
||||
if (itemValue.ItemClass.GetItemName() == "modUpgradeExplConcrete")
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 8");
|
||||
canUpgradeExplosiveConcrete = true;
|
||||
|
||||
string strUpgradeBlock = upgradeInfo.ToBlock.Replace("steel", "ResistantConcrete");
|
||||
|
||||
upgradeInfo.ToBlock = strUpgradeBlock;
|
||||
upgradeInfo.ItemCount = 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (blockValue.Block.GetBlockName().Contains("steelShapes"))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 9");
|
||||
if (itemValue.ItemClass.GetItemName() == "modUpgradeExplConcrete")
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 10");
|
||||
canUpgradeExplosiveConcrete = true;
|
||||
|
||||
string strUpgradeBlock = blockValue.Block.GetBlockName().Replace("steel", "ResistantConcrete");
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource blockValue.Block.GetBlockName(): " + blockValue.Block.GetBlockName());
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource strUpgradeBlock: " + strUpgradeBlock);
|
||||
|
||||
upgradeInfo.ToBlock = strUpgradeBlock;
|
||||
upgradeInfo.ItemCount = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!canUpgradeExplosiveConcrete && upgradeInfo.ToBlock == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 11");
|
||||
upgradeInfo.Item = upgradeItemName;
|
||||
if (this.allowedUpgradeItems.Length > 0 && !this.allowedUpgradeItems.ContainsCaseInsensitive(upgradeInfo.Item))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 12 :" + this.allowedUpgradeItems.ToString());
|
||||
return false;
|
||||
}
|
||||
if (this.restrictedUpgradeItems.Length > 0 && this.restrictedUpgradeItems.ContainsCaseInsensitive(upgradeInfo.Item))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 13");
|
||||
return false;
|
||||
}
|
||||
if (!canUpgradeExplosiveConcrete)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 13a");
|
||||
if (!int.TryParse(block.Properties.Values[Block.PropUpgradeBlockClassItemCount], out upgradeInfo.ItemCount))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 13b");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canUpgradeExplosiveConcrete)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 14");
|
||||
upgradeInfo.Item = "resourceResistantConcreteMix";
|
||||
flag = true;
|
||||
}
|
||||
if (this.upgradeActionSound.Length > 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 15");
|
||||
upgradeInfo.Sound = this.upgradeActionSound;
|
||||
}
|
||||
else if (flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 16");
|
||||
upgradeInfo.Sound = string.Format("ImpactSurface/{0}hit{1}", data.holdingEntity.inventory.holdingItem.MadeOfMaterial.SurfaceCategory, ItemClass.GetForId(ItemClass.GetItem(upgradeInfo.Item, false).type).MadeOfMaterial.SurfaceCategory);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 17");
|
||||
upgradeInfo.Sound = "";
|
||||
}
|
||||
int num;
|
||||
if (!int.TryParse(block.Properties.Values["UpgradeBlock.UpgradeHitCount"], out num))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 18");
|
||||
return false;
|
||||
}
|
||||
upgradeInfo.Hits = (int)(((float)num + this.hitCountOffset < 1f) ? 1f : ((float)num + this.hitCountOffset));
|
||||
if (!canUpgradeExplosiveConcrete && !int.TryParse(block.Properties.Values[Block.PropUpgradeBlockClassItemCount], out upgradeInfo.ItemCount) && flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 19");
|
||||
return false;
|
||||
}
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource upgradeInfo.ItemCount: " + upgradeInfo.ItemCount);
|
||||
|
||||
this.currentUpgradeInfo = upgradeInfo;
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource this.currentUpgradeInfo.ItemCount: " + this.currentUpgradeInfo.ItemCount);
|
||||
if (this.currentUpgradeInfo.FromBlock != null && flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 20, this.currentUpgradeInfo.ItemCount: " + this.currentUpgradeInfo.ItemCount);
|
||||
ItemValue item = ItemClass.GetItem(this.currentUpgradeInfo.Item, false);
|
||||
if (data.holdingEntity.inventory.GetItemCount(item, false, -1, -1) >= this.currentUpgradeInfo.ItemCount)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 21");
|
||||
return true;
|
||||
}
|
||||
if (data.holdingEntity.bag.GetItemCount(item, -1, -1, false) >= this.currentUpgradeInfo.ItemCount)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 22");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (!flag)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 23");
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
ItemStack _itemStack = new ItemStack(ItemClass.GetItem(this.currentUpgradeInfo.Item, false), this.currentUpgradeInfo.ItemCount);
|
||||
|
||||
int totalCount = RemoteCraftingUtils.SearchNearbyContainers(primaryPlayer, _itemStack.itemValue).Sum(y => y.count);
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-CanRemoveRequiredResource totalCount: " + totalCount);
|
||||
|
||||
if (totalCount >= this.currentUpgradeInfo.ItemCount)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-CanRemoveRequiredResource 13");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionRepairRebirth-CanRemoveRequiredResource 24");
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool RemoveRequiredResource(ItemInventoryData data)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource this.currentUpgradeInfo: " + this.currentUpgradeInfo.Item);
|
||||
|
||||
if (string.IsNullOrEmpty(this.currentUpgradeInfo.Item))
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource 1");
|
||||
return true;
|
||||
}
|
||||
ItemValue itemValue = ItemClass.GetItem(this.currentUpgradeInfo.Item, false);
|
||||
if (data.holdingEntity.inventory.DecItem(itemValue, this.currentUpgradeInfo.ItemCount, false) == this.currentUpgradeInfo.ItemCount)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource 2");
|
||||
EntityPlayerLocal entityPlayerLocal = data.holdingEntity as EntityPlayerLocal;
|
||||
if (entityPlayerLocal != null && this.currentUpgradeInfo.ItemCount != 0)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource 3");
|
||||
entityPlayerLocal.AddUIHarvestingItem(new ItemStack(itemValue, -this.currentUpgradeInfo.ItemCount), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (data.holdingEntity.bag.DecItem(itemValue, this.currentUpgradeInfo.ItemCount, false) == this.currentUpgradeInfo.ItemCount)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource 4");
|
||||
EntityPlayerLocal entityPlayerLocal2 = data.holdingEntity as EntityPlayerLocal;
|
||||
if (entityPlayerLocal2 != null)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource 5");
|
||||
entityPlayerLocal2.AddUIHarvestingItem(new ItemStack(itemValue, -this.currentUpgradeInfo.ItemCount), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
var tileEntities = RemoteCraftingUtils.GetTileEntities(primaryPlayer);
|
||||
|
||||
// counter quantity needed from item
|
||||
int q = this.currentUpgradeInfo.ItemCount;
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource q: " + q);
|
||||
|
||||
ItemStack _itemStack = new ItemStack(ItemClass.GetItem(this.currentUpgradeInfo.Item, false), this.currentUpgradeInfo.ItemCount);
|
||||
|
||||
//check player inventory for materials and reduce counter
|
||||
var slots = primaryPlayer.bag.GetSlots();
|
||||
q = q - slots
|
||||
.Where(x => x.itemValue.ItemClass == _itemStack.itemValue.ItemClass)
|
||||
.Sum(y => y.count);
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource AFTER PLAYER INVENTORY, q: " + q);
|
||||
|
||||
// check storage boxes
|
||||
foreach (var tileEntity in tileEntities)
|
||||
{
|
||||
if (q <= 0) break;
|
||||
|
||||
if (!tileEntity.TryGetSelfOrFeature<ITileEntityLootable>(out var lootTileEntity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there's no items in this container, skip.
|
||||
if (!lootTileEntity.HasItem(_itemStack.itemValue)) continue;
|
||||
|
||||
int num = this.currentUpgradeInfo.ItemCount;
|
||||
if (lootTileEntity == null) break;
|
||||
for (int y = 0; y < lootTileEntity.items.Length; y++)
|
||||
{
|
||||
var item = lootTileEntity.items[y];
|
||||
if (item.IsEmpty()) continue;
|
||||
if (item.itemValue.ItemClass == _itemStack.itemValue.ItemClass)
|
||||
{
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource BEFORE item.count: " + item.count);
|
||||
|
||||
// If we can completely satisfy the result, let's do that.
|
||||
if (item.count >= q)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource SATISFIED");
|
||||
|
||||
item.count -= q;
|
||||
q = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, let's just count down until we meet the requirement.
|
||||
while (q >= 0)
|
||||
{
|
||||
item.count--;
|
||||
q--;
|
||||
if (item.count <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Update the slot on the container, and do the Setmodified(), so that the dedis can get updated.
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-RemoveRequiredResource AFTER item.count: " + item.count);
|
||||
|
||||
if (item.count < 1)
|
||||
{
|
||||
lootTileEntity.UpdateSlot(y, ItemStack.Empty.Clone());
|
||||
}
|
||||
else
|
||||
{
|
||||
lootTileEntity.UpdateSlot(y, item);
|
||||
}
|
||||
lootTileEntity.SetModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
primaryPlayer.AddUIHarvestingItem(new ItemStack(itemValue, -this.currentUpgradeInfo.ItemCount), false);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private bool canRemoveRequiredItem(ItemInventoryData _data, ItemStack _itemStack)
|
||||
{
|
||||
if (_data.holdingEntity.inventory.GetItemCount(_itemStack.itemValue, false, -1, -1) >= _itemStack.count || _data.holdingEntity.bag.GetItemCount(_itemStack.itemValue, -1, -1, false) >= _itemStack.count)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-canRemoveRequiredItem Have items in my inventory");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-canRemoveRequiredItem Don't have items in my inventory");
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
int totalCount = RemoteCraftingUtils.SearchNearbyContainers(primaryPlayer, _itemStack.itemValue).Sum(y => y.count);
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-canRemoveRequiredItem totalCount: " + totalCount);
|
||||
|
||||
if (totalCount > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool removeRequiredItem(ItemInventoryData _data, ItemStack _itemStack)
|
||||
{
|
||||
bool __result = false;
|
||||
|
||||
//Log.Out("ItemActionRepairRebirthPatches-removeRequiredItem START");
|
||||
|
||||
__result = _data.holdingEntity.inventory.DecItem(_itemStack.itemValue, _itemStack.count, false) == _itemStack.count || _data.holdingEntity.bag.DecItem(_itemStack.itemValue, _itemStack.count, false) == _itemStack.count;
|
||||
|
||||
if (__result)
|
||||
{
|
||||
//Log.Out("ItemActionRepairRebirthPatches-canRemoveRequiredItem Have items in my inventory");
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
var tileEntities = RemoteCraftingUtils.GetTileEntities(primaryPlayer);
|
||||
|
||||
// counter quantity needed from item
|
||||
int q = _itemStack.count;
|
||||
|
||||
//check player inventory for materials and reduce counter
|
||||
var slots = primaryPlayer.bag.GetSlots();
|
||||
q = q - slots
|
||||
.Where(x => x.itemValue.ItemClass == _itemStack.itemValue.ItemClass)
|
||||
.Sum(y => y.count);
|
||||
|
||||
// check storage boxes
|
||||
foreach (var tileEntity in tileEntities)
|
||||
{
|
||||
if (q <= 0) break;
|
||||
|
||||
if (!tileEntity.TryGetSelfOrFeature<ITileEntityLootable>(out var lootTileEntity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there's no items in this container, skip.
|
||||
if (!lootTileEntity.HasItem(_itemStack.itemValue)) continue;
|
||||
|
||||
int num = _itemStack.count;
|
||||
if (lootTileEntity == null) break;
|
||||
for (int y = 0; y < lootTileEntity.items.Length; y++)
|
||||
{
|
||||
var item = lootTileEntity.items[y];
|
||||
if (item.IsEmpty()) continue;
|
||||
if (item.itemValue.ItemClass == _itemStack.itemValue.ItemClass)
|
||||
{
|
||||
// If we can completely satisfy the result, let's do that.
|
||||
if (item.count >= q)
|
||||
{
|
||||
item.count -= q;
|
||||
q = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, let's just count down until we meet the requirement.
|
||||
while (q >= 0)
|
||||
{
|
||||
item.count--;
|
||||
q--;
|
||||
if (item.count <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Update the slot on the container, and do the Setmodified(), so that the dedis can get updated.
|
||||
if (item.count < 1)
|
||||
lootTileEntity.UpdateSlot(y, ItemStack.Empty.Clone());
|
||||
else
|
||||
lootTileEntity.UpdateSlot(y, item);
|
||||
lootTileEntity.SetModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return __result;
|
||||
}
|
||||
|
||||
public override ItemClass.EnumCrosshairType GetCrosshairType(ItemActionData _actionData)
|
||||
{
|
||||
ItemActionRepairRebirth.EnumRepairType repairType = ((ItemActionRepairRebirth.InventoryDataRepair)_actionData).repairType;
|
||||
if (repairType == ItemActionRepairRebirth.EnumRepairType.Repair)
|
||||
{
|
||||
return ItemClass.EnumCrosshairType.Repair;
|
||||
}
|
||||
if (repairType != ItemActionRepairRebirth.EnumRepairType.Upgrade)
|
||||
{
|
||||
return ItemClass.EnumCrosshairType.Plus;
|
||||
}
|
||||
return ItemClass.EnumCrosshairType.Upgrade;
|
||||
}
|
||||
|
||||
public override bool isShowOverlay(ItemActionData _actionData)
|
||||
{
|
||||
WorldRayHitInfo hitInfo = _actionData.invData.hitInfo;
|
||||
if (hitInfo.bHitValid && hitInfo.hit.distanceSq > Constants.cDigAndBuildDistance * Constants.cDigAndBuildDistance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
ItemActionRepairRebirth.InventoryDataRepair inventoryDataRepair = (ItemActionRepairRebirth.InventoryDataRepair)_actionData;
|
||||
if (inventoryDataRepair.repairType == ItemActionRepairRebirth.EnumRepairType.None)
|
||||
{
|
||||
if (hitInfo.bHitValid)
|
||||
{
|
||||
int damage = 0;
|
||||
if (!hitInfo.hit.blockValue.ischild)
|
||||
{
|
||||
damage = hitInfo.hit.blockValue.damage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hitInfo.hit.blockValue.Block == null)
|
||||
{
|
||||
//Log.Out("hitInfo.hit.blockValue.Block == null");
|
||||
return false;
|
||||
}
|
||||
if (hitInfo.hit.blockValue.Block.multiBlockPos == null) // problem here with guppys fire extinguisher guppysFireExtinguisherBlock
|
||||
{
|
||||
//Log.Out("hitInfo.hit.blockValue.Block.multiBlockPos == null");
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3i parentPos = hitInfo.hit.blockValue.Block.multiBlockPos.GetParentPos(hitInfo.hit.blockPos, hitInfo.hit.blockValue);
|
||||
damage = _actionData.invData.world.GetBlock(parentPos).damage;
|
||||
}
|
||||
result = (damage > 0);
|
||||
}
|
||||
}
|
||||
else if (inventoryDataRepair.repairType == ItemActionRepairRebirth.EnumRepairType.Repair)
|
||||
{
|
||||
EntityPlayerLocal entityPlayerLocal = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
result = (entityPlayerLocal != null && entityPlayerLocal.HitInfo.bHitValid && Time.time - _actionData.lastUseTime <= 1.5f);
|
||||
}
|
||||
else if (inventoryDataRepair.repairType == ItemActionRepairRebirth.EnumRepairType.Upgrade)
|
||||
{
|
||||
EntityPlayerLocal entityPlayerLocal2 = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
result = (entityPlayerLocal2 != null && entityPlayerLocal2.HitInfo.bHitValid && Time.time - _actionData.lastUseTime <= 1.5f && inventoryDataRepair.upgradePerc > 0f);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void getOverlayData(ItemActionData _actionData, out float _perc, out string _text)
|
||||
{
|
||||
ItemActionRepairRebirth.InventoryDataRepair inventoryDataRepair = (ItemActionRepairRebirth.InventoryDataRepair)_actionData;
|
||||
if (inventoryDataRepair.repairType == ItemActionRepairRebirth.EnumRepairType.None)
|
||||
{
|
||||
BlockValue blockValue = _actionData.invData.hitInfo.hit.blockValue;
|
||||
if (blockValue.ischild)
|
||||
{
|
||||
Vector3i parentPos = blockValue.Block.multiBlockPos.GetParentPos(_actionData.invData.hitInfo.hit.blockPos, blockValue);
|
||||
blockValue = _actionData.invData.world.GetBlock(parentPos);
|
||||
}
|
||||
int shownMaxDamage = blockValue.Block.GetShownMaxDamage();
|
||||
_perc = ((float)shownMaxDamage - (float)blockValue.damage) / (float)shownMaxDamage;
|
||||
_text = string.Format("{0}/{1}", Utils.FastMax(0, shownMaxDamage - blockValue.damage), shownMaxDamage);
|
||||
return;
|
||||
}
|
||||
if (inventoryDataRepair.repairType == ItemActionRepairRebirth.EnumRepairType.Repair)
|
||||
{
|
||||
_perc = 1f - inventoryDataRepair.blockDamagePerc;
|
||||
_text = string.Format("{0}%", (_perc * 100f).ToCultureInvariantString("0"));
|
||||
return;
|
||||
}
|
||||
if (inventoryDataRepair.repairType == ItemActionRepairRebirth.EnumRepairType.Upgrade)
|
||||
{
|
||||
_perc = inventoryDataRepair.upgradePerc;
|
||||
_text = string.Format("{0}%", (_perc * 100f).ToCultureInvariantString("0"));
|
||||
return;
|
||||
}
|
||||
_perc = 0f;
|
||||
_text = string.Empty;
|
||||
}
|
||||
|
||||
public override bool IsActionRunning(ItemActionData _actionData)
|
||||
{
|
||||
ItemActionRepairRebirth.InventoryDataRepair inventoryDataRepair = (ItemActionRepairRebirth.InventoryDataRepair)_actionData;
|
||||
return Time.time - inventoryDataRepair.lastUseTime < this.Delay + 0.1f;
|
||||
}
|
||||
|
||||
public override void GetItemValueActionInfo(ref List<string> _infoList, ItemValue _itemValue, XUi _xui, int _actionIndex = 0)
|
||||
{
|
||||
base.GetItemValueActionInfo(ref _infoList, _itemValue, _xui, _actionIndex);
|
||||
_infoList.Add(ItemAction.StringFormatHandler(Localization.Get("lblBlkRpr"), this.GetRepairAmount().ToCultureInvariantString()));
|
||||
}
|
||||
|
||||
private const float showUpgradeDelay = 1f;
|
||||
protected BlockValue targetBlock;
|
||||
protected float repairAmount;
|
||||
protected float hitCountOffset;
|
||||
protected float soundAnimActionSyncTimer;
|
||||
protected const float SOUND_LENGTH = 0.3f;
|
||||
private ItemActionRepairRebirth.UpgradeInfo currentUpgradeInfo;
|
||||
private bool isUpgradeItem = true;
|
||||
private float upgradeRepeatTime;
|
||||
private Vector3i blockTargetPos;
|
||||
private int blockTargetClrIdx;
|
||||
private Vector3i lastBlockTargetPos;
|
||||
private int blockUpgradeCount;
|
||||
private bool bUpgradeCountChanged;
|
||||
private string repairActionSound;
|
||||
private string upgradeActionSound;
|
||||
private string allowedUpgradeItems;
|
||||
private string restrictedUpgradeItems;
|
||||
private struct UpgradeInfo
|
||||
{
|
||||
public string FromBlock;
|
||||
public string ToBlock;
|
||||
public string Item;
|
||||
public int ItemCount;
|
||||
public string Sound;
|
||||
public int Hits;
|
||||
}
|
||||
|
||||
protected enum EnumRepairType
|
||||
{
|
||||
None,
|
||||
Repair,
|
||||
Upgrade
|
||||
}
|
||||
|
||||
protected class InventoryDataRepair : ItemActionAttackData
|
||||
{
|
||||
public InventoryDataRepair(ItemInventoryData _invData, int _indexInEntityOfAction) : base(_invData, _indexInEntityOfAction)
|
||||
{
|
||||
}
|
||||
|
||||
public new bool uiOpenedByMe;
|
||||
public ItemActionRepairRebirth.EnumRepairType repairType;
|
||||
public float blockDamagePerc;
|
||||
public bool bUseStarted;
|
||||
public float upgradePerc;
|
||||
public BlockValue lastHitBlockValue;
|
||||
public Vector3i lastHitPosition = Vector3i.zero;
|
||||
public List<Block.SItemNameCount> lastRepairItems;
|
||||
public float[] lastRepairItemsPercents;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user