public bool PlayFootstepSound(ComponentCreature componentCreature, float loudnessMultiplier)
        {
            string footstepSoundMaterialName = GetFootstepSoundMaterialName(componentCreature);

            if (!string.IsNullOrEmpty(footstepSoundMaterialName))
            {
                string value = componentCreature.ComponentCreatureSounds.ValuesDictionary.GetValue <ValuesDictionary>("CustomFootstepSounds").GetValue <string>(footstepSoundMaterialName, null);
                if (string.IsNullOrEmpty(value))
                {
                    value = m_footstepSoundsValuesDictionary.GetValue <string>(footstepSoundMaterialName, null);
                }
                if (!string.IsNullOrEmpty(value))
                {
                    float pitch = m_random.Float(-0.2f, 0.2f);
                    m_subsystemAudio.PlayRandomSound(value, 0.75f * loudnessMultiplier, pitch, componentCreature.ComponentBody.Position, 2f * loudnessMultiplier, autoDelay: true);
                    ComponentPlayer componentPlayer = componentCreature as ComponentPlayer;
                    if (componentPlayer != null && componentPlayer.ComponentVitalStats.Wetness > 0f)
                    {
                        string value2 = m_footstepSoundsValuesDictionary.GetValue <string>("Squishy", null);
                        if (!string.IsNullOrEmpty(value2))
                        {
                            float volume = 0.7f * loudnessMultiplier * MathUtils.Pow(componentPlayer.ComponentVitalStats.Wetness, 4f);
                            m_subsystemAudio.PlayRandomSound(value2, volume, pitch, componentCreature.ComponentBody.Position, 2f * loudnessMultiplier, autoDelay: true);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
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_subsystemTerrain  = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
 }
Esempio n. 3
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime                = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemGameInfo            = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_componentCreature            = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentMount               = base.Entity.FindComponent <ComponentMount>(throwOnError: true);
     m_componentSteedBehavior       = base.Entity.FindComponent <ComponentSteedBehavior>(throwOnError: true);
     m_componentEatPickableBehavior = base.Entity.FindComponent <ComponentEatPickableBehavior>(throwOnError: true);
     m_stubbornProbability          = valuesDictionary.GetValue <float>("StubbornProbability");
     m_stubbornEndTime              = valuesDictionary.GetValue <double>("StubbornEndTime");
     m_periodicEventOffset          = m_random.Float(0f, 100f);
     m_isSaddled = base.Entity.ValuesDictionary.DatabaseObject.Name.EndsWith("_Saddled");
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (m_subsystemTime.PeriodicGameTimeEvent(1.0, m_periodicEventOffset) && m_componentMount.Rider != null && m_random.Float(0f, 1f) < m_stubbornProbability && (!m_isSaddled || m_componentEatPickableBehavior.Satiation <= 0f))
         {
             m_stubbornEndTime = m_subsystemGameInfo.TotalElapsedGameTime + (double)m_random.Float(60f, 120f);
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Stubborn");
         }
     }, null);
     m_stateMachine.AddState("Stubborn", null, delegate
     {
         if (m_componentSteedBehavior.WasOrderIssued)
         {
             m_componentCreature.ComponentCreatureModel.HeadShakeOrder = m_random.Float(0.6f, 1f);
             m_componentCreature.ComponentCreatureSounds.PlayPainSound();
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Esempio n. 4
0
 public void Injure(float amount, ComponentCreature attacker, bool ignoreInvulnerability)
 {
     if (amount > 0f)
     {
         Health = MathUtils.Max(Health - amount, 0f);
     }
 }
 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 string GetFootstepSoundMaterialName(ComponentCreature componentCreature)
        {
            Vector3 position = componentCreature.ComponentBody.Position;

            if (componentCreature.ComponentBody.ImmersionDepth > 0.2f && componentCreature.ComponentBody.ImmersionFluidBlock is WaterBlock)
            {
                return("Water");
            }
            if (componentCreature.ComponentLocomotion.LadderValue.HasValue)
            {
                if (Terrain.ExtractContents(componentCreature.ComponentLocomotion.LadderValue.Value) == 59)
                {
                    return("WoodenLadder");
                }
                return("MetalLadder");
            }
            int    cellValue         = m_subsystemTerrain.Terrain.GetCellValue(Terrain.ToCell(position.X), Terrain.ToCell(position.Y + 0.1f), Terrain.ToCell(position.Z));
            int    num               = Terrain.ExtractContents(cellValue);
            string soundMaterialName = BlocksManager.Blocks[num].GetSoundMaterialName(m_subsystemTerrain, cellValue);

            if (string.IsNullOrEmpty(soundMaterialName) && componentCreature.ComponentBody.StandingOnValue.HasValue)
            {
                soundMaterialName = BlocksManager.Blocks[Terrain.ExtractContents(componentCreature.ComponentBody.StandingOnValue.Value)].GetSoundMaterialName(m_subsystemTerrain, componentCreature.ComponentBody.StandingOnValue.Value);
            }
            if (!string.IsNullOrEmpty(soundMaterialName))
            {
                return(soundMaterialName);
            }
            return(string.Empty);
        }
Esempio n. 7
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemGameInfo    = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_milkRegenerationTime = valuesDictionary.GetValue <float>("MilkRegenerationTime");
     m_lastMilkingTime      = valuesDictionary.GetValue <double>("LastMilkingTime");
 }
Esempio n. 8
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     base.Load(valuesDictionary, idToEntityMap);
     m_subsystemSky        = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_componentHumanModel = base.Entity.FindComponent <ComponentHumanModel>(throwOnError: true);
     m_componentCreature   = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
 }
Esempio n. 9
0
 public CommandStream(ComponentCreature creature, Point3?exePosition, string command)
 {
     m_commands       = GetCommands(command);
     m_creature       = creature;
     this.exePosition = exePosition;
     hasCreature      = creature != null;
 }
Esempio n. 10
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemTime      = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
            m_subsystemTimeOfDay = base.Project.FindSubsystem <SubsystemTimeOfDay>(throwOnError: true);
            m_subsystemTerrain   = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            m_subsystemParticles = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
            m_subsystemGameInfo  = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
            m_subsystemPickables = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
            m_componentCreature  = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
            m_componentPlayer    = base.Entity.FindComponent <ComponentPlayer>();
            m_componentOnFire    = base.Entity.FindComponent <ComponentOnFire>(throwOnError: true);
            AttackResilience     = valuesDictionary.GetValue <float>("AttackResilience");
            FallResilience       = valuesDictionary.GetValue <float>("FallResilience");
            FireResilience       = valuesDictionary.GetValue <float>("FireResilience");
            CorpseDuration       = valuesDictionary.GetValue <float>("CorpseDuration");
            BreathingMode        = valuesDictionary.GetValue <BreathingMode>("BreathingMode");
            CanStrand            = valuesDictionary.GetValue <bool>("CanStrand");
            Health      = valuesDictionary.GetValue <float>("Health");
            Air         = valuesDictionary.GetValue <float>("Air");
            AirCapacity = valuesDictionary.GetValue <float>("AirCapacity");
            double value = valuesDictionary.GetValue <double>("DeathTime");

            DeathTime    = ((value >= 0.0) ? new double?(value) : null);
            CauseOfDeath = valuesDictionary.GetValue <string>("CauseOfDeath");
            if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative && base.Entity.FindComponent <ComponentPlayer>() != null)
            {
                IsInvulnerable = true;
            }
        }
 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_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_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_target          = null;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Move");
         }
         m_target = FindTarget(out float targetScore);
         if (m_target != null)
         {
             Vector3.Distance(m_target.ComponentBody.Position, m_componentCreature.ComponentBody.Position);
             SetImportanceLevel(targetScore);
         }
         else
         {
             m_importanceLevel = 0f;
         }
     }, null);
