Exemple #1
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemTime          = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
            m_subsystemTerrain       = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            m_subsystemAudio         = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
            m_subsystemAmbientSounds = base.Project.FindSubsystem <SubsystemAmbientSounds>(throwOnError: true);
            m_subsystemParticles     = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
            ComponentBody            = base.Entity.FindComponent <ComponentBody>();
            float value = valuesDictionary.GetValue <float>("FireDuration");

            if (value > 0f)
            {
                SetOnFire(null, value);
            }
        }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     base.Load(valuesDictionary, idToEntityMap);
     m_subsystemTime     = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemSky      = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentCreature.ComponentHealth.Attacked += delegate(ComponentCreature attacker)
     {
         if (DeathPhase == 0f && m_componentCreature.ComponentHealth.Health == 0f)
         {
             DeathCauseOffset = attacker.ComponentBody.BoundingBox.Center() - m_componentCreature.ComponentBody.BoundingBox.Center();
         }
     };
 }
Exemple #3
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime                  = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemSky                   = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_componentCreature              = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding           = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_subsystemCampfireBlockBehavior = base.Project.FindSubsystem <SubsystemCampfireBlockBehavior>(throwOnError: true);
     m_dayRange            = valuesDictionary.GetValue <float>("DayRange");
     m_nightRange          = valuesDictionary.GetValue <float>("NightRange");
     m_periodicEventOffset = m_random.Float(0f, 10f);
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_target          = null;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo((m_importanceLevel < 10f) ? "Circle" : "Move");
         }
         else if (m_subsystemTime.PeriodicGameTimeEvent(1.0, m_periodicEventOffset))
         {
             m_target = FindTarget(out float targetScore);
             if (m_target.HasValue)
             {
                 if (m_random.Float(0f, 1f) < 0.015f)
                 {
                     m_ignoreFireUntil = m_subsystemTime.GameTime + 20.0;
                 }
                 Vector3.Distance(m_target.Value, m_componentCreature.ComponentBody.Position);
                 if (m_subsystemTime.GameTime < m_ignoreFireUntil)
                 {
                     m_importanceLevel = 0f;
                 }
                 else
                 {
                     m_importanceLevel = ((targetScore > 0.5f) ? 250f : m_random.Float(1f, 5f));
                 }
             }
             else
             {
                 m_importanceLevel = 0f;
             }
         }
     }, null);
Exemple #4
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemBodies      = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_componentMount       = base.Entity.FindComponent <ComponentMount>(throwOnError: true);
     m_isEnabled            = base.Entity.ValuesDictionary.DatabaseObject.Name.EndsWith("_Saddled");
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Wait");
         }
     }, null);
     m_stateMachine.AddState("Wait", delegate
     {
         ComponentRider componentRider = FindNearbyRider(6f);
         if (componentRider != null)
         {
             m_componentPathfinding.SetDestination(componentRider.ComponentCreature.ComponentBody.Position, m_random.Float(0.2f, 0.3f), 3.25f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
             if (m_random.Float(0f, 1f) < 0.5f)
             {
                 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
             }
         }
     }, delegate
     {
         if (m_componentMount.Rider != null)
         {
             m_stateMachine.TransitionTo("Steed");
         }
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
     }, null);
     m_stateMachine.AddState("Steed", delegate
     {
         m_componentPathfinding.Stop();
         m_speed      = 0f;
         m_speedLevel = 1;
     }, delegate
     {
         ProcessRidingOrders();
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Exemple #5
0
 public static void Load(Project Project)
 {
     if (LoadedProject)
     {
         return;
     }
     SubsystemGameInfo                = Project.FindSubsystem <SubsystemGameInfo>(true);
     SubsystemAudio                   = Project.FindSubsystem <SubsystemAudio>(true);
     SubsystemBodies                  = Project.FindSubsystem <SubsystemBodies>(true);
     SubsystemTime                    = Project.FindSubsystem <SubsystemTime>(true);
     SubsystemItemsScanner            = Project.FindSubsystem <SubsystemItemsScanner>(true);
     SubsystemMovingBlocks            = Project.FindSubsystem <SubsystemMovingBlocks>(true);
     SubsystemBlockEntities           = Project.FindSubsystem <SubsystemBlockEntities>(true);
     SubsystemExplosions              = Project.FindSubsystem <SubsystemExplosions>(true);
     SubsystemCollapsingBlockBehavior = Project.FindSubsystem <SubsystemCollapsingBlockBehavior>(true);
     SubsystemPickables               = Project.FindSubsystem <SubsystemPickables>(true);
     SubsystemProjectiles             = Project.FindSubsystem <SubsystemProjectiles>(true);
     Terrain       = (SubsystemTerrain = Project.FindSubsystem <SubsystemTerrain>(true)).Terrain;
     LoadedProject = true;
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemTimeOfDay          = base.Project.FindSubsystem <SubsystemTimeOfDay>(throwOnError: true);
     m_subsystemTime               = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemGameInfo           = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTerrain            = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemWeather            = base.Project.FindSubsystem <SubsystemWeather>(throwOnError: true);
     m_subsystemAudio              = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemBodies             = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemFluidBlockBehavior = base.Project.FindSubsystem <SubsystemFluidBlockBehavior>(throwOnError: true);
     m_sunTexture    = ContentManager.Get <Texture2D>("Textures/Sun");
     m_glowTexture   = ContentManager.Get <Texture2D>("Textures/SkyGlow");
     m_cloudsTexture = ContentManager.Get <Texture2D>("Textures/Clouds");
     for (int i = 0; i < 8; i++)
     {
         m_moonTextures[i] = ContentManager.Get <Texture2D>("Textures/Moon" + (i + 1).ToString(CultureInfo.InvariantCulture));
     }
     UpdateLightAndViewParameters();
     Display.DeviceReset += Display_DeviceReset;
 }
Exemple #7
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime           = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemAudio          = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemSoundMaterials = base.Project.FindSubsystem <SubsystemSoundMaterials>(throwOnError: true);
     m_componentCreature       = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_idleSound              = valuesDictionary.GetValue <string>("IdleSound");
     m_painSound              = valuesDictionary.GetValue <string>("PainSound");
     m_moanSound              = valuesDictionary.GetValue <string>("MoanSound");
     m_sneezeSound            = valuesDictionary.GetValue <string>("SneezeSound");
     m_coughSound             = valuesDictionary.GetValue <string>("CoughSound");
     m_pukeSound              = valuesDictionary.GetValue <string>("PukeSound");
     m_attackSound            = valuesDictionary.GetValue <string>("AttackSound");
     m_idleSoundMinDistance   = valuesDictionary.GetValue <float>("IdleSoundMinDistance");
     m_painSoundMinDistance   = valuesDictionary.GetValue <float>("PainSoundMinDistance");
     m_moanSoundMinDistance   = valuesDictionary.GetValue <float>("MoanSoundMinDistance");
     m_sneezeSoundMinDistance = valuesDictionary.GetValue <float>("SneezeSoundMinDistance");
     m_coughSoundMinDistance  = valuesDictionary.GetValue <float>("CoughSoundMinDistance");
     m_pukeSoundMinDistance   = valuesDictionary.GetValue <float>("PukeSoundMinDistance");
     m_attackSoundMinDistance = valuesDictionary.GetValue <float>("AttackSoundMinDistance");
 }
Exemple #8
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     m_subsystemGameInfo       = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTime           = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemExplosions     = base.Project.FindSubsystem <SubsystemExplosions>(throwOnError: true);
     m_subsystemProjectiles    = base.Project.FindSubsystem <SubsystemProjectiles>(throwOnError: true);
     m_subsystemBlockBehaviors = base.Project.FindSubsystem <SubsystemBlockBehaviors>(throwOnError: true);
     foreach (Projectile projectile in m_subsystemProjectiles.Projectiles)
     {
         ScanProjectile(projectile);
     }
     m_subsystemProjectiles.ProjectileAdded += delegate(Projectile projectile)
     {
         ScanProjectile(projectile);
     };
     m_subsystemProjectiles.ProjectileRemoved += delegate(Projectile projectile)
     {
         m_projectiles.Remove(projectile);
     };
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime     = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = m_random.Float(0f, 1f);
     }, delegate
     {
         if (m_componentCreature.ComponentBody.StandingOnValue.HasValue && m_random.Float(0f, 1f) < 0.05f * m_subsystemTime.GameTimeDelta)
         {
             m_importanceLevel = m_random.Float(1f, 5f);
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("LookAround");
         }
     }, null);
     m_stateMachine.AddState("LookAround", delegate
     {
         m_lookAroundTime = m_random.Float(8f, 15f);
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_lookAroundTime <= 0f)
         {
             m_importanceLevel = 0f;
         }
         else if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
         }
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
         m_lookAroundTime -= m_subsystemTime.GameTimeDelta;
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Exemple #10
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemPlayers  = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemViews    = base.Project.FindSubsystem <SubsystemGameWidgets>(throwOnError: true);
     m_subsystemTerrain  = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemTime     = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     foreach (KeyValuePair <string, object> item in valuesDictionary.GetValue <ValuesDictionary>("Chunks"))
     {
         ValuesDictionary valuesDictionary2 = (ValuesDictionary)item.Value;
         SpawnChunk       spawnChunk        = new SpawnChunk();
         spawnChunk.Point           = HumanReadableConverter.ConvertFromString <Point2>(item.Key);
         spawnChunk.IsSpawned       = valuesDictionary2.GetValue <bool>("IsSpawned");
         spawnChunk.LastVisitedTime = valuesDictionary2.GetValue <double>("LastVisitedTime");
         string value = valuesDictionary2.GetValue("SpawnsData", string.Empty);
         if (!string.IsNullOrEmpty(value))
         {
             LoadSpawnsData(value, spawnChunk.SpawnsData);
         }
         m_chunks[spawnChunk.Point] = spawnChunk;
     }
 }
