예제 #1
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemNoise       = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemGameInfo    = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPlayer      = base.Entity.FindComponent <ComponentPlayer>();
     m_componentLevel       = base.Entity.FindComponent <ComponentLevel>();
     m_componentClothing    = base.Entity.FindComponent <ComponentClothing>();
     m_componentMount       = base.Entity.FindComponent <ComponentMount>();
     m_componentRider       = base.Entity.FindComponent <ComponentRider>();
     IsCreativeFlyEnabled   = valuesDictionary.GetValue <bool>("IsCreativeFlyEnabled");
     AccelerationFactor     = valuesDictionary.GetValue <float>("AccelerationFactor");
     WalkSpeed              = valuesDictionary.GetValue <float>("WalkSpeed");
     LadderSpeed            = valuesDictionary.GetValue <float>("LadderSpeed");
     JumpSpeed              = valuesDictionary.GetValue <float>("JumpSpeed");
     CreativeFlySpeed       = valuesDictionary.GetValue <float>("CreativeFlySpeed");
     FlySpeed               = valuesDictionary.GetValue <float>("FlySpeed");
     SwimSpeed              = valuesDictionary.GetValue <float>("SwimSpeed");
     TurnSpeed              = valuesDictionary.GetValue <float>("TurnSpeed");
     LookSpeed              = valuesDictionary.GetValue <float>("LookSpeed");
     InAirWalkFactor        = valuesDictionary.GetValue <float>("InAirWalkFactor");
     m_walkSpeedWhenTurning = valuesDictionary.GetValue <float>("WalkSpeedWhenTurning");
     m_minFrictionFactor    = valuesDictionary.GetValue <float>("MinFrictionFactor");
     m_lookAutoLevelX       = valuesDictionary.GetValue <bool>("LookAutoLevelX");
     m_lookAutoLevelY       = valuesDictionary.GetValue <bool>("LookAutoLevelY");
     if (base.Entity.FindComponent <ComponentPlayer>() == null)
     {
         WalkSpeed *= m_random.Float(0.85f, 1f);
         FlySpeed  *= m_random.Float(0.85f, 1f);
         SwimSpeed *= m_random.Float(0.85f, 1f);
     }
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemAudio              = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemSoundMaterials     = base.Project.FindSubsystem <SubsystemSoundMaterials>(throwOnError: true);
     m_subsystemParticles          = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
     m_subsystemPickables          = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
     m_subsystemBodies             = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemTerrain            = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemSky                = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemTime               = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemNoise              = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     m_subsystemExplosions         = base.Project.FindSubsystem <SubsystemExplosions>(throwOnError: true);
     m_subsystemGameInfo           = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemBlockBehaviors     = base.Project.FindSubsystem <SubsystemBlockBehaviors>(throwOnError: true);
     m_subsystemFluidBlockBehavior = base.Project.FindSubsystem <SubsystemFluidBlockBehavior>(throwOnError: true);
     m_subsystemFireBlockBehavior  = base.Project.FindSubsystem <SubsystemFireBlockBehavior>(throwOnError: true);
     foreach (ValuesDictionary item in valuesDictionary.GetValue <ValuesDictionary>("Projectiles").Values.Where((object v) => v is ValuesDictionary))
     {
         Projectile projectile = new Projectile();
         projectile.Value        = item.GetValue <int>("Value");
         projectile.Position     = item.GetValue <Vector3>("Position");
         projectile.Velocity     = item.GetValue <Vector3>("Velocity");
         projectile.CreationTime = item.GetValue <double>("CreationTime");
         m_projectiles.Add(projectile);
     }
 }
예제 #3
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     m_subsystemBodies = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemAudio  = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemNoise  = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemBodies      = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemAudio       = base.Project.FindSubsystem <SubsystemAudio>(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_componentCreature.ComponentBody.CollidedWithBody += delegate
     {
         if (m_stateMachine.CurrentState != "RunningAway")
         {
             m_stateMachine.TransitionTo("DangerDetected");
         }
     };
     m_stateMachine.AddState("LookingForDanger", null, delegate
     {
         if (ScanForDanger())
         {
             m_stateMachine.TransitionTo("DangerDetected");
         }
     }, null);
     m_stateMachine.AddState("DangerDetected", delegate
     {
         m_importanceLevel = ((m_componentCreature.ComponentHealth.Health < 0.33f) ? 300 : 100);
         m_nextUpdateTime  = 0.0;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("RunningAway");
             m_nextUpdateTime = 0.0;
         }
     }, null);
     m_stateMachine.AddState("RunningAway", delegate
     {
         m_componentPathfinding.SetDestination(FindSafePlace(), 1f, 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
         m_subsystemAudio.PlayRandomSound("Audio/Creatures/Wings", 0.8f, m_random.Float(-0.1f, 0.2f), m_componentCreature.ComponentBody.Position, 3f, autoDelay: true);
         m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         m_subsystemNoise.MakeNoise(m_componentCreature.ComponentBody, 0.25f, 6f);
     }, delegate
     {
         if (!IsActive || !m_componentPathfinding.Destination.HasValue || m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("LookingForDanger");
         }
         else if (ScoreSafePlace(m_componentCreature.ComponentBody.Position, m_componentPathfinding.Destination.Value, null) < 4f)
         {
             m_componentPathfinding.SetDestination(FindSafePlace(), 1f, 0.5f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
         }
     }, delegate
     {
         m_importanceLevel = 0f;
     });
     m_stateMachine.TransitionTo("LookingForDanger");
 }
        public SoundGeneratorElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
            : base(subsystemElectricity, cellFace)
        {
            m_subsystemNoise     = subsystemElectricity.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
            m_subsystemParticles = subsystemElectricity.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
            Vector3 vector   = CellFace.FaceToVector3(cellFace.Face);
            Vector3 position = new Vector3(cellFace.Point) + new Vector3(0.5f) - 0.2f * vector;

            m_particleSystem = new SoundParticleSystem(subsystemElectricity.SubsystemTerrain, position, vector);
        }
예제 #6
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemProjectiles = base.Project.FindSubsystem <SubsystemProjectiles>(throwOnError: true);
     m_subsystemParticles   = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
     m_subsystemAudio       = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemNoise       = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     base.Load(valuesDictionary);
 }
예제 #7
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemAudio             = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemParticles         = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
     m_subsystemTerrain           = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemNoise             = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     m_subsystemBodies            = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_subsystemPickables         = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
     m_subsystemProjectiles       = base.Project.FindSubsystem <SubsystemProjectiles>(throwOnError: true);
     m_subsystemBlockBehaviors    = base.Project.FindSubsystem <SubsystemBlockBehaviors>(throwOnError: true);
     m_subsystemFireBlockBehavior = base.Project.FindSubsystem <SubsystemFireBlockBehavior>(throwOnError: true);
     m_explosionParticleSystem    = new ExplosionParticleSystem();
     m_subsystemParticles.AddParticleSystem(m_explosionParticleSystem);
 }
예제 #8
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     base.Load(valuesDictionary, idToEntityMap);
     m_subsystemTerrain        = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemModelsRenderer = base.Project.FindSubsystem <SubsystemModelsRenderer>(throwOnError: true);
     m_subsystemNoise          = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true);
     m_subsystemAudio          = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_componentMiner          = base.Entity.FindComponent <ComponentMiner>();
     m_componentRider          = base.Entity.FindComponent <ComponentRider>();
     m_componentSleep          = base.Entity.FindComponent <ComponentSleep>();
     m_componentPlayer         = base.Entity.FindComponent <ComponentPlayer>();
     m_walkAnimationSpeed      = valuesDictionary.GetValue <float>("WalkAnimationSpeed");
     m_walkBobHeight           = valuesDictionary.GetValue <float>("WalkBobHeight");
     m_walkLegsAngle           = valuesDictionary.GetValue <float>("WalkLegsAngle");
 }
 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");
 }
예제 #10
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");
 }