Exemplo n.º 1
0
        public static StringBuilder Get(MyStringId id)
        {
            StringBuilder result;

            if (!m_stringBuilders.TryGetValue(id, out result))
            {
                if (CheckMissingTexts)
                {
                    result = new StringBuilder("X_" + id.ToString());
                }
                else
                {
                    result = new StringBuilder(id.ToString());
                }
                //System.Diagnostics.Debug.Assert(false, String.Format("Key text \"{0}\" isn't translated. Should it be in CommonTexts.resx or where?", id.ToString()));
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }
            if (CheckMissingTexts)
            {
                StringBuilder resultMod = new StringBuilder();
                resultMod.Append("T_");
                result = resultMod.Append(result);
            }

            return(result);
        }
        internal static void GetMaterialSources(MyStringId id, out MyMaterialShaderInfo info)
        {
            if (!MaterialSources.TryGetValue(id, out info))
            {
                info = new MyMaterialShaderInfo();

                info.VertexShaderFilename = Path.Combine(MaterialsFolder, id.ToString(), "Vertex.hlsl");;
                info.VertexShaderFilepath = Path.Combine(MyShaders.ShadersPath, info.VertexShaderFilename);
                info.PixelShaderFilename  = Path.Combine(MaterialsFolder, id.ToString(), "Pixel.hlsl");
                info.PixelShaderFilepath  = Path.Combine(MyShaders.ShadersPath, info.PixelShaderFilename);

                MaterialSources[id] = info;
            }
        }
Exemplo n.º 3
0
        private void AddAssembly(MyModContext context, MyStringId myStringId, Assembly assembly)
        {
            if (Scripts.ContainsKey(myStringId))
            {
                MySandboxGame.Log.WriteLine(string.Format("Script already in list {0}", myStringId.ToString()));
                Debug.Fail(string.Format("Script already in list {0}", myStringId.ToString()));
                return;
            }
            HashSet <MyStringId> names;

            if (!ScriptsPerMod.TryGetValue(context, out names))
            {
                names = new HashSet <MyStringId>();
                ScriptsPerMod.Add(context, names);
            }

            names.Add(myStringId);

            Scripts.Add(myStringId, assembly);
            foreach (var type in assembly.GetTypes())
            {
                MyConsole.AddCommand(new MyCommandScript(type));
            }
            TryAddEntityScripts(context, assembly);
            AddStatScripts(assembly);
        }
Exemplo n.º 4
0
        private void AddAssembly(MyModContext context, MyStringId myStringId, Assembly assembly)
        {
#if XB1 // XB1_ALLINONEASSEMBLY
            System.Diagnostics.Debug.Assert(false, "XB1 TODO?");
#else // !XB1
            if (Scripts.ContainsKey(myStringId))
            {
                MySandboxGame.Log.WriteLine(string.Format("Script already in list {0}", myStringId.ToString()));
                Debug.Fail(string.Format("Script already in list {0}", myStringId.ToString()));
                return;
            }
            HashSet <MyStringId> names;
            if (!ScriptsPerMod.TryGetValue(context, out names))
            {
                names = new HashSet <MyStringId>();
                ScriptsPerMod.Add(context, names);
            }

            names.Add(myStringId);

            Scripts.Add(myStringId, assembly);
            foreach (var type in assembly.GetTypes())
            {
                MyConsole.AddCommand(new MyCommandScript(type));
            }
            TryAddEntityScripts(context, assembly);
            AddStatScripts(assembly);
#endif // !XB1
        }