Exemple #11
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTerrain        = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemBodies         = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemMovingBlocks   = base.Project.FindSubsystem <SubsystemMovingBlocks>(throwOnError: true);
     m_subsystemGameInfo       = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTime           = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemAudio          = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemSoundMaterials = base.Project.FindSubsystem <SubsystemSoundMaterials>(throwOnError: true);
     m_subsystemBlockBehaviors = base.Project.FindSubsystem <SubsystemBlockBehaviors>(throwOnError: true);
     ComponentCreature         = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     ComponentPlayer           = base.Entity.FindComponent <ComponentPlayer>();
     if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && ComponentPlayer != null)
     {
         Inventory = base.Entity.FindComponent <ComponentCreativeInventory>();
     }
     else
     {
         Inventory = base.Entity.FindComponent <ComponentInventory>();
     }
     AttackPower = valuesDictionary.GetValue <float>("AttackPower");
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemTime             = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemTerrain          = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemSky              = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemAnimatedTextures = base.Project.FindSubsystem <SubsystemAnimatedTextures>(throwOnError: true);
     m_shader = ContentManager.Get <Shader>("Shaders/AlphaTested");
     foreach (ValuesDictionary value9 in valuesDictionary.GetValue <ValuesDictionary>("MovingBlockSets").Values)
     {
         Vector3            value  = value9.GetValue <Vector3>("Position");
         Vector3            value2 = value9.GetValue <Vector3>("TargetPosition");
         float              value3 = value9.GetValue <float>("Speed");
         float              value4 = value9.GetValue <float>("Acceleration");
         float              value5 = value9.GetValue <float>("Drag");
         Vector2            value6 = value9.GetValue("Smoothness", Vector2.Zero);
         string             value7 = value9.GetValue <string>("Id", null);
         object             value8 = value9.GetValue <object>("Tag", null);
         List <MovingBlock> list   = new List <MovingBlock>();
         string[]           array  = value9.GetValue <string>("Blocks").Split(new char[1]
         {
             ';'
         }, StringSplitOptions.RemoveEmptyEntries);
         foreach (string obj2 in array)
         {
             MovingBlock item   = default(MovingBlock);
             string[]    array2 = obj2.Split(new char[1]
             {
                 ','
             }, StringSplitOptions.RemoveEmptyEntries);
             item.Value    = HumanReadableConverter.ConvertFromString <int>(array2[0]);
             item.Offset.X = HumanReadableConverter.ConvertFromString <int>(array2[1]);
             item.Offset.Y = HumanReadableConverter.ConvertFromString <int>(array2[2]);
             item.Offset.Z = HumanReadableConverter.ConvertFromString <int>(array2[3]);
             list.Add(item);
         }
         AddMovingBlockSet(value, value2, value3, value4, value5, value6, list, value7, value8, testCollision: false);
     }
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemTime          = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemBlocksTexture = base.Project.FindSubsystem <SubsystemBlocksTexture>(throwOnError: true);
     Display.DeviceReset     += Display_DeviceReset;
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime   = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_componentGui    = base.Entity.FindComponent <ComponentGui>(throwOnError: true);
     m_componentPlayer = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemTime  = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemViews = base.Project.FindSubsystem <SubsystemGameWidgets>(throwOnError: true);
 }
        public void Update(float dt)
        {
            if (m_subsystemGameInfo.TotalElapsedGameTime > m_precipitationEndTime)
            {
                if (m_precipitationEndTime == 0.0)
                {
                    if (m_subsystemGameInfo.WorldSettings.StartingPositionMode == StartingPositionMode.Hard)
                    {
                        m_precipitationStartTime = m_subsystemGameInfo.TotalElapsedGameTime + (double)(60f * m_random.Float(2f, 3f));
                        m_lightningIntensity     = m_random.Float(0.5f, 1f);
                    }
                    else
                    {
                        m_precipitationStartTime = m_subsystemGameInfo.TotalElapsedGameTime + (double)(60f * m_random.Float(3f, 6f));
                        m_lightningIntensity     = m_random.Float(0.33f, 0.66f);
                    }
                }
                else
                {
                    m_precipitationStartTime = m_subsystemGameInfo.TotalElapsedGameTime + (double)(60f * m_random.Float(5f, 45f));
                    m_lightningIntensity     = ((m_random.Float(0f, 1f) < 0.5f) ? m_random.Float(0.33f, 1f) : 0f);
                }
                m_precipitationEndTime = m_precipitationStartTime + (double)(60f * m_random.Float(3f, 6f));
            }
            float num = (float)MathUtils.Max(0.0, MathUtils.Min(m_subsystemGameInfo.TotalElapsedGameTime - m_precipitationStartTime, m_precipitationEndTime - m_subsystemGameInfo.TotalElapsedGameTime));

            GlobalPrecipitationIntensity = (m_subsystemGameInfo.WorldSettings.AreWeatherEffectsEnabled ? MathUtils.Saturate(num * 0.04f) : 0f);
            if (GlobalPrecipitationIntensity == 1f && SubsystemTime.PeriodicGameTimeEvent(1.0, 0.0))
            {
                TerrainChunk[] allocatedChunks = SubsystemTerrain.Terrain.AllocatedChunks;
                for (int i = 0; i < allocatedChunks.Length; i++)
                {
                    TerrainChunk terrainChunk = allocatedChunks[m_random.Int(0, allocatedChunks.Length - 1)];
                    if (terrainChunk.State < TerrainChunkState.InvalidVertices1 || !m_random.Bool(m_lightningIntensity * 0.0002f))
                    {
                        continue;
                    }
                    int     num2   = terrainChunk.Origin.X + m_random.Int(0, 15);
                    int     num3   = terrainChunk.Origin.Y + m_random.Int(0, 15);
                    Vector3?vector = null;
                    for (int j = num2 - 8; j < num2 + 8; j++)
                    {
                        for (int k = num3 - 8; k < num3 + 8; k++)
                        {
                            int topHeight = SubsystemTerrain.Terrain.GetTopHeight(j, k);
                            if (!vector.HasValue || (float)topHeight > vector.Value.Y)
                            {
                                vector = new Vector3(j, topHeight, k);
                            }
                        }
                    }
                    if (vector.HasValue)
                    {
                        SubsystemSky.MakeLightningStrike(vector.Value);
                        return;
                    }
                }
            }
            if (Time.PeriodicEvent(0.5, 0.0))
            {
                float num4 = 0f;
                if (GlobalPrecipitationIntensity > 0f)
                {
                    float num5 = 0f;
                    foreach (Vector3 listenerPosition in m_subsystemAudio.ListenerPositions)
                    {
                        int     num6    = Terrain.ToCell(listenerPosition.X) - 5;
                        int     num7    = Terrain.ToCell(listenerPosition.Z) - 5;
                        int     num8    = Terrain.ToCell(listenerPosition.X) + 5;
                        int     num9    = Terrain.ToCell(listenerPosition.Z) + 5;
                        Vector3 vector2 = default(Vector3);
                        for (int l = num6; l <= num8; l++)
                        {
                            for (int m = num7; m <= num9; m++)
                            {
                                PrecipitationShaftInfo precipitationShaftInfo = GetPrecipitationShaftInfo(l, m);
                                if (precipitationShaftInfo.Type == PrecipitationType.Rain && precipitationShaftInfo.Intensity > 0f)
                                {
                                    vector2.X = (float)l + 0.5f;
                                    vector2.Y = MathUtils.Max(precipitationShaftInfo.YLimit, listenerPosition.Y);
                                    vector2.Z = (float)m + 0.5f;
                                    float num10    = vector2.X - listenerPosition.X;
                                    float num11    = 8f * (vector2.Y - listenerPosition.Y);
                                    float num12    = vector2.Z - listenerPosition.Z;
                                    float distance = MathUtils.Sqrt(num10 * num10 + num11 * num11 + num12 * num12);
                                    num5 += m_subsystemAudio.CalculateVolume(distance, 1.5f) * precipitationShaftInfo.Intensity;
                                }
                            }
                        }
                    }
                    num4 = MathUtils.Max(num4, num5);
                }
                m_targetRainSoundVolume = MathUtils.Saturate(1.5f * num4 / m_rainVolumeFactor);
            }
            m_rainSound.Volume = MathUtils.Saturate(MathUtils.Lerp(m_rainSound.Volume, SettingsManager.SoundsVolume * m_targetRainSoundVolume, 5f * dt));
            if (m_rainSound.Volume > AudioManager.MinAudibleVolume)
            {
                m_rainSound.Play();
            }
            else
            {
                m_rainSound.Pause();
            }
        }
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
            m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            m_subsystemPickables   = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
            m_subsystemAudio       = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
            m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
            m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
            EggBlock eggBlock = (EggBlock)BlocksManager.Blocks[118];

            m_layFrequency = valuesDictionary.GetValue <float>("LayFrequency");
            m_eggType      = eggBlock.GetEggTypeByCreatureTemplateName(base.Entity.ValuesDictionary.DatabaseObject.Name);
            m_stateMachine.AddState("Inactive", null, delegate
            {
                if (IsActive)
                {
                    m_stateMachine.TransitionTo("Move");
                }
            }, null);
            m_stateMachine.AddState("Stuck", delegate
            {
                m_stateMachine.TransitionTo("Move");
            }, null, null);
            m_stateMachine.AddState("Move", delegate
            {
                Vector3 position2 = m_componentCreature.ComponentBody.Position;
                float num         = 5f;
                Vector3 value3    = position2 + new Vector3(num * m_random.Float(-1f, 1f), 0f, num * m_random.Float(-1f, 1f));
                value3.Y          = m_subsystemTerrain.Terrain.GetTopHeight(Terrain.ToCell(value3.X), Terrain.ToCell(value3.Z)) + 1;
                m_componentPathfinding.SetDestination(value3, m_random.Float(0.4f, 0.6f), 0.5f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
            }, delegate
            {
                if (!m_componentPathfinding.Destination.HasValue)
                {
                    m_stateMachine.TransitionTo("Lay");
                }
                else if (m_componentPathfinding.IsStuck)
                {
                    if (m_random.Float(0f, 1f) < 0.5f)
                    {
                        m_stateMachine.TransitionTo("Stuck");
                    }
                    else
                    {
                        m_importanceLevel = 0f;
                    }
                }
            }, null);
            m_stateMachine.AddState("Lay", delegate
            {
                m_layTime = 0f;
            }, delegate
            {
                if (m_eggType != null)
                {
                    m_layTime += m_dt;
                    if (m_componentCreature.ComponentBody.StandingOnValue.HasValue)
                    {
                        m_componentCreature.ComponentLocomotion.LookOrder = new Vector2(0f, 0.25f * (float)MathUtils.Sin(20.0 * m_subsystemTime.GameTime) + m_layTime / 3f) - m_componentCreature.ComponentLocomotion.LookAngles;
                        if (m_layTime >= 3f)
                        {
                            m_importanceLevel = 0f;
                            int value         = Terrain.MakeBlockValue(118, 0, EggBlock.SetIsLaid(EggBlock.SetEggType(0, m_eggType.EggTypeIndex), isLaid: true));
                            Matrix matrix     = m_componentCreature.ComponentBody.Matrix;
                            Vector3 position  = 0.5f * (m_componentCreature.ComponentBody.BoundingBox.Min + m_componentCreature.ComponentBody.BoundingBox.Max);
                            Vector3 value2    = 3f * Vector3.Normalize(-matrix.Forward + 0.1f * matrix.Up + 0.2f * m_random.Float(-1f, 1f) * matrix.Right);
                            m_subsystemPickables.AddPickable(value, 1, position, value2, null);
                            m_subsystemAudio.PlaySound("Audio/EggLaid", 1f, m_random.Float(-0.1f, 0.1f), position, 2f, autoDelay: true);
                        }
                    }
                    else if (m_layTime >= 3f)
                    {
                        m_importanceLevel = 0f;
                    }
                }
                else
                {
                    m_importanceLevel = 0f;
                }
            }, null);
        }