Esempio n. 12
0
        public override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody)
        {
            int data = Terrain.ExtractData(base.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z));

            if (!SpikedPlankBlock.GetSpikesState(data))
            {
                return;
            }
            int mountingFace = SpikedPlankBlock.GetMountingFace(data);

            if (cellFace.Face != mountingFace)
            {
                return;
            }
            ComponentCreature componentCreature = componentBody.Entity.FindComponent <ComponentCreature>();

            if (componentCreature != null)
            {
                m_lastInjuryTimes.TryGetValue(componentCreature, out double value);
                if (m_subsystemTime.GameTime - value > 1.0)
                {
                    m_lastInjuryTimes[componentCreature] = m_subsystemTime.GameTime;
                    componentCreature.ComponentHealth.Injure(0.1f, null, ignoreInvulnerability: false, "Spiked by a trap");
                }
            }
        }
 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;
     });
 }
 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_stareRange           = valuesDictionary.GetValue <float>("StareRange");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
     }, delegate
     {
         if (m_subsystemTime.GameTime > m_stareEndTime + 8.0 && m_random.Float(0f, 1f) < 1f * m_subsystemTime.GameTimeDelta)
         {
             m_target = FindTarget();
             if (m_target != null)
             {
                 float probability = (m_target.Entity.FindComponent <ComponentPlayer>() != null) ? 1f : 0.25f;
                 if (m_random.Bool(probability))
                 {
                     m_importanceLevel = m_random.Float(3f, 5f);
                 }
             }
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Stare");
         }
     }, null);
     m_stateMachine.AddState("Stare", delegate
     {
         m_stareEndTime = m_subsystemTime.GameTime + (double)m_random.Float(6f, 12f);
         if (m_target != null)
         {
             Vector3 position = m_componentCreature.ComponentBody.Position;
             Vector3 v        = Vector3.Normalize(m_target.ComponentBody.Position - position);
             m_componentPathfinding.SetDestination(position + 1.1f * v, m_random.Float(0.3f, 0.4f), 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
             if (m_random.Float(0f, 1f) < 0.5f)
             {
                 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
             }
         }
     }, delegate
     {
         if (!IsActive || m_target == null || m_componentPathfinding.IsStuck || m_subsystemTime.GameTime > m_stareEndTime)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_random.Float(0f, 1f) < 1f * m_subsystemTime.GameTimeDelta && ScoreTarget(m_target) <= 0f)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else
         {
             m_componentCreature.ComponentCreatureModel.LookAtOrder = m_target.ComponentCreatureModel.EyePosition;
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Esempio n. 15
0
 public void SetOnFire(ComponentCreature attacker, float duration)
 {
     if (!IsOnFire)
     {
         Attacker = attacker;
     }
     m_fireDuration = MathUtils.Max(m_fireDuration, duration);
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     foreach (ComponentBehavior item in base.Entity.FindComponents <ComponentBehavior>())
     {
         m_behaviors.Add(item);
     }
 }
 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");
 }
Esempio n. 18
0
        public override void OnEntityRemoved(Entity entity)
        {
            ComponentCreature componentCreature = entity.FindComponent <ComponentCreature>();

            if (componentCreature != null)
            {
                m_lastInjuryTimes.Remove(componentCreature);
            }
        }
Esempio n. 19
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemGameInfo  = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemPickables = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
     m_componentCreature  = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_lootDropped        = valuesDictionary.GetValue <bool>("LootDropped");
     m_lootList           = ParseLootList(valuesDictionary.GetValue <ValuesDictionary>("Loot"));
     m_lootOnFireList     = ParseLootList(valuesDictionary.GetValue <ValuesDictionary>("LootOnFire"));
 }
 public void Attack(ComponentCreature componentCreature, float maxRange, float maxChaseTime, bool isPersistent)
 {
     m_target          = componentCreature;
     m_nextUpdateTime  = 0.0;
     m_range           = maxRange;
     m_chaseTime       = maxChaseTime;
     m_isPersistent    = isPersistent;
     m_importanceLevel = 200f;
 }
 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_isEnabled            = valuesDictionary.GetValue <bool>("IsEnabled");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         SummonTarget      = null;
         m_summonedTime    = 0.0;
     }, delegate
     {
         if (m_isEnabled && SummonTarget != null && m_summonedTime == 0.0)
         {
             m_subsystemTime.QueueGameTimeDelayedExecution(m_subsystemTime.GameTime + 0.5, delegate
             {
                 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
                 m_importanceLevel = 270f;
                 m_summonedTime    = m_subsystemTime.GameTime;
             });
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("FollowTarget");
         }
     }, null);
     m_stateMachine.AddState("FollowTarget", delegate
     {
         FollowTarget(noDelay: true);
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (SummonTarget == null || m_componentPathfinding.IsStuck || m_subsystemTime.GameTime - m_summonedTime > 30.0)
         {
             m_importanceLevel = 0f;
         }
         else if (!m_componentPathfinding.Destination.HasValue)
         {
             if (m_stoppedTime < 0.0)
             {
                 m_stoppedTime = m_subsystemTime.GameTime;
             }
             if (m_subsystemTime.GameTime - m_stoppedTime > 6.0)
             {
                 m_importanceLevel = 0f;
             }
         }
         FollowTarget(noDelay: false);
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Esempio n. 22
0
        public void MakeLightningStrike(Vector3 targetPosition)
        {
            if (m_lightningStrikePosition.HasValue || !(m_subsystemTime.GameTime - m_lastLightningStrikeTime > 1.0))
            {
                return;
            }
            m_lastLightningStrikeTime   = m_subsystemTime.GameTime;
            m_lightningStrikePosition   = targetPosition;
            m_lightningStrikeBrightness = 1f;
            float num = float.MaxValue;

            foreach (Vector3 listenerPosition in m_subsystemAudio.ListenerPositions)
            {
                float num2 = Vector2.Distance(new Vector2(listenerPosition.X, listenerPosition.Z), new Vector2(targetPosition.X, targetPosition.Z));
                if (num2 < num)
                {
                    num = num2;
                }
            }
            float delay = m_subsystemAudio.CalculateDelay(num);

            if (num < 40f)
            {
                m_subsystemAudio.PlayRandomSound("Audio/ThunderNear", 1f, m_random.Float(-0.2f, 0.2f), 0f, delay);
            }
            else if (num < 200f)
            {
                m_subsystemAudio.PlayRandomSound("Audio/ThunderFar", 0.8f, m_random.Float(-0.2f, 0.2f), 0f, delay);
            }
            if (m_subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode != 0)
            {
                return;
            }
            DynamicArray <ComponentBody> dynamicArray = new DynamicArray <ComponentBody>();

            m_subsystemBodies.FindBodiesAroundPoint(new Vector2(targetPosition.X, targetPosition.Z), 4f, dynamicArray);
            for (int i = 0; i < dynamicArray.Count; i++)
            {
                ComponentBody componentBody = dynamicArray.Array[i];
                if (componentBody.Position.Y > targetPosition.Y - 1.5f && Vector2.Distance(new Vector2(componentBody.Position.X, componentBody.Position.Z), new Vector2(targetPosition.X, targetPosition.Z)) < 4f)
                {
                    componentBody.Entity.FindComponent <ComponentOnFire>()?.SetOnFire(null, m_random.Float(12f, 15f));
                }
                ComponentCreature componentCreature = componentBody.Entity.FindComponent <ComponentCreature>();
                if (componentCreature != null && componentCreature.PlayerStats != null)
                {
                    componentCreature.PlayerStats.StruckByLightning++;
                }
            }
            int   x        = Terrain.ToCell(targetPosition.X);
            int   num3     = Terrain.ToCell(targetPosition.Y);
            int   z        = Terrain.ToCell(targetPosition.Z);
            float pressure = (m_random.Float(0f, 1f) < 0.2f) ? 39 : 19;

            base.Project.FindSubsystem <SubsystemExplosions>(throwOnError: true).AddExplosion(x, num3 + 1, z, pressure, isIncendiary: false, noExplosionSound: true);
        }
Esempio n. 23
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");
 }
Esempio n. 24
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_alwaysEnabled     = valuesDictionary.GetValue <bool>("AlwaysEnabled");
     m_jumpStrength      = valuesDictionary.GetValue <float>("JumpStrength");
     m_componentCreature.ComponentBody.CollidedWithBody += delegate
     {
         m_collidedWithBody = true;
     };
 }
 public bool IsPredator(Entity entity)
 {
     if (entity != base.Entity)
     {
         ComponentCreature componentCreature = entity.FindComponent <ComponentCreature>();
         if (componentCreature != null && (componentCreature.Category == CreatureCategory.LandPredator || componentCreature.Category == CreatureCategory.WaterPredator || componentCreature.Category == CreatureCategory.LandOther))
         {
             return(true);
         }
     }
     return(false);
 }
 public float ScoreTarget(ComponentCreature componentCreature)
 {
     if (componentCreature != m_componentCreature && componentCreature.Entity.IsAddedToProject)
     {
         float num  = Vector3.Distance(m_componentCreature.ComponentBody.Position, componentCreature.ComponentBody.Position);
         float num2 = m_stareRange - num;
         if (m_random.Float(0f, 1f) < 0.66f && componentCreature.Entity.FindComponent <ComponentPlayer>() != null)
         {
             num2 *= 100f;
         }
         return(num2);
     }
     return(0f);
 }