Exemplo n.º 5
0
            private void GetControlStringIDs(MyKeys[] keys, out string[] allControls, out string[] mouseControls)
            {
                var           mouseButtons    = Enum.GetValues(typeof(MyMouseButtonsEnum)) as MyMouseButtonsEnum[];
                List <string> controlIDs      = new List <string>(keys.Length),
                              mouseControlIDs = new List <string>(mouseButtons.Length);

                foreach (MyKeys key in keys)
                {
                    MyStringId?id       = MyAPIGateway.Input.GetControl(key)?.GetGameControlEnum();
                    string     stringID = id?.ToString();

                    if (stringID != null && stringID.Length > 0)
                    {
                        controlIDs.Add(stringID);
                    }
                }

                foreach (MyMouseButtonsEnum key in mouseButtons)
                {
                    MyStringId?id       = MyAPIGateway.Input.GetControl(key)?.GetGameControlEnum();
                    string     stringID = id?.ToString();

                    if (stringID != null && stringID.Length > 0 && stringID != "FORWARD") // WTH is FORWARD in there?
                    {
                        mouseControlIDs.Add(stringID);
                    }
                }

                allControls   = controlIDs.ToArray();
                mouseControls = mouseControlIDs.ToArray();
            }
Exemplo n.º 6
0
 public MyEffectInstance CreateEffect(IMySourceVoice input, MyStringId effect, MySourceVoice[] cues = null, float? duration = null)
 {
     if(!m_effects.ContainsKey(effect))
     {
         Debug.Fail(string.Format("Effect not found: {0}", effect.ToString()));
         return null;
     }
     var instance = new MyEffectInstance(m_effects[effect], input, cues, duration, m_engine);
     m_activeEffects.Add(instance);
     return instance;
 }
Exemplo n.º 7
0
        public override MyObjectBuilder_GuiControlBase GetObjectBuilder()
        {
            var objectBuilder = (MyObjectBuilder_GuiControlLabel)base.GetObjectBuilder();

            objectBuilder.TextEnum  = m_textEnum.ToString();
            objectBuilder.TextScale = TextScale;
            objectBuilder.Text      = m_text;
            objectBuilder.Font      = Font;

            return(objectBuilder);
        }
Exemplo n.º 8
0
        public static string GetString(MyStringId id)
        {
            string result;
            if (!m_strings.TryGetValue(id, out result))
            {
                result = id.ToString();
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }

            return result;
        }
Exemplo n.º 9
0
        public static StringBuilder Get(MyStringId id)
        {
            StringBuilder result;
            if (!m_stringBuilders.TryGetValue(id, out result))
            {
                result = new StringBuilder(id.ToString());
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }

            return result;
        }
Exemplo n.º 10
0
        public MyEffectInstance CreateEffect(IMySourceVoice input, MyStringId effect, MySourceVoice[] cues = null, float?duration = null)
        {
            if (!m_effects.ContainsKey(effect))
            {
                Debug.Fail(string.Format("Effect not found: {0}", effect.ToString()));
                return(null);
            }
            var instance = new MyEffectInstance(m_effects[effect], input, cues, duration, m_engine);

            m_activeEffects.Add(instance);
            return(instance);
        }
