public override bool CanExecute() { // if you are supposed to stay put, don't wander. if (EntityUtilities.CanExecuteTask(this.theEntity.entityId, EntityUtilities.Orders.Stay)) { return(false); } // If Pathing blocks does not exist, don't bother trying to do the enhanced wander code if (!EntityUtilities.CheckProperty(this.theEntity.entityId, "PathingBlocks")) { return(base.CanExecute()); } // If there's a target to fight, dont wander around. That's lame, sir. if (EntityUtilities.GetAttackOrReventTarget(this.theEntity.entityId) != null) { return(false); } this.throttle += 0.05f; // If we have Paths available, allow us to look for a new one. if (this.throttle > 10 || SphereCache.GetPaths(this.theEntity.entityId) != null) { Vector3 newPosition = EntityUtilities.GetNewPositon(this.theEntity.entityId); if (newPosition != Vector3.zero) { this.throttle = 11; String strParticleName = "#@modfolder(0-SphereIICore):Resources/PathSmoke.unity3d?P_PathSmoke_X"; if (!ParticleEffect.IsAvailable(strParticleName)) { ParticleEffect.RegisterBundleParticleEffect(strParticleName); } BlockValue myBlock = GameManager.Instance.World.GetBlock(new Vector3i(newPosition)); DisplayLog(" I have a new position I can path too."); // For testing, change the target to this block, so we can see where the NPC intends to go. if (blShowPathFindingBlocks) { DisplayLog(" I have highlighted where I am going: " + newPosition); Vector3 supportBlock = GameManager.Instance.World.FindSupportingBlockPos(newPosition); BlockUtilitiesSDX.addParticles(strParticleName, new Vector3i(supportBlock)); } if (SphereCache.LastBlock.ContainsKey(this.theEntity.entityId)) { if (blShowPathFindingBlocks) { DisplayLog("I am changing the block back to the pathing block"); Vector3 supportBlock = GameManager.Instance.World.FindSupportingBlockPos(this.position); BlockUtilitiesSDX.removeParticles(new Vector3i(supportBlock)); } SphereCache.LastBlock[this.theEntity.entityId] = newPosition; } else { // Store the LastBlock position here, so we know what we can remove next time. SphereCache.LastBlock.Add(this.theEntity.entityId, newPosition); } this.position = newPosition; return(true); } else { // no positions, so reset the time out. this.throttle = 0; } } return(base.CanExecute()); }
public override bool CanExecute() { // if they are set to IsBusy, don't try to wander around. bool isBusy = false; this.theEntity.emodel.avatarController.TryGetBool("IsBusy", out isBusy); if (isBusy) { return(false); } // if you are supposed to stay put, don't wander. if (EntityUtilities.CanExecuteTask(this.theEntity.entityId, EntityUtilities.Orders.Stay)) { return(false); } // If there's a target to fight, dont wander around. That's lame, sir. if (EntityUtilities.GetAttackOrReventTarget(this.theEntity.entityId) != null) { return(false); } if (this.theEntity.Buffs.HasCustomVar("PathingCode") && this.theEntity.Buffs.GetCustomVar("PathingCode") == -1) { return(false); } // If Pathing blocks does not exist, don't bother trying to do the enhanced wander code if (!EntityUtilities.CheckProperty(this.theEntity.entityId, "PathingBlocks")) { if (!this.theEntity.Buffs.HasCustomVar("PathingCode")) { return(base.CanExecute()); } } if (this.theEntity.sleepingOrWakingUp) { return(false); } if (this.theEntity.GetTicksNoPlayerAdjacent() >= 120) { return(false); } if (this.theEntity.bodyDamage.CurrentStun != EnumEntityStunType.None) { return(false); } int num = (int)(200f * this.executeWaitTime); if (base.GetRandom(1000) >= num) { return(false); } if (this.manager.lookTime > 0f) { return(false); } Vector3 newPosition = EntityUtilities.GetNewPositon(this.theEntity.entityId); if (newPosition == Vector3.zero) { DisplayLog("I do not have any pathing blocks"); return(base.CanExecute()); } DisplayLog(" I have a new position I can path to: " + newPosition); // For testing, change the target to this block, so we can see where the NPC intends to go. if (blShowPathFindingBlocks) { DisplayLog(" I have highlighted where I am going: " + newPosition); String strParticleName = "#@modfolder(0-SphereIICore):Resources/PathSmoke.unity3d?P_PathSmoke_X"; if (!ParticleEffect.IsAvailable(strParticleName)) { ParticleEffect.RegisterBundleParticleEffect(strParticleName); } Vector3 supportBlock = GameManager.Instance.World.FindSupportingBlockPos(newPosition); BlockUtilitiesSDX.addParticles(strParticleName, new Vector3i(supportBlock)); } if (SphereCache.LastBlock.ContainsKey(this.theEntity.entityId)) { if (blShowPathFindingBlocks) { DisplayLog("I am changing the block back to the pathing block"); Vector3 supportBlock = GameManager.Instance.World.FindSupportingBlockPos(this.position); BlockUtilitiesSDX.removeParticles(new Vector3i(supportBlock)); } SphereCache.LastBlock[this.theEntity.entityId] = newPosition; } else { // Store the LastBlock position here, so we know what we can remove next time. SphereCache.LastBlock.Add(this.theEntity.entityId, newPosition); } this.position = newPosition; return(true); }
public override bool CanExecute() { if (!EntityUtilities.CheckProperty(this.theEntity.entityId, "PathingBlocks")) { return(base.CanExecute()); } if (EntityUtilities.GetAttackOrReventTarget(this.theEntity.entityId) != null) { return(false); } Vector3 newPosition = EntityUtilities.GetNewPositon(this.theEntity.entityId); if (newPosition != Vector3.zero) { String strParticleName = "#@modfolder(0-SphereIICore):Resources/PathSmoke.unity3d?P_PathSmoke_X"; //String strParticleName = "forge"; ParticleEffect.RegisterBundleParticleEffect(strParticleName); BlockValue myBlock = GameManager.Instance.World.GetBlock(new Vector3i(newPosition)); DisplayLog(" I have a new position I can path too."); // For testing, change the target to this block, so we can see where the NPC intends to go. if (blShowPathFindingBlocks) { DisplayLog(" I have highlighted where I am going: " + newPosition); Vector3 supportBlock = GameManager.Instance.World.FindSupportingBlockPos(newPosition); BlockUtilitiesSDX.addParticles(strParticleName, new Vector3i(supportBlock)); } if (SphereCache.LastBlock.ContainsKey(this.theEntity.entityId)) { if (blShowPathFindingBlocks) { DisplayLog("I am changing the block back to the pathing block"); Vector3 supportBlock = GameManager.Instance.World.FindSupportingBlockPos(this.position); BlockUtilitiesSDX.removeParticles(new Vector3i(supportBlock)); } SphereCache.LastBlock[this.theEntity.entityId] = newPosition; } else { // Store the LastBlock position here, so we know what we can remove next time. SphereCache.LastBlock.Add(this.theEntity.entityId, newPosition); } this.position = newPosition; return(true); } else { DisplayLog("I do not have any pathing blocks"); //result = EntityUtilities.CanExecuteTask(this.theEntity.entityId, EntityUtilities.Orders.Wander); //if (result == false) // return false; //else // DisplayLog("CanExecuteTask(): Order is set for Wander"); return(base.CanExecute()); } }