Esempio n. 27
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_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, 2f);
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Walk");
         }
     }, null);
     m_stateMachine.AddState("Walk", delegate
     {
         float speed = (m_componentCreature.ComponentBody.ImmersionFactor > 0.5f) ? 1f : m_random.Float(0.25f, 0.35f);
         m_componentPathfinding.SetDestination(FindDestination(), speed, 1f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
     }, delegate
     {
         if (m_componentPathfinding.IsStuck || !IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         if (!m_componentPathfinding.Destination.HasValue)
         {
             if (m_random.Float(0f, 1f) < 0.5f)
             {
                 m_stateMachine.TransitionTo("Inactive");
             }
             else
             {
                 m_stateMachine.TransitionTo(null);
                 m_stateMachine.TransitionTo("Walk");
             }
         }
         if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
         }
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
     }, 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_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");
 }
Esempio n. 29
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_componentFishModel = base.Entity.FindComponent <ComponentFishModel>(throwOnError: true);
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (IsOutOfWater())
         {
             m_outOfWaterTime += m_subsystemTime.GameTimeDelta;
         }
         else
         {
             m_outOfWaterTime = 0f;
         }
         if (m_outOfWaterTime > 3f)
         {
             m_importanceLevel = 1000f;
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Jump");
         }
     }, null);
     m_stateMachine.AddState("Jump", null, delegate
     {
         m_componentFishModel.BendOrder = 2f * (2f * MathUtils.Saturate(SimplexNoise.OctavedNoise((float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0), 1.2f * m_componentCreature.ComponentLocomotion.TurnSpeed, 1, 1f, 1f)) - 1f);
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         if (!IsOutOfWater())
         {
             m_importanceLevel = 0f;
         }
         if (m_random.Float(0f, 1f) < 2.5f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentLocomotion.JumpOrder = m_random.Float(0.33f, 1f);
             m_direction = new Vector2(MathUtils.Sign(m_componentFishModel.BendOrder.Value), 0f);
         }
         if (!m_componentCreature.ComponentBody.StandingOnValue.HasValue)
         {
             m_componentCreature.ComponentLocomotion.TurnOrder = new Vector2(0f - m_componentFishModel.BendOrder.Value, 0f);
             m_componentCreature.ComponentLocomotion.WalkOrder = m_direction;
         }
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
Esempio n. 30
0
 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);
     m_componentHerdBehavior  = base.Entity.FindComponent <ComponentHerdBehavior>(throwOnError: true);
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_driveVector     = Vector3.Zero;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Drive");
         }
         if (m_driveVector.Length() > 3f)
         {
             m_importanceLevel = 7f;
         }
         FadeDriveVector();
     }, null);
     m_stateMachine.AddState("Drive", delegate
     {
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         if (m_driveVector.LengthSquared() < 1f || m_componentPathfinding.IsStuck)
         {
             m_importanceLevel = 0f;
         }
         if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
         }
         if (m_random.Float(0f, 1f) < 3f * m_subsystemTime.GameTimeDelta)
         {
             Vector3 v   = CalculateDriveDirectionAndSpeed();
             float speed = MathUtils.Saturate(0.2f * v.Length());
             m_componentPathfinding.SetDestination(m_componentCreature.ComponentBody.Position + 15f * Vector3.Normalize(v), speed, 5f, 0, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
         }
         FadeDriveVector();
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }