Example #1
0
 // Methods
 protected override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     this.m_subsystemGameInfo      = base.Project.FindSubsystem <SubsystemGameInfo>(true);
     this.m_subsystemEntityFactory = base.Project.FindSubsystem <SubsystemEntityFactory>(true);
     this.m_subsystemCreatureSpawn = base.Project.FindSubsystem <SubsystemCreatureSpawn>(true);
     this.m_subsystemGui           = base.Project.FindSubsystem <SubsystemGui>(true);
 }
Example #2
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");
 }
        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();
        }
Example #4
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            flatBatch           = primitivesRenderer.FlatBatch();
            componentPlayer     = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
            subsystemTerrain    = base.Entity.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            subsystemPlantBlock = base.Entity.Project.FindSubsystem <SubsystemPlantBlockBehavior>(throwOnError: true);
            creatureSpawn       = Project.FindSubsystem <SubsystemCreatureSpawn>();
            modelsRenderer      = base.Entity.Project.FindSubsystem <SubsystemModelsRenderer>();
            subsystemBodies     = Project.FindSubsystem <SubsystemBodies>();
            jeiBehavior         = base.Entity.Project.FindSubsystem <SubsystemXjJeiBehavior>();
            jump.Texture        = TextureAtlasManager.GetSubtexture("JEITextures/JEI_Jump").Texture;
            jumpcanvas.Children.Add(touch);
            jumpcanvas.Children.Add(jump);
            jumpcanvas.DesiredSize = SubsystemXjJeiBehavior.jumpsize;
            jump.DesiredSize       = SubsystemXjJeiBehavior.jumpsize;
            jumpcanvas.IsVisible   = SubsystemXjJeiBehavior.showjump;
            messageInfo.setPlayer(componentPlayer);
            if (componentPlayer != null)
            {
                msginfobtn.NormalSubtexture  = new Subtexture(ContentManager.Get <Texture2D>("JEITextures/JEI_MSG"), Vector2.Zero, Vector2.One);
                msginfobtn.ClickedSubtexture = new Subtexture(ContentManager.Get <Texture2D>("JEITextures/JEI_MSG_P"), Vector2.Zero, Vector2.One);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(infoDialog);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(messageInfo);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(moreInfo);
                componentPlayer.GuiWidget.Children.Find <StackPanelWidget>("RightControlsContainer").Children.Add(msginfobtn);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(jumpcanvas);
            }

            int num = 0;

            try
            {
                List <string> namelist = new List <string>();
                Dictionary <string, List <string> > depancys = new Dictionary <string, List <string> >();
                List <uint> verList = new List <uint>();
                foreach (ModInfo modInfo in ModsManager.LoadedMods)
                {
                    if (!namelist.Contains(modInfo.Name))
                    {
                        if (!string.IsNullOrEmpty(modInfo.Dependency))
                        {
                            string[]      mm    = modInfo.Dependency.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            List <string> mlist = new List <string>();
                            if (mm.Length == 1)
                            {
                                mlist.Add(modInfo.Dependency);
                            }
                            else
                            {
                                foreach (string mmsa in mm)
                                {
                                    mlist.Add(mmsa);
                                }
                            }
                            depancys.Add(modInfo.Name, mlist);
                        }
                        namelist.Add(modInfo.Name);
                        verList.Add(modInfo.Version);
                    }
                }
                messageInfo.addMessage("[color=yellow]欢迎使用[/color][color=red]SCCRF合成书[/color][color=yellow]模组![/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]使用一根[color=red]木棍[/color]开始你的[color=green]合成之旅[/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]电脑端按下[color=red]TAB[/color]快捷打开[color=green]消息框[/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]电脑端按下[color=red]B[/color]快捷打开[color=green]合成谱[/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]输入[color=red]/help[/color]使用[color=green]命令[/color]帮助");
                messageInfo.addMessage($"[color=green]并且您已安装([/color][color=red]{namelist.Count}[/color][color=green])个模组[/color]");
                foreach (string modInfo in namelist)
                {
                    messageInfo.addMessage($"[color=blue]{num+1}.[/color] {modInfo.Replace('[','{').Replace(']','}')} [color=yellow]{parseVersion(verList[num])}[/color]");
                    num++;
                }
                num = 0;
                foreach (KeyValuePair <string, List <string> > kkop in depancys)
                {
                    foreach (string huap in kkop.Value)
                    {
                        if (!namelist.Contains(huap))
                        {
                            if (huap == "zh-cn" && namelist.Contains("NewBlocks_SC"))
                            {
                                continue;
                            }
                            messageInfo.addMessage($"[color=yellow]<警告>[/color]:使用[color=blue]{kkop.Key}[/color]需要安装依赖MOD [color=green]{huap}[/color]");
                        }
                    }
                    ++num;
                }
                messageInfo.IsVisible = false;
            }
            catch (Exception e) {
                messageInfo.addMessage(e.ToString());
            }
            infoDialog.IsVisible = false;
            base.Load(valuesDictionary, idToEntityMap);
        }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     subsystemCreatureSpawn = Project.FindSubsystem <SubsystemCreatureSpawn>();
     base.Load(valuesDictionary);
 }
 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);
     HerdName                  = valuesDictionary.GetValue <string>("HerdName");
     m_herdingRange            = valuesDictionary.GetValue <float>("HerdingRange");
     m_autoNearbyCreaturesHelp = valuesDictionary.GetValue <bool>("AutoNearbyCreaturesHelp");
     m_componentCreature.ComponentHealth.Attacked += delegate(ComponentCreature attacker)
     {
         CallNearbyCreaturesHelp(attacker, 20f, 30f, isPersistent: false);
     };
     m_stateMachine.AddState("Inactive", null, delegate
     {
         if (m_subsystemTime.PeriodicGameTimeEvent(1.0, 1f * ((float)(GetHashCode() % 256) / 256f)))
         {
             Vector3?vector2 = FindHerdCenter();
             if (vector2.HasValue)
             {
                 float num = Vector3.Distance(vector2.Value, m_componentCreature.ComponentBody.Position);
                 if (num > 10f)
                 {
                     m_importanceLevel = 1f;
                 }
                 if (num > 12f)
                 {
                     m_importanceLevel = 3f;
                 }
                 if (num > 16f)
                 {
                     m_importanceLevel = 50f;
                 }
                 if (num > 20f)
                 {
                     m_importanceLevel = 250f;
                 }
             }
         }
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Herd");
         }
     }, null);
     m_stateMachine.AddState("Stuck", delegate
     {
         m_stateMachine.TransitionTo("Herd");
         if (m_random.Bool(0.5f))
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
             m_importanceLevel = 0f;
         }
     }, null, null);
     m_stateMachine.AddState("Herd", delegate
     {
         Vector3?vector = FindHerdCenter();
         if (vector.HasValue && Vector3.Distance(m_componentCreature.ComponentBody.Position, vector.Value) > 6f)
         {
             float speed = (m_importanceLevel > 10f) ? m_random.Float(0.9f, 1f) : m_random.Float(0.25f, 0.35f);
             int maxPathfindingPositions = (m_importanceLevel > 200f) ? 100 : 0;
             m_componentPathfinding.SetDestination(vector.Value, speed, 7f, maxPathfindingPositions, useRandomMovements: false, ignoreHeightDifference: true, raycastDestination: false, null);
         }
         else
         {
             m_importanceLevel = 0f;
         }
     }, delegate
     {
         m_componentCreature.ComponentLocomotion.LookOrder = m_look - m_componentCreature.ComponentLocomotion.LookAngles;
         if (m_componentPathfinding.IsStuck)
         {
             m_stateMachine.TransitionTo("Stuck");
         }
         if (!m_componentPathfinding.Destination.HasValue)
         {
             m_importanceLevel = 0f;
         }
         if (m_random.Float(0f, 1f) < 0.05f * m_dt)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false);
         }
         if (m_random.Float(0f, 1f) < 1.5f * m_dt)
         {
             m_look = new Vector2(MathUtils.DegToRad(45f) * m_random.Float(-1f, 1f), MathUtils.DegToRad(10f) * m_random.Float(-1f, 1f));
         }
     }, null);
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     base.Load(valuesDictionary);
     m_subsystemGameInfo      = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemCreatureSpawn = base.Project.FindSubsystem <SubsystemCreatureSpawn>(throwOnError: true);
 }