Exemplo n.º 11
0
        public override MyObjectBuilder_GuiControlBase GetObjectBuilder()
        {
            var objectBuilder = (MyObjectBuilder_GuiControlImageButton)base.GetObjectBuilder();

            objectBuilder.Text          = Text;
            objectBuilder.TextEnum      = m_textEnum.ToString();
            objectBuilder.TextScale     = TextScale;
            objectBuilder.TextAlignment = (int)TextAlignment;
            objectBuilder.DrawCrossTextureWhenDisabled = DrawCrossTextureWhenDisabled;

            return(objectBuilder);
        }
        public override MyObjectBuilder_DefinitionBase GetObjectBuilder()
        {
            var ob = base.GetObjectBuilder() as MyObjectBuilder_ScenarioDefinition;

            ob.AsteroidClusters.Enabled        = AsteroidClustersEnabled;
            ob.AsteroidClusters.Offset         = AsteroidClustersOffset;
            ob.AsteroidClusters.CentralCluster = CentralClusterEnabled;
            ob.DefaultEnvironment     = DefaultEnvironment;
            ob.CreativeDefaultToolbar = CreativeDefaultToolbar;
            ob.SurvivalDefaultToolbar = SurvivalDefaultToolbar;
            ob.MainCharacterModel     = MainCharacterModel.ToString();
            ob.GameDate = GameDate.Ticks;

            if (PossiblePlayerStarts != null && PossiblePlayerStarts.Length > 0)
            {
                ob.PossibleStartingStates = new MyObjectBuilder_WorldGeneratorPlayerStartingState[PossiblePlayerStarts.Length];
                for (int i = 0; i < PossiblePlayerStarts.Length; ++i)
                {
                    ob.PossibleStartingStates[i] = PossiblePlayerStarts[i].GetObjectBuilder();
                }
            }

            if (WorldGeneratorOperations != null && WorldGeneratorOperations.Length > 0)
            {
                ob.WorldGeneratorOperations = new MyObjectBuilder_WorldGeneratorOperation[WorldGeneratorOperations.Length];
                for (int i = 0; i < WorldGeneratorOperations.Length; ++i)
                {
                    ob.WorldGeneratorOperations[i] = WorldGeneratorOperations[i].GetObjectBuilder();
                }
            }

            if (CreativeModeWeapons != null && CreativeModeWeapons.Length > 0)
            {
                ob.CreativeModeWeapons = new string[CreativeModeWeapons.Length];
                for (int i = 0; i < CreativeModeWeapons.Length; ++i)
                {
                    ob.CreativeModeWeapons[i] = CreativeModeWeapons[i].ToString();
                }
            }

            if (SurvivalModeWeapons != null && SurvivalModeWeapons.Length > 0)
            {
                ob.SurvivalModeWeapons = new string[SurvivalModeWeapons.Length];
                for (int i = 0; i < SurvivalModeWeapons.Length; ++i)
                {
                    ob.SurvivalModeWeapons[i] = SurvivalModeWeapons[i].ToString();
                }
            }

            return(ob);
        }
Exemplo n.º 13
0
        public static string GetString(MyStringId id)
        {
            string result;

            if (!m_strings.TryGetValue(id, out result))
            {
                if (CheckMissingTexts)
                {
                    result = "X_" + id.ToString();
                }
                else
                {
                    result = id.ToString();
                }
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }
            if (CheckMissingTexts)
            {
                result = "T_" + result;
            }

            return(result);
        }
Exemplo n.º 14
0
 private void AddAssembly(MyStringId myStringId, Assembly assembly)
 {
     if (Scripts.ContainsKey(myStringId))
     {
         MySandboxGame.Log.WriteLine(string.Format("Script already in list {0}", myStringId.ToString()));
         Debug.Fail(string.Format("Script already in list {0}", myStringId.ToString()));
         return;
     }
     Scripts.Add(myStringId, assembly);
     foreach (var type in assembly.GetTypes())
     {
         MyConsole.AddCommand(new MyCommandScript(type));
     }
     TryAddEntityScripts(assembly);
 }
Exemplo n.º 15
0
        static void PrefetchPassSources(MyStringId id)
        {
            if (!MaterialPassSources.ContainsKey(id))
            {
                var info = new MyMaterialPassInfo();

                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShaders.ShadersContentPath, "passes", id.ToString()), "vertex_stage.hlsl"))
                {
                    info.VertexStageTemplate = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShaders.ShadersContentPath, "passes", id.ToString()), "pixel_stage.hlsl"))
                {
                    info.PixelStageTemplate = new StreamReader(stream).ReadToEnd();
                }

                MaterialPassSources[id] = info;
            }
        }
Exemplo n.º 16
0
        static void PrefetchMaterialSources(MyStringId id)
        {
            if(!MaterialSources.ContainsKey(id))
            {
                var info = new MyMaterialShaderInfo();

                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShaders.ShadersContentPath, "materials", id.ToString()), "declarations.h"))
                {
                    info.Declarations = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShaders.ShadersContentPath, "materials", id.ToString()), "vertex.h"))
                {
                    info.VertexShaderSource = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShaders.ShadersContentPath, "materials", id.ToString()), "pixel.h"))
                {
                    info.PixelShaderSource = new StreamReader(stream).ReadToEnd();
                }

                MaterialSources[id] = info;
            }
        }
Exemplo n.º 17
0
        private void AddAssembly(MyModContext context, MyStringId myStringId, Assembly assembly)
        {
            if (Scripts.ContainsKey(myStringId))
            {
                MySandboxGame.Log.WriteLine(string.Format("Script already in list {0}", myStringId.ToString()));
                Debug.Fail(string.Format("Script already in list {0}", myStringId.ToString()));
                return;
            }
            HashSet<MyStringId> names;
            if (!ScriptsPerMod.TryGetValue(context, out names))
            {
                names = new HashSet<MyStringId>();
                ScriptsPerMod.Add(context, names);
            }

            names.Add(myStringId);

            Scripts.Add(myStringId, assembly);
            foreach (var type in assembly.GetTypes())
            {
                MyConsole.AddCommand(new MyCommandScript(type));
            }
            TryAddEntityScripts(context, assembly);
            AddStatScripts(assembly);
        }
Exemplo n.º 18
0
        internal static void GetMaterialSources(MyStringId id, out MyMaterialShaderInfo info)
        {
            if (!MaterialSources.TryGetValue(id, out info))
            {
                info = new MyMaterialShaderInfo();

                info.VertexShaderFilename = Path.Combine(MaterialsFolder, id.ToString(), "Vertex.hlsl"); ;
                info.VertexShaderFilepath = Path.Combine(MyShaders.ShadersPath, info.VertexShaderFilename);
                info.PixelShaderFilename = Path.Combine(MaterialsFolder, id.ToString(), "Pixel.hlsl");
                info.PixelShaderFilepath = Path.Combine(MyShaders.ShadersPath, info.PixelShaderFilename);

                MaterialSources[id] = info;
            }
        }