Exemple #18
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_autoFeed             = valuesDictionary.GetValue <bool>("AutoFeed");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = m_random.Float(0f, 1f);
     }, delegate
     {
         if (m_random.Float(0f, 1f) < 0.05f * m_subsystemTime.GameTimeDelta)
         {
             m_importanceLevel = m_random.Float(1f, 3f);
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Move");
         }
     }, null);
     m_stateMachine.AddState("Move", delegate
     {
         Vector3 value;
         if (m_feedPosition.HasValue)
         {
             value = m_feedPosition.Value;
         }
         else
         {
             Vector3 position = m_componentCreature.ComponentBody.Position;
             Vector3 forward  = m_componentCreature.ComponentBody.Matrix.Forward;
             float num4       = (m_random.Float(0f, 1f) < 0.2f) ? 5f : 1.5f;
             value            = position + num4 * forward + 0.5f * num4 * new Vector3(m_random.Float(-1f, 1f), 0f, m_random.Float(-1f, 1f));
         }
         value.Y = m_subsystemTerrain.Terrain.GetTopHeight(Terrain.ToCell(value.X), Terrain.ToCell(value.Z)) + 1;
         m_componentPathfinding.SetDestination(value, m_random.Float(0.25f, 0.35f), 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
     }, delegate
     {
         if (!m_componentPathfinding.Destination.HasValue)
         {
             float num3 = m_random.Float(0f, 1f);
             if (num3 < 0.33f)
             {
                 m_stateMachine.TransitionTo("Inactive");
             }
             else if (num3 < 0.66f)
             {
                 m_stateMachine.TransitionTo("LookAround");
             }
             else
             {
                 m_stateMachine.TransitionTo("Feed");
             }
         }
         else if (!IsActive || m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
     }, delegate
     {
         m_feedPosition = null;
     });
     m_stateMachine.AddState("LookAround", delegate
     {
         m_waitTime = m_random.Float(1f, 2f);
     }, delegate
     {
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
         m_waitTime -= m_subsystemTime.GameTimeDelta;
         if (m_waitTime <= 0f)
         {
             float num2 = m_random.Float(0f, 1f);
             if (num2 < 0.25f)
             {
                 m_stateMachine.TransitionTo("Inactive");
             }
             if (num2 < 0.5f)
             {
                 m_stateMachine.TransitionTo(null);
                 m_stateMachine.TransitionTo("LookAround");
             }
             else if (num2 < 0.75f)
             {
                 m_stateMachine.TransitionTo("Move");
                 if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
                 {
                     m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
                 }
             }
             else
             {
                 m_stateMachine.TransitionTo("Feed");
             }
         }
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
     }, null);
     m_stateMachine.AddState("Feed", delegate
     {
         m_feedTime = m_random.Float(4f, 6f);
     }, delegate
     {
         m_feedTime -= m_subsystemTime.GameTimeDelta;
         if (m_componentCreature.ComponentBody.StandingOnValue.HasValue)
         {
             m_componentCreature.ComponentCreatureModel.FeedOrder = true;
             if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
             {
                 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
             }
             if (m_random.Float(0f, 1f) < 1.5f * m_subsystemTime.GameTimeDelta)
             {
                 m_componentCreature.ComponentCreatureSounds.PlayFootstepSound(2f);
             }
         }
         if (m_feedTime <= 0f)
         {
             if (m_autoFeed)
             {
                 float num = m_random.Float(0f, 1f);
                 if (num < 0.33f)
                 {
                     m_stateMachine.TransitionTo("Inactive");
                 }
                 if (num < 0.66f)
                 {
                     m_stateMachine.TransitionTo("Move");
                 }
                 else
                 {
                     m_stateMachine.TransitionTo("LookAround");
                 }
             }
             else
             {
                 m_importanceLevel = 0f;
             }
         }
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Exemple #19
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_componentMount       = base.Entity.FindComponent <ComponentMount>(throwOnError: true);
     m_isEnabled            = !base.Entity.ValuesDictionary.DatabaseObject.Name.EndsWith("_Saddled");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_rider           = null;
     }, delegate
     {
         if (m_isEnabled && m_random.Float(0f, 1f) < 1f * m_subsystemTime.GameTimeDelta && m_componentMount.Rider != null)
         {
             m_importanceLevel = 220f;
             m_dumpStartTime   = m_subsystemTime.GameTime;
             m_rider           = m_componentMount.Rider;
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("WildJumping");
         }
     }, null);
     m_stateMachine.AddState("WildJumping", delegate
     {
         m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         m_componentPathfinding.Stop();
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_componentMount.Rider == null)
         {
             m_importanceLevel = 0f;
             RunAway();
         }
         if (m_random.Float(0f, 1f) < 1f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         }
         if (m_random.Float(0f, 1f) < 3f * m_subsystemTime.GameTimeDelta)
         {
             m_walkOrder = new Vector2(m_random.Float(-0.5f, 0.5f), m_random.Float(-0.5f, 1.5f));
         }
         if (m_random.Float(0f, 1f) < 2.5f * m_subsystemTime.GameTimeDelta)
         {
             m_turnOrder.X = m_random.Float(-1f, 1f);
         }
         if (m_random.Float(0f, 1f) < 2f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentLocomotion.JumpOrder = m_random.Float(0.9f, 1f);
             if (m_componentMount.Rider != null && m_subsystemTime.GameTime - m_dumpStartTime > 3.0)
             {
                 if (m_random.Float(0f, 1f) < 0.05f)
                 {
                     m_componentMount.Rider.StartDismounting();
                     m_componentMount.Rider.ComponentCreature.ComponentHealth.Injure(m_random.Float(0.05f, 0.2f), m_componentCreature, ignoreInvulnerability: false, "Thrown from a mount");
                 }
                 if (m_random.Float(0f, 1f) < 0.25f)
                 {
                     m_componentMount.Rider.ComponentCreature.ComponentHealth.Injure(0.05f, m_componentCreature, ignoreInvulnerability: false, "Thrown from a mount");
                 }
             }
         }
         if (m_random.Float(0f, 1f) < 4f * m_subsystemTime.GameTimeDelta)
         {
             m_lookOrder = new Vector2(m_random.Float(-3f, 3f), m_lookOrder.Y);
         }
         if (m_random.Float(0f, 1f) < 0.25f * m_subsystemTime.GameTimeDelta)
         {
             TransitionToRandomDumpingBehavior();
         }
         m_componentCreature.ComponentLocomotion.WalkOrder = m_walkOrder;
         m_componentCreature.ComponentLocomotion.TurnOrder = m_turnOrder;
         m_componentCreature.ComponentLocomotion.LookOrder = m_lookOrder;
     }, null);
     m_stateMachine.AddState("BlindRacing", delegate
     {
         m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         m_componentPathfinding.SetDestination(m_componentCreature.ComponentBody.Position + new Vector3(m_random.Float(-15f, 15f), 0f, m_random.Float(-15f, 15f)), 1f, 2f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_componentMount.Rider == null)
         {
             m_importanceLevel = 0f;
             RunAway();
         }
         else if (!m_componentPathfinding.Destination.HasValue || m_componentPathfinding.IsStuck)
         {
             TransitionToRandomDumpingBehavior();
         }
         if (m_random.Float(0f, 1f) < 0.5f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentLocomotion.JumpOrder = 1f;
             m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         }
     }, null);
     m_stateMachine.AddState("Stupor", delegate
     {
         m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         m_componentPathfinding.Stop();
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_componentMount.Rider == null)
         {
             m_importanceLevel = 0f;
         }
         if (m_subsystemTime.PeriodicGameTimeEvent(2.0, 0.0))
         {
             TransitionToRandomDumpingBehavior();
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemTerrain          = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            m_subsystemTime             = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
            m_componentCreature         = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
            m_componentPathfinding      = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
            m_componentMiner            = base.Entity.FindComponent <ComponentMiner>(throwOnError: true);
            m_componentFishModel        = base.Entity.FindComponent <ComponentFishModel>(throwOnError: true);
            m_componentSwimAwayBehavior = base.Entity.FindComponent <ComponentSwimAwayBehavior>(throwOnError: true);
            string digInBlockName = valuesDictionary.GetValue <string>("DigInBlockName");

            m_digInBlockIndex = ((!string.IsNullOrEmpty(digInBlockName)) ? BlocksManager.Blocks.First((Block b) => b.GetType().Name == digInBlockName).BlockIndex : 0);
            m_maxDigInDepth   = valuesDictionary.GetValue <float>("MaxDigInDepth");
            m_componentCreature.ComponentBody.CollidedWithBody += delegate(ComponentBody b)
            {
                m_collidedWithBody = b;
            };
            m_stateMachine.AddState("Inactive", delegate
            {
                m_importanceLevel = 0f;
            }, delegate
            {
                if (m_random.Float(0f, 1f) < 0.5f * m_subsystemTime.GameTimeDelta && m_subsystemTime.GameTime > m_digOutTime + 15.0 && m_digInBlockIndex != 0)
                {
                    int x = Terrain.ToCell(m_componentCreature.ComponentBody.Position.X);
                    int y = Terrain.ToCell(m_componentCreature.ComponentBody.Position.Y - 0.9f);
                    int z = Terrain.ToCell(m_componentCreature.ComponentBody.Position.Z);
                    if (m_subsystemTerrain.Terrain.GetCellContents(x, y, z) == m_digInBlockIndex)
                    {
                        m_importanceLevel = m_random.Float(1f, 3f);
                    }
                }
                if (IsActive)
                {
                    m_stateMachine.TransitionTo("Sink");
                }
            }, null);
            m_stateMachine.AddState("Sink", delegate
            {
                m_importanceLevel = 10f;
                m_sinkTime        = m_subsystemTime.GameTime;
                m_componentPathfinding.Stop();
            }, delegate
            {
                if (m_random.Float(0f, 1f) < 2f * m_subsystemTime.GameTimeDelta && m_componentCreature.ComponentBody.StandingOnValue == m_digInBlockIndex && m_componentCreature.ComponentBody.Velocity.LengthSquared() < 1f)
                {
                    m_stateMachine.TransitionTo("DigIn");
                }
                if (!IsActive || m_subsystemTime.GameTime > m_sinkTime + 6.0)
                {
                    m_stateMachine.TransitionTo("Inactive");
                }
            }, null);
            m_stateMachine.AddState("DigIn", delegate
            {
                m_digInTime  = m_subsystemTime.GameTime;
                m_digOutTime = m_digInTime + (double)m_random.Float(30f, 60f);
            }, delegate
            {
                m_componentFishModel.DigInOrder = m_maxDigInDepth;
                if (m_collidedWithBody != null)
                {
                    if (m_subsystemTime.GameTime - m_digInTime > 2.0 && m_collidedWithBody.Density < 0.95f)
                    {
                        m_componentMiner.Hit(m_collidedWithBody, m_collidedWithBody.Position, Vector3.Normalize(m_collidedWithBody.Position - m_componentCreature.ComponentBody.Position));
                    }
                    m_componentSwimAwayBehavior.SwimAwayFrom(m_collidedWithBody);
                    m_stateMachine.TransitionTo("Inactive");
                }
                if (!IsActive || m_subsystemTime.GameTime >= m_digOutTime || m_componentCreature.ComponentBody.StandingOnValue != m_digInBlockIndex || m_componentCreature.ComponentBody.Velocity.LengthSquared() > 1f)
                {
                    m_stateMachine.TransitionTo("Inactive");
                }
            }, null);
            m_stateMachine.TransitionTo("Inactive");
        }
Exemple #21
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     m_subsystemTime = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
 }
Exemple #22
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTerrain      = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemTime         = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemNoise        = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     m_componentCreature     = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding  = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_componentHerdBehavior = base.Entity.FindComponent <ComponentHerdBehavior>();
     m_componentCreature.ComponentHealth.Attacked += delegate(ComponentCreature attacker)
     {
         RunAwayFrom(attacker.ComponentBody);
     };
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel         = 0f;
         m_lastNoiseSourcePosition = null;
     }, delegate
     {
         if (m_attacker != null)
         {
             m_timeToForgetAttacker -= m_subsystemTime.GameTimeDelta;
             if (m_timeToForgetAttacker <= 0f)
             {
                 m_attacker = null;
             }
         }
         if (m_componentCreature.ComponentHealth.HealthChange < 0f || (m_attacker != null && Vector3.DistanceSquared(m_attacker.Position, m_componentCreature.ComponentBody.Position) < 36f))
         {
             m_importanceLevel = MathUtils.Max(m_importanceLevel, (m_componentCreature.ComponentHealth.Health < 0.33f) ? 300 : 100);
         }
         else if (m_heardNoise)
         {
             m_importanceLevel = MathUtils.Max(m_importanceLevel, 5f);
         }
         else if (!IsActive)
         {
             m_importanceLevel = 0f;
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("RunningAway");
         }
     }, null);
     m_stateMachine.AddState("RunningAway", delegate
     {
         Vector3 value = FindSafePlace();
         m_componentPathfinding.SetDestination(value, 1f, 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
         m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         m_subsystemNoise.MakeNoise(m_componentCreature.ComponentBody, 0.25f, 6f);
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (!m_componentPathfinding.Destination.HasValue || m_componentPathfinding.IsStuck)
         {
             m_importanceLevel = 0f;
         }
         else if (m_attacker != null)
         {
             if (!m_attacker.IsAddedToProject)
             {
                 m_importanceLevel = 0f;
                 m_attacker        = null;
             }
             else
             {
                 ComponentHealth componentHealth = m_attacker.Entity.FindComponent <ComponentHealth>();
                 if (componentHealth != null && componentHealth.Health == 0f)
                 {
                     m_importanceLevel = 0f;
                     m_attacker        = null;
                 }
             }
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime          = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemCreatureSpawn = base.Project.FindSubsystem <SubsystemCreatureSpawn>(throwOnError: true);
     m_componentCreature      = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding   = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     HerdName                  = valuesDictionary.GetValue <string>("HerdName");
     m_herdingRange            = valuesDictionary.GetValue <float>("HerdingRange");
     m_autoNearbyCreaturesHelp = valuesDictionary.GetValue <bool>("AutoNearbyCreaturesHelp");
     m_componentCreature.ComponentHealth.Attacked += delegate(ComponentCreature attacker)
     {
         CallNearbyCreaturesHelp(attacker, 20f, 30f, isPersistent: false);
     };
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (m_subsystemTime.PeriodicGameTimeEvent(1.0, 1f * ((float)(GetHashCode() % 256) / 256f)))
         {
             Vector3?vector2 = FindHerdCenter();
             if (vector2.HasValue)
             {
                 float num = Vector3.Distance(vector2.Value, m_componentCreature.ComponentBody.Position);
                 if (num > 10f)
                 {
                     m_importanceLevel = 1f;
                 }
                 if (num > 12f)
                 {
                     m_importanceLevel = 3f;
                 }
                 if (num > 16f)
                 {
                     m_importanceLevel = 50f;
                 }
                 if (num > 20f)
                 {
                     m_importanceLevel = 250f;
                 }
             }
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Herd");
         }
     }, null);
     m_stateMachine.AddState("Stuck", delegate
     {
         m_stateMachine.TransitionTo("Herd");
         if (m_random.Bool(0.5f))
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
             m_importanceLevel = 0f;
         }
     }, null, null);
     m_stateMachine.AddState("Herd", delegate
     {
         Vector3?vector = FindHerdCenter();
         if (vector.HasValue && Vector3.Distance(m_componentCreature.ComponentBody.Position, vector.Value) > 6f)
         {
             float speed = (m_importanceLevel > 10f) ? m_random.Float(0.9f, 1f) : m_random.Float(0.25f, 0.35f);
             int maxPathfindingPositions = (m_importanceLevel > 200f) ? 100 : 0;
             m_componentPathfinding.SetDestination(vector.Value, speed, 7f, maxPathfindingPositions, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
         }
         else
         {
             m_importanceLevel = 0f;
         }
     }, delegate
     {
         m_componentCreature.ComponentLocomotion.LookOrder = m_look - m_componentCreature.ComponentLocomotion.LookAngles;
         if (m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("Stuck");
         }
         if (!m_componentPathfinding.Destination.HasValue)
         {
             m_importanceLevel = 0f;
         }
         if (m_random.Float(0f, 1f) < 0.05f * m_dt)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
         }
         if (m_random.Float(0f, 1f) < 1.5f * m_dt)
         {
             m_look = new Vector2(MathUtils.DegToRad(45f) * m_random.Float(-1f, 1f), MathUtils.DegToRad(10f) * m_random.Float(-1f, 1f));
         }
     }, null);
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemGameInfo    = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemSky         = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemBodies      = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_dayRange             = valuesDictionary.GetValue <float>("DayRange");
     m_nightRange           = valuesDictionary.GetValue <float>("NightRange");
     m_minRange             = valuesDictionary.GetValue <float>("MinRange");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_target          = null;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Move");
         }
         if (m_subsystemGameInfo.WorldSettings.GameMode > GameMode.Harmless)
         {
             m_target = FindTarget();
             if (m_target != null)
             {
                 ComponentPlayer componentPlayer = m_target.Entity.FindComponent <ComponentPlayer>();
                 if (componentPlayer != null && componentPlayer.ComponentSleep.IsSleeping)
                 {
                     m_importanceLevel = 5f;
                 }
                 else if (m_random.Float(0f, 1f) < 0.05f * m_dt)
                 {
                     m_importanceLevel = m_random.Float(1f, 4f);
                 }
             }
             else
             {
                 m_importanceLevel = 0f;
             }
         }
     }, null);
     m_stateMachine.AddState("Move", delegate
     {
         if (m_target != null)
         {
             m_componentPathfinding.SetDestination(m_target.ComponentBody.Position, m_random.Float(0.5f, 0.7f), m_minRange, 500, useRandomMovements: true, ignoreHeightDifference: true, raycastDestination: false, null);
         }
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_target == null || m_componentPathfinding.IsStuck || !m_componentPathfinding.Destination.HasValue || ScoreTarget(m_target) <= 0f)
         {
             m_importanceLevel = 0f;
         }
         if (m_random.Float(0f, 1f) < 0.1f * m_dt)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
         }
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Exemple #25
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemPathfinding = base.Project.FindSubsystem <SubsystemPathfinding>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPilot       = base.Entity.FindComponent <ComponentPilot>(throwOnError: true);
     m_stateMachine.AddState("Stopped", delegate
     {
         Stop();
         m_randomMoveCount = 0;
     }, delegate
     {
         if (Destination.HasValue)
         {
             m_stateMachine.TransitionTo("MovingDirect");
         }
     }, null);
     m_stateMachine.AddState("MovingDirect", delegate
     {
         IsStuck = false;
         m_destinationChanged = true;
     }, delegate
     {
         if (!Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Stopped");
         }
         else if (m_destinationChanged)
         {
             m_componentPilot.SetDestination(Destination, Speed, Range, IgnoreHeightDifference, RaycastDestination, Speed >= 1f, DoNotAvoidBody);
             m_destinationChanged = false;
         }
         else if (!m_componentPilot.Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Stopped");
         }
         else if (m_componentPilot.IsStuck)
         {
             if (MaxPathfindingPositions > 0 && m_componentCreature.ComponentLocomotion.WalkSpeed > 0f)
             {
                 m_stateMachine.TransitionTo("SearchingForPath");
             }
             else if (UseRandomMovements)
             {
                 m_stateMachine.TransitionTo("MovingRandomly");
             }
             else
             {
                 m_stateMachine.TransitionTo("Stuck");
             }
         }
     }, null);
     m_stateMachine.AddState("SearchingForPath", delegate
     {
         m_pathfindingResult.IsCompleted  = false;
         m_pathfindingResult.IsInProgress = false;
     }, delegate
     {
         if (!Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Stopped");
         }
         else if (!m_pathfindingResult.IsInProgress && (!m_lastPathfindingTime.HasValue || m_subsystemTime.GameTime - m_lastPathfindingTime > 8.0) && m_pathfindingCongestion < 500f)
         {
             m_lastPathfindingDestination = Destination.Value;
             m_lastPathfindingTime        = m_subsystemTime.GameTime;
             m_subsystemPathfinding.QueuePathSearch(m_componentCreature.ComponentBody.Position + new Vector3(0f, 0.01f, 0f), Destination.Value + new Vector3(0f, 0.01f, 0f), 1f, m_componentCreature.ComponentBody.BoxSize, MaxPathfindingPositions, m_pathfindingResult);
         }
         else if (UseRandomMovements)
         {
             m_stateMachine.TransitionTo("MovingRandomly");
         }
         if (m_pathfindingResult.IsCompleted)
         {
             m_pathfindingCongestion = MathUtils.Min(m_pathfindingCongestion + (float)m_pathfindingResult.PositionsChecked, 1000f);
             if (m_pathfindingResult.Path.Count > 0)
             {
                 m_stateMachine.TransitionTo("MovingWithPath");
             }
             else if (UseRandomMovements)
             {
                 m_stateMachine.TransitionTo("MovingRandomly");
             }
             else
             {
                 m_stateMachine.TransitionTo("Stuck");
             }
         }
     }, null);
     m_stateMachine.AddState("MovingWithPath", delegate
     {
         m_componentPilot.Stop();
         m_randomMoveCount = 0;
     }, delegate
     {
         if (!Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Stopped");
         }
         else if (!m_componentPilot.Destination.HasValue)
         {
             if (m_pathfindingResult.Path.Count > 0)
             {
                 Vector3 value = m_pathfindingResult.Path.Array[m_pathfindingResult.Path.Count - 1];
                 m_componentPilot.SetDestination(value, MathUtils.Min(Speed, 0.75f), 0.75f, ignoreHeightDifference: false, raycastDestination: false, Speed >= 1f, DoNotAvoidBody);
                 m_pathfindingResult.Path.RemoveAt(m_pathfindingResult.Path.Count - 1);
             }
             else
             {
                 m_stateMachine.TransitionTo("MovingDirect");
             }
         }
         else if (m_componentPilot.IsStuck)
         {
             if (UseRandomMovements)
             {
                 m_stateMachine.TransitionTo("MovingRandomly");
             }
             else
             {
                 m_stateMachine.TransitionTo("Stuck");
             }
         }
         else
         {
             float num = Vector3.DistanceSquared(m_componentCreature.ComponentBody.Position, Destination.Value);
             if (Vector3.DistanceSquared(m_lastPathfindingDestination.Value, Destination.Value) > num)
             {
                 m_stateMachine.TransitionTo("MovingDirect");
             }
         }
     }, null);
     m_stateMachine.AddState("MovingRandomly", delegate
     {
         m_componentPilot.SetDestination(m_componentCreature.ComponentBody.Position + new Vector3(5f * m_random.Float(-1f, 1f), 0f, 5f * m_random.Float(-1f, 1f)), 1f, 1f, ignoreHeightDifference: true, raycastDestination: false, takeRisks: false, DoNotAvoidBody);
         m_randomMoveCount++;
     }, delegate
     {
         if (!Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Stopped");
         }
         else if (m_randomMoveCount > 3)
         {
             m_stateMachine.TransitionTo("Stuck");
         }
         else if (m_componentPilot.IsStuck || !m_componentPilot.Destination.HasValue)
         {
             m_stateMachine.TransitionTo("MovingDirect");
         }
     }, null);
     m_stateMachine.AddState("Stuck", delegate
     {
         IsStuck = true;
     }, delegate
     {
         if (!Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Stopped");
         }
         else if (m_destinationChanged)
         {
             m_destinationChanged = false;
             m_stateMachine.TransitionTo("MovingDirect");
         }
     }, null);
     m_stateMachine.TransitionTo("Stopped");
 }
