Ejemplo n.º 1
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemPlayers   = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemTime      = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemUpdate    = base.Project.FindSubsystem <SubsystemUpdate>(throwOnError: true);
     m_subsystemGameInfo  = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTimeOfDay = base.Project.FindSubsystem <SubsystemTimeOfDay>(throwOnError: true);
     m_subsystemTerrain   = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_componentPlayer    = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
     m_sleepStartTime     = valuesDictionary.GetValue <double>("SleepStartTime");
     m_allowManualWakeUp  = valuesDictionary.GetValue <bool>("AllowManualWakeUp");
     if (m_sleepStartTime == 0.0)
     {
         m_sleepStartTime = null;
     }
     if (m_sleepStartTime.HasValue)
     {
         m_sleepFactor = 1f;
         m_minWetness  = float.MaxValue;
     }
     m_componentPlayer.ComponentHealth.Attacked += delegate
     {
         if (IsSleeping && m_componentPlayer.ComponentVitalStats.Sleep > 0.25f)
         {
             WakeUp();
         }
     };
 }
Ejemplo n.º 2
0
 public override void Enter(object[] parameters)
 {
     m_subsystemPlayers                = (SubsystemPlayers)parameters[0];
     m_subsystemPlayers.PlayerAdded   += PlayersChanged;
     m_subsystemPlayers.PlayerRemoved += PlayersChanged;
     UpdatePlayersPanel();
 }
Ejemplo n.º 3
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemAudio              = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
     m_subsystemPlayers            = base.Project.FindSubsystem <SubsystemPlayers>(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_subsystemGameInfo           = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemParticles          = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
     m_subsystemExplosions         = base.Project.FindSubsystem <SubsystemExplosions>(throwOnError: true);
     m_subsystemBlockBehaviors     = base.Project.FindSubsystem <SubsystemBlockBehaviors>(throwOnError: true);
     m_subsystemFireBlockBehavior  = base.Project.FindSubsystem <SubsystemFireBlockBehavior>(throwOnError: true);
     m_subsystemFluidBlockBehavior = base.Project.FindSubsystem <SubsystemFluidBlockBehavior>(throwOnError: true);
     foreach (ValuesDictionary item in valuesDictionary.GetValue <ValuesDictionary>("Pickables").Values.Where((object v) => v is ValuesDictionary))
     {
         Pickable pickable = new Pickable();
         pickable.Value        = item.GetValue <int>("Value");
         pickable.Count        = item.GetValue <int>("Count");
         pickable.Position     = item.GetValue <Vector3>("Position");
         pickable.Velocity     = item.GetValue <Vector3>("Velocity");
         pickable.CreationTime = item.GetValue("CreationTime", 0.0);
         if (item.ContainsKey("StuckMatrix"))
         {
             pickable.StuckMatrix = item.GetValue <Matrix>("StuckMatrix");
         }
         m_pickables.Add(pickable);
     }
 }
Ejemplo n.º 4
0
 public override void Update(float dt)
 {
     if (m_random.Float(0f, 1f) < 0.1f * dt)
     {
         m_frequency = m_random.Float(0.33f, 5f) * 0.5f;
     }
     if (m_random.Float(0f, 1f) < m_frequency * dt)
     {
         SubsystemPlayers subsystemPlayers = base.GameWidget.SubsystemGameWidgets.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
         if (subsystemPlayers.PlayersData.Count > 0)
         {
             Vector3 spawnPosition = subsystemPlayers.PlayersData[0].SpawnPosition;
             spawnPosition.X += m_random.Float(-150f, 150f);
             spawnPosition.Y  = m_random.Float(70f, 120f);
             spawnPosition.Z += m_random.Float(-150f, 150f);
             Vector3 direction = m_random.Vector3(1f);
             SetupPerspectiveCamera(spawnPosition, direction, Vector3.UnitY);
         }
     }
     if (m_random.Float(0f, 1f) < 0.5f * m_frequency * dt)
     {
         base.GameWidget.SubsystemGameWidgets.Project.FindSubsystem <SubsystemTimeOfDay>(throwOnError: true).TimeOfDayOffset = m_random.Float(0f, 1f);
     }
     if (m_random.Float(0f, 1f) < 1f * dt * 0.5f)
     {
         GameManager.SaveProject(waitForCompletion: false, showErrorDialog: false);
     }
 }
        public override void Load(ValuesDictionary valuesDictionary)
        {
            base.Load(valuesDictionary);
            m_subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
            string value = valuesDictionary.GetValue <string>("Magnets");

            m_magnets = new DynamicArray <Vector3>(HumanReadableConverter.ValuesListFromString <Vector3>(';', value));
        }
Ejemplo n.º 6
0
 public override void Leave()
 {
     m_subsystemPlayers.PlayerAdded   -= PlayersChanged;
     m_subsystemPlayers.PlayerRemoved -= PlayersChanged;
     m_subsystemPlayers = null;
     m_characterSkinsCache.Clear();
     m_playersPanel.Children.Clear();
 }
