public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemParticles   = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
     m_subsystemAudio       = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_stateMachine.AddState("Inactive", null, delegate
     {
         m_importanceLevel = MathUtils.Lerp(0f, 400f, MathUtils.Saturate((0.75f - m_componentCreature.ComponentHealth.Air) / 0.75f));
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Surface");
         }
     }, null);
     m_stateMachine.AddState("Surface", delegate
     {
         m_componentPathfinding.Stop();
     }, delegate
     {
         _ = m_componentCreature.ComponentBody.Position;
         if (!m_componentPathfinding.Destination.HasValue)
         {
             Vector3?destination = FindSurfaceDestination();
             if (destination.HasValue)
             {
                 float speed = (m_componentCreature.ComponentHealth.Air < 0.25f) ? 1f : m_random.Float(0.4f, 0.6f);
                 m_componentPathfinding.SetDestination(destination, speed, 1f, 0, useRandomMovements: false, ignoreHeightDifference: false, raycastDestination: false, null);
             }
         }
         else if (m_componentPathfinding.IsStuck)
         {
             m_importanceLevel = 0f;
         }
         if (m_componentCreature.ComponentHealth.Air > 0.9f)
         {
             m_stateMachine.TransitionTo("Breathe");
         }
     }, null);
     m_stateMachine.AddState("Breathe", delegate
     {
         Vector3 forward = m_componentCreature.ComponentBody.Matrix.Forward;
         Vector3 value   = m_componentCreature.ComponentBody.Matrix.Translation + 10f * forward + new Vector3(0f, 2f, 0f);
         m_componentPathfinding.SetDestination(value, 0.6f, 1f, 0, useRandomMovements: false, ignoreHeightDifference: false, raycastDestination: false, null);
         m_particleSystem = new WhalePlumeParticleSystem(m_subsystemTerrain, m_random.Float(0.8f, 1.1f), m_random.Float(1f, 1.3f));
         m_subsystemParticles.AddParticleSystem(m_particleSystem);
         m_subsystemAudio.PlayRandomSound("Audio/Creatures/WhaleBlow", 1f, m_random.Float(-0.2f, 0.2f), m_componentCreature.ComponentBody.Position, 10f, autoDelay: true);
     }, delegate
     {
         m_particleSystem.Position = m_componentCreature.ComponentBody.Position + new Vector3(0f, 0.8f * m_componentCreature.ComponentBody.BoxSize.Y, 0f);
         if (!m_subsystemParticles.ContainsParticleSystem(m_particleSystem))
         {
             m_importanceLevel = 0f;
         }
     }, delegate
     {
         m_particleSystem.IsStopped = true;
         m_particleSystem           = null;
     });
 }
예제 #2
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemSky         = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(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);
     m_howlSoundName        = valuesDictionary.GetValue <string>("HowlSoundName");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Howl");
         }
         if (m_subsystemSky.SkyLightIntensity < 0.1f)
         {
             if (m_random.Float(0f, 1f) < 0.015f * m_subsystemTime.GameTimeDelta)
             {
                 m_importanceLevel = m_random.Float(1f, 3f);
             }
         }
         else
         {
             m_importanceLevel = 0f;
         }
     }, null);
     m_stateMachine.AddState("Howl", delegate
     {
         m_howlTime     = 0f;
         m_howlDuration = m_random.Float(5f, 6f);
         m_componentPathfinding.Stop();
         m_importanceLevel = 10f;
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         m_componentCreature.ComponentLocomotion.LookOrder = new Vector2(m_componentCreature.ComponentLocomotion.LookOrder.X, 2f);
         float num = m_howlTime + m_subsystemTime.GameTimeDelta;
         if (m_howlTime <= 0.5f && num > 0.5f)
         {
             m_subsystemAudio.PlayRandomSound(m_howlSoundName, 1f, m_random.Float(-0.1f, 0.1f), m_componentCreature.ComponentBody.Position, 10f, autoDelay: true);
         }
         m_howlTime = num;
         if (m_howlTime >= m_howlDuration)
         {
             m_importanceLevel = 0f;
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Fly");
         }
     }, null);
     m_stateMachine.AddState("Stuck", delegate
     {
         m_stateMachine.TransitionTo("Fly");
         if (m_random.Float(0f, 1f) < 0.5f)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
             m_importanceLevel = 1f;
         }
     }, null, null);
     m_stateMachine.AddState("Fly", delegate
     {
         m_angle = m_random.Float(0f, (float)Math.PI * 2f);
         m_componentPathfinding.Stop();
     }, delegate
     {
         Vector3 position = m_componentCreature.ComponentBody.Position;
         if (!m_componentPathfinding.Destination.HasValue)
         {
             float num      = (m_random.Float(0f, 1f) < 0.2f) ? m_random.Float(0.4f, 0.6f) : (0f - m_random.Float(0.4f, 0.6f));
             m_angle        = MathUtils.NormalizeAngle(m_angle + num);
             Vector2 vector = Vector2.CreateFromAngle(m_angle);
             Vector3 value  = position + new Vector3(vector.X, 0f, vector.Y) * 10f;
             value.Y        = EstimateHeight(new Vector2(value.X, value.Z), 8) + m_random.Float(3f, 5f);
             m_componentPathfinding.SetDestination(value, m_random.Float(0.6f, 1.05f), 6f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
             if (m_random.Float(0f, 1f) < 0.15f)
             {
                 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
             }
         }
         else if (m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("Stuck");
         }
     }, null);
 }
예제 #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");
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Swim");
         }
     }, null);
     m_stateMachine.AddState("Stuck", delegate
     {
         if (m_random.Float(0f, 1f) < 0.5f)
         {
             m_importanceLevel = 1f;
         }
         m_stateMachine.TransitionTo("Swim");
     }, null, null);
     m_stateMachine.AddState("Swim", delegate
     {
         m_componentPathfinding.Stop();
     }, delegate
     {
         _ = m_componentCreature.ComponentBody.Position;
         if (!m_componentPathfinding.Destination.HasValue)
         {
             Vector3?destination = FindDestination();
             if (destination.HasValue)
             {
                 m_componentPathfinding.SetDestination(destination, m_random.Float(0.3f, 0.4f), 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
             }
             else
             {
                 m_importanceLevel = 1f;
             }
         }
         else if (m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("Stuck");
         }
     }, null);
 }
예제 #6
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_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");
 }
        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");
        }