protected override void OnActivate()
        {
            AIPathPoint aipathPoint = this.GetClosestPathPointInRange(EnemyAISpawnManager.Get().m_MinActivationDistance, EnemyAISpawnManager.Get().m_MaxActivationDistance);

            if (!aipathPoint)
            {
                float num = 0f;
                aipathPoint = this.GetClosestPathPoint(out num);
            }
            Vector3 normalized = (aipathPoint.m_Next.transform.position - aipathPoint.transform.position).normalized;

            foreach (HumanAI humanAI in this.m_Members)
            {
                humanAI.transform.position = aipathPoint.transform.position + UnityEngine.Random.insideUnitSphere * humanAI.m_PatrolModule.m_PathShift;
                humanAI.transform.rotation = Quaternion.LookRotation(normalized, Vector3.up);
                humanAI.m_PatrolModule.m_CurrentPathPoint = aipathPoint.m_Next;
                humanAI.m_PatrolModule.CalcPath();
            }
            if (this.m_Members.Count > 0)
            {
                this.m_Leader = this.m_Members[UnityEngine.Random.Range(0, this.m_Members.Count)];
            }
            else
            {
                this.m_Leader = null;
            }
            base.OnActivate();
        }
Beispiel #2
0
 protected override void OnDisable()
 {
     base.OnDisable();
     AIManager.Get().OnDisableAI(this);
     NoiseManager.UnregisterReceiver(this);
     if (this.IsCat())
     {
         EnemyAISpawnManager.Get().OnDeactivatePredator(this);
     }
 }
Beispiel #3
0
 protected override void Start()
 {
     this.m_Params = AIManager.Get().m_AIParamsMap[(int)this.m_ID];
     if (this.m_Params.m_BigAnimal)
     {
         if (this.m_ID == AI.AIID.BlackCaiman)
         {
             this.m_SoundModule = base.gameObject.AddComponent <BlackCaimanSoundModule>();
         }
         else
         {
             this.m_SoundModule = base.gameObject.AddComponent <BigAnimalSoundModule>();
         }
     }
     else if (this.m_ID == AI.AIID.Mouse || this.m_ID == AI.AIID.CaneToad)
     {
         this.m_SoundModule = base.gameObject.AddComponent <AISoundModule>();
     }
     if (this.m_SoundModule && this.m_Trap && (this.m_Trap.m_Effect == Trap.Effect.Block || this.m_Trap.m_Info.m_ID == ItemID.Snare_Trap))
     {
         this.m_SoundModule.RequestSound(AISoundType.Panic);
     }
     AIManager.Get().RegisterAI(this);
     base.Start();
     this.m_StartExecuted = true;
     this.OnEnable();
     if (this.IsCat())
     {
         EnemyAISpawnManager.Get().OnActivatePredator(this);
     }
     AudioSource[] components = base.GetComponents <AudioSource>();
     for (int i = 0; i < components.Length; i++)
     {
         components[i].rolloffMode = AudioRolloffMode.Linear;
     }
     this.UpdateSwimming();
     if (this.m_StartAttractor)
     {
         this.SetAttractor(this.m_StartAttractor);
     }
     if (this.m_ID == AI.AIID.PoisonDartFrog || this.m_ID == AI.AIID.CaneToad)
     {
         this.m_BoxCollider.isTrigger = true;
     }
 }
Beispiel #4
0
        public virtual void OnDie()
        {
            this.m_HasBody = GreenHellGame.Instance.GetPrefab(this.m_ID.ToString() + "_Body");
            if (!this.m_HasBody)
            {
                this.AddDeadBodyComponent();
            }
            List <BeingModule> list = new List <BeingModule>();

            base.GetComponents <BeingModule>(list);
            for (int i = 0; i < list.Count; i++)
            {
                list[i].OnDie();
            }
            if (this.m_Params.m_BigAnimal || this.m_Params.m_Human)
            {
                foreach (Behaviour behaviour in base.GetComponents <Behaviour>())
                {
                    Type type = behaviour.GetType();
                    if (Array.IndexOf <Type>(AI.s_DontRemoveComponents, type) == -1)
                    {
                        if (behaviour is IReplicatedBehaviour)
                        {
                            behaviour.enabled = false;
                        }
                        else
                        {
                            this.DestroyComponentWithEvent(behaviour);
                        }
                    }
                }
                this.m_BoxCollider.center = base.transform.InverseTransformPoint(this.m_Renderer.bounds.center);
                this.m_BoxCollider.size   = this.m_Renderer.bounds.size;
                this.StartRagdoll();
            }
            if (this.m_Spawner != null)
            {
                this.m_Spawner.OnDestroyAI(this);
                this.m_Spawner = null;
            }
            if (this.IsCat())
            {
                EnemyAISpawnManager.Get().OnDeactivatePredator(this);
            }
        }
Beispiel #5
0
 public void Activate()
 {
     base.gameObject.SetActive(true);
     foreach (GameObject gameObject in this.m_AllObjects)
     {
         gameObject.SetActive(true);
     }
     if (!this.m_ChallengeGroup && this.m_FromBalance)
     {
         int currentGroupMembersCount = EnemyAISpawnManager.Get().GetCurrentGroupMembersCount();
         while (this.m_Members.Count > currentGroupMembersCount)
         {
             HumanAI humanAI = this.m_Members[UnityEngine.Random.Range(0, this.m_Members.Count)];
             this.RemovedAI(humanAI, false);
             UnityEngine.Object.Destroy(humanAI.gameObject);
         }
     }
     this.m_Active = true;
     this.OnActivate();
 }
Beispiel #6
0
 private bool CanSpawn()
 {
     return(!(AIManager.Get() == null) && !ScenarioManager.Get().IsDreamOrPreDream() && (!AI.IsCat(this.m_ID) || EnemyAISpawnManager.Get().CanSpawnPredator()) && DifficultySettings.IsAIIDEnabled(this.m_ID) && this.m_AICount < this.GetWantedAICount() && (!this.m_SpawnersGroup || this.m_SpawnersGroup.CanSpawnAI()));
 }
Beispiel #7
0
 protected virtual void OnDeactivate()
 {
     EnemyAISpawnManager.Get().OnDeactivateGroup(this);
     this.SetState(HumanAIGroup.State.None);
 }