Ejemplo n.º 1
0
 public void PositionChanged(ComponentFrame frame)
 {
     if ((frame.Position - ComponentBody.Position).LengthSquared() > .216f)
     {
         frame.PositionChanged -= PositionChanged;
         Fire();
     }
 }
Ejemplo n.º 2
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime     = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemViews    = base.Project.FindSubsystem <SubsystemGameWidgets>(throwOnError: true);
     m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemSky      = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_componentFrame    = base.Entity.FindComponent <ComponentFrame>(throwOnError: true);
     m_componentModel    = base.Entity.FindComponent <ComponentModel>(throwOnError: true);
     m_creationTime      = m_subsystemTime.GameTime;
     Heading             = valuesDictionary.GetValue <float>("Heading");
 }
Ejemplo n.º 3
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemSky   = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
            m_componentFrame = base.Entity.FindComponent <ComponentFrame>(throwOnError: true);
            string value = valuesDictionary.GetValue <string>("ModelName");

            Model       = ContentManager.Get <Model>(value);
            CastsShadow = valuesDictionary.GetValue <bool>("CastsShadow");
            string value2 = valuesDictionary.GetValue <string>("TextureOverride");

            TextureOverride        = (string.IsNullOrEmpty(value2) ? null : ContentManager.Get <Texture2D>(value2));
            PrepareOrder           = valuesDictionary.GetValue <int>("PrepareOrder");
            m_boundingSphereRadius = valuesDictionary.GetValue <float>("BoundingSphereRadius");
        }
 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_componentHerdBehavior = base.Entity.FindComponent <ComponentHerdBehavior>();
     m_componentCreature.ComponentHealth.Attacked += delegate(ComponentCreature attacker)
     {
         SwimAwayFrom(attacker.ComponentBody);
     };
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_attacker        = 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_importanceLevel = ((m_componentCreature.ComponentHealth.Health < 0.33f) ? 300 : 100);
         }
         else if (m_attacker != null && Vector3.DistanceSquared(m_attacker.Position, m_componentCreature.ComponentBody.Position) < 25f)
         {
             m_importanceLevel = 100f;
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("SwimmingAway");
         }
     }, null);
     m_stateMachine.AddState("SwimmingAway", delegate
     {
         m_componentPathfinding.SetDestination(FindSafePlace(), 1f, 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
     }, delegate
     {
         if (!IsActive || !m_componentPathfinding.Destination.HasValue || m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Ejemplo n.º 5
0
 public void ComponentBody_PositionChanged(ComponentFrame componentFrame)
 {
     UpdateBody((ComponentBody)componentFrame);
 }
 public void SwimAwayFrom(ComponentBody attacker)
 {
     m_attacker             = attacker;
     m_timeToForgetAttacker = m_random.Float(10f, 20f);
 }
Ejemplo n.º 7
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");
 }
Ejemplo n.º 8
0
 public void RunAwayFrom(ComponentBody componentBody)
 {
     m_attacker             = componentBody;
     m_timeToForgetAttacker = m_random.Float(10f, 20f);
 }