Example #1
0
 protected override void OnDisable()
 {
     base.OnDisable();
     AIManager.Get().OnDisableAI(this);
     NoiseManager.UnregisterReceiver(this);
     this.m_Visible = false;
 }
Example #2
0
        public override void Initialize()
        {
            base.Initialize();
            this.m_WantedBlend       = this.DEFAULT_BLEND;
            this.m_WantedAttackBlend = this.DEFAULT_BLEND;
            TextAssetParser textAssetParser = AIManager.Get().m_AnimatorDataParsers[this.GetStatesDataScript()];

            for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
            {
                Key key = textAssetParser.GetKey(i);
                if (key.GetName() == "State")
                {
                    StateData stateData = new StateData();
                    stateData.m_ClipName = key.GetVariable(1).SValue;
                    stateData.m_Duration = key.GetVariable(2).FValue;
                    stateData.m_Loop     = (key.GetVariable(3).IValue != 0);
                    this.m_StatesData.Add(key.GetVariable(0).SValue, stateData);
                    this.m_StateNames.Add(key.GetVariable(0).SValue);
                    if (!this.m_HasSpecificIdle)
                    {
                        this.m_HasSpecificIdle = key.GetVariable(0).SValue.Contains("SpecificIdle");
                    }
                }
            }
        }
        public override void Initialize(Being being)
        {
            base.Initialize(being);
            this.m_AudioSource = base.gameObject.AddComponent <AudioSource>();
            this.m_AudioSource.outputAudioMixerGroup = GreenHellGame.Instance.GetAudioMixerGroup(AudioMixerGroupGame.AI);
            this.m_AudioSource.spatialBlend          = 1f;
            this.m_AudioSource.rolloffMode           = AudioRolloffMode.Linear;
            this.m_AudioSource.minDistance           = 2f;
            this.m_AudioSource.maxDistance           = 25f;
            this.m_AudioSource.spatialize            = true;
            this.m_AudioSource.priority    = 50;
            this.m_AudioSource.playOnAwake = false;
            switch (this.m_AI.m_SoundPreset)
            {
            case AI.SoundPreset.Tribe0:
                this.m_Sounds = AIManager.Get().m_Tribe0Sounds;
                break;

            case AI.SoundPreset.Tribe1:
                this.m_Sounds = AIManager.Get().m_Tribe1Sounds;
                break;

            case AI.SoundPreset.Tribe2:
                this.m_Sounds = AIManager.Get().m_Tribe2Sounds;
                break;
            }
            this.m_HumanAI = (HumanAI)this.m_AI;
        }
Example #4
0
        private void SpawnBlood(DamageInfo info)
        {
            if (AI.IsTurtle(this.m_AI.m_ID) || this.m_AI.m_ID == AI.AIID.ArmadilloThreeBanded)
            {
                return;
            }
            AIManager.BloodFXType key  = info.m_DamageItem ? info.m_DamageItem.m_Info.m_BloodFXType : AIManager.BloodFXType.Blunt;
            List <string>         list = AIManager.Get().m_BloodFXNames[(int)key];

            if (list.Count == 0)
            {
                DebugUtils.Assert("Missing blood fxes!", true, DebugUtils.AssertType.Info);
                return;
            }
            string text = list[UnityEngine.Random.Range(0, list.Count)];

            text += ((this.m_AI.m_Params.m_Human || this.m_AI.m_Params.m_BigAnimal) ? "_M" : "_S");
            Vector3     vector             = Vector3.zero;
            RagdollBone closestRagdollBone = this.m_AI.GetClosestRagdollBone(info.m_Position);

            if (closestRagdollBone)
            {
                vector = closestRagdollBone.transform.position;
            }
            else
            {
                vector = base.transform.position;
            }
            Vector3 forward = (info.m_Damager && info.m_Damager.IsPlayer()) ? (Camera.main.transform.position - Camera.main.transform.right - vector).normalized : (-info.m_HitDir);

            ParticlesManager.Get().Spawn(text, vector, Quaternion.LookRotation(forward), Vector3.zero, null, -1f, false);
        }