Exemple #26
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemPickables   = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_foodFactors          = new float[EnumUtils.GetEnumValues(typeof(FoodType)).Max() + 1];
     foreach (KeyValuePair <string, object> item in valuesDictionary.GetValue <ValuesDictionary>("FoodFactors"))
     {
         FoodType foodType = (FoodType)Enum.Parse(typeof(FoodType), item.Key, ignoreCase: false);
         m_foodFactors[(int)foodType] = (float)item.Value;
     }
     m_subsystemPickables.PickableAdded += delegate(Pickable pickable)
     {
         if (TryAddPickable(pickable) && m_pickable == null)
         {
             m_pickable = pickable;
         }
     };
     m_subsystemPickables.PickableRemoved += delegate(Pickable pickable)
     {
         m_pickables.Remove(pickable);
         if (m_pickable == pickable)
         {
             m_pickable = null;
         }
     };
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_pickable        = null;
     }, delegate
     {
         if (m_satiation < 1f)
         {
             if (m_pickable == null)
             {
                 if (m_subsystemTime.GameTime > m_nextFindPickableTime)
                 {
                     m_nextFindPickableTime = m_subsystemTime.GameTime + (double)m_random.Float(2f, 4f);
                     m_pickable             = FindPickable(m_componentCreature.ComponentBody.Position);
                 }
             }
             else
             {
                 m_importanceLevel = m_random.Float(5f, 10f);
             }
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Move");
             m_blockedCount = 0;
         }
     }, null);
     m_stateMachine.AddState("Move", delegate
     {
         if (m_pickable != null)
         {
             float speed = (m_satiation == 0f) ? m_random.Float(0.5f, 0.7f) : 0.5f;
             int maxPathfindingPositions = (m_satiation == 0f) ? 1000 : 500;
             float num2 = Vector3.Distance(m_componentCreature.ComponentCreatureModel.EyePosition, m_componentCreature.ComponentBody.Position);
             m_componentPathfinding.SetDestination(m_pickable.Position, speed, 1f + num2, maxPathfindingPositions, useRandomMovements: true, ignoreHeightDifference: false, raycastDestination: true, null);
             if (m_random.Float(0f, 1f) < 0.66f)
             {
                 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
             }
         }
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_pickable == null)
         {
             m_importanceLevel = 0f;
         }
         else if (m_componentPathfinding.IsStuck)
         {
             m_importanceLevel = 0f;
             m_satiation      += 0.75f;
         }
         else if (!m_componentPathfinding.Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Eat");
         }
         else if (Vector3.DistanceSquared(m_componentPathfinding.Destination.Value, m_pickable.Position) > 0.0625f)
         {
             m_stateMachine.TransitionTo("PickableMoved");
         }
         if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
         }
         if (m_pickable != null)
         {
             m_componentCreature.ComponentCreatureModel.LookAtOrder = m_pickable.Position;
         }
         else
         {
             m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
         }
     }, null);
     m_stateMachine.AddState("PickableMoved", null, delegate
     {
         if (m_pickable != null)
         {
             m_componentCreature.ComponentCreatureModel.LookAtOrder = m_pickable.Position;
         }
         if (m_subsystemTime.PeriodicGameTimeEvent(0.25, (double)(GetHashCode() % 100) * 0.01))
         {
             m_stateMachine.TransitionTo("Move");
         }
     }, null);
     m_stateMachine.AddState("Eat", delegate
     {
         m_eatTime     = m_random.Float(4f, 5f);
         m_blockedTime = 0f;
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         if (m_pickable == null)
         {
             m_importanceLevel = 0f;
         }
         if (m_pickable != null)
         {
             if (Vector3.DistanceSquared(new Vector3(m_componentCreature.ComponentCreatureModel.EyePosition.X, m_componentCreature.ComponentBody.Position.Y, m_componentCreature.ComponentCreatureModel.EyePosition.Z), m_pickable.Position) < 0.640000045f)
             {
                 m_eatTime    -= m_subsystemTime.GameTimeDelta;
                 m_blockedTime = 0f;
                 if (m_eatTime <= 0.0)
                 {
                     m_satiation     += 1f;
                     m_pickable.Count = MathUtils.Max(m_pickable.Count - 1, 0);
                     if (m_pickable.Count == 0)
                     {
                         m_pickable.ToRemove = true;
                         m_importanceLevel   = 0f;
                     }
                     else if (m_random.Float(0f, 1f) < 0.5f)
                     {
                         m_importanceLevel = 0f;
                     }
                 }
             }
             else
             {
                 float num = Vector3.Distance(m_componentCreature.ComponentCreatureModel.EyePosition, m_componentCreature.ComponentBody.Position);
                 m_componentPathfinding.SetDestination(m_pickable.Position, 0.3f, 0.5f + num, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
                 m_blockedTime += m_subsystemTime.GameTimeDelta;
             }
             if (m_blockedTime > 3f)
             {
                 m_blockedCount++;
                 if (m_blockedCount >= 3)
                 {
                     m_importanceLevel = 0f;
                     m_satiation      += 0.75f;
                 }
                 else
                 {
                     m_stateMachine.TransitionTo("Move");
                 }
             }
         }
         m_componentCreature.ComponentCreatureModel.FeedOrder = true;
         if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
         }
         if (m_random.Float(0f, 1f) < 1.5f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayFootstepSound(2f);
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemGameInfo            = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemPlayers             = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemSky                 = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemBodies              = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemTime                = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemNoise               = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     m_componentCreature            = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding         = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_componentMiner               = base.Entity.FindComponent <ComponentMiner>(throwOnError: true);
     m_componentFeedBehavior        = base.Entity.FindComponent <ComponentRandomFeedBehavior>();
     m_componentCreatureModel       = base.Entity.FindComponent <ComponentCreatureModel>(throwOnError: true);
     m_dayChaseRange                = valuesDictionary.GetValue <float>("DayChaseRange");
     m_nightChaseRange              = valuesDictionary.GetValue <float>("NightChaseRange");
     m_dayChaseTime                 = valuesDictionary.GetValue <float>("DayChaseTime");
     m_nightChaseTime               = valuesDictionary.GetValue <float>("NightChaseTime");
     m_autoChaseMask                = valuesDictionary.GetValue <CreatureCategory>("AutoChaseMask");
     m_chaseNonPlayerProbability    = valuesDictionary.GetValue <float>("ChaseNonPlayerProbability");
     m_chaseWhenAttackedProbability = valuesDictionary.GetValue <float>("ChaseWhenAttackedProbability");
     m_chaseOnTouchProbability      = valuesDictionary.GetValue <float>("ChaseOnTouchProbability");
     m_componentCreature.ComponentHealth.Attacked += delegate(ComponentCreature attacker)
     {
         if (m_random.Float(0f, 1f) < m_chaseWhenAttackedProbability)
         {
             if (m_chaseWhenAttackedProbability >= 1f)
             {
                 Attack(attacker, 30f, 60f, isPersistent: true);
             }
             else
             {
                 Attack(attacker, 7f, 7f, isPersistent: false);
             }
         }
     };
     m_componentCreature.ComponentBody.CollidedWithBody += delegate(ComponentBody body)
     {
         if (m_target == null && m_autoChaseSuppressionTime <= 0f && m_random.Float(0f, 1f) < m_chaseOnTouchProbability)
         {
             ComponentCreature componentCreature2 = body.Entity.FindComponent <ComponentCreature>();
             if (componentCreature2 != null)
             {
                 bool flag2 = m_subsystemPlayers.IsPlayer(body.Entity);
                 bool flag3 = (componentCreature2.Category & m_autoChaseMask) != 0;
                 if ((flag2 && m_subsystemGameInfo.WorldSettings.GameMode > GameMode.Harmless) || (!flag2 && flag3))
                 {
                     Attack(componentCreature2, 7f, 7f, isPersistent: false);
                 }
             }
         }
         if (m_target != null && body == m_target.ComponentBody && body.StandingOnBody == m_componentCreature.ComponentBody)
         {
             m_componentCreature.ComponentLocomotion.JumpOrder = 1f;
         }
     };
     m_stateMachine.AddState("LookingForTarget", delegate
     {
         m_importanceLevel = 0f;
         m_target          = null;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Chasing");
         }
         else if (m_autoChaseSuppressionTime <= 0f && (m_target == null || ScoreTarget(m_target) <= 0f) && m_componentCreature.ComponentHealth.Health > 0.4f)
         {
             m_range = ((m_subsystemSky.SkyLightIntensity < 0.2f) ? m_nightChaseRange : m_dayChaseRange);
             ComponentCreature componentCreature = FindTarget();
             if (componentCreature != null)
             {
                 m_targetInRangeTime += m_dt;
             }
             else
             {
                 m_targetInRangeTime = 0f;
             }
             if (m_targetInRangeTime > 3f)
             {
                 bool flag          = m_subsystemSky.SkyLightIntensity >= 0.1f;
                 float maxRange     = flag ? (m_dayChaseRange + 6f) : (m_nightChaseRange + 6f);
                 float maxChaseTime = flag ? (m_dayChaseTime * m_random.Float(0.75f, 1f)) : (m_nightChaseTime * m_random.Float(0.75f, 1f));
                 Attack(componentCreature, maxRange, maxChaseTime, (!flag) ? true : false);
             }
         }
     }, null);
     m_stateMachine.AddState("RandomMoving", delegate
     {
         m_componentPathfinding.SetDestination(m_componentCreature.ComponentBody.Position + new Vector3(6f * m_random.Float(-1f, 1f), 0f, 6f * m_random.Float(-1f, 1f)), 1f, 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
     }, delegate
     {
         if (m_componentPathfinding.IsStuck || !m_componentPathfinding.Destination.HasValue)
         {
             m_stateMachine.TransitionTo("Chasing");
         }
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("LookingForTarget");
         }
     }, delegate
     {
         m_componentPathfinding.Stop();
     });
     m_stateMachine.AddState("Chasing", delegate
     {
         m_subsystemNoise.MakeNoise(m_componentCreature.ComponentBody, 0.25f, 6f);
         m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
         m_nextUpdateTime = 0.0;
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("LookingForTarget");
         }
         else if (m_chaseTime <= 0f)
         {
             m_autoChaseSuppressionTime = m_random.Float(10f, 60f);
             m_importanceLevel          = 0f;
         }
         else if (m_target == null)
         {
             m_importanceLevel = 0f;
         }
         else if (m_target.ComponentHealth.Health <= 0f)
         {
             if (m_componentFeedBehavior != null)
             {
                 m_subsystemTime.QueueGameTimeDelayedExecution(m_subsystemTime.GameTime + (double)m_random.Float(1f, 3f), delegate
                 {
                     if (m_target != null)
                     {
                         m_componentFeedBehavior.Feed(m_target.ComponentBody.Position);
                     }
                 });
             }
             m_importanceLevel = 0f;
         }
         else if (!m_isPersistent && m_componentPathfinding.IsStuck)
         {
             m_importanceLevel = 0f;
         }
         else if (m_isPersistent && m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("RandomMoving");
         }
         else
         {
             if (ScoreTarget(m_target) <= 0f)
             {
                 m_targetUnsuitableTime += m_dt;
             }
             else
             {
                 m_targetUnsuitableTime = 0f;
             }
             if (m_targetUnsuitableTime > 3f)
             {
                 m_importanceLevel = 0f;
             }
             else
             {
                 int maxPathfindingPositions = 0;
                 if (m_isPersistent)
                 {
                     maxPathfindingPositions = (m_subsystemTime.FixedTimeStep.HasValue ? 1500 : 500);
                 }
                 BoundingBox boundingBox  = m_componentCreature.ComponentBody.BoundingBox;
                 BoundingBox boundingBox2 = m_target.ComponentBody.BoundingBox;
                 Vector3 v      = 0.5f * (boundingBox.Min + boundingBox.Max);
                 Vector3 vector = 0.5f * (boundingBox2.Min + boundingBox2.Max);
                 float num      = Vector3.Distance(v, vector);
                 float num2     = (num < 4f) ? 0.2f : 0f;
                 m_componentPathfinding.SetDestination(vector + num2 * num * m_target.ComponentBody.Velocity, 1f, 1.5f, maxPathfindingPositions, useRandomMovements: true, ignoreHeightDifference: false, raycastDestination: true, m_target.ComponentBody);
                 if (m_random.Float(0f, 1f) < 0.33f * m_dt)
                 {
                     m_componentCreature.ComponentCreatureSounds.PlayAttackSound();
                 }
             }
         }
     }, null);
     m_stateMachine.TransitionTo("LookingForTarget");
 }