Upload from upload_mods.ps1
This commit is contained in:
815
Scripts/ItemAction/ItemActionAttackRebirth.cs
Normal file
815
Scripts/ItemAction/ItemActionAttackRebirth.cs
Normal file
@@ -0,0 +1,815 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ItemActionAttackRebirth
|
||||
{
|
||||
static float _KillExpMaxDist = 50f;
|
||||
static float _NPCKillExpMod = 1f;
|
||||
|
||||
public static void Hit(
|
||||
WorldRayHitInfo hitInfo_,
|
||||
int attackerEntityId_,
|
||||
EnumDamageTypes damageType_,
|
||||
float blockDamage_,
|
||||
float entityDamage_,
|
||||
float staminaDamageMultiplier_,
|
||||
float weaponCondition_,
|
||||
float criticalHitChanceOLD_, // unused
|
||||
float dismemberChance_,
|
||||
string attackingDeviceMadeOf_,
|
||||
DamageMultiplier damageMultiplier_,
|
||||
List<string> buffActions_,
|
||||
ItemActionAttack.AttackHitInfo attackDetails_,
|
||||
int flags_ = 1,
|
||||
int actionExp_ = 0, // unused
|
||||
float actionExpBonus_ = 0f, // unused
|
||||
ItemActionAttack rangeCheckedAction_ = null,
|
||||
Dictionary<string, ItemActionAttack.Bonuses> toolBonuses_ = null,
|
||||
ItemActionAttack.EnumAttackMode attackMode_ = ItemActionAttack.EnumAttackMode.RealNoHarvesting,
|
||||
Dictionary<string, string> hitSoundOverrides_ = null,
|
||||
int ownedEntityId_ = -1,
|
||||
ItemValue damagingItemValue_ = null)
|
||||
{
|
||||
//Log.Out("ItemActionAttackPatches-Hit attackerEntityId_: " + attackerEntityId_);
|
||||
//Log.Out("ItemActionAttackPatches-Hit ownedEntityId_: " + ownedEntityId_);
|
||||
//Log.Out("ItemActionAttackPatches-Hit attackDetails_.WeaponTypeTag: " + attackDetails_.WeaponTypeTag);
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit weaponCondition_: " + weaponCondition_);
|
||||
//Log.Out("ItemActionAttackPatches-Hit blockDamage_: " + blockDamage_);
|
||||
//Log.Out("ItemActionAttackPatches-Hit entityDamage_: " + entityDamage_);
|
||||
|
||||
if (hitInfo_ == null || hitInfo_.tag == null) return;
|
||||
|
||||
bool bypassXP = false;
|
||||
|
||||
if (damagingItemValue_ != null && damagingItemValue_.ItemClass != null)
|
||||
{
|
||||
if (damagingItemValue_.ItemClass.Name.ToLower() == "autoturret" ||
|
||||
damagingItemValue_.ItemClass.Name.ToLower() == "shotgunturret"
|
||||
)
|
||||
{
|
||||
bypassXP = true;
|
||||
}
|
||||
}
|
||||
|
||||
World world = GameManager.Instance.World;
|
||||
bool isNot_RNHOE = true;
|
||||
|
||||
if (attackMode_ == ItemActionAttack.EnumAttackMode.RealNoHarvestingOrEffects)
|
||||
{
|
||||
isNot_RNHOE = false;
|
||||
attackMode_ = ItemActionAttack.EnumAttackMode.RealNoHarvesting;
|
||||
}
|
||||
|
||||
if (attackDetails_ != null)
|
||||
{
|
||||
attackDetails_.itemsToDrop = null;
|
||||
attackDetails_.bBlockHit = false;
|
||||
attackDetails_.entityHit = null;
|
||||
}
|
||||
|
||||
string particleCategory = null;
|
||||
string surfaceCategory = null;
|
||||
float lightValue = 1f;
|
||||
Color particleColor = Color.white;
|
||||
bool islphModLessThanOne = false;
|
||||
EntityAlive attackingEntity = world.GetEntity(attackerEntityId_) as EntityAlive;
|
||||
EntityNPCRebirth attackingNPC = attackingEntity as EntityNPCRebirth;
|
||||
bool isInventoryItem = false;
|
||||
|
||||
if (attackingEntity != null)
|
||||
{
|
||||
if (damagingItemValue_ == null)
|
||||
{
|
||||
damagingItemValue_ = attackingEntity.inventory.holdingItemItemValue;
|
||||
}
|
||||
|
||||
isInventoryItem = damagingItemValue_.Equals(attackingEntity.inventory.holdingItemItemValue);
|
||||
}
|
||||
|
||||
bool isNotPlayerHit = true;
|
||||
|
||||
#region Hit -> Block/Terrain
|
||||
if (GameUtils.IsBlockOrTerrain(hitInfo_.tag))
|
||||
{
|
||||
// Does this work outside of Unity Editor mode?
|
||||
/*if (ItemAction.ShowDebugDisplayHit)
|
||||
{
|
||||
Vector3 position = Camera.main.transform.position;
|
||||
DebugLines.Create(null, attackingEntity.RootTransform, position + Origin.position, hitInfo_.hit.pos, new Color(1f, 0.5f, 1f), new Color(1f, 0f, 1f), ItemAction.DebugDisplayHitSize * 2f, ItemAction.DebugDisplayHitSize, ItemAction.DebugDisplayHitTime);
|
||||
}*/
|
||||
|
||||
// Nullify npc hire damage. Would be better to stop them from actually shooting/swinging in the first place
|
||||
if (attackingNPC != null && attackingNPC.Buffs.GetCustomVar("$Leader") > 0 && attackDetails_.damage == 0)
|
||||
{
|
||||
//Log.Out("ItemActionAttackPatches-Hit 7a, _attackDetails: " + _attackDetails.damage);
|
||||
return;
|
||||
}
|
||||
|
||||
ChunkCluster chunkCluster = world.ChunkClusters[hitInfo_.hit.clrIdx];
|
||||
|
||||
if (chunkCluster == null) return;
|
||||
|
||||
Vector3i vecHitBlockPos = hitInfo_.hit.blockPos;
|
||||
BlockValue blockValue = chunkCluster.GetBlock(vecHitBlockPos);
|
||||
|
||||
if (blockValue.isair && hitInfo_.hit.blockValue.Block.IsDistantDecoration && hitInfo_.hit.blockValue.damage >= hitInfo_.hit.blockValue.Block.MaxDamage - 1)
|
||||
{
|
||||
blockValue = hitInfo_.hit.blockValue;
|
||||
world.SetBlockRPC(vecHitBlockPos, blockValue);
|
||||
}
|
||||
|
||||
Block blockClass = blockValue.Block;
|
||||
|
||||
if (blockClass == null) return;
|
||||
|
||||
if (blockValue.ischild)
|
||||
{
|
||||
vecHitBlockPos = blockClass.multiBlockPos.GetParentPos(vecHitBlockPos, blockValue);
|
||||
blockValue = chunkCluster.GetBlock(vecHitBlockPos);
|
||||
blockClass = blockValue.Block;
|
||||
|
||||
if (blockClass == null) return;
|
||||
}
|
||||
|
||||
if (blockValue.isair) return;
|
||||
|
||||
float lphModifier = world.GetLandProtectionHardnessModifier(hitInfo_.hit.blockPos, attackingEntity, world.GetGameManager().GetPersistentLocalPlayer());
|
||||
if (world.IsWithinTraderArea(hitInfo_.hit.blockPos))
|
||||
{
|
||||
lphModifier = 0f;
|
||||
}
|
||||
|
||||
if (blockClass.blockMaterial.id == "Mbedrock")
|
||||
{
|
||||
lphModifier = 0f;
|
||||
}
|
||||
|
||||
if (lphModifier != 1f)
|
||||
{
|
||||
if (attackingEntity != null && attackMode_ != ItemActionAttack.EnumAttackMode.Simulate && attackingEntity is EntityPlayer && !damagingItemValue_.ItemClass.ignoreKeystoneSound && !damagingItemValue_.ToBlockValue().Block.IgnoreKeystoneOverlay)
|
||||
{
|
||||
attackingEntity.PlayOneShot("keystone_impact_overlay");
|
||||
}
|
||||
|
||||
if (lphModifier < 1f)
|
||||
{
|
||||
islphModLessThanOne = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (vecHitBlockPos != attackDetails_.hitPosition || lphModifier != attackDetails_.hardnessScale || blockValue.type != attackDetails_.blockBeingDamaged.type || (isInventoryItem && damagingItemValue_.SelectedAmmoTypeIndex != attackDetails_.ammoIndex))
|
||||
{
|
||||
float hardness = Mathf.Max(blockClass.GetHardness(), 0.1f) * lphModifier;
|
||||
float dmgPerHit = blockDamage_ * (damageMultiplier_ != null ? damageMultiplier_.Get(blockClass.blockMaterial.DamageCategory) : 1f);
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit BEFORE dmgPerHit: " + dmgPerHit);
|
||||
|
||||
if (attackingEntity != null)
|
||||
{
|
||||
dmgPerHit *= attackingEntity.GetBlockDamageScale();
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit MID dmgPerHit: " + dmgPerHit);
|
||||
|
||||
if (toolBonuses_ != null && toolBonuses_.Count > 0)
|
||||
{
|
||||
dmgPerHit *= CalculateHarvestToolDamageBonus(toolBonuses_, blockClass.itemsToDrop);
|
||||
attackDetails_.bHarvestTool = true;
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit AFTER dmgPerHit: " + dmgPerHit);
|
||||
//Log.Out("ItemActionAttackPatches-Hit hardness: " + hardness);
|
||||
//Log.Out("ItemActionAttackPatches-Hit (dmgPerHit / hardness): " + (dmgPerHit / hardness));
|
||||
|
||||
attackDetails_.damagePerHit = (!islphModLessThanOne) ? (dmgPerHit / hardness) : 0f;
|
||||
attackDetails_.damage = 0f;
|
||||
attackDetails_.hardnessScale = lphModifier;
|
||||
attackDetails_.hitPosition = vecHitBlockPos;
|
||||
attackDetails_.blockBeingDamaged = blockValue;
|
||||
|
||||
if (isInventoryItem)
|
||||
{
|
||||
attackDetails_.ammoIndex = damagingItemValue_.SelectedAmmoTypeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
attackDetails_.raycastHitPosition = hitInfo_.hit.blockPos;
|
||||
Block block2 = hitInfo_.fmcHit.blockValue.Block;
|
||||
lightValue = world.GetLightBrightness(hitInfo_.fmcHit.blockPos);
|
||||
particleColor = block2.GetColorForSide(hitInfo_.fmcHit.blockValue, hitInfo_.fmcHit.blockFace);
|
||||
particleCategory = block2.GetParticleForSide(hitInfo_.fmcHit.blockValue, hitInfo_.fmcHit.blockFace);
|
||||
MaterialBlock materialForSide = block2.GetMaterialForSide(hitInfo_.fmcHit.blockValue, hitInfo_.fmcHit.blockFace);
|
||||
surfaceCategory = materialForSide.SurfaceCategory;
|
||||
|
||||
//NEW CODE - START
|
||||
if (attackingEntity is EntityNPCRebirth)
|
||||
{
|
||||
staminaDamageMultiplier_ = 1;
|
||||
}
|
||||
//NEW CODE - END
|
||||
|
||||
float dmgPerHitStam = attackDetails_.damagePerHit * staminaDamageMultiplier_;
|
||||
//Log.Out($"dmgPerHitStam: {dmgPerHitStam}, damagePerHit: {attackDetails_.damagePerHit}, staminaDamageMultiplier_: {staminaDamageMultiplier_}");
|
||||
|
||||
if (attackingEntity != null)
|
||||
{
|
||||
string dmgCategory = materialForSide.DamageCategory ?? string.Empty;
|
||||
dmgPerHitStam = (int)EffectManager.GetValue(PassiveEffects.DamageModifier, damagingItemValue_, dmgPerHitStam, attackingEntity, null, FastTags<TagGroup.Global>.Parse(dmgCategory) | attackDetails_.WeaponTypeTag | hitInfo_.fmcHit.blockValue.Block.Tags);
|
||||
}
|
||||
|
||||
dmgPerHitStam = ItemActionAttack.DegradationModifier(dmgPerHitStam, weaponCondition_);
|
||||
dmgPerHitStam = (!islphModLessThanOne) ? Utils.FastMax(1f, dmgPerHitStam) : 0f;
|
||||
|
||||
attackDetails_.damage += dmgPerHitStam;
|
||||
attackDetails_.bKilled = false;
|
||||
attackDetails_.damageTotalOfTarget = blockValue.damage + attackDetails_.damage;
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit blockValue.damage: " + blockValue.damage);
|
||||
//Log.Out("ItemActionAttackPatches-Hit attackDetails_.damage: " + attackDetails_.damage);
|
||||
|
||||
if (attackDetails_.damage > 0f)
|
||||
{
|
||||
Vector3 _hitFaceCenter;
|
||||
Vector3 _hitFaceNormal;
|
||||
BlockFace blockFaceFromHitInfo = GameUtils.GetBlockFaceFromHitInfo(vecHitBlockPos, blockValue, hitInfo_.hitCollider, hitInfo_.hitTriangleIdx, out _hitFaceCenter, out _hitFaceNormal);
|
||||
int blockFaceTexture = chunkCluster.GetBlockFaceTexture(vecHitBlockPos, blockFaceFromHitInfo);
|
||||
int curBlockDmg = blockValue.damage; // the amount of damage this block has currently taken. 0 if block hp is 100%
|
||||
bool isOverkill = curBlockDmg >= blockClass.MaxDamage;
|
||||
int entityIdThatDamaged = ((ownedEntityId_ != -1 && ownedEntityId_ != -2) ? ownedEntityId_ : attackerEntityId_);
|
||||
|
||||
int blockDmgAmt = (attackMode_ != ItemActionAttack.EnumAttackMode.Simulate) ? blockClass.DamageBlock(world, chunkCluster.ClusterIdx, vecHitBlockPos, blockValue, (int)attackDetails_.damage, entityIdThatDamaged, attackDetails_, attackDetails_.bHarvestTool) : 0;
|
||||
//Log.Out($"blockVal curBlockDmg: {curBlockDmg}, blockDmgAmt: {blockDmgAmt}");
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit blockDmgAmt: " + blockDmgAmt);
|
||||
|
||||
if (blockDmgAmt == 0)
|
||||
{
|
||||
attackDetails_.damage = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
attackDetails_.damage -= blockDmgAmt - curBlockDmg;
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionAttackPatches-Hit curBlockDmg: " + curBlockDmg);
|
||||
//Log.Out("ItemActionAttackPatches-Hit attackDetails_.damage: " + attackDetails_.damage);
|
||||
|
||||
if (attackMode_ != ItemActionAttack.EnumAttackMode.Simulate && isNot_RNHOE && attackingEntity is EntityPlayerLocal && blockFaceTexture > 0 && blockClass.MeshIndex == 0 && (float)blockDmgAmt >= (float)blockClass.MaxDamage * 1f)
|
||||
{
|
||||
try
|
||||
{
|
||||
ParticleEffect particleEffect = new ParticleEffect("paint_block", hitInfo_.fmcHit.pos - Origin.position, Utils.BlockFaceToRotation(hitInfo_.fmcHit.blockFace), lightValue, particleColor, null, null);
|
||||
particleEffect.opqueTextureId = BlockTextureData.list[blockFaceTexture].TextureID;
|
||||
GameManager.Instance.SpawnParticleEffectClient(particleEffect, attackerEntityId_);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
attackDetails_.damageGiven = (!isOverkill) ? (blockDmgAmt - curBlockDmg) : 0;
|
||||
|
||||
// NEW CODE - START
|
||||
RebirthVariables.damageGiven = attackDetails_.damageGiven;
|
||||
|
||||
// NEW CODE - END
|
||||
|
||||
attackDetails_.damageMax = blockClass.MaxDamage;
|
||||
attackDetails_.bKilled = !isOverkill && blockDmgAmt >= blockClass.MaxDamage;
|
||||
attackDetails_.itemsToDrop = blockClass.itemsToDrop;
|
||||
attackDetails_.bBlockHit = true;
|
||||
attackDetails_.materialCategory = blockClass.blockMaterial.SurfaceCategory;
|
||||
|
||||
if (attackingEntity != null && attackMode_ != ItemActionAttack.EnumAttackMode.Simulate)
|
||||
{
|
||||
attackingEntity.MinEventContext.ItemValue = damagingItemValue_;
|
||||
attackingEntity.MinEventContext.BlockValue = blockValue;
|
||||
attackingEntity.MinEventContext.Tags = blockClass.Tags;
|
||||
if (attackDetails_.bKilled)
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfDestroyedBlock, isInventoryItem);
|
||||
attackingEntity.NotifyDestroyedBlock(attackDetails_);
|
||||
}
|
||||
else
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfDamagedBlock, isInventoryItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Hit -> Entity
|
||||
else if (hitInfo_.tag.StartsWith("E_"))
|
||||
{
|
||||
string bodyPartName;
|
||||
Entity hitEntity = ItemActionAttack.FindHitEntityNoTagCheck(hitInfo_, out bodyPartName);
|
||||
|
||||
// need to check CanDamageEntity to see if it's related to no hit bug
|
||||
if (hitEntity == null || hitEntity.entityId == attackerEntityId_ || !hitEntity.CanDamageEntity(attackerEntityId_)) return;
|
||||
|
||||
EntityAlive hitEntityAlive = hitEntity as EntityAlive;
|
||||
|
||||
if (attackingEntity is EntityNPCRebirth && attackingEntity.HasAnyTags(FastTags<TagGroup.Global>.Parse("ranged")))
|
||||
{
|
||||
int npcLevel = (int)attackingEntity.Buffs.GetCustomVar("$FR_NPC_Level");
|
||||
|
||||
int headshotChance = npcLevel - 1;
|
||||
|
||||
int random = GameManager.Instance.World.GetGameRandom().RandomRange(1, 11);
|
||||
|
||||
string tagName = "E_BP_Head";
|
||||
|
||||
if (headshotChance < random)
|
||||
{
|
||||
tagName = RebirthVariables.bodyTags[random];
|
||||
}
|
||||
|
||||
float numAccuracyModifier = float.Parse(RebirthVariables.customRangedNPCAccuracyModifier) / 100;
|
||||
|
||||
float baseValue = 100 * numAccuracyModifier;
|
||||
|
||||
int numMagazineSize = 0;
|
||||
float roundsPerMinute = 60;
|
||||
|
||||
if (numMagazineSize == 0)
|
||||
{
|
||||
ItemActionRanged myAction = null;
|
||||
|
||||
myAction = (ItemActionRanged)attackingEntity.inventory.holdingItem.Actions[1];
|
||||
ItemActionData _actionData = attackingEntity.inventory.holdingItemData.actionData[1];
|
||||
ItemActionRanged.ItemActionDataRanged itemActionDataRanged = (ItemActionRanged.ItemActionDataRanged)_actionData;
|
||||
float myDelay = 60f / EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemActionDataRanged.invData.itemValue, 60f / itemActionDataRanged.OriginalDelay, attackingEntity);
|
||||
roundsPerMinute = 60 / myDelay;
|
||||
|
||||
numMagazineSize = (int)EffectManager.GetValue(PassiveEffects.MagazineSize, itemActionDataRanged.invData.itemValue, myAction.BulletsPerMagazine, attackingEntity);
|
||||
}
|
||||
|
||||
if (numMagazineSize > 1)
|
||||
{
|
||||
baseValue = 60 * numAccuracyModifier;
|
||||
int baseRoundsPerMinute = 60;
|
||||
|
||||
if (roundsPerMinute > baseRoundsPerMinute)
|
||||
{
|
||||
float multiplier = 1 - ((roundsPerMinute / baseRoundsPerMinute) / 15);
|
||||
|
||||
baseValue *= multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
float missShotChance = baseValue + (npcLevel * 0.3f * numAccuracyModifier) * 10;
|
||||
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget level: " + attackingEntity.Buffs.GetCustomVar("$FR_NPC_Level"));
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget A random: " + random);
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget missShotChance: " + missShotChance);
|
||||
|
||||
random = GameManager.Instance.World.GetGameRandom().RandomRange(1, 101);
|
||||
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget B random: " + random);
|
||||
|
||||
if (missShotChance < random)
|
||||
{
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget MISS");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hitEntityAlive is EntityPlayer)
|
||||
{
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget EntityName: " + hitEntityAlive.EntityName);
|
||||
|
||||
ProgressionValue progressionValue = hitEntityAlive.Progression.GetProgressionValue("perkDodge");
|
||||
|
||||
bool hitTarget = true;
|
||||
|
||||
if (progressionValue != null)
|
||||
{
|
||||
float chance = progressionValue.level * 5f;
|
||||
random = GameManager.Instance.World.GetGameRandom().RandomRange(0, 101);
|
||||
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget progressionValue.level: " + progressionValue.level);
|
||||
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget chance: " + chance);
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget random: " + random);
|
||||
|
||||
if (random < chance)
|
||||
{
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget EXIT");
|
||||
hitTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hitTarget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 uvHit = Vector2.zero;
|
||||
MeshCollider meshCollider = Voxel.phyxRaycastHit.collider as MeshCollider;
|
||||
|
||||
if (meshCollider != null && meshCollider.sharedMesh != null && meshCollider.sharedMesh.HasVertexAttribute(UnityEngine.Rendering.VertexAttribute.TexCoord0))
|
||||
{
|
||||
uvHit = Voxel.phyxRaycastHit.textureCoord;
|
||||
}
|
||||
|
||||
DamageSourceEntity damageSourceEntity = new DamageSourceEntity(EnumDamageSource.External, damageType_, attackerEntityId_, hitInfo_.ray.direction, hitInfo_.transform.name, hitInfo_.hit.pos, uvHit);
|
||||
damageSourceEntity.AttackingItem = damagingItemValue_;
|
||||
damageSourceEntity.DismemberChance = dismemberChance_;
|
||||
damageSourceEntity.CreatorEntityId = ownedEntityId_;
|
||||
bool isCriticalHit = attackDetails_.isCriticalHit;
|
||||
int entityDamage = (int)entityDamage_;
|
||||
//Log.Out($"Entity Damage: {entityDamage}, attack mode: {attackMode_}");
|
||||
|
||||
if (attackingEntity != null && hitEntityAlive != null)
|
||||
{
|
||||
FastTags<TagGroup.Global> fastTags = FastTags<TagGroup.Global>.none;
|
||||
if (hitEntityAlive.Health > 0)
|
||||
{
|
||||
fastTags = FastTags<TagGroup.Global>.Parse(damageSourceEntity.GetEntityDamageEquipmentSlotGroup(hitEntityAlive).ToStringCached());
|
||||
}
|
||||
entityDamage = (int)EffectManager.GetValue(PassiveEffects.DamageModifier, damagingItemValue_, entityDamage, attackingEntity, null, fastTags | attackDetails_.WeaponTypeTag | hitEntityAlive.EntityClass.Tags);
|
||||
entityDamage = (int)EffectManager.GetValue(PassiveEffects.InternalDamageModifier, damagingItemValue_, entityDamage, hitEntityAlive, null, fastTags | damagingItemValue_.ItemClass.ItemTags);
|
||||
}
|
||||
|
||||
if (!hitEntityAlive || hitEntityAlive.Health > 0)
|
||||
{
|
||||
entityDamage = Utils.FastMax(1, DifficultyModifier(entityDamage, world.GetEntity(attackerEntityId_), hitEntity));
|
||||
}
|
||||
else if (toolBonuses_ != null)
|
||||
{
|
||||
entityDamage = (int)(entityDamage * CalculateHarvestToolDamageBonus(toolBonuses_, EntityClass.list[hitEntity.entityClass].itemsToDrop));
|
||||
}
|
||||
|
||||
// rebirth genetic level strengh mod
|
||||
if (hitEntityAlive is EntityPlayer)
|
||||
{
|
||||
bool bMelee = hitEntityAlive.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("melee");
|
||||
if (bMelee)
|
||||
{
|
||||
//bool bSalvage = hitEntityAlive.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("perkSalvageOperations"); // Unused at the moment?
|
||||
entityDamage += entityDamage * RebirthUtilities.GetGeneticLevel("Strength") * 5 / 100;
|
||||
}
|
||||
}
|
||||
|
||||
bool hitEntityIsDead = hitEntity.IsDead();
|
||||
int corpseHP = (hitEntityAlive != null) ? hitEntityAlive.DeathHealth : 0;
|
||||
|
||||
if (attackMode_ != ItemActionAttack.EnumAttackMode.Simulate)
|
||||
{
|
||||
if (attackingEntity != null)
|
||||
{
|
||||
MinEventParams minEventContext = attackingEntity.MinEventContext;
|
||||
minEventContext.Other = hitEntityAlive;
|
||||
minEventContext.ItemValue = damagingItemValue_;
|
||||
minEventContext.StartPosition = hitInfo_.ray.origin;
|
||||
}
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer &&
|
||||
(attackingEntity as EntityPlayer == null || !attackingEntity.isEntityRemote) &&
|
||||
hitEntity.isEntityRemote && rangeCheckedAction_ != null)
|
||||
{
|
||||
EntityPlayer hitPlayer = hitEntity as EntityPlayer;
|
||||
|
||||
if (hitPlayer != null) // if the target is a player
|
||||
{
|
||||
isNotPlayerHit = false;
|
||||
|
||||
// to do: check entity height and get a different ray origin. look ray might be too high for certain taller entitites that would cause them to consecutively miss shorter entities
|
||||
// nevermind, wrong place...
|
||||
Ray lookRay = attackingEntity.GetLookRay();
|
||||
lookRay.origin -= lookRay.direction * 0.15f;
|
||||
float maxRange = Utils.FastMax(rangeCheckedAction_.Range, rangeCheckedAction_.BlockRange) * ItemActionAttack.attackRangeMultiplier; // Why are we multiplying by 1f?
|
||||
string buffActionsContext = null;
|
||||
List<string> buffActions = buffActions_;
|
||||
|
||||
if (buffActions != null)
|
||||
{
|
||||
if (hitEntityAlive != null)
|
||||
{
|
||||
buffActionsContext = ((bodyPartName != null) ? GameUtils.GetChildTransformPath(hitEntity.transform, hitInfo_.transform) : null);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffActions = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (attackingEntity != null)
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfAttackedOther, isInventoryItem);
|
||||
if (hitEntityAlive != null && hitEntityAlive.RecordedDamage.Strength > 0)
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfDamagedOther, isInventoryItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hitEntityIsDead && hitEntity.IsDead() && attackingEntity != null)
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfKilledOther, isInventoryItem);
|
||||
AddKillExpNPC(attackingNPC, hitEntityAlive);
|
||||
}
|
||||
|
||||
surfaceCategory = ((!hitEntityAlive || hitEntityAlive.RecordedDamage.ArmorDamage <= hitEntityAlive.RecordedDamage.Strength) ? EntityClass.list[hitEntity.entityClass].Properties.Values["SurfaceCategory"] : "metal");
|
||||
particleCategory = surfaceCategory;
|
||||
lightValue = hitEntity.GetLightBrightness();
|
||||
string particleEffectName = $"impact_{attackingDeviceMadeOf_}_on_{particleCategory}";
|
||||
string soundName = ((surfaceCategory != null) ? $"{attackingDeviceMadeOf_}hit{surfaceCategory}" : null);
|
||||
|
||||
if (hitSoundOverrides_ != null && hitSoundOverrides_.ContainsKey(surfaceCategory))
|
||||
{
|
||||
soundName = hitSoundOverrides_[surfaceCategory];
|
||||
}
|
||||
|
||||
ParticleEffect particleEffect2 = new ParticleEffect(particleEffectName, hitInfo_.fmcHit.pos, Utils.BlockFaceToRotation(hitInfo_.fmcHit.blockFace), lightValue, particleColor, soundName, null);
|
||||
hitPlayer.ServerNetSendRangeCheckedDamage(lookRay.origin, maxRange, damageSourceEntity, entityDamage, isCriticalHit, buffActions, buffActionsContext, particleEffect2);
|
||||
//Log.Out($"Rebirth Hit ServerNetSend - attackingEntity: {attackingEntity}, hitEntity: {hitEntity} entityDamage: {entityDamage}, stacktrace: {System.Environment.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
if (isNotPlayerHit)
|
||||
{
|
||||
// rebirth mod to recalculate damage
|
||||
if (hitInfo_.tag.Equals("E_BP_Head"))
|
||||
{
|
||||
EntityPlayer sourcePlayer = world.GetEntity(damageSourceEntity.getEntityId()) as EntityPlayer;
|
||||
|
||||
if (sourcePlayer != null)
|
||||
{
|
||||
bool isLongRangeWeapon = sourcePlayer.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("WeaponTier3LongRangeRifles"));
|
||||
|
||||
if (isLongRangeWeapon)
|
||||
{
|
||||
int activeClassID = (int)sourcePlayer.Buffs.GetCustomVar("$ActiveClass_FR");
|
||||
|
||||
if (RebirthUtilities.IsClassActive(activeClassID))
|
||||
{
|
||||
ProgressionValue progressionValue = sourcePlayer.Progression.GetProgressionValue("FuriousRamsayPerkLongRangeRifles");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
int progressionLevel = progressionValue.Level;
|
||||
float damageMultiplier = progressionLevel * 0.025f;
|
||||
bool isSingShotWeapon = sourcePlayer.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("SingleShot"));
|
||||
|
||||
if (isSingShotWeapon) damageMultiplier *= 2f;
|
||||
entityDamage *= (int)(1f + damageMultiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int dmgResult = hitEntity.DamageEntity(damageSourceEntity, entityDamage, isCriticalHit);
|
||||
//Log.Out($"Rebirth Hit - attackingEntity: {attackingEntity}, hitEntity: {hitEntity} dmg entity result: {dmgResult}, stacktrace: {System.Environment.StackTrace}");
|
||||
|
||||
if (dmgResult != -1 && attackingEntity != null)
|
||||
{
|
||||
MinEventParams minEventContext2 = attackingEntity.MinEventContext;
|
||||
minEventContext2.Other = hitEntityAlive;
|
||||
minEventContext2.ItemValue = damagingItemValue_;
|
||||
minEventContext2.StartPosition = hitInfo_.ray.origin;
|
||||
|
||||
if (ownedEntityId_ != -1)
|
||||
{
|
||||
damagingItemValue_.FireEvent(MinEventTypes.onSelfAttackedOther, attackingEntity.MinEventContext);
|
||||
}
|
||||
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfAttackedOther, isInventoryItem);
|
||||
|
||||
if (hitEntityAlive != null && hitEntityAlive.RecordedDamage.Strength > 0)
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfDamagedOther, isInventoryItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hitEntityIsDead && hitEntity.IsDead() && attackingEntity != null)
|
||||
{
|
||||
attackingEntity.FireEvent(MinEventTypes.onSelfKilledOther, isInventoryItem);
|
||||
AddKillExpNPC(attackingNPC, hitEntityAlive);
|
||||
}
|
||||
|
||||
if (dmgResult != -1 && hitEntityAlive != null && buffActions_ != null && buffActions_.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < buffActions_.Count; i++)
|
||||
{
|
||||
BuffClass buff = BuffManager.GetBuff(buffActions_[i]);
|
||||
if (buff != null)
|
||||
{
|
||||
float originalValue = 1f;
|
||||
originalValue = EffectManager.GetValue(PassiveEffects.BuffProcChance, null, originalValue, attackingEntity, null, FastTags<TagGroup.Global>.Parse(buff.Name));
|
||||
if (hitEntityAlive.rand.RandomFloat <= originalValue)
|
||||
{
|
||||
hitEntityAlive.Buffs.AddBuff(buffActions_[i], attackingEntity.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
surfaceCategory = (!hitEntityAlive || hitEntityAlive.RecordedDamage.ArmorDamage <= hitEntityAlive.RecordedDamage.Strength) ? EntityClass.list[hitEntity.entityClass].Properties.Values["SurfaceCategory"] : "metal";
|
||||
particleCategory = surfaceCategory;
|
||||
lightValue = hitEntity.GetLightBrightness();
|
||||
EntityPlayer attackingPlayer = attackingEntity as EntityPlayer;
|
||||
|
||||
if (attackingPlayer != null) // The attacker is a Player
|
||||
{
|
||||
if (hitEntityIsDead && hitEntity.IsDead() && (bool)hitEntityAlive && hitEntityAlive.DeathHealth + entityDamage > -1 * EntityClass.list[hitEntity.entityClass].DeadBodyHitPoints)
|
||||
{
|
||||
attackDetails_.damageTotalOfTarget = -1 * hitEntityAlive.DeathHealth;
|
||||
attackDetails_.damageGiven = corpseHP + Mathf.Min(EntityClass.list[hitEntity.entityClass].DeadBodyHitPoints, Mathf.Abs(hitEntityAlive.DeathHealth));
|
||||
attackDetails_.damageMax = EntityClass.list[hitEntity.entityClass].DeadBodyHitPoints;
|
||||
attackDetails_.bKilled = -1 * hitEntityAlive.DeathHealth >= EntityClass.list[hitEntity.entityClass].DeadBodyHitPoints;
|
||||
attackDetails_.itemsToDrop = EntityClass.list[hitEntity.entityClass].itemsToDrop;
|
||||
attackDetails_.entityHit = hitEntity;
|
||||
attackDetails_.materialCategory = surfaceCategory;
|
||||
}
|
||||
|
||||
if (!hitEntityIsDead && (hitEntityAlive.IsDead() || hitEntityAlive.Health <= 0) && EntityClass.list.ContainsKey(hitEntity.entityClass))
|
||||
{
|
||||
if ((flags_ & 2) > 0)
|
||||
{
|
||||
float value = EffectManager.GetValue(PassiveEffects.ElectricalTrapXP, attackingPlayer.inventory.holdingItemItemValue, 0f, attackingPlayer);
|
||||
if (value > 0f)
|
||||
{
|
||||
if (!bypassXP)
|
||||
{
|
||||
attackingPlayer.AddKillXP(hitEntityAlive, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bypassXP)
|
||||
{
|
||||
attackingPlayer.AddKillXP(hitEntityAlive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hitEntity is EntityDrone)
|
||||
{
|
||||
attackDetails_.entityHit = hitEntity;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if ((flags_ & 8) > 0)
|
||||
{
|
||||
isNot_RNHOE = false;
|
||||
}
|
||||
|
||||
// Spawn Particle Effect
|
||||
if (isNotPlayerHit && attackMode_ != ItemActionAttack.EnumAttackMode.Simulate && isNot_RNHOE && particleCategory != null && ((attackDetails_.bBlockHit && !attackDetails_.bKilled) || !attackDetails_.bBlockHit))
|
||||
{
|
||||
string particleName = $"impact_{attackingDeviceMadeOf_}_on_{particleCategory}";
|
||||
|
||||
if (attackMode_ == ItemActionAttack.EnumAttackMode.RealAndHarvesting && (flags_ & 4) > 0 && ParticleEffect.IsAvailable(particleName + "_harvest"))
|
||||
{
|
||||
particleName += "_harvest";
|
||||
}
|
||||
|
||||
string soundName2 = ((surfaceCategory != null) ? $"{attackingDeviceMadeOf_}hit{surfaceCategory}" : null);
|
||||
if (hitSoundOverrides_ != null && hitSoundOverrides_.ContainsKey(surfaceCategory))
|
||||
{
|
||||
soundName2 = hitSoundOverrides_[surfaceCategory];
|
||||
}
|
||||
|
||||
world.GetGameManager().SpawnParticleEffectServer(new ParticleEffect(particleName, hitInfo_.fmcHit.pos, Utils.BlockFaceToRotation(hitInfo_.fmcHit.blockFace), lightValue, particleColor, soundName2, null), attackerEntityId_, _forceCreation: false, _worldSpawn: true);
|
||||
}
|
||||
|
||||
// Update the attacking entity's toolbelt
|
||||
if ((flags_ & 1) > 0 && attackingEntity != null && attackingEntity.inventory != null)
|
||||
{
|
||||
attackingEntity.inventory.CallOnToolbeltChangedInternal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int DifficultyModifier(int _strength, Entity _attacker, Entity _target)
|
||||
{
|
||||
if (_attacker == null || _target == null
|
||||
|| (_attacker.IsClientControlled() && _target.IsClientControlled())
|
||||
|| (!_attacker.IsClientControlled() && !_target.IsClientControlled())) return _strength;
|
||||
|
||||
int difficultyLevel = GameStats.GetInt(EnumGameStats.GameDifficulty);
|
||||
if (_attacker.IsClientControlled())
|
||||
{
|
||||
switch (difficultyLevel)
|
||||
{
|
||||
case 0:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 2f);
|
||||
break;
|
||||
case 1:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 1.5f);
|
||||
break;
|
||||
case 3:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 0.83f);
|
||||
break;
|
||||
case 4:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 0.66f);
|
||||
break;
|
||||
case 5:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 0.5f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (difficultyLevel)
|
||||
{
|
||||
case 0:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 0.5f);
|
||||
break;
|
||||
case 1:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 0.75f);
|
||||
break;
|
||||
case 3:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 1.5f);
|
||||
break;
|
||||
case 4:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 2f);
|
||||
break;
|
||||
case 5:
|
||||
_strength = Mathf.RoundToInt((float)_strength * 2.5f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return _strength;
|
||||
}
|
||||
|
||||
static float CalculateHarvestToolDamageBonus(Dictionary<string, ItemActionAttack.Bonuses> _toolBonuses, Dictionary<EnumDropEvent, List<Block.SItemDropProb>> _harvestItems)
|
||||
{
|
||||
if (!_harvestItems.ContainsKey(EnumDropEvent.Harvest)) return 1f;
|
||||
|
||||
List<Block.SItemDropProb> list = _harvestItems[EnumDropEvent.Harvest];
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (list[i].toolCategory != null && _toolBonuses.ContainsKey(list[i].toolCategory))
|
||||
{
|
||||
return _toolBonuses[list[i].toolCategory].Damage;
|
||||
}
|
||||
}
|
||||
|
||||
return 1f;
|
||||
}
|
||||
|
||||
static void AddKillExpNPC(EntityNPCRebirth attackingNPC, EntityAlive entityTarget)
|
||||
{
|
||||
if (attackingNPC == null || entityTarget == null) return;
|
||||
|
||||
int leaderID = RebirthUtilities.GetLeader(attackingNPC);
|
||||
|
||||
if (leaderID <= 0) return;
|
||||
|
||||
var leaderPlayer = attackingNPC.world.GetEntity(leaderID) as EntityPlayer;
|
||||
|
||||
if (leaderPlayer == null)
|
||||
{
|
||||
Log.Warning($"NPC has leader, unable to locate the player. Leader id: {leaderID}");
|
||||
return;
|
||||
}
|
||||
|
||||
float distanceEntity = leaderPlayer.GetDistance(attackingNPC);
|
||||
|
||||
if (distanceEntity > _KillExpMaxDist) return; // too far away
|
||||
|
||||
bool isNaturalSelectionCountingOn = RebirthUtilities.IsNaturalSelectionCountingOn();
|
||||
|
||||
/*if (isNaturalSelectionCountingOn)
|
||||
{
|
||||
Log.Out($"ItemActionAttackRebirth-AddKillExpNPC $NaturalSelection_FR: {leaderPlayer.Buffs.GetCustomVar("$NaturalSelection_FR")}");
|
||||
|
||||
int numNS = (int)leaderPlayer.Buffs.GetCustomVar("$NaturalSelection_FR") + 1;
|
||||
leaderPlayer.Buffs.SetCustomVar("$NaturalSelection_FR", numNS);
|
||||
RebirthVariables.localConstants["$varFuriousRamsayTheyGrowStrongerKills_Cst"] = numNS;
|
||||
}*/
|
||||
|
||||
float expMod = _NPCKillExpMod;
|
||||
|
||||
if (RebirthUtilities.IsHordeNight()) expMod *= RebirthVariables.hordeNightXPMultiplier;
|
||||
|
||||
float partyMultiplierOption = 1; // float.Parse(RebirthVariables.customPartyXPMultiplier) / 100;
|
||||
expMod = expMod * partyMultiplierOption;
|
||||
|
||||
float experienceGained = entityTarget.ExperienceValue * expMod;
|
||||
|
||||
//Log.Out($"ItemActionAttackRebirth-AddKillExpNPC entity xp: {entityTarget.ExperienceValue}");
|
||||
//Log.Out($"ItemActionAttackRebirth-AddKillExpNPC partyMultiplierOption: {partyMultiplierOption}");
|
||||
//Log.Out($"ItemActionAttackRebirth-AddKillExpNPC _NPCKillExpMod: {_NPCKillExpMod}");
|
||||
//Log.Out($"ItemActionAttackRebirth-AddKillExpNPC _HordeNightExpMod: {RebirthVariables.hordeNightXPMultiplier}");
|
||||
//Log.Out($"ItemActionAttackRebirth-AddKillExpNPC expMod: {expMod}");
|
||||
//Log.Out($"ItemActionAttackRebirth-AddKillExpNPC experienceGained: {experienceGained}");
|
||||
|
||||
leaderPlayer.AddKillXP(entityTarget, expMod);
|
||||
leaderPlayer.Progression.bProgressionStatsChanged = true;
|
||||
leaderPlayer.bPlayerStatsChanged = true;
|
||||
|
||||
if (entityTarget is EntityPlayer)
|
||||
leaderPlayer.KilledPlayers++;
|
||||
else
|
||||
leaderPlayer.KilledZombies++;
|
||||
}
|
||||
}
|
||||
|
||||
431
Scripts/ItemAction/ItemActionExchangeItemRebirth.cs
Normal file
431
Scripts/ItemAction/ItemActionExchangeItemRebirth.cs
Normal file
@@ -0,0 +1,431 @@
|
||||
using Audio;
|
||||
|
||||
public class ItemActionExchangeItemRebirth : ItemActionExchangeItem
|
||||
{
|
||||
protected int removeWater = 0;
|
||||
private bool isFocusingBlock(WorldRayHitInfo _hitInfo)
|
||||
{
|
||||
for (int i = 0; i < this.focusedBlocks.Count; i++)
|
||||
{
|
||||
BlockValue other = this.focusedBlocks[i];
|
||||
if (_hitInfo.hit.blockValue.Equals(other))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction START");
|
||||
if (!_bReleased)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction 1");
|
||||
return;
|
||||
}
|
||||
if (_actionData.lastUseTime > 0f)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction 2");
|
||||
return;
|
||||
}
|
||||
ItemInventoryData invData = _actionData.invData;
|
||||
Ray lookRay = invData.holdingEntity.GetLookRay();
|
||||
lookRay.origin += lookRay.direction.normalized * 0.5f;
|
||||
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction EntityName: " + invData.holdingEntity.EntityName);
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction Voxel.voxelRayHitInfo.bHitValid: " + Voxel.voxelRayHitInfo.bHitValid);
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction this.isFocusingBlock(Voxel.voxelRayHitInfo): " + this.isFocusingBlock(Voxel.voxelRayHitInfo));
|
||||
|
||||
if (!Voxel.Raycast(invData.world, lookRay, Constants.cDigAndBuildDistance, -538480645, 4095, 0.0f))
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction 3");
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (!Voxel.Raycast(invData.world, lookRay, Constants.cDigAndBuildDistance, -538480645, 4095, 0f))
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction 3");
|
||||
return;
|
||||
}*/
|
||||
if (Voxel.voxelRayHitInfo.hit.waterValue.HasMass())
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction 4");
|
||||
this.removeWater = _actionData.invData.holdingEntity.inventory.holdingCount;
|
||||
this.hitLiquidBlock = Voxel.voxelRayHitInfo.hit.blockValue;
|
||||
this.hitLiquidPos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
_actionData.lastUseTime = Time.time;
|
||||
invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Voxel.voxelRayHitInfo.bHitValid && this.isFocusingBlock(Voxel.voxelRayHitInfo))
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction Block Name: " + Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName());
|
||||
if ((Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayWaterTank" || Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayDewCollector") && _actionData.invData.item.GetItemName() == "bucketRiverWater")
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction A");
|
||||
Chunk chunk = (Chunk)invData.world.GetChunkFromWorldPos(Voxel.voxelRayHitInfo.hit.blockPos);
|
||||
TileEntityWaterTankRebirth tileEntity = invData.world.GetTileEntity(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos) as TileEntityWaterTankRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
int waterMax = tileEntity.waterMax;
|
||||
if (Voxel.voxelRayHitInfo.hit.blockValue.Block.Properties.Values.ContainsKey("MaxWater"))
|
||||
{
|
||||
waterMax = Int16.Parse(Voxel.voxelRayHitInfo.hit.blockValue.Block.Properties.Values["MaxWater"]);
|
||||
}
|
||||
|
||||
if (tileEntity.waterCount == waterMax)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeWater = 1;
|
||||
this.hitLiquidBlock = Voxel.voxelRayHitInfo.hit.blockValue;
|
||||
this.hitLiquidPos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
_actionData.lastUseTime = Time.time;
|
||||
invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
int waterCount = tileEntity.waterCount + 200;
|
||||
if (waterCount > waterMax)
|
||||
{
|
||||
waterCount = waterMax;
|
||||
}
|
||||
|
||||
if (!invData.world.IsRemote())
|
||||
{
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayWaterTank" || Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayDewCollector") &&
|
||||
(_actionData.invData.item.GetItemName() == "drinkJarRiverWater" ||
|
||||
_actionData.invData.item.GetItemName() == "drinkJarBoiledWater" ||
|
||||
_actionData.invData.item.GetItemName() == "drinkJarPureMineralWater")
|
||||
)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B");
|
||||
Chunk chunk = (Chunk)invData.world.GetChunkFromWorldPos(Voxel.voxelRayHitInfo.hit.blockPos);
|
||||
TileEntityWaterTankRebirth tileEntity = invData.world.GetTileEntity(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos) as TileEntityWaterTankRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B1");
|
||||
int waterMax = tileEntity.waterMax;
|
||||
if (Voxel.voxelRayHitInfo.hit.blockValue.Block.Properties.Values.ContainsKey("MaxWater"))
|
||||
{
|
||||
waterMax = Int16.Parse(Voxel.voxelRayHitInfo.hit.blockValue.Block.Properties.Values["MaxWater"]);
|
||||
}
|
||||
|
||||
if (tileEntity.waterCount == waterMax)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B2");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B3");
|
||||
this.hitLiquidBlock = Voxel.voxelRayHitInfo.hit.blockValue;
|
||||
this.hitLiquidPos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
_actionData.lastUseTime = Time.time;
|
||||
invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B4");
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
|
||||
int numWater = _actionData.invData.holdingEntity.inventory.holdingCount;
|
||||
int missingWater = waterMax - tileEntity.waterCount;
|
||||
this.removeWater = 0;
|
||||
|
||||
if (numWater >= missingWater)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B5");
|
||||
this.removeWater = missingWater;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction B6");
|
||||
this.removeWater = numWater;
|
||||
}
|
||||
|
||||
int waterCount = tileEntity.waterCount + this.removeWater;
|
||||
|
||||
if (!invData.world.IsRemote())
|
||||
{
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayWaterTank" || Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayDewCollector") &&
|
||||
_actionData.invData.item.GetItemName() == "drinkJarEmpty"
|
||||
)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C");
|
||||
Chunk chunk = (Chunk)invData.world.GetChunkFromWorldPos(Voxel.voxelRayHitInfo.hit.blockPos);
|
||||
TileEntityWaterTankRebirth tileEntity = invData.world.GetTileEntity(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos) as TileEntityWaterTankRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C1");
|
||||
if (tileEntity.waterCount == 0)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C2");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C3");
|
||||
this.hitLiquidBlock = Voxel.voxelRayHitInfo.hit.blockValue;
|
||||
this.hitLiquidPos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
_actionData.lastUseTime = Time.time;
|
||||
invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
|
||||
int numEmpty = _actionData.invData.holdingEntity.inventory.holdingCount;
|
||||
|
||||
int missingWater = 0;
|
||||
|
||||
if (numEmpty > tileEntity.waterCount)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C4");
|
||||
missingWater = tileEntity.waterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C5");
|
||||
missingWater = numEmpty;
|
||||
}
|
||||
|
||||
this.removeWater = missingWater;
|
||||
|
||||
int waterCount = tileEntity.waterCount - this.removeWater;
|
||||
|
||||
if (!invData.world.IsRemote())
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction C6");
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayWaterTank" || Voxel.voxelRayHitInfo.hit.blockValue.Block.GetBlockName() == "FuriousRamsayDewCollector") &&
|
||||
_actionData.invData.item.GetItemName() == "bucketEmpty"
|
||||
)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction D");
|
||||
Chunk chunk = (Chunk)invData.world.GetChunkFromWorldPos(Voxel.voxelRayHitInfo.hit.blockPos);
|
||||
TileEntityWaterTankRebirth tileEntity = invData.world.GetTileEntity(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos) as TileEntityWaterTankRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity.waterCount < 200)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(invData.holdingEntity as EntityPlayerLocal, Localization.Get("ttNeedMoreBucketWater"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hitLiquidBlock = Voxel.voxelRayHitInfo.hit.blockValue;
|
||||
this.hitLiquidPos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
_actionData.lastUseTime = Time.time;
|
||||
invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
|
||||
int numEmpty = 200;
|
||||
|
||||
int missingWater = 0;
|
||||
|
||||
if (numEmpty > tileEntity.waterCount)
|
||||
{
|
||||
missingWater = tileEntity.waterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
missingWater = numEmpty;
|
||||
}
|
||||
|
||||
this.removeWater = missingWater;
|
||||
|
||||
int waterCount = tileEntity.waterCount - this.removeWater;
|
||||
|
||||
if (!invData.world.IsRemote())
|
||||
{
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos, waterCount));
|
||||
tileEntity.waterCount = waterCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction E");
|
||||
|
||||
Chunk chunk = (Chunk)invData.world.GetChunkFromWorldPos(Voxel.voxelRayHitInfo.hit.blockPos);
|
||||
TileEntityLootContainer tileEntity = invData.world.GetTileEntity(chunk.ClrIdx, Voxel.voxelRayHitInfo.hit.blockPos) as TileEntityLootContainer;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction E1");
|
||||
if (tileEntity.bPlayerStorage)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-ExecuteAction E2");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(invData.holdingEntity as EntityPlayerLocal, Localization.Get("ttNoPlumbing"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*PrefabInstance prefabFromWorldPos = GameManager.Instance.GetDynamicPrefabDecorator().GetPrefabFromWorldPos((int)Voxel.voxelRayHitInfo.hit.blockPos.x, (int)Voxel.voxelRayHitInfo.hit.blockPos.z);
|
||||
if (prefabFromWorldPos != null)
|
||||
{
|
||||
// RETURNS NULL FOR country_junkyard_02
|
||||
// part_appliance_pile-02 (toilet)
|
||||
Log.Out("ItemActionExchangeItemRebirth-ExecuteAction E3 prefabFromWorldPos: " + prefabFromWorldPos.name);
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(invData.holdingEntity as EntityPlayerLocal, Localization.Get("ttNoPlumbing"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}*/
|
||||
|
||||
this.removeWater = _actionData.invData.holdingEntity.inventory.holdingCount;
|
||||
this.hitLiquidBlock = Voxel.voxelRayHitInfo.hit.blockValue;
|
||||
this.hitLiquidPos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
_actionData.lastUseTime = Time.time;
|
||||
invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Voxel.voxelRayHitInfo.bHitValid && !this.isFocusingBlock(Voxel.voxelRayHitInfo))
|
||||
{
|
||||
if (Voxel.voxelRayHitInfo.hit.blockValue.Block.Properties.Values.ContainsKey("WaterSource"))
|
||||
{
|
||||
string WaterSource = Voxel.voxelRayHitInfo.hit.blockValue.Block.Properties.Values["WaterSource"];
|
||||
if (WaterSource == "False")
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(invData.holdingEntity as EntityPlayerLocal, Localization.Get("ttNoPlumbing"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHoldingUpdate(ItemActionData _actionData)
|
||||
{
|
||||
////Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate START");
|
||||
if (_actionData.lastUseTime == 0f || this.IsActionRunning(_actionData))
|
||||
{
|
||||
////Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate 1");
|
||||
return;
|
||||
}
|
||||
|
||||
QuestEventManager.Current.ExchangedFromItem(_actionData.invData.itemStack);
|
||||
ItemValue item = ItemClass.GetItem(this.changeItemToItem, false);
|
||||
|
||||
if (this.removeWater > 0)
|
||||
{
|
||||
//Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate 2");
|
||||
EntityPlayerLocal player = (EntityPlayerLocal)_actionData.invData.holdingEntity;
|
||||
int itemIndex = player.inventory.GetFocusedItemIdx();
|
||||
|
||||
int decrease = 1;
|
||||
|
||||
if (!_actionData.invData.item.GetItemName().Contains("bucket"))
|
||||
{
|
||||
decrease = this.removeWater;
|
||||
}
|
||||
|
||||
//Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate decrease: " + decrease);
|
||||
|
||||
int numItems = player.inventory.DecItem(_actionData.invData.holdingEntity.inventory.holdingItemItemValue, decrease, false);
|
||||
|
||||
//Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate numItems: " + numItems);
|
||||
|
||||
//Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate this.changeItemToItem: " + this.changeItemToItem);
|
||||
ItemValue newItem = ItemClass.GetItem(this.changeItemToItem, false);
|
||||
ItemClass itemClass = newItem.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), decrease);
|
||||
bool couldAdd = player.inventory.AddItem(@is);
|
||||
if (!couldAdd)
|
||||
{
|
||||
couldAdd = player.bag.AddItem(@is);
|
||||
if (!couldAdd)
|
||||
{
|
||||
GameManager.Instance.ItemDropServer(@is, player.GetPosition(), new Vector3(0.5f, 0f, 0.5f), player.entityId, 60f, false);
|
||||
player.PlayOneShot("itemdropped", false);
|
||||
}
|
||||
}
|
||||
|
||||
player.PlayerUI.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
|
||||
this.removeWater = 0;
|
||||
_actionData.lastUseTime = 0;
|
||||
}
|
||||
//Log.Out("ItemActionExchangeItemRebirth-OnHoldingUpdate END");
|
||||
}
|
||||
}
|
||||
402
Scripts/ItemAction/ItemActionMeleeRebirth.cs
Normal file
402
Scripts/ItemAction/ItemActionMeleeRebirth.cs
Normal file
@@ -0,0 +1,402 @@
|
||||
using System.Collections.Generic;
|
||||
using static RebirthManager;
|
||||
|
||||
// Replaces ItemActionMelee
|
||||
|
||||
public class ItemActionMeleeRebirth : ItemActionMelee
|
||||
{
|
||||
public override void OnHoldingUpdate(ItemActionData _actionData)
|
||||
{
|
||||
InventoryDataMelee inventoryDataMelee = (InventoryDataMelee)_actionData;
|
||||
EntityAlive holdingEntity = _actionData.invData.holdingEntity;
|
||||
AvatarZombieController AvController = holdingEntity.emodel.avatarController as AvatarZombieController;
|
||||
EntityZombieSDX eZombieSdx = holdingEntity as EntityZombieSDX;
|
||||
|
||||
//if (AvController == null)
|
||||
//Log.Out($"holdingEntity: {holdingEntity} - emodel: {holdingEntity.emodel}");
|
||||
//if (holdingEntity.emodel != null && AvController == null)
|
||||
//Log.Out($"holdingEntity: {holdingEntity} - avatarController: {holdingEntity.emodel.avatarController}");
|
||||
|
||||
if (holdingEntity.IsDead())
|
||||
return;
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth OnHoldingUpdate entity: {holdingEntity}");
|
||||
|
||||
if (RebirthUtilities.canAttack2(holdingEntity))
|
||||
{
|
||||
//Log.Out("ItemActionMeleeRebirth-OnHoldingUpdate CANNOT ATTACK");
|
||||
return;
|
||||
}
|
||||
|
||||
if (AvController == null)
|
||||
{
|
||||
if (!inventoryDataMelee.bAttackStarted || Time.time - inventoryDataMelee.lastUseTime < rayCastDelay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (rayCastDelay <= 0f && !holdingEntity.IsAttackImpact())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!holdingEntity.IsAttackValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!AvController.isAttackImpact || !inventoryDataMelee.bAttackStarted)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth OnHoldingUpdate is not impact yet {holdingEntity}, bAttackStarted: {inventoryDataMelee.bAttackStarted}");
|
||||
return;
|
||||
}
|
||||
|
||||
long LastHit = (eZombieSdx == null) ? 0L : eZombieSdx.LastHit;
|
||||
|
||||
TimeSpan tsLastHit = TimeSpan.FromTicks(DateTime.UtcNow.Ticks - LastHit);
|
||||
float HitDelay = Delay * 1000.0f;
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth entity: {holdingEntity}, Delay: {Delay}, HitDelay: {HitDelay}, tsLastHit. milliseconds: {tsLastHit.TotalMilliseconds}");
|
||||
|
||||
inventoryDataMelee.bAttackStarted = false;
|
||||
|
||||
if (tsLastHit.TotalMilliseconds < HitDelay)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth entity: {holdingEntity} - too soon to hit");
|
||||
|
||||
ResetImpact(AvController);
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryDataMelee.bAttackStarted = false;
|
||||
ItemActionAttackData.HitDelegate hitDelegate = inventoryDataMelee.hitDelegate;
|
||||
inventoryDataMelee.hitDelegate = null;
|
||||
float value = EffectManager.GetValue(PassiveEffects.StaminaLoss, inventoryDataMelee.invData.itemValue, 0f, holdingEntity, null, (_actionData.indexInEntityOfAction == 0) ? FastTags<TagGroup.Global>.Parse("primary") : FastTags<TagGroup.Global>.Parse("secondary"));
|
||||
holdingEntity.AddStamina(0f - value);
|
||||
float damageScale = 1f;
|
||||
WorldRayHitInfo worldRayHitInfo = ((hitDelegate == null) ? GetExecuteActionTarget(_actionData) : hitDelegate(out damageScale));
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth entity: {holdingEntity} - hitDelegate: {hitDelegate}, worldRayHitInfo: {worldRayHitInfo}, AttackTarget: {holdingEntity.GetAttackTarget()}");
|
||||
|
||||
//if (worldRayHitInfo != null && ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth entity: {holdingEntity} - worldRayHitInfo hit valid: {worldRayHitInfo.bHitValid}, tag: {worldRayHitInfo.tag}, hit dist: {worldRayHitInfo.hit.distanceSq}, collider: {worldRayHitInfo.hitCollider}");
|
||||
|
||||
/*if (worldRayHitInfo != null && worldRayHitInfo.bHitValid)
|
||||
{
|
||||
string bodyPartName;
|
||||
Entity entityNoTagCheck = ItemActionAttack.FindHitEntityNoTagCheck(worldRayHitInfo, out bodyPartName);
|
||||
EntityAlive entityTarget = entityNoTagCheck as EntityAlive;
|
||||
|
||||
if (entityTarget != null)
|
||||
{
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
if (entityTarget.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse("allyanimal,animal")))
|
||||
{
|
||||
Range = 1.6f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (worldRayHitInfo != null && worldRayHitInfo.bHitValid &&
|
||||
(worldRayHitInfo.tag == null || !GameUtils.IsBlockOrTerrain(worldRayHitInfo.tag) || !(worldRayHitInfo.hit.distanceSq > BlockRange * BlockRange)) &&
|
||||
(worldRayHitInfo.tag == null || !worldRayHitInfo.tag.StartsWith("E_") || !(worldRayHitInfo.hit.distanceSq > Range * Range)))
|
||||
{
|
||||
//Log.Out("ItemActionMeleeRebirth-OnHoldingUpdate Range: " + Range);
|
||||
|
||||
// npc weapons should not break
|
||||
/*if (inventoryDataMelee.invData.itemValue.MaxUseTimes > 0)
|
||||
{
|
||||
_actionData.invData.itemValue.UseTimes += EffectManager.GetValue(PassiveEffects.DegradationPerUse, inventoryDataMelee.invData.itemValue, 1f, holdingEntity, null, _actionData.invData.itemValue.ItemClass.ItemTags);
|
||||
HandleItemBreak(_actionData);
|
||||
}*/
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//DebugLines.Create("MeleeHit", holdingEntity.RootTransform, holdingEntity.position, worldRayHitInfo.hit.pos, new Color(0.7f, 0f, 0f), new Color(1f, 1f, 0f), 0.05f, 0.02f, 1f);
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth hit Target this entity: {holdingEntity}");
|
||||
|
||||
hitTheTarget(inventoryDataMelee, worldRayHitInfo, damageScale);
|
||||
|
||||
if (eZombieSdx != null)
|
||||
eZombieSdx.LastHit = DateTime.UtcNow.Ticks;
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth OnHoldingUpdate after hit target this entity: {holdingEntity}");
|
||||
|
||||
if (inventoryDataMelee.bFirstHitInARow)
|
||||
{
|
||||
inventoryDataMelee.bFirstHitInARow = false;
|
||||
}
|
||||
}
|
||||
/* debug testing stuff
|
||||
else
|
||||
{
|
||||
if (ItemAction.ShowDebugDisplayHit)
|
||||
{
|
||||
Log.Out($"Rebirth Else Failed to obtain worldRayHitInfo this entity: {holdingEntity}");
|
||||
|
||||
int layerMask = ~(1 << 2 | 1 << 4 | 1 << 12 | 1 << 13 | 1 << 14 | 1 << 15 | 1 << 16 | 1 << 18 | 1 << 19 | 1 << 20);
|
||||
//holdingEntity.SetModelLayer(2);
|
||||
var allColliders = Physics.OverlapSphere(holdingEntity.transform.position, 2f, layerMask, QueryTriggerInteraction.Ignore);
|
||||
//holdingEntity.SetModelLayer(0);
|
||||
|
||||
Log.Out($"Rebirth layerMask: {layerMask}, allColliders: {allColliders.Length}, voxelRayHitInfo bValid: {Voxel.voxelRayHitInfo.bHitValid}, tag: {Voxel.voxelRayHitInfo.tag}, transform: {Voxel.voxelRayHitInfo.transform}");
|
||||
|
||||
foreach (var c in allColliders)
|
||||
{
|
||||
Log.Out($"Rebirth coll: {c}, layer: {c.gameObject.layer}, tag: {c.tag}, pos: {c.transform.position}, root: {c.transform.root}");
|
||||
RootTransformRefEntity refEntity = c.gameObject.GetComponent<RootTransformRefEntity>();
|
||||
if (refEntity != null && refEntity.RootTransform != null)
|
||||
{
|
||||
EntityAlive hitEntity = refEntity.RootTransform.GetComponent<EntityAlive>();
|
||||
if (hitEntity != null)
|
||||
{
|
||||
Log.Out($"Rebirth ref Entity: {hitEntity}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
ResetImpact(AvController);
|
||||
}
|
||||
|
||||
public override WorldRayHitInfo GetExecuteActionTarget(ItemActionData _actionData)
|
||||
{
|
||||
InventoryDataMelee inventoryDataMelee = (InventoryDataMelee)_actionData;
|
||||
EntityAlive holdingEntity = inventoryDataMelee.invData.holdingEntity;
|
||||
inventoryDataMelee.ray = holdingEntity.GetLookRay();
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::GetExecuteActionTarget - holdingEntity: {holdingEntity} My Position: {holdingEntity.position}, AttackTarget: {holdingEntity.GetAttackTarget()}");
|
||||
|
||||
//if (holdingEntity.GetAttackTarget() == null)
|
||||
//Log.Out($"Rebirth ItemActionMelee::GetExecuteActionTarget - holdingEntity: {holdingEntity}, AttackTarget NULL: {holdingEntity.GetAttackTarget()}");
|
||||
|
||||
if (holdingEntity.IsBreakingBlocks)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::GetExecuteActionTarget - holdingEntity: {holdingEntity} IsBreakingBlocks");
|
||||
|
||||
if (inventoryDataMelee.ray.direction.y < 0f)
|
||||
{
|
||||
inventoryDataMelee.ray.direction = new Vector3(inventoryDataMelee.ray.direction.x, 0f, inventoryDataMelee.ray.direction.z);
|
||||
inventoryDataMelee.ray.origin += new Vector3(0f, -0.7f, 0f);
|
||||
}
|
||||
}
|
||||
else if (holdingEntity.GetAttackTarget() != null)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::GetExecuteActionTarget - holdingEntity: {holdingEntity} My Position: {holdingEntity.position}, AttackTarget: {holdingEntity.GetAttackTarget()}, Target HitPosition: {holdingEntity.GetAttackTargetHitPosition()}, dist apart: {holdingEntity.GetDistance(holdingEntity.GetAttackTarget())}");
|
||||
|
||||
Vector3 direction = holdingEntity.GetAttackTargetHitPosition() - inventoryDataMelee.ray.origin;
|
||||
inventoryDataMelee.ray = new Ray(inventoryDataMelee.ray.origin, direction);
|
||||
}
|
||||
|
||||
inventoryDataMelee.ray.origin -= 0.15f * inventoryDataMelee.ray.direction;
|
||||
int modelLayer = holdingEntity.GetModelLayer();
|
||||
holdingEntity.SetModelLayer(2);
|
||||
float distance = Utils.FastMax(Range, BlockRange) + 0.15f;
|
||||
|
||||
if (holdingEntity is EntityEnemy && holdingEntity.IsBreakingBlocks)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee - holdingEntity: {holdingEntity}, EntityEnemy && holdingEntity.IsBreakingBlocks - calling Voxel.Raycast");
|
||||
|
||||
bool blockHit = Voxel.Raycast(inventoryDataMelee.invData.world, inventoryDataMelee.ray, distance, 1073807360, 128, 0.4f);
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee - holdingEntity: {holdingEntity}, EntityEnemy && holdingEntity.IsBreakingBlocks - after Voxel.Raycast, blockHit: {blockHit}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee - holdingEntity: {holdingEntity}, else EntityAlive - calling Voxel.Raycast target: {holdingEntity.GetAttackTarget()}");
|
||||
|
||||
EntityAlive entityAlive = null;
|
||||
int layerMask = -538767381;
|
||||
|
||||
if (Voxel.Raycast(inventoryDataMelee.invData.world, inventoryDataMelee.ray, distance, layerMask, 128, SphereRadius))
|
||||
{
|
||||
entityAlive = ItemActionAttack.GetEntityFromHit(Voxel.voxelRayHitInfo) as EntityAlive;
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee - holdingEntity: {holdingEntity}, entityAlive: {entityAlive} Voxel.Raycast success");
|
||||
|
||||
if (entityAlive == null)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth Entity: {holdingEntity}, First raycast voxelRayHitInfo bValid: {Voxel.voxelRayHitInfo.bHitValid}, tag: {Voxel.voxelRayHitInfo.tag}, transform: {Voxel.voxelRayHitInfo.transform}");
|
||||
|
||||
if (Voxel.voxelRayHitInfo.bHitValid && Voxel.voxelRayHitInfo.transform != null && Voxel.voxelRayHitInfo.transform.name.Contains("Hips") && Voxel.voxelRayHitInfo.hitCollider.transform.CompareTag("Untagged"))
|
||||
{
|
||||
//Log.Out($"Rebirth Entity: {holdingEntity}, closest player: {holdingEntity.aiClosestPlayer}, dist: {holdingEntity.aiClosestPlayerDistSq}, First raycast success, entity null - voxelRayHitInfo bValid: {Voxel.voxelRayHitInfo.bHitValid}, tag: {Voxel.voxelRayHitInfo.tag}, transform: {Voxel.voxelRayHitInfo.transform}, layer: {Voxel.voxelRayHitInfo.hitCollider.gameObject.layer}, collider hit pos: {Voxel.voxelRayHitInfo.hit.pos}");
|
||||
|
||||
var entityUp = RebirthUtilities.FindEntityUp(Voxel.voxelRayHitInfo.hitCollider.transform);
|
||||
|
||||
if (entityUp != null)
|
||||
{
|
||||
entityAlive = entityUp.GetComponent<EntityAlive>();
|
||||
var targetColliders = entityAlive.GetComponentsInChildren<Collider>();
|
||||
foreach (var targC in targetColliders)
|
||||
{
|
||||
if (targC.CompareTag("E_BP_Body"))
|
||||
{
|
||||
Voxel.voxelRayHitInfo.tag = "E_BP_Body";
|
||||
Voxel.voxelRayHitInfo.transform = targC.transform;
|
||||
Voxel.voxelRayHitInfo.hit.pos = targC.transform.position + Origin.position;
|
||||
Voxel.voxelRayHitInfo.hit.distanceSq = ((Voxel.voxelRayHitInfo.hit.pos != Vector3.zero) ? (holdingEntity.getChestPosition() - Voxel.voxelRayHitInfo.hit.pos).sqrMagnitude : float.MaxValue);
|
||||
Voxel.voxelRayHitInfo.fmcHit = Voxel.voxelRayHitInfo.hit;
|
||||
//Log.Out($"Rebirth Found Body Collider: {Voxel.voxelRayHitInfo.transform}, pos: {Voxel.voxelRayHitInfo.hit.pos}, distanceSq: {Voxel.voxelRayHitInfo.hit.distanceSq}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entityAlive == null)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee - holdingEntity: {holdingEntity}, entityAlive == null - calling Second Voxel.Raycast");
|
||||
|
||||
bool didHit = Voxel.Raycast(inventoryDataMelee.invData.world, inventoryDataMelee.ray, distance, -538488837, 128, SphereRadius);
|
||||
entityAlive = ItemActionAttack.GetEntityFromHit(Voxel.voxelRayHitInfo) as EntityAlive;
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee - holdingEntity: {holdingEntity}, - after Second Voxel.Raycast didHit: {didHit}");
|
||||
|
||||
if (entityAlive == null)// && didHit && ItemAction.ShowDebugDisplayHit)
|
||||
{
|
||||
//Log.Out($"Rebirth Entity: {holdingEntity}, Second raycast voxelRayHitInfo bValid: {Voxel.voxelRayHitInfo.bHitValid}, tag: {Voxel.voxelRayHitInfo.tag}, transform: {Voxel.voxelRayHitInfo.transform}");
|
||||
layerMask = ~(1 << 2 | 1 << 4 | 1 << 12 | 1 << 13 | 1 << 14 | 1 << 15 | 1 << 16 | 1 << 18 | 1 << 19 | 1 << 20);
|
||||
RebirthUtilities.FindEntityOverlap(holdingEntity.GetAttackTarget(), holdingEntity.transform.position, layerMask, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holdingEntity.SetModelLayer(modelLayer);
|
||||
|
||||
return _actionData.GetUpdatedHitInfo();
|
||||
}
|
||||
|
||||
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
//Log.Out("ItemActionMeleeRebirth-ExecuteAction START");
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::ExecuteAction - entity: {_actionData.invData.holdingEntity}, bReleased: {_bReleased}");
|
||||
|
||||
InventoryDataMelee inventoryDataMelee = (InventoryDataMelee)_actionData;
|
||||
|
||||
if (_bReleased)
|
||||
{
|
||||
inventoryDataMelee.bFirstHitInARow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time.time - inventoryDataMelee.lastUseTime < Delay)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::ExecuteAction - inventoryDataMelee.lastUseTime: {inventoryDataMelee.lastUseTime}, Delay: {Delay}");
|
||||
return;
|
||||
}
|
||||
|
||||
inventoryDataMelee.lastUseTime = Time.time;
|
||||
/*
|
||||
if (inventoryDataMelee.invData.itemValue.MaxUseTimes > 0 && inventoryDataMelee.invData.itemValue.UseTimes >= (float)inventoryDataMelee.invData.itemValue.MaxUseTimes)
|
||||
{
|
||||
EntityPlayerLocal player = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
|
||||
if (item.Properties.Values.ContainsKey(ItemClass.PropSoundJammed))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead(item.Properties.Values[ItemClass.PropSoundJammed]);
|
||||
}
|
||||
|
||||
GameManager.ShowTooltip(player, "ttItemNeedsRepair");
|
||||
return;
|
||||
}*/
|
||||
|
||||
_actionData.invData.holdingEntity.RightArmAnimationAttack = true;
|
||||
/*
|
||||
inventoryDataMelee.bHarvesting = CheckHarvesting(_actionData, out var _);
|
||||
|
||||
if (inventoryDataMelee.bHarvesting)
|
||||
{
|
||||
_actionData.invData.holdingEntity.HarvestingAnimation = true;
|
||||
}*/
|
||||
|
||||
if (soundStart != null)
|
||||
{
|
||||
_actionData.invData.holdingEntity.PlayOneShot(soundStart);
|
||||
}
|
||||
|
||||
inventoryDataMelee.bAttackStarted = true;
|
||||
|
||||
if ((double)inventoryDataMelee.invData.holdingEntity.speedForward > 0.009)
|
||||
{
|
||||
rayCastDelay = AnimationDelayData.AnimationDelay[inventoryDataMelee.invData.item.HoldType.Value].RayCastMoving;
|
||||
}
|
||||
else
|
||||
{
|
||||
rayCastDelay = AnimationDelayData.AnimationDelay[inventoryDataMelee.invData.item.HoldType.Value].RayCast;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckHarvesting(ItemActionData _actionData, out AttackHitInfo myAttackHitInfo)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::CheckHarvesting {_actionData.invData.holdingEntity}");
|
||||
|
||||
WorldRayHitInfo executeActionTarget = GetExecuteActionTarget(_actionData);
|
||||
ItemValue itemValue = _actionData.invData.itemValue;
|
||||
myAttackHitInfo = new AttackHitInfo { WeaponTypeTag = ItemActionAttack.MeleeTag };
|
||||
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ItemActionMelee::CheckHarvesting {_actionData.invData.holdingEntity}");
|
||||
|
||||
ItemActionAttack.Hit(executeActionTarget, _actionData.invData.holdingEntity.entityId, (DamageType == EnumDamageTypes.None) ? EnumDamageTypes.Bashing : DamageType, GetDamageBlock(itemValue, ItemActionAttack.GetBlockHit(_actionData.invData.world, executeActionTarget), _actionData.invData.holdingEntity, _actionData.indexInEntityOfAction), GetDamageEntity(itemValue, _actionData.invData.holdingEntity, _actionData.indexInEntityOfAction), 1f, 1f, 0f, ItemAction.GetDismemberChance(_actionData, executeActionTarget), item.MadeOfMaterial.id, damageMultiplier, getBuffActions(_actionData), myAttackHitInfo, 1, ActionExp, ActionExpBonusMultiplier, this, ToolBonuses, EnumAttackMode.Simulate);
|
||||
|
||||
if (myAttackHitInfo.bKilled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (myAttackHitInfo.itemsToDrop != null && myAttackHitInfo.itemsToDrop.ContainsKey(EnumDropEvent.Harvest))
|
||||
{
|
||||
List<Block.SItemDropProb> list = myAttackHitInfo.itemsToDrop[EnumDropEvent.Harvest];
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (list[i].toolCategory != null && ToolBonuses != null && ToolBonuses.ContainsKey(list[i].toolCategory))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ResetImpact(AvatarZombieController AvController)
|
||||
{
|
||||
if (AvController != null)
|
||||
{
|
||||
//if (ItemAction.ShowDebugDisplayHit)
|
||||
//Log.Out($"Rebirth ResetImpact setting isAttackImpact to false");
|
||||
|
||||
AvController.isAttackImpact = false;
|
||||
AvController.attackPlayingTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
283
Scripts/ItemAction/ItemActionSpawnVehicleRebirth.cs
Normal file
283
Scripts/ItemAction/ItemActionSpawnVehicleRebirth.cs
Normal file
@@ -0,0 +1,283 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class ItemActionSpawnVehicleRebirth : ItemAction
|
||||
{
|
||||
public override ItemActionData CreateModifierData(ItemInventoryData _invData, int _indexInEntityOfAction)
|
||||
{
|
||||
return new ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle(_invData, _indexInEntityOfAction);
|
||||
}
|
||||
|
||||
public override void ReadFrom(DynamicProperties _props)
|
||||
{
|
||||
base.ReadFrom(_props);
|
||||
if (_props.Values.ContainsKey("Vehicle"))
|
||||
{
|
||||
this.entityToSpawn = _props.Values["Vehicle"];
|
||||
}
|
||||
this.vehicleSize = new Vector3(1f, 1.9f, 2f);
|
||||
if (_props.Values.ContainsKey("VehicleSize"))
|
||||
{
|
||||
this.vehicleSize = StringParsers.ParseVector3(_props.Values["VehicleSize"], 0, -1);
|
||||
}
|
||||
foreach (KeyValuePair<int, EntityClass> keyValuePair in EntityClass.list.Dict)
|
||||
{
|
||||
if (keyValuePair.Value.entityClassName == this.entityToSpawn)
|
||||
{
|
||||
this.entityId = keyValuePair.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void StartHolding(ItemActionData _actionData)
|
||||
{
|
||||
ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle itemActionDataSpawnVehicle = (ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle)_actionData;
|
||||
EntityPlayerLocal entityPlayerLocal = itemActionDataSpawnVehicle.invData.holdingEntity as EntityPlayerLocal;
|
||||
if (!entityPlayerLocal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (itemActionDataSpawnVehicle.VehiclePreviewT)
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(itemActionDataSpawnVehicle.VehiclePreviewT.gameObject);
|
||||
}
|
||||
GameObject original = DataLoader.LoadAsset<GameObject>(entityPlayerLocal.inventory.holdingItem.MeshFile);
|
||||
itemActionDataSpawnVehicle.VehiclePreviewT = UnityEngine.Object.Instantiate<GameObject>(original).transform;
|
||||
Vehicle.SetupPreview(itemActionDataSpawnVehicle.VehiclePreviewT);
|
||||
this.SetupPreview(itemActionDataSpawnVehicle);
|
||||
GameManager.Instance.StartCoroutine(this.UpdatePreview(itemActionDataSpawnVehicle));
|
||||
}
|
||||
|
||||
private void SetupPreview(ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle data)
|
||||
{
|
||||
data.ValidPosition = false;
|
||||
if (data.PreviewRenderers == null || data.PreviewRenderers.Length == 0 || data.PreviewRenderers[0] == null)
|
||||
{
|
||||
data.PreviewRenderers = data.VehiclePreviewT.GetComponentsInChildren<Renderer>();
|
||||
}
|
||||
for (int i = 0; i < data.PreviewRenderers.Length; i++)
|
||||
{
|
||||
data.PreviewRenderers[i].material.color = new Color(2f, 0.25f, 0.25f);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator UpdatePreview(ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle data)
|
||||
{
|
||||
World world = data.invData.world;
|
||||
while (data.VehiclePreviewT)
|
||||
{
|
||||
bool flag = this.CalcSpawnPosition(data, ref data.Position) && world.CanPlaceBlockAt(new Vector3i(data.Position), world.GetGameManager().GetPersistentLocalPlayer(), false);
|
||||
if (data.ValidPosition != flag)
|
||||
{
|
||||
data.ValidPosition = flag;
|
||||
if (data.PreviewRenderers == null || data.PreviewRenderers.Length == 0 || data.PreviewRenderers[0] == null)
|
||||
{
|
||||
data.PreviewRenderers = data.VehiclePreviewT.GetComponentsInChildren<Renderer>();
|
||||
}
|
||||
Color color = flag ? new Color(0.25f, 2f, 0.25f) : new Color(2f, 0.25f, 0.25f);
|
||||
for (int i = 0; i < data.PreviewRenderers.Length; i++)
|
||||
{
|
||||
data.PreviewRenderers[i].material.color = color;
|
||||
}
|
||||
}
|
||||
if (data.Position.y < 9999f)
|
||||
{
|
||||
Quaternion localRotation = Quaternion.Euler(0f, data.invData.holdingEntity.rotation.y + 90f, 0f);
|
||||
data.VehiclePreviewT.localRotation = localRotation;
|
||||
data.VehiclePreviewT.position = data.Position - Origin.position;
|
||||
data.VehiclePreviewT.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.VehiclePreviewT.gameObject.SetActive(false);
|
||||
}
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public override void CancelAction(ItemActionData _actionData)
|
||||
{
|
||||
ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle itemActionDataSpawnVehicle = (ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle)_actionData;
|
||||
if (itemActionDataSpawnVehicle.VehiclePreviewT && itemActionDataSpawnVehicle.invData.holdingEntity is EntityPlayerLocal)
|
||||
{
|
||||
UnityEngine.Object.Destroy(itemActionDataSpawnVehicle.VehiclePreviewT.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopHolding(ItemActionData _actionData)
|
||||
{
|
||||
ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle itemActionDataSpawnVehicle = (ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle)_actionData;
|
||||
if (itemActionDataSpawnVehicle.VehiclePreviewT && itemActionDataSpawnVehicle.invData.holdingEntity is EntityPlayerLocal)
|
||||
{
|
||||
UnityEngine.Object.Destroy(itemActionDataSpawnVehicle.VehiclePreviewT.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHoldingUpdate(ItemActionData _actionData)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
EntityPlayerLocal entityPlayerLocal = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
if (!entityPlayerLocal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_bReleased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Time.time - _actionData.lastUseTime < this.Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Time.time - _actionData.lastUseTime < Constants.cBuildIntervall)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle itemActionDataSpawnVehicle = (ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle)_actionData;
|
||||
if (!itemActionDataSpawnVehicle.ValidPosition)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.entityId < 0)
|
||||
{
|
||||
foreach (KeyValuePair<int, EntityClass> keyValuePair in EntityClass.list.Dict)
|
||||
{
|
||||
if (keyValuePair.Value.entityClassName == this.entityToSpawn)
|
||||
{
|
||||
this.entityId = keyValuePair.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.entityId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
ItemValue holdingItemItemValue = entityPlayerLocal.inventory.holdingItemItemValue;
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageSpawnVehicleFromItemRebirth>().Setup(this.entityToSpawn,
|
||||
itemActionDataSpawnVehicle.Position,
|
||||
new Vector3(0f, entityPlayerLocal.rotation.y + 90f, 0f),
|
||||
holdingItemItemValue.Clone(),
|
||||
entityPlayerLocal.entityId,
|
||||
false
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemValue[] itemValues = { ItemValue.None };
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.SpawnVehicleFromItemCoroutine(
|
||||
this.entityToSpawn,
|
||||
itemActionDataSpawnVehicle.Position,
|
||||
new Vector3(0f, entityPlayerLocal.rotation.y + 90f, 0f),
|
||||
holdingItemItemValue.Clone(),
|
||||
entityPlayerLocal.entityId,
|
||||
true
|
||||
));
|
||||
}
|
||||
|
||||
if (itemActionDataSpawnVehicle.VehiclePreviewT)
|
||||
{
|
||||
UnityEngine.Object.Destroy(itemActionDataSpawnVehicle.VehiclePreviewT.gameObject);
|
||||
}
|
||||
entityPlayerLocal.RightArmAnimationUse = true;
|
||||
entityPlayerLocal.DropTimeDelay = 0.5f;
|
||||
entityPlayerLocal.inventory.DecHoldingItem(1);
|
||||
entityPlayerLocal.PlayOneShot((this.soundStart != null) ? this.soundStart : "placeblock", false);
|
||||
}
|
||||
|
||||
private bool CalcSpawnPosition(ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle _actionData, ref Vector3 position)
|
||||
{
|
||||
World world = _actionData.invData.world;
|
||||
Ray lookRay = _actionData.invData.holdingEntity.GetLookRay();
|
||||
if (Vector3.Dot(lookRay.direction, Vector3.up) == 1f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
position.y = float.MaxValue;
|
||||
float num = 4f + this.vehicleSize.x;
|
||||
if (Voxel.Raycast(world, lookRay, num + 1.5f, 8454144, 69, 0f))
|
||||
{
|
||||
if ((Voxel.voxelRayHitInfo.hit.pos - lookRay.origin).magnitude > num)
|
||||
{
|
||||
position = Voxel.voxelRayHitInfo.hit.pos;
|
||||
return false;
|
||||
}
|
||||
for (float num2 = 0.14f; num2 < 0.91f; num2 += 0.25f)
|
||||
{
|
||||
position = Voxel.voxelRayHitInfo.hit.pos;
|
||||
position.y += num2;
|
||||
BlockValue block = world.GetBlock(World.worldToBlockPos(position));
|
||||
if (block.isair || block.Block.IsTerrainDecoration)
|
||||
{
|
||||
Vector3 normalized = Vector3.Cross(lookRay.direction, Vector3.up).normalized;
|
||||
Vector3 vector = Vector3.Cross(normalized, Vector3.up);
|
||||
Vector3 localPos = position - Origin.position;
|
||||
localPos.y += this.vehicleSize.y * 0.5f + 0.05f;
|
||||
if (this.CheckForSpace(localPos, normalized, this.vehicleSize.z, vector, this.vehicleSize.x, Vector3.up, this.vehicleSize.y) && this.CheckForSpace(localPos, vector, this.vehicleSize.x, normalized, this.vehicleSize.z, Vector3.up, this.vehicleSize.y) && this.CheckForSpace(localPos, Vector3.up, this.vehicleSize.y, normalized, this.vehicleSize.z, vector, this.vehicleSize.x))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool CheckForSpace(Vector3 localPos, Vector3 dirN, float length, Vector3 axis1N, float axis1Length, Vector3 axis2N, float axis2Length)
|
||||
{
|
||||
Vector3 b = dirN * length * 0.5f;
|
||||
for (float num = -axis1Length * 0.5f; num <= axis1Length * 0.5f; num += 0.2499f)
|
||||
{
|
||||
Vector3 a = localPos + axis1N * num;
|
||||
for (float num2 = -axis2Length * 0.5f; num2 <= axis2Length * 0.5f; num2 += 0.2499f)
|
||||
{
|
||||
Vector3 a2 = a + axis2N * num2;
|
||||
if (Physics.Raycast(a2 - b, dirN, length, 28901376))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Physics.Raycast(a2 + b, -dirN, length, 28901376))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Cleanup(ItemActionData _data)
|
||||
{
|
||||
base.Cleanup(_data);
|
||||
ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle itemActionDataSpawnVehicle = _data as ItemActionSpawnVehicleRebirth.ItemActionDataSpawnVehicle;
|
||||
if (itemActionDataSpawnVehicle != null && itemActionDataSpawnVehicle.invData != null && itemActionDataSpawnVehicle.invData.holdingEntity is EntityPlayerLocal && itemActionDataSpawnVehicle.VehiclePreviewT)
|
||||
{
|
||||
UnityEngine.Object.Destroy(itemActionDataSpawnVehicle.VehiclePreviewT.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private const int cColliderMask = 28901376;
|
||||
private string entityToSpawn;
|
||||
private int entityId = -1;
|
||||
private Vector3 vehicleSize;
|
||||
protected class ItemActionDataSpawnVehicle : ItemActionAttackData
|
||||
{
|
||||
public ItemActionDataSpawnVehicle(ItemInventoryData _invData, int _indexInEntityOfAction) : base(_invData, _indexInEntityOfAction)
|
||||
{
|
||||
}
|
||||
|
||||
public Transform VehiclePreviewT;
|
||||
public Renderer[] PreviewRenderers;
|
||||
public bool ValidPosition;
|
||||
public Vector3 Position;
|
||||
}
|
||||
}
|
||||
235
Scripts/ItemAction/ItemActionThrownWeaponRebirth.cs
Normal file
235
Scripts/ItemAction/ItemActionThrownWeaponRebirth.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using Audio;
|
||||
using System.Globalization;
|
||||
|
||||
public class ItemActionThrownWeaponRebirth : ItemActionThrownWeapon
|
||||
{
|
||||
public new ExplosionData Explosion { get; set; }
|
||||
|
||||
public new int Velocity { get; set; }
|
||||
|
||||
public new float FlyTime { get; set; }
|
||||
|
||||
public new float LifeTime { get; set; }
|
||||
|
||||
public new float CollisionRadius { get; set; }
|
||||
|
||||
public float Gravity { get; set; }
|
||||
|
||||
public override void ReadFrom(DynamicProperties _props)
|
||||
{
|
||||
base.ReadFrom(_props);
|
||||
this.Explosion = new ExplosionData(this.Properties);
|
||||
if (this.Properties.Values.ContainsKey("Velocity"))
|
||||
{
|
||||
this.Velocity = (int)StringParsers.ParseFloat(this.Properties.Values["Velocity"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Velocity = 1;
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("FlyTime"))
|
||||
{
|
||||
this.FlyTime = StringParsers.ParseFloat(this.Properties.Values["FlyTime"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FlyTime = 20f;
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("LifeTime"))
|
||||
{
|
||||
this.LifeTime = StringParsers.ParseFloat(this.Properties.Values["LifeTime"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LifeTime = 100f;
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("CollisionRadius"))
|
||||
{
|
||||
this.CollisionRadius = StringParsers.ParseFloat(this.Properties.Values["CollisionRadius"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CollisionRadius = 0.05f;
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("Gravity"))
|
||||
{
|
||||
this.Gravity = StringParsers.ParseFloat(this.Properties.Values["Gravity"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Gravity = -9.81f;
|
||||
}
|
||||
if (_props.Values.ContainsKey("DamageEntity"))
|
||||
{
|
||||
this.damageEntity = StringParsers.ParseFloat(_props.Values["DamageEntity"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.damageEntity = 0f;
|
||||
}
|
||||
if (_props.Values.ContainsKey("DamageBlock"))
|
||||
{
|
||||
this.damageBlock = StringParsers.ParseFloat(_props.Values["DamageBlock"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.damageBlock = 0f;
|
||||
}
|
||||
if (_props.Values.ContainsKey("Hitmask_override"))
|
||||
{
|
||||
if (_props.Values["Hitmask_override"].Equals("Melee"))
|
||||
{
|
||||
this.hitmaskOverride = 128;
|
||||
return;
|
||||
}
|
||||
if (_props.Values["Hitmask_override"].Equals("Arrow"))
|
||||
{
|
||||
this.hitmaskOverride = 32;
|
||||
return;
|
||||
}
|
||||
if (_props.Values["Hitmask_override"].Equals("Bullet"))
|
||||
{
|
||||
this.hitmaskOverride = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsActionRunning(ItemActionData _actionData)
|
||||
{
|
||||
//Log.Out("IsActionRunning");
|
||||
return ((ItemActionThrowAway.MyInventoryData)_actionData).m_bActivated;
|
||||
}
|
||||
|
||||
public override void StartHolding(ItemActionData _actionData)
|
||||
{
|
||||
//Log.Out("StartHolding");
|
||||
base.StartHolding(_actionData);
|
||||
ItemActionThrowAway.MyInventoryData myInventoryData = (ItemActionThrowAway.MyInventoryData)_actionData;
|
||||
myInventoryData.m_bActivated = false;
|
||||
myInventoryData.m_ActivateTime = 0f;
|
||||
myInventoryData.m_LastThrowTime = 0f;
|
||||
}
|
||||
|
||||
public override void OnHoldingUpdate(ItemActionData _actionData)
|
||||
{
|
||||
ItemActionThrowAway.MyInventoryData myInventoryData = (ItemActionThrowAway.MyInventoryData)_actionData;
|
||||
float num = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient ? 0.1f : AnimationDelayData.AnimationDelay[myInventoryData.invData.item.HoldType.Value].RayCast;
|
||||
if (myInventoryData.m_LastThrowTime <= 0f || Time.time - myInventoryData.m_LastThrowTime < num)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GameManager.Instance.ItemActionEffectsServer(myInventoryData.invData.holdingEntity.entityId, myInventoryData.invData.slotIdx, myInventoryData.indexInEntityOfAction, 0, Vector3.zero, Vector3.zero, 0);
|
||||
EntityPlayer primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
primaryPlayer.inventory.ForceHoldingItemUpdate();
|
||||
//Log.Out("OnHoldingUpdate");
|
||||
}
|
||||
|
||||
public override void ItemActionEffects(GameManager _gameManager, ItemActionData _actionData, int _firingState, Vector3 _startPos, Vector3 _direction, int _userData = 0)
|
||||
{
|
||||
//Log.Out("ItemActionEffects");
|
||||
_actionData.invData.holdingEntity.emodel.avatarController.TriggerEvent("WeaponFire");
|
||||
(_actionData as ItemActionThrowAway.MyInventoryData).m_LastThrowTime = 0f;
|
||||
if (!_actionData.invData.holdingEntity.isEntityRemote)
|
||||
{
|
||||
this.throwAway(_actionData as ItemActionThrowAway.MyInventoryData);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 1");
|
||||
ItemActionThrowAway.MyInventoryData myInventoryData = (ItemActionThrowAway.MyInventoryData)_actionData;
|
||||
if (!myInventoryData.m_bActivated && Time.time - myInventoryData.m_LastThrowTime < this.Delay)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 1a");
|
||||
return;
|
||||
}
|
||||
//Log.Out("EXECUTEACTION 2");
|
||||
if (_actionData.invData.itemValue.PercentUsesLeft == 0f)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 2a");
|
||||
if (_bReleased)
|
||||
{
|
||||
EntityPlayerLocal player = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
//Log.Out("EXECUTEACTION 2b");
|
||||
if (this.item.Properties.Values.ContainsKey(ItemClass.PropSoundJammed))
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 2c");
|
||||
Manager.PlayInsidePlayerHead(this.item.Properties.Values[ItemClass.PropSoundJammed], -1, 0f, false);
|
||||
}
|
||||
GameManager.ShowTooltip(player, "ttItemNeedsRepair");
|
||||
}
|
||||
return;
|
||||
}
|
||||
//Log.Out("EXECUTEACTION 3");
|
||||
if (!_bReleased)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 3a");
|
||||
if (!myInventoryData.m_bActivated && !myInventoryData.m_bCanceled)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 3b");
|
||||
myInventoryData.m_bActivated = true;
|
||||
myInventoryData.m_ActivateTime = Time.time;
|
||||
}
|
||||
return;
|
||||
}
|
||||
//Log.Out("EXECUTEACTION 4");
|
||||
if (myInventoryData.m_bCanceled)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 4a");
|
||||
myInventoryData.m_bCanceled = false;
|
||||
return;
|
||||
}
|
||||
//Log.Out("EXECUTEACTION 5");
|
||||
if (!myInventoryData.m_bActivated)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 5a");
|
||||
return;
|
||||
}
|
||||
|
||||
//Log.Out("EXECUTEACTION 6");
|
||||
myInventoryData.m_ThrowStrength = Mathf.Min(this.maxStrainTime, Time.time - myInventoryData.m_ActivateTime) / this.maxStrainTime * this.maxThrowStrength;
|
||||
myInventoryData.m_LastThrowTime = Time.time;
|
||||
myInventoryData.m_bActivated = false;
|
||||
if (!myInventoryData.invData.holdingEntity.isEntityRemote)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 6a");
|
||||
EntityPlayer primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
int itemIndex = primaryPlayer.inventory.GetFocusedItemIdx();
|
||||
|
||||
ItemValue itemKunai = ItemClass.GetItem("FuriousRamsayKnife004_FR", false);
|
||||
ItemClass itemClassKunai = itemKunai.ItemClass;
|
||||
int itemCountKunai = 0;
|
||||
|
||||
if (itemClassKunai != null)
|
||||
{
|
||||
itemCountKunai = primaryPlayer.inventory.GetItemCount(itemKunai, false, -1, -1);
|
||||
if (itemCountKunai > 1)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Out("EXECUTEACTION 7");
|
||||
if (this.soundStart != null)
|
||||
{
|
||||
//Log.Out("EXECUTEACTION 7a");
|
||||
myInventoryData.invData.holdingEntity.PlayOneShot(this.soundStart, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void CancelAction(ItemActionData _actionData)
|
||||
{
|
||||
//Log.Out("CancelAction");
|
||||
ItemActionThrowAway.MyInventoryData myInventoryData = (ItemActionThrowAway.MyInventoryData)_actionData;
|
||||
myInventoryData.invData.holdingEntity.emodel.avatarController.TriggerEvent("WeaponPreFireCancel");
|
||||
myInventoryData.m_bActivated = false;
|
||||
myInventoryData.m_bCanceled = true;
|
||||
myInventoryData.m_ActivateTime = 0f;
|
||||
myInventoryData.m_LastThrowTime = 0f;
|
||||
}
|
||||
|
||||
private FastTags<TagGroup.Global> usePassedInTransformTag = FastTags<TagGroup.Global>.Parse("usePassedInTransform");
|
||||
private FastTags<TagGroup.Global> tmpTag;
|
||||
}
|
||||
18
Scripts/ItemAction/ItemActionUseMedRebirth.cs
Normal file
18
Scripts/ItemAction/ItemActionUseMedRebirth.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
public class ItemActionUseMedRebirth : ItemActionEat
|
||||
{
|
||||
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
EntityAlive holdingEntity = _actionData.invData.holdingEntity;
|
||||
|
||||
float healingAmount = holdingEntity.Buffs.GetCustomVar("medicalRegHealthAmount");
|
||||
|
||||
if (healingAmount <= 10)
|
||||
{
|
||||
base.ExecuteAction(_actionData, _bReleased);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.ShowTooltip(holdingEntity as EntityPlayerLocal, Localization.Get("ttNotDoneHealing"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user