Example #5
0
        private void UpdateActivity()
        {
            if (Time.time < this.m_NextUpdateActivityTime)
            {
                return;
            }
            float num  = 0f;
            bool  flag = this.m_Bounds.Contains(Player.Get().transform.position);
            bool  flag2;

            if (flag)
            {
                flag2 = true;
            }
            else
            {
                Vector3 vector = this.m_Bounds.ClosestPoint(Player.Get().transform.position);
                num   = vector.Distance(Player.Get().transform.position);
                flag2 = (num <= AIManager.Get().m_FishDeactivationRange);
            }
            if (flag2 && !base.gameObject.activeSelf)
            {
                this.Activate();
                if (this.m_Water == null)
                {
                    this.FindWater();
                }
            }
            else if (!flag2 && base.gameObject.activeSelf)
            {
                this.Deactivate();
            }
            this.m_NextUpdateActivityTime = Time.time + CJTools.Math.GetProportionalClamp(0.1f, 5f, num, AIManager.Get().m_FishDeactivationRange, AIManager.Get().m_FishDeactivationRange * 5f);
        }
 public override void Initialize()
 {
     base.Initialize();
     this.m_AudioSource = base.gameObject.AddComponent <AudioSource>();
     this.m_AudioSource.outputAudioMixerGroup = GreenHellGame.Instance.GetAudioMixerGroup(AudioMixerGroupGame.AI);
     this.m_AudioSource.spatialBlend          = 1f;
     this.m_AudioSource.rolloffMode           = AudioRolloffMode.Linear;
     this.m_AudioSource.minDistance           = 2f;
     this.m_AudioSource.maxDistance           = 25f;
     this.m_AudioSource.spatialize            = true;
     AI.SoundPreset soundPreset = this.m_AI.m_SoundPreset;
     if (soundPreset != AI.SoundPreset.Tribe0)
     {
         if (soundPreset != AI.SoundPreset.Tribe1)
         {
             if (soundPreset == AI.SoundPreset.Tribe2)
             {
                 this.m_Sounds = AIManager.Get().m_Tribe2Sounds;
             }
         }
         else
         {
             this.m_Sounds = AIManager.Get().m_Tribe1Sounds;
         }
     }
     else
     {
         this.m_Sounds = AIManager.Get().m_Tribe0Sounds;
     }
     this.m_HumanAI = (HumanAI)this.m_AI;
 }
Example #7
0
 protected override void Awake()
 {
     base.Awake();
     AIManager.Get().m_DeadBodies.Add(this);
     this.m_Renderer  = base.GetComponentInChildren <SkinnedMeshRenderer>();
     this.m_VisModule = base.GetComponent <VisModule>();
 }
Example #8
0
        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;
            }
        }
Example #9
0
 protected override void OnDisable()
 {
     base.OnDisable();
     AIManager.Get().OnDisableAI(this);
     NoiseManager.UnregisterReceiver(this);
     if (this.IsCat())
     {
         EnemyAISpawnManager.Get().OnDeactivatePredator(this);
     }
 }
Example #10
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     AIManager.Get().UnregisterAI(this);
     if (this.m_Spawner != null)
     {
         this.m_Spawner.OnDestroyAI(this);
         this.m_Spawner = null;
     }
 }
Example #11
0
 private void OnDestroy()
 {
     for (int i = 0; i < this.m_AIDatas.Count; i++)
     {
         if (this.m_AIDatas[i].m_AI)
         {
             this.m_AIDatas[i].m_AI.m_Spawner = null;
         }
     }
     AIManager.Get().UnregisterSpawner(this);
 }
Example #12
0
 protected override void OnEnable()
 {
     if (!this.m_StartExecuted)
     {
         return;
     }
     base.OnEnable();
     AIManager.Get().OnEnableAI(this);
     NoiseManager.RegisterReceiver(this);
     if (!this.IsHuman() && !this.IsCat() && !this.IsCaiman() && !this.IsStringray())
     {
         Physics.IgnoreCollision(Player.Get().m_Collider, this.m_BoxCollider);
     }
 }
Example #13
0
        private bool CanSpawn()
        {
            if (AIManager.Get() == null)
            {
                return(false);
            }
            if (this.m_ID == AI.AIID.Jaguar && !BalanceSystem.Get().CanSpawnJaguar())
            {
                return(false);
            }
            int num = (!MainLevel.Instance.IsNight()) ? this.m_DayCount : this.m_NightCount;

            return(this.m_AICount < num && (!this.m_SpawnersGroup || this.m_SpawnersGroup.CanSpawnAI()));
        }
