public void OnActivateGoal(AIGoal goal) { if (this.m_AI.m_BodyRotationModule) { this.m_AI.m_BodyRotationModule.m_LookAtPlayer = this.m_ActiveGoal.ShouldLookAtPlayer(); this.m_AI.m_BodyRotationModule.m_RotateToPlayer = this.m_ActiveGoal.ShouldLookAtPlayer(); } }
public override void Initialize(Being being) { base.Initialize(being); if (this.m_ActiveGoal != null) { this.m_ActiveGoal.Deactivate(); } this.m_Goals.Clear(); if (!AIManager.Get().m_GoalParsers.ContainsKey((int)this.m_AI.m_ID)) { DebugUtils.Assert("[GoalsModule:Initialize] ERROR, missing goals parser of ai " + this.m_AI.m_ID.ToString(), true, DebugUtils.AssertType.Info); return; } TextAssetParser textAssetParser = null; if (this.m_AI.m_PresetName != string.Empty) { textAssetParser = AIManager.Get().GetGoalParser(this.m_AI.m_PresetName); } if (textAssetParser == null) { textAssetParser = AIManager.Get().GetRandomGoalsParser(this.m_AI.m_ID); } for (int i = 0; i < textAssetParser.GetKeysCount(); i++) { Key key = textAssetParser.GetKey(i); if (key.GetName() == "Goal") { AIGoal aigoal = this.CreateGoal(key.GetVariable(0).SValue); aigoal.m_Priority = key.GetVariable(1).IValue; aigoal.m_Probability = ((key.GetVariablesCount() > 2) ? key.GetVariable(2).FValue : 1f); if (aigoal.m_Type == AIGoalType.HumanJumpBack || aigoal.m_Type == AIGoalType.JumpBack) { this.m_JumpBackGoal = aigoal; } else if (aigoal.m_Type == AIGoalType.HumanPunchBack || aigoal.m_Type == AIGoalType.PunchBack) { this.m_PunchBackGoal = aigoal; } else if (aigoal.m_Type == AIGoalType.HumanTaunt) { this.m_TauntGoal = aigoal; } this.m_Goals.Add(aigoal); } else { DebugUtils.Assert("[GoalsModule::Initialize] Unknown keyword - " + key.GetName(), true, DebugUtils.AssertType.Info); } } if (this.m_GoalToActivate != AIGoalType.None) { this.ActivateGoal(this.m_GoalToActivate); this.m_GoalToActivate = AIGoalType.None; } }
private void ActivateGoal(AIGoal goal) { if (this.m_ActiveGoal != null) { this.m_ActiveGoal.Deactivate(); } this.m_ActiveGoal = goal; this.m_ActiveGoal.Activate(); this.OnActivateGoal(goal); }
public void OnActivateGoal(AIGoal goal) { if (this.m_AI.m_BodyRotationModule) { this.m_AI.m_BodyRotationModule.m_LookAtPlayer = this.m_ActiveGoal.ShouldLookAtPlayer(); this.m_AI.m_BodyRotationModule.m_RotateToPlayer = this.m_ActiveGoal.ShouldLookAtPlayer(); } if (goal.m_Type == AIGoalType.MoveToEnemy && this.m_AI.m_ID == AI.AIID.BlackCaiman) { this.m_AI.m_SoundModule.PlayRandomGrowlSound(); } }
private AIGoal CreateGoal(string goal_name) { Type type = Type.GetType("AIs.Goal" + goal_name); if (DebugUtils.Assert(type != null, "[GoalsModule::CreateGoal] ERROR - Can't create goal " + goal_name, true, DebugUtils.AssertType.Info)) { return(null); } AIGoal aigoal = Activator.CreateInstance(type) as AIGoal; aigoal.Initialize(this.m_AI); return(aigoal); }
public void SetupActiveGoal() { if (this.m_ForcedGoal != AIGoalType.None) { if (this.m_ActiveGoal == null || this.m_ActiveGoal.m_Type != this.m_ForcedGoal) { for (int i = 0; i < this.m_Goals.Count; i++) { AIGoal aigoal = this.m_Goals[i]; if (aigoal.m_Type == this.m_ForcedGoal) { this.ActivateGoal(aigoal); return; } } } return; } int num = (this.m_ActiveGoal == null) ? int.MaxValue : this.m_ActiveGoal.m_Priority; for (int j = 0; j < this.m_Goals.Count; j++) { AIGoal aigoal = this.m_Goals[j]; if (aigoal.m_Priority >= num) { break; } float num2 = (aigoal.m_Probability != 1f) ? UnityEngine.Random.Range(0f, 1f) : 1f; if (num2 <= aigoal.m_Probability) { if (aigoal.ShouldPerform()) { this.ActivateGoal(aigoal); break; } } } if (this.m_ActiveGoal == null) { this.ActivateGoal(AIGoalType.Idle); if (this.m_ActiveGoal == null) { DebugUtils.Assert("[GoalsModule::SetupActiveGoal] Can't find proper goal - " + this.m_AI.name, true, DebugUtils.AssertType.Info); bool flag = false; if (flag) { this.SetupActiveGoal(); } } } }
private bool CanJumpBack() { if (this.m_GoalsModule.m_JumpBackGoal == null) { return(false); } AIGoal activeGoal = this.m_GoalsModule.m_ActiveGoal; if (activeGoal == null) { return(false); } AIGoalType type = activeGoal.m_Type; return(type != AIGoalType.JumpBack && ((type != AIGoalType.ReactOnHit && type != AIGoalType.HumanPunchBack) || this.m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.5f) && base.transform.position.Distance(this.m_EnemyModule.m_Enemy.transform.position) <= this.m_Params.m_JumpBackRange && UnityEngine.Random.Range(0f, 1f) <= this.m_GoalsModule.m_JumpBackGoal.m_Probability); }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); string str = this.m_AI.IsHunter() ? "HunterTaunt_" : "Taunt_"; int num = 0; while (num < 999 && this.m_AI.m_AnimationModule.ContainsState(str + num.ToString())) { this.m_Anims.Add(str + num.ToString()); num++; } if (this.m_Anims.Count == 0) { this.m_Anims.Add(this.m_AI.IsHunter() ? "HunterTaunt" : "Taunt"); } }
private bool CanJumpBack() { if (this.m_AI.m_GoalsModule.m_JumpBackGoal == null) { return(false); } AIGoal activeGoal = this.m_AI.m_GoalsModule.m_ActiveGoal; if (activeGoal == null) { return(false); } AIGoalType type = activeGoal.m_Type; return(type != AIGoalType.HumanJumpBack && type != AIGoalType.HumanJumpAttack && ((type != AIGoalType.HumanHitReaction && type != AIGoalType.HumanPunchBack) || this.m_AI.m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.5f) && base.transform.position.Distance(Player.Get().transform.position) <= this.m_AI.m_Params.m_JumpBackRange && (!(this.m_LastFailedJumpBackPos != Vector3.zero) || this.m_LastFailedJumpBackPos.Distance(base.transform.position) >= 5f) && Vector3.Dot(base.transform.forward, (Player.Get().transform.position - base.transform.position).normalized) >= 0.25f && UnityEngine.Random.Range(0f, 1f) <= this.m_AI.m_GoalsModule.m_JumpBackGoal.m_Probability); }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); string str = (!this.m_AI.IsHunter()) ? "Taunt_" : "HunterTaunt_"; for (int i = 0; i < 999; i++) { if (!this.m_AI.m_AnimationModule.ContainsState(str + i.ToString())) { break; } this.m_Anims.Add(str + i.ToString()); } if (this.m_Anims.Count == 0) { this.m_Anims.Add((!this.m_AI.IsHunter()) ? "Taunt" : "HunterTaunt"); } }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); string text = string.Empty; for (int i = 0; i < 999; i++) { text = "Idle_" + i.ToString(); if (!this.m_AI.m_AnimationModule.ContainsState(text)) { break; } this.m_Anims.Add(text); } if (this.m_Anims.Count == 0) { this.m_Anims.Add("Idle"); } }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); string text = string.Empty; string str = (this.m_Type == HitReaction.Type.None) ? string.Empty : this.m_Type.ToString(); for (int i = 0; i < 999; i++) { text = str + "HitReaction_" + i.ToString(); if (!this.m_AI.m_AnimationModule.ContainsState(text)) { break; } this.m_Anims.Add(text); } if (this.m_Anims.Count == 0) { this.m_Anims.Add("HitReaction"); } }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); string text = "PostAttack_"; if (this.m_AI.IsHunter()) { text = "Hunter" + text; } int num = 0; while (num < 999 && this.m_AI.m_AnimationModule.ContainsState(text + num.ToString())) { this.m_Anims.Add(text + num.ToString()); num++; } if (this.m_Anims.Count == 0) { this.m_Anims.Add(this.m_AI.IsHunter() ? "HunterPostAttack" : "PostAttack"); } this.m_Animation = this.m_Anims[UnityEngine.Random.Range(0, this.m_Anims.Count)]; }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); string text = "PostAttack_"; if (this.m_AI.IsHunter()) { text = "Hunter" + text; } for (int i = 0; i < 999; i++) { if (!this.m_AI.m_AnimationModule.ContainsState(text + i.ToString())) { break; } this.m_Anims.Add(text + i.ToString()); } if (this.m_Anims.Count == 0) { this.m_Anims.Add((!this.m_AI.IsHunter()) ? "PostAttack" : "HunterPostAttack"); } this.m_Animation = this.m_Anims[UnityEngine.Random.Range(0, this.m_Anims.Count)]; }
public override void OnUpdate() { base.OnUpdate(); AIGoal activeGoal = this.m_AI.m_GoalsModule.m_ActiveGoal; bool flag = false; if (!MainLevel.Instance.IsPause() && activeGoal != null && activeGoal.m_Type == AIGoalType.MoveToEnemy && this.m_AI.m_HostileStateModule && this.m_AI.m_HostileStateModule.m_State == HostileStateModule.State.Upset) { flag = true; } if (flag) { if (!this.m_IdleAudioSource.isPlaying) { AudioClip clip = AISoundModule.s_IdleClips[(int)this.m_AI.m_ID][UnityEngine.Random.Range(0, AISoundModule.s_IdleClips[(int)this.m_AI.m_ID].Count)]; this.m_IdleAudioSource.PlayOneShot(clip); return; } } else if (this.m_IdleAudioSource.isPlaying) { this.m_IdleAudioSource.Stop(); } }
public override void Initialize(AI ai, AIGoal goal) { base.Initialize(ai, goal); this.m_HumanAI = (HumanAI)ai; }
public void OnDeactivateGoal(AIGoal goal) { this.m_PrevGoal = this.m_ActiveGoal; this.m_ActiveGoal = null; this.m_AI.m_AnimationModule.SetWantedAnim(string.Empty); }
public virtual void Initialize(AI ai, AIGoal goal) { this.m_AI = ai; DebugUtils.Assert(this.m_AI, true); this.m_Goal = goal; }