Exemplo n.º 19
0
        private static void GenerateCombo(MyStringId materialId, MyStringId passId, MyShaderUnifiedFlags additionalFlags, MyShaderUnifiedFlags unsupportedFlags, MatCombos.Combo[] comboList1, MatCombos.Combo[] comboList2,
                                          float progress, OnShaderCacheProgressDelegate onShaderCacheProgress)
        {
            if (comboList1 == null || comboList1.Length == 0)
            {
                comboList1 = new[] { new MatCombos.Combo() }
            }
            ;
            if (comboList2 == null || comboList2.Length == 0)
            {
                comboList2 = new[] { new MatCombos.Combo() }
            }
            ;
            for (int k = 0; k < comboList1.Length; k++)
            {
                MyVertexInputComponentType[] vertexInput1 = comboList1[k].VertexInput;
                if (vertexInput1 == null)
                {
                    vertexInput1 = new MyVertexInputComponentType[0];
                }
                int[] vertexInputOrder1 = comboList1[k].VertexInputOrder;
                if (vertexInputOrder1 == null || vertexInputOrder1.Length != vertexInput1.Length)
                {
                    vertexInputOrder1 = new int[vertexInput1.Length];
                    for (int x = 0; x < vertexInput1.Length; x++)
                    {
                        vertexInputOrder1[x] = x;
                    }
                }
                MyShaderUnifiedFlags flags1 = ParseFlags(comboList1[k].FlagNames);
                if ((flags1 & unsupportedFlags) != 0)
                {
                    continue;
                }

                // go through all combinations of shader flags
                for (int l = 0; l < comboList2.Length; l++)
                {
                    MyVertexInputComponentType[] vertexInput2 = comboList2[l].VertexInput;
                    if (vertexInput2 == null)
                    {
                        vertexInput2 = new MyVertexInputComponentType[0];
                    }
                    int[] vertexInputOrder2 = comboList2[l].VertexInputOrder;
                    if (vertexInputOrder2 == null || vertexInputOrder2.Length != vertexInput2.Length)
                    {
                        vertexInputOrder2 = new int[vertexInput2.Length];
                        for (int x = 0; x < vertexInput2.Length; x++)
                        {
                            vertexInputOrder2[x] = x;
                        }
                    }
                    var vertexInput      = vertexInput1.Concat(vertexInput2).ToArray();
                    var vertexInputOrder = vertexInputOrder1.Concat(vertexInputOrder2).ToArray();
                    Array.Sort(vertexInputOrder, vertexInput, m_intComparer);
                    VertexLayoutId vertexLayout;
                    if (vertexInput.Length != 0)
                    {
                        vertexLayout = MyVertexLayouts.GetLayout(vertexInput);
                    }
                    else
                    {
                        vertexLayout = MyVertexLayouts.Empty;
                    }

                    // return errors & skipped info
                    string vsSource;
                    string psSource;
                    MyMaterialShaders.Preprocess(materialId, passId, vertexLayout.Info, out vsSource, out psSource);

                    MyShaderUnifiedFlags flags = ParseFlags(comboList2[l].FlagNames) | flags1 | additionalFlags;
                    if ((flags & unsupportedFlags) != 0)
                    {
                        continue;
                    }

                    var macros             = MyMaterialShaders.GenerateMaterialShaderFlagMacros(flags);
                    var descriptor         = String.Format("{0}_{1}", materialId.ToString(), passId.ToString());
                    var vertexLayoutString = vertexLayout.Info.Components.GetString();

                    PreCompile(vsSource, macros, MyShadersDefines.Profiles.vs_5_0, descriptor, vertexLayoutString, progress, onShaderCacheProgress);
                    PreCompile(psSource, macros, MyShadersDefines.Profiles.ps_5_0, descriptor, vertexLayoutString, progress, onShaderCacheProgress);
                    macros.Add(m_globalMacros[0]);
                    for (int m = 0; m < m_globalMacros.Length; m++)
                    {
                        macros[macros.Count - 1] = m_globalMacros[m];
                        //PreCompile(vsSource, macros, MyShadersDefines.Profiles.vs_5_0, descriptor, vertexLayoutString, progress, onShaderCacheProgress);
                        PreCompile(psSource, macros, MyShadersDefines.Profiles.ps_5_0, descriptor, vertexLayoutString, progress, onShaderCacheProgress);
                    }
                }
            }
        }
Exemplo n.º 20
0
        private MyControl FindNotAssignedGameControl(MyStringId controlId, MyGuiInputDeviceEnum deviceType)
        {
            MyControl control;
            if (!m_gameControlsList.TryGetValue(controlId, out control))
                throw new Exception("Game control \"" + controlId.ToString() + "\" not found in control list.");

            if (control.IsControlAssigned(deviceType))
                throw new Exception("Game control \"" + controlId.ToString() + "\" is already assigned.");

            return control;
        }
Exemplo n.º 21
0
 public override string ToString()
 {
     return(string.Format(m_cue.ToString()));
 }
 public override string ToString()
 {
     return(Name.ToString());
 }
        public bool DisableInstance(int sectorInstanceId, MyStringId subtypeId)
        {
            MyModelInstanceData instanceData = null;
            m_instanceParts.TryGetValue(subtypeId, out instanceData);
            Debug.Assert(instanceData != null, "Could not find instance data in a sector for subtype " + subtypeId.ToString());
            if (instanceData == null) return false;

            Debug.Assert(instanceData.InstanceData.Count > sectorInstanceId, "Disabling invalid instance in environment item sector!");
            if (instanceData.InstanceData.Count <= sectorInstanceId) return false;

            var data = instanceData.InstanceData[sectorInstanceId];
            data.LocalMatrix = Matrix.Zero;
            instanceData.InstanceData[sectorInstanceId] = data;

            return true;
        }
Exemplo n.º 24
0
        public override MyObjectBuilder_DefinitionBase GetObjectBuilder()
        {
            var ob = base.GetObjectBuilder() as MyObjectBuilder_ScenarioDefinition;

            ob.AsteroidClusters.Enabled        = AsteroidClustersEnabled;
            ob.AsteroidClusters.Offset         = AsteroidClustersOffset;
            ob.AsteroidClusters.CentralCluster = CentralClusterEnabled;
            ob.DefaultToolbar     = DefaultToolbar;
            ob.MainCharacterModel = MainCharacterModel.ToString();

            if (PossiblePlayerStarts != null && PossiblePlayerStarts.Length > 0)
            {
                ob.PossibleStartingStates = new MyObjectBuilder_WorldGeneratorPlayerStartingState[PossiblePlayerStarts.Length];
                for (int i = 0; i < PossiblePlayerStarts.Length; ++i)
                {
                    ob.PossibleStartingStates[i] = PossiblePlayerStarts[i].GetObjectBuilder();
                }
            }

            if (WorldGeneratorOperations != null && WorldGeneratorOperations.Length > 0)
            {
                ob.WorldGeneratorOperations = new MyObjectBuilder_WorldGeneratorOperation[WorldGeneratorOperations.Length];
                for (int i = 0; i < WorldGeneratorOperations.Length; ++i)
                {
                    ob.WorldGeneratorOperations[i] = WorldGeneratorOperations[i].GetObjectBuilder();
                }
            }

            if (CreativeModeWeapons != null && CreativeModeWeapons.Length > 0)
            {
                ob.CreativeModeWeapons = new string[CreativeModeWeapons.Length];
                for (int i = 0; i < CreativeModeWeapons.Length; ++i)
                {
                    ob.CreativeModeWeapons[i] = CreativeModeWeapons[i].ToString();
                }
            }

            if (SurvivalModeWeapons != null && SurvivalModeWeapons.Length > 0)
            {
                ob.SurvivalModeWeapons = new string[SurvivalModeWeapons.Length];
                for (int i = 0; i < SurvivalModeWeapons.Length; ++i)
                {
                    ob.SurvivalModeWeapons[i] = SurvivalModeWeapons[i].ToString();
                }
            }

            if (MyFakes.ENABLE_BATTLE_SYSTEM && Battle != null)
            {
                ob.Battle = new Sandbox.Common.ObjectBuilders.Definitions.MyObjectBuilder_ScenarioDefinition.MyOBBattleSettings();

                if (Battle.AttackerSlots != null && Battle.AttackerSlots.Length > 0)
                {
                    ob.Battle.AttackerSlots = new SerializableBoundingBoxD[Battle.AttackerSlots.Length];
                    for (int i = 0; i < Battle.AttackerSlots.Length; ++i)
                    {
                        ob.Battle.AttackerSlots[i] = Battle.AttackerSlots[i];
                    }
                }
            }

            return(ob);
        }
