Beispiel #1
0
            public unsafe void Get(int index, out Color color, out MyStringHash skinSubtypeId, out MyStringHash edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
            {
                uint *numPtr  = &this.m_data.FixedElementField;
                byte *numPtr2 = &this.m_data2.FixedElementField;
                int * numPtr3 = &this.m_edgeModels.FixedElementField;
                int * numPtr4 = &this.m_skinSubtypes.FixedElementField;

                color         = new Color(numPtr[index]);
                normal0       = (Base27Directions.Direction)color.A;
                normal1       = (Base27Directions.Direction)numPtr2[index];
                edgeModel     = MyStringHash.TryGet(numPtr3[index]);
                skinSubtypeId = MyStringHash.TryGet(numPtr4[index]);
                fixed(int *numRef4 = null)
                {
                    fixed(int *numRef3 = null)
                    {
                        fixed(byte *numRef2 = null)
                        {
                            fixed(uint *numRef = null)
                            {
                                return;
                            }
                        }
                    }
                }
            }
Beispiel #2
0
        public static MyCueId GetCueId(this IMyAudio self, string cueName)
        {
            MyStringHash hash;

            if (self == null || !MyStringHash.TryGet(cueName, out hash))
            {
                hash = MyStringHash.NullOrEmpty;
            }
            return(new MyCueId(hash));
        }
Beispiel #3
0
        void cuesCombo_OnSelect()
        {
            m_currentCueSelectedItem = (int)m_cuesCombo.GetSelectedKey();
            var cue = new MyCueId(MyStringHash.TryGet(m_cuesCombo.GetSelectedValue().ToString()));

            m_currentCue = MyAudio.Static.GetCue(cue);

            UpdateCueValues();
            //RecreateControls(false);
        }
Beispiel #4
0
        public bool TryGetBehaviorTreeByName(string name, out MyBehaviorTree behaviorTree)
        {
            MyStringHash hash;

            MyStringHash.TryGet(name, out hash);
            if ((hash == MyStringHash.NullOrEmpty) || !this.m_BTDataByName.ContainsKey(hash))
            {
                behaviorTree = null;
                return(false);
            }
            behaviorTree = this.m_BTDataByName[hash].BehaviorTree;
            return(behaviorTree != null);
        }
Beispiel #5
0
 public void Get(int index, out Color color, out MyStringHash edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
 {
     fixed(uint *i = m_data)
     fixed(byte *d    = m_data2)
     fixed(int *edges = m_edgeModels)
     {
         color     = new Color(i[index]);
         normal0   = (Base27Directions.Direction)color.A;
         normal1   = (Base27Directions.Direction)d[index];
         edgeModel = MyStringHash.TryGet(edges[index]);
         Debug.Assert(edges[index] == 0 || edgeModel != MyStringHash.NullOrEmpty);
     }
 }
        public bool AssignBotToBehaviorTree(string behaviorName, IMyBot bot)
        {
            var treeId = MyStringHash.TryGet(behaviorName);

            Debug.Assert(m_BTDataByName.ContainsKey(treeId), "The given tree does not exist in the collection.");
            if (treeId == MyStringHash.NullOrEmpty || !m_BTDataByName.ContainsKey(treeId))
            {
                return(false);
            }
            else
            {
                return(AssignBotToBehaviorTree(m_BTDataByName[treeId].BehaviorTree, bot));
            }
        }
        public bool TryGetBehaviorTreeByName(string name, out MyBehaviorTree behaviorTree)
        {
            MyStringHash stringId;

            MyStringHash.TryGet(name, out stringId);
            if (stringId != MyStringHash.NullOrEmpty && m_BTDataByName.ContainsKey(stringId))
            {
                behaviorTree = m_BTDataByName[stringId].BehaviorTree;
                return(behaviorTree != null);
            }
            else
            {
                Debug.Fail("Could not find a behavior tree with provided name: " + name);
                behaviorTree = null;
                return(false);
            }
        }
Beispiel #8
0
        void effects_ItemSelected()
        {
            foreach (var box in m_cues)
            {
                Controls.Remove(box);
            }
            m_cues.Clear();
            var eff = MyStringHash.TryGet(m_effects.GetSelectedValue().ToString());
            MyAudioEffectDefinition def;

            if (MyDefinitionManager.Static.TryGetDefinition <MyAudioEffectDefinition>(new MyDefinitionId(typeof(MyObjectBuilder_AudioEffectDefinition), eff), out def))
            {
                for (int i = 0; i < def.Effect.SoundsEffects.Count - 1; i++)
                {
                    var combo = AddCombo();
                    UdpateCuesCombo(combo);
                    m_cues.Add(combo);
                }
            }
        }
Beispiel #9
0
        void OnPlaySelected(MyGuiControlButton button)
        {
            if ((m_sound != null) && (m_sound.IsPlaying))
            {
                m_sound.Stop(true);
            }
            var cue = new MyCueId(MyStringHash.TryGet(m_cuesCombo.GetSelectedValue().ToString()));

            m_sound = MyAudio.Static.PlaySound(cue);
            var effect = MyStringHash.TryGet(m_effects.GetSelectedValue().ToString());

            if (effect != MyStringHash.NullOrEmpty)
            {
                foreach (var box in m_cues)
                {
                    var effCue = new MyCueId(MyStringHash.TryGet(box.GetSelectedValue().ToString()));
                    m_cueCache.Add(effCue);
                }
                var eff = MyAudio.Static.ApplyEffect(m_sound, effect, m_cueCache.ToArray());
                m_sound = eff.OutputSound;
                m_cueCache.Clear();
            }
        }
Beispiel #10
0
        public bool AssignBotToBehaviorTree(string behaviorName, IMyBot bot)
        {
            MyStringHash key = MyStringHash.TryGet(behaviorName);

            return((key != MyStringHash.NullOrEmpty) && (this.m_BTDataByName.ContainsKey(key) && this.AssignBotToBehaviorTree(this.m_BTDataByName[key].BehaviorTree, bot)));
        }
Beispiel #11
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyTextPanel>())
            {
                return;
            }
            base.CreateTerminalControls();
            var publicTitleField = new MyTerminalControlTextbox <MyTextPanel>("Title", MySpaceTexts.BlockPropertyTitle_TextPanelPublicTitle, MySpaceTexts.Blank);

            publicTitleField.Getter = (x) => x.PublicTitle;
            publicTitleField.Setter = (x, v) => x.SendChangeTitleMessage(v, true);
            publicTitleField.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(publicTitleField);

            var showPublicButton = new MyTerminalControlButton <MyTextPanel>("ShowTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowPublicTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, true));

            showPublicButton.Enabled = (x) => !x.IsOpen;
            showPublicButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(showPublicButton);

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>());

            var showTextOnScreen = new MyTerminalControlOnOffSwitch <MyTextPanel>("ShowTextOnScreen", MySpaceTexts.BlockPropertyTitle_ShowTextOnScreen, MySpaceTexts.Blank);

            showTextOnScreen.Getter = (x) => x.ShowTextFlag != ShowTextOnScreenFlag.NONE;
            showTextOnScreen.Setter = (x, y) => x.ShowTextFlag = y ? ShowTextOnScreenFlag.PUBLIC : ShowTextOnScreenFlag.NONE;

            MyTerminalControlFactory.AddControl(showTextOnScreen);


            var comboFont = new MyTerminalControlCombobox <MyTextPanel>("Font", MySpaceTexts.BlockPropertyTitle_Font, MySpaceTexts.Blank);

            comboFont.ComboBoxContent = (x) => FillFontComboBoxContent(x);
            comboFont.Getter          = (x) => (long)x.Font.SubtypeId;
            comboFont.Setter          = (x, y) => x.Font = new MyDefinitionId(typeof(MyObjectBuilder_FontDefinition), MyStringHash.TryGet((int)y));
            MyTerminalControlFactory.AddControl(comboFont);
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>());

            var changeFontSlider = new MyTerminalControlSlider <MyTextPanel>("FontSize", MySpaceTexts.BlockPropertyTitle_LCDScreenTextSize, MySpaceTexts.Blank);

            changeFontSlider.SetLimits(0.1f, 10.0f);
            changeFontSlider.DefaultValue = 1.0f;
            changeFontSlider.Getter       = (x) => x.FontSize;
            changeFontSlider.Setter       = (x, v) => x.FontSize = v;
            changeFontSlider.Writer       = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.FontSize, NUM_DECIMALS));
            changeFontSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeFontSlider);

            var fontColor = new MyTerminalControlColor <MyTextPanel>("FontColor", MySpaceTexts.BlockPropertyTitle_FontColor);

            fontColor.Getter = (x) => x.FontColor;
            fontColor.Setter = (x, v) => x.FontColor = v;
            MyTerminalControlFactory.AddControl(fontColor);

            var backgroundColor = new MyTerminalControlColor <MyTextPanel>("BackgroundColor", MySpaceTexts.BlockPropertyTitle_BackgroundColor);

            backgroundColor.Getter = (x) => x.BackgroundColor;
            backgroundColor.Setter = (x, v) => x.BackgroundColor = v;
            MyTerminalControlFactory.AddControl(backgroundColor);

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>());

            var imagesList = new MyTerminalControlListbox <MyTextPanel>("ImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenDefinitionsTextures, MySpaceTexts.Blank, true);

            imagesList.ListContent  = (x, list1, list2) => x.FillListContent(list1, list2);
            imagesList.ItemSelected = (x, y) => x.SelectImageToDraw(y);
            MyTerminalControlFactory.AddControl(imagesList);

            var addToSelectionButton = new MyTerminalControlButton <MyTextPanel>("SelectTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectTextures, MySpaceTexts.Blank, (x) => x.AddImagesToSelection());

            MyTerminalControlFactory.AddControl(addToSelectionButton);

            var changeIntervalSlider = new MyTerminalControlSlider <MyTextPanel>("ChangeIntervalSlider", MySpaceTexts.BlockPropertyTitle_LCDScreenRefreshInterval, MySpaceTexts.Blank);

            changeIntervalSlider.SetLimits(0, 30.0f);
            changeIntervalSlider.DefaultValue = 0;
            changeIntervalSlider.Getter       = (x) => x.ChangeInterval;
            changeIntervalSlider.Setter       = (x, v) => x.ChangeInterval = v;
            changeIntervalSlider.Writer       = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.ChangeInterval, NUM_DECIMALS)).Append(" s");
            changeIntervalSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeIntervalSlider);

            var selectedImagesList = new MyTerminalControlListbox <MyTextPanel>("SelectedImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectedTextures, MySpaceTexts.Blank, true);

            selectedImagesList.ListContent  = (x, list1, list2) => x.FillSelectedListContent(list1, list2);
            selectedImagesList.ItemSelected = (x, y) => x.SelectImage(y);
            MyTerminalControlFactory.AddControl(selectedImagesList);

            var removeSelectedButton = new MyTerminalControlButton <MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection());

            MyTerminalControlFactory.AddControl(removeSelectedButton);
        }