public void Tick(IHTNAgent npc, float deltaTime, float time) { BearContext npcContext = npc.AiDomain.NpcContext as BearContext; if (npcContext == null) { return; } HTNAnimal htnAnimal = npc as HTNAnimal; if (Object.op_Equality((Object)htnAnimal, (Object)null)) { return; } NpcOrientation npcOrientation = NpcOrientation.Heading; if (npc.IsDestroyed || htnAnimal.IsDead()) { npcOrientation = NpcOrientation.None; } else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownAnimal.Animal, (Object)null)) { npcOrientation = !Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null) ? NpcOrientation.LookAtAnimal : ((double)npcContext.Memory.PrimaryKnownAnimal.SqrDistance >= (double)npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance ? (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible ? NpcOrientation.PrimaryTargetBody : (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation)) : NpcOrientation.LookAtAnimal); } else if (Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null)) { npcOrientation = npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible ? NpcOrientation.PrimaryTargetBody : (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation); } else if (Object.op_Inequality((Object)htnAnimal.lastAttacker, (Object)null) && (double)htnAnimal.lastAttackedTime > 0.0 && (double)time - (double)htnAnimal.lastAttackedTime < 2.0) { npcOrientation = NpcOrientation.LastAttackedDirection; } else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null)) { npcOrientation = npcContext.GetFact(Rust.Ai.HTN.Bear.Facts.IsSearching) <= (byte)0 || npcContext.GetFact(Rust.Ai.HTN.Bear.Facts.IsNavigating) != (byte)0 ? (npcContext.GetFact(Rust.Ai.HTN.Bear.Facts.IsIdle) <= (byte)0 ? NpcOrientation.LastKnownPrimaryTargetLocation : (!npcContext.IsFact(Rust.Ai.HTN.Bear.Facts.CanHearEnemy) ? NpcOrientation.Heading : NpcOrientation.AudibleTargetDirection)) : NpcOrientation.LookAround; } else if (npcContext.IsFact(Rust.Ai.HTN.Bear.Facts.CanHearEnemy)) { npcOrientation = NpcOrientation.AudibleTargetDirection; } npcContext.OrientationType = npcOrientation; }
private IEnumerator PlayEffects(HTNAnimal target) { while (this._isEffectRunning && Object.op_Inequality((Object)target, (Object)null) && (Object.op_Inequality((Object)((Component)target).get_transform(), (Object)null) && !target.IsDestroyed) && !target.IsDead()) { if (this.IdleEffect.isValid) { Effect.server.Run(this.IdleEffect.resourcePath, (BaseEntity)target, StringPool.Get("head"), Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false); } yield return((object)CoroutineEx.waitForSeconds(Random.Range((float)this.IdleEffectRepeatRange.x, (float)(this.IdleEffectRepeatRange.y + 1.0)))); } }
private IEnumerator PlayEffects(HTNAnimal target) { BearDefinition bearDefinition = null; while (bearDefinition._isEffectRunning && target != null && target.transform != null && !target.IsDestroyed && !target.IsDead()) { if (bearDefinition.IdleEffect.isValid) { Effect.server.Run(bearDefinition.IdleEffect.resourcePath, target, StringPool.Get("head"), Vector3.zero, Vector3.zero, null, false); } float single = UnityEngine.Random.Range(bearDefinition.IdleEffectRepeatRange.x, bearDefinition.IdleEffectRepeatRange.y + 1f); yield return(CoroutineEx.waitForSeconds(single)); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { NpcOrientation npcOrientation; NpcOrientation npcOrientation1; BearContext npcContext = npc.AiDomain.NpcContext as BearContext; if (npcContext == null) { return; } HTNAnimal hTNAnimal = npc as HTNAnimal; if (hTNAnimal == null) { return; } NpcOrientation npcOrientation2 = NpcOrientation.Heading; if (npc.IsDestroyed || hTNAnimal.IsDead()) { npcOrientation2 = NpcOrientation.None; } else if (npcContext.Memory.PrimaryKnownAnimal.Animal != null) { if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player == null) { npcOrientation2 = NpcOrientation.LookAtAnimal; } else if (npcContext.Memory.PrimaryKnownAnimal.SqrDistance >= npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance) { if (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible) { npcOrientation1 = NpcOrientation.PrimaryTargetBody; } else { npcOrientation1 = (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation); } npcOrientation2 = npcOrientation1; } else { npcOrientation2 = NpcOrientation.LookAtAnimal; } } else if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player != null) { if (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible) { npcOrientation = NpcOrientation.PrimaryTargetBody; } else { npcOrientation = (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation); } npcOrientation2 = npcOrientation; } else if (hTNAnimal.lastAttacker != null && hTNAnimal.lastAttackedTime > 0f && time - hTNAnimal.lastAttackedTime < 2f) { npcOrientation2 = NpcOrientation.LastAttackedDirection; } else if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null) { if (npcContext.IsFact(Facts.CanHearEnemy)) { npcOrientation2 = NpcOrientation.AudibleTargetDirection; } } else if (npcContext.GetFact(Facts.IsSearching) > 0 && npcContext.GetFact(Facts.IsNavigating) == 0) { npcOrientation2 = NpcOrientation.LookAround; } else if (npcContext.GetFact(Facts.IsIdle) <= 0) { npcOrientation2 = NpcOrientation.LastKnownPrimaryTargetLocation; } else { npcOrientation2 = (!npcContext.IsFact(Facts.CanHearEnemy) ? NpcOrientation.Heading : NpcOrientation.AudibleTargetDirection); } npcContext.OrientationType = npcOrientation2; }