Ejemplo n.º 7
0
        public IEnumerable <ActiveExternalContentInfo> GetActiveExternalContent()
        {
            string downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.World, DirectoryName);

            if (!string.IsNullOrEmpty(downloadedContentAddress))
            {
                yield return(new ActiveExternalContentInfo
                {
                    Address = downloadedContentAddress,
                    DisplayName = WorldSettings.Name,
                    Type = ExternalContentType.World
                });
            }
            if (!BlocksTexturesManager.IsBuiltIn(WorldSettings.BlocksTextureName))
            {
                downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.BlocksTexture, WorldSettings.BlocksTextureName);
                if (!string.IsNullOrEmpty(downloadedContentAddress))
                {
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = BlocksTexturesManager.GetDisplayName(WorldSettings.BlocksTextureName),
                        Type = ExternalContentType.BlocksTexture
                    });
                }
            }
            SubsystemPlayers subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);

            foreach (PlayerData playersDatum in subsystemPlayers.PlayersData)
            {
                if (!CharacterSkinsManager.IsBuiltIn(playersDatum.CharacterSkinName))
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.CharacterSkin, playersDatum.CharacterSkinName);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = CharacterSkinsManager.GetDisplayName(playersDatum.CharacterSkinName),
                        Type = ExternalContentType.CharacterSkin
                    });
                }
            }
            SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);

            foreach (FurnitureSet furnitureSet in subsystemFurnitureBlockBehavior.FurnitureSets)
            {
                if (furnitureSet.ImportedFrom != null)
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.FurniturePack, furnitureSet.ImportedFrom);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = FurniturePacksManager.GetDisplayName(furnitureSet.ImportedFrom),
                        Type = ExternalContentType.FurniturePack
                    });
                }
            }
        }
Ejemplo n.º 8
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     m_subsystemTerrain     = base.Project.FindSubsystem <SubsystemTerrain>(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);
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemSky         = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemPlayers     = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
 }
        protected override void Load(TemplatesDatabase.ValuesDictionary valuesDictionary)
        {
            base.Load(valuesDictionary);
            subsystemPlayers  = Project.FindSubsystem <SubsystemPlayers>();
            subsystemTerrain  = Project.FindSubsystem <SubsystemTerrain>();
            subsystemSky      = Project.FindSubsystem <SubsystemSky>();
            subsystemCreature = Project.FindSubsystem <SubsystemCreatureSpawn>();
            subsystemTime     = Project.FindSubsystem <SubsystemTimeOfDay>();

            LoadCreatureTemplateNames();
            LoadCreatureDatas();

            foreach (KeyValuePair <string, object> pair in valuesDictionary.GetValue <TemplatesDatabase.ValuesDictionary>("Points"))
            {
                var p = Engine.Serialization.HumanReadableConverter.ConvertFromString <Point3>(pair.Key);
                storedPoints[pair.Key] = p;
            }

            InitCommands();
        }
Ejemplo n.º 10
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemPlayers              = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     SubsystemTerrain                = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemPlayers.PlayerAdded += delegate(PlayerData playerData)
     {
         AddGameWidgetForPlayer(playerData);
     };
     m_subsystemPlayers.PlayerRemoved += delegate(PlayerData playerData)
     {
         if (playerData.GameWidget != null)
         {
             RemoveGameWidget(playerData.GameWidget);
         }
     };
     GamesWidget = valuesDictionary.GetValue <GamesWidget>("GamesWidget");
     foreach (PlayerData playersDatum in m_subsystemPlayers.PlayersData)
     {
         AddGameWidgetForPlayer(playersDatum);
     }
 }
Ejemplo n.º 11
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemPlayers  = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemViews    = base.Project.FindSubsystem <SubsystemGameWidgets>(throwOnError: true);
     m_subsystemTerrain  = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_subsystemTime     = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     foreach (KeyValuePair <string, object> item in valuesDictionary.GetValue <ValuesDictionary>("Chunks"))
     {
         ValuesDictionary valuesDictionary2 = (ValuesDictionary)item.Value;
         SpawnChunk       spawnChunk        = new SpawnChunk();
         spawnChunk.Point           = HumanReadableConverter.ConvertFromString <Point2>(item.Key);
         spawnChunk.IsSpawned       = valuesDictionary2.GetValue <bool>("IsSpawned");
         spawnChunk.LastVisitedTime = valuesDictionary2.GetValue <double>("LastVisitedTime");
         string value = valuesDictionary2.GetValue("SpawnsData", string.Empty);
         if (!string.IsNullOrEmpty(value))
         {
             LoadSpawnsData(value, spawnChunk.SpawnsData);
         }
         m_chunks[spawnChunk.Point] = spawnChunk;
     }
 }
Ejemplo n.º 12
0
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemUpdate  = base.Project.FindSubsystem <SubsystemUpdate>(throwOnError: true);
 }
 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");
 }
Ejemplo n.º 14
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     this.LoadItems(valuesDictionary);
     m_componentBlockEntity = Entity.FindComponent <ComponentBlockEntity>(true);
     SubsystemPlayers       = Project.FindSubsystem <SubsystemPlayers>(true);
 }