Example #14
0
 protected override void OnEnable()
 {
     if (!this.m_StartExecuted)
     {
         return;
     }
     base.OnEnable();
     AIManager.Get().OnEnableAI(this);
     NoiseManager.RegisterReceiver(this);
     if (!this.IsHuman() && this.m_ID != AI.AIID.Jaguar)
     {
         Physics.IgnoreCollision(Player.Get().GetComponent <Collider>(), this.m_BoxCollider);
         this.m_BoxCollider.isTrigger = true;
     }
 }
Example #15
0
 private void PlayDamageSound()
 {
     if (this.m_DamageAudioSource == null)
     {
         this.m_DamageAudioSource = base.gameObject.AddComponent <AudioSource>();
         this.m_DamageAudioSource.outputAudioMixerGroup = GreenHellGame.Instance.GetAudioMixerGroup(AudioMixerGroupGame.AI);
         this.m_DamageAudioSource.spatialBlend          = 1f;
         this.m_DamageAudioSource.rolloffMode           = AudioRolloffMode.Linear;
         this.m_DamageAudioSource.maxDistance           = 12f;
         this.m_DamageAudioSource.spatialize            = true;
     }
     this.m_DamageAudioSource.Stop();
     this.m_DamageAudioSource.clip = AIManager.Get().m_FleshHitSounds[UnityEngine.Random.Range(0, AIManager.Get().m_FleshHitSounds.Count)];
     this.m_DamageAudioSource.Play();
 }
Example #16
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;
     }
 }
Example #17
0
        public void Harvest()
        {
            base.gameObject.ReplRequestOwnership(false);
            AIParams aiparams = AIManager.Get().m_AIParamsMap[(int)this.m_AIID];

            foreach (GameObject gameObject in aiparams.m_HarvestingResult)
            {
                Item component = gameObject.GetComponent <Item>();
                DebugUtils.Assert(component != null, "[DeadBody:OnExecute] Harvesting result list contains object without Item component - " + gameObject.name, true, DebugUtils.AssertType.Info);
                ItemID itemID = (ItemID)Enum.Parse(typeof(ItemID), component.m_InfoName);
                if (MainLevel.s_GameTime - this.m_StartTime >= aiparams.m_DeadBodyFoodSpoilTime)
                {
                    ItemInfo info = ItemsManager.Get().GetInfo(itemID);
                    if (info.IsFood())
                    {
                        FoodInfo foodInfo = (FoodInfo)info;
                        if (foodInfo.m_SpoilEffectID != ItemID.None)
                        {
                            itemID = foodInfo.m_SpoilEffectID;
                        }
                    }
                }
                for (int i = 0; i < Skill.Get <HarvestingAnimalsSkill>().GetItemsCountMul(); i++)
                {
                    ItemsManager.Get().CreateItem(itemID, false, base.transform).Take();
                }
            }
            if (this.m_AddHarvestingItem != ItemID.None)
            {
                ItemsManager.Get().CreateItem(this.m_AddHarvestingItem, false, base.transform).Take();
            }
            Item[] componentsInChildren = base.transform.GetComponentsInChildren <Item>();
            for (int j = 0; j < componentsInChildren.Length; j++)
            {
                componentsInChildren[j].transform.parent = null;
                componentsInChildren[j].StaticPhxRequestRemove();
                componentsInChildren[j].Take();
            }
            this.OnHarvest();
            UnityEngine.Object.Destroy(base.gameObject);
            if (!AI.IsHuman(this.m_AIID))
            {
                Skill.Get <HarvestingAnimalsSkill>().OnSkillAction();
            }
        }
Example #18
0
        private void InitMaterials()
        {
            switch (AIManager.Get().GetBodyPaintingIndex())
            {
            case 0:
                this.m_Renderer.materials = AIManager.Get().m_Painting0;
                return;

            case 1:
                this.m_Renderer.materials = AIManager.Get().m_Painting1;
                return;

            case 2:
                this.m_Renderer.materials = AIManager.Get().m_Painting2;
                return;

            default:
                return;
            }
        }
Example #19
0
        private void Start()
        {
            Vector3 size = base.gameObject.GetComponent <BoxCollider>().size;

            this.m_MinDistance = AIManager.Get().m_AIActivationRange * 0.7f;
            this.m_MaxDistance = AIManager.Get().m_AIActivationRange * 0.9f;
            for (int i = 0; i < 99; i++)
            {
                Vector3 spawnPosition = this.GetSpawnPosition();
                if (spawnPosition != Vector3.zero)
                {
                    this.m_Positions.Add(spawnPosition);
                }
                if (this.m_Positions.Count >= Mathf.Max(this.m_NightCount, this.m_DayCount) * 2)
                {
                    break;
                }
            }
            AIManager.Get().RegisterSpawner(this);
        }
Example #20
0
        private void Start()
        {
            BoxCollider component = base.gameObject.GetComponent <BoxCollider>();
            Vector3     size      = component.size;

            this.m_MinDistance = AIManager.Get().m_AIActivationRange * 0.7f;
            this.m_MaxDistance = AIManager.Get().m_AIActivationRange * 0.9f;
            int num = Mathf.Max(this.m_DayCount, this.m_NightCount);

            for (int i = 0; i < num; i++)
            {
                AISpawnData aispawnData = new AISpawnData();
                aispawnData.m_Position = this.GetSpawnPosition();
                if (aispawnData.m_Position != Vector3.zero)
                {
                    this.m_AIDatas.Add(aispawnData);
                }
            }
            AIManager.Get().RegisterSpawner(this);
        }
Example #21
0
 protected override void Start()
 {
     this.m_Params = AIManager.Get().m_AIParamsMap[(int)this.m_ID];
     if (this.m_Params.m_BigAnimal)
     {
         this.m_SoundModule = base.gameObject.AddComponent <BigAnimalSoundModule>();
     }
     AIManager.Get().RegisterAI(this);
     base.Start();
     this.m_StartExecuted = true;
     this.OnEnable();
     if (this.m_ID == AI.AIID.Jaguar)
     {
         BalanceSystem.Get().OnJaguarActivated();
     }
     AudioSource[] components = base.GetComponents <AudioSource>();
     foreach (AudioSource audioSource in components)
     {
         audioSource.rolloffMode = AudioRolloffMode.Linear;
     }
 }
Example #22
0
        public override void OnTakeDamage(DamageInfo info)
        {
            base.OnTakeDamage(info);
            AIManager.BloodFXType key  = (!info.m_DamageItem) ? AIManager.BloodFXType.Blunt : info.m_DamageItem.m_Info.m_BloodFXType;
            List <string>         list = AIManager.Get().m_BloodFXNames[(int)key];

            if (list.Count == 0)
            {
                DebugUtils.Assert("Missing blood fxes!", true, DebugUtils.AssertType.Info);
                return;
            }
            string text = list[UnityEngine.Random.Range(0, list.Count)];

            text += ((!this.m_AI.m_Params.m_Human && !this.m_AI.m_Params.m_BigAnimal) ? "_S" : "_M");
            Vector3 vector = Vector3.zero;

            if (this.m_AI.m_RagdollBones.Count > 0)
            {
                float num = float.MaxValue;
                foreach (Collider collider in this.m_AI.m_RagdollBones.Keys)
                {
                    Vector3 vector2 = collider.ClosestPoint(info.m_Position);
                    float   num2    = vector2.Distance(info.m_Position);
                    if (num2 < num)
                    {
                        vector = vector2;
                        Transform transform = collider.transform;
                        num = num2;
                    }
                }
            }
            else
            {
                vector = base.transform.position;
            }
            ParticlesManager.Get().Spawn(text, vector, Quaternion.LookRotation((Camera.main.transform.position - Camera.main.transform.right - vector).normalized), null);
            this.m_DamageAudioSource.Stop();
            this.m_DamageAudioSource.clip = AIManager.Get().m_FleshHitSounds[UnityEngine.Random.Range(0, AIManager.Get().m_FleshHitSounds.Count)];
            this.m_DamageAudioSource.Play();
        }
Example #23
0
        private void OnHarvest()
        {
            AIParams aiparams = AIManager.Get().m_AIParamsMap[(int)this.m_AIID];

            Player.Get().DirtAddOnHarvest(aiparams.m_DirtAddOnHarvest);
        }
Example #24
0
 private void OnDestroy()
 {
     AIManager.Get().UnregisterSpawner(this);
 }
Example #25
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()));
 }
Example #26
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     AIManager.Get().m_DeadBodies.Remove(this);
 }