Exemplo n.º 25
0
 public override void DebugDraw(Vector2 position, Vector2 size, List <MyBehaviorTreeNodeMemory> nodesMemory)
 {
     VRageRender.MyRenderProxy.DebugDrawText2D(position, "A:" + m_actionName.ToString(), nodesMemory[MemoryIndex].NodeStateColor, DEBUG_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
 }
Exemplo n.º 26
0
        private void AddAssembly(MyStringId myStringId, Assembly assembly)
        {
            if (Scripts.ContainsKey(myStringId))
            {
                MySandboxGame.Log.WriteLine(string.Format("Script already in list {0}", myStringId.ToString()));
                Debug.Fail(string.Format("Script already in list {0}", myStringId.ToString()));
                return;
            }
            Scripts.Add(myStringId, assembly);
            foreach (var type in assembly.GetTypes())
            {
                MyConsole.AddCommand(new MyCommandScript(type));
            }
            TryAddEntityScripts(assembly);
			AddStatScripts(assembly);
        }
Exemplo n.º 27
0
        public static StringBuilder Get(MyStringId id)
        {
            StringBuilder result;
            if (!m_stringBuilders.TryGetValue(id, out result))
            {
                result = new StringBuilder(id.ToString());
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }

            return result;
        }
Exemplo n.º 28
0
        public static StringBuilder Get(MyStringId id)
        {
            StringBuilder result;
            if (!m_stringBuilders.TryGetValue(id, out result))
            {
                if (CheckMissingTexts)
                    result = new StringBuilder("X_"+id.ToString());
                else
                    result = new StringBuilder(id.ToString());
                //System.Diagnostics.Debug.Assert(false, String.Format("Key text \"{0}\" isn't translated. Should it be in CommonTexts.resx or where?", id.ToString()));
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }
            if (CheckMissingTexts)
            {
                StringBuilder resultMod = new StringBuilder();
                resultMod.Append("T_");
                result = resultMod.Append(result);
            }

            return result;
        }
Exemplo n.º 29
0
        public static string GetString(MyStringId id)
        {
            string result;
            if (!m_strings.TryGetValue(id, out result))
            {
                if (CheckMissingTexts)
                    result = "X_" + id.ToString();
                else
                    result = id.ToString();
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }
            if (CheckMissingTexts)
                result = "T_" + result;

            return result;
        }
Exemplo n.º 30
0
        public bool DisableInstance(int sectorInstanceId, MyStringId subtypeId)
        {
            MyModelInstanceData instanceData = null;

            m_instanceParts.TryGetValue(subtypeId, out instanceData);
            Debug.Assert(instanceData != null, "Could not find instance data in a sector for subtype " + subtypeId.ToString());
            if (instanceData == null)
            {
                return(false);
            }

            Debug.Assert(instanceData.InstanceData.Count > sectorInstanceId, "Disabling invalid instance in environment item sector!");
            if (instanceData.InstanceData.Count <= sectorInstanceId)
            {
                return(false);
            }

            var data = instanceData.InstanceData[sectorInstanceId];

            data.LocalMatrix = Matrix.Zero;
            instanceData.InstanceData[sectorInstanceId] = data;

            return(true);
        }
Exemplo n.º 31
0
        static void PrefetchMaterialSources(MyStringId id)
        {
            if (!MaterialSources.ContainsKey(id))
            {
                var info = new MyMaterialShaderInfo();

                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "materials", id.ToString()), "declarations.h"))
                {
                    info.Declarations = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "materials", id.ToString()), "vertex.h"))
                {
                    info.VertexShaderSource = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "materials", id.ToString()), "pixel.h"))
                {
                    info.PixelShaderSource = new StreamReader(stream).ReadToEnd();
                }

                MaterialSources[id] = info;
            }
        }
Exemplo n.º 32
0
        static void PrefetchPassSources(MyStringId id)
        {
            if (!MaterialPassSources.ContainsKey(id))
            {
                var info = new MyMaterialPassInfo();

                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "passes", id.ToString()), "vertex_stage.hlsl"))
                {
                    info.VertexStageTemplate = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "passes", id.ToString()), "pixel_stage.hlsl"))
                {
                    info.PixelStageTemplate = new StreamReader(stream).ReadToEnd();
                }

                MaterialPassSources[id] = info;
            }
        }
Exemplo n.º 33
0
        internal static TexId GetTexture(MyStringId nameId, string contentPath, MyTextureEnum type, bool waitTillLoaded = false)
        {
            if(nameId == MyStringId.NullOrEmpty)
            {
                switch (type)
                {
                    case MyTextureEnum.NORMALMAP_GLOSS:
                        return MissingNormalGlossTexId;
                    case MyTextureEnum.EXTENSIONS:
                        return MissingExtensionTexId;
                    case MyTextureEnum.ALPHAMASK:
                        return MissingAlphamaskTexId;
                    case MyTextureEnum.CUBEMAP:
                        return MissingCubeTexId;
                    case MyTextureEnum.COLOR_METAL:
                        return MyRender11.DebugMode ? DebugPinkTexId : ZeroTexId;
                }
                return ZeroTexId;
            }

            var nameKey = nameId;
            if (!NameIndex.ContainsKey(nameKey))
            {
                //Debug.Assert(type != MyTextureEnum.SYSTEM);

                var texId = NameIndex[nameKey] = new TexId{ Index = Textures.Allocate() };
                InitState(texId, MyTextureState.WAITING);

                Textures.Data[texId.Index] = new MyTextureInfo
                {
                    Name = nameId.ToString(),
                    ContentPath = contentPath,
                    Type = type,
                    OwnsData = true
                };
                MyArrayHelpers.Reserve(ref Views, texId.Index + 1);
                Views[texId.Index] = null;

                if (waitTillLoaded)
                {
                    LoadTexture(texId);
                    MoveState(texId, MyTextureState.WAITING, MyTextureState.LOADED);
                }
            }
            return NameIndex[nameKey];
        }
Exemplo n.º 34
0
        private void AddAssembly(MyModContext context, MyStringId myStringId, Assembly assembly)
        {
#if XB1 // XB1_ALLINONEASSEMBLY
            System.Diagnostics.Debug.Assert(false, "XB1 TODO?");
#else // !XB1
            if (Scripts.ContainsKey(myStringId))
            {
                MySandboxGame.Log.WriteLine(string.Format("Script already in list {0}", myStringId.ToString()));
                Debug.Fail(string.Format("Script already in list {0}", myStringId.ToString()));
                return;
            }
            HashSet<MyStringId> names;
            if (!ScriptsPerMod.TryGetValue(context, out names))
            {
                names = new HashSet<MyStringId>();
                ScriptsPerMod.Add(context, names);
            }

            names.Add(myStringId);

            Scripts.Add(myStringId, assembly);
            foreach (var type in assembly.GetTypes())
            {
                MyConsole.AddCommand(new MyCommandScript(type));
            }
            TryAddEntityScripts(context, assembly);
            AddStatScripts(assembly);
#endif // !XB1
        }
Exemplo n.º 35
0
        // Implementation of ToString - for better debugging in VS. :)
        public override string ToString()
        {
            if (m_operation == MyOperation.AlwaysTrue)
            {
                return("true");
            }
            if (m_operation == MyOperation.AlwaysFalse)
            {
                return("false");
            }

            StringBuilder strBuilder = new StringBuilder(128);

            // fetch values
            if (m_leftSideStorage != MyStringId.NullOrEmpty)
            {
                strBuilder.Append(m_leftSideStorage.ToString());
            }
            else
            {
                strBuilder.Append(m_leftSideValue);
            }

            strBuilder.Append(" ");
            switch (m_operation)
            {
            case MyOperation.Less:
                strBuilder.Append("<");
                break;

            case MyOperation.LessOrEqual:
                strBuilder.Append("<=");
                break;

            case MyOperation.Equal:
                strBuilder.Append("==");
                break;

            case MyOperation.GreaterOrEqual:
                strBuilder.Append(">=");
                break;

            case MyOperation.Greater:
                strBuilder.Append(">");
                break;

            case MyOperation.NotEqual:
                strBuilder.Append("!=");
                break;

            default:
                strBuilder.Append("???");
                break;
            }
            strBuilder.Append(" ");

            if (m_rightSideStorage != MyStringId.NullOrEmpty)
            {
                strBuilder.Append(m_rightSideStorage.ToString());
            }
            else
            {
                strBuilder.Append(m_rightSideValue);
            }
            return(strBuilder.ToString());
        }
Exemplo n.º 36
0
        public static string GetString(MyStringId id)
        {
            string result;
            if (!m_strings.TryGetValue(id, out result))
            {
                result = id.ToString();
                //Debug.Fail(string.Format("Missing text for localization. Id: {0}", id.ToString()));
            }

            return result;
        }