// Rebuild bone mask array.
 private void RebuildBoneMask()
 {
     if (CurrentUpdateData.CharacterBones == null)
     {
         return;
     }
     BoneMask = new bool[CurrentUpdateData.CharacterBones.Length];
     if (BoneMaskStrIds.Count == 0) // no mask => all bones by default.
     {
         for (int i = 0; i < CurrentUpdateData.CharacterBones.Length; i++)
         {
             BoneMask[i] = true;
         }
     }
     else // mask defined => affect only bones named in BoneMaskStrIds
     {
         for (int i = 0; i < CurrentUpdateData.CharacterBones.Length; i++)
         {
             MyStringId charBoneStrId = MyStringId.TryGet(CurrentUpdateData.CharacterBones[i].Name);
             if (charBoneStrId != MyStringId.NullOrEmpty && BoneMaskStrIds.Contains(charBoneStrId))
             {
                 BoneMask[i] = true;
             }
         }
     }
 }
Exemple #2
0
        private string GetTextForState(FurnaceState state)
        {
            string str;

            switch (state)
            {
            case FurnaceState.Waiting:
                // we found replacement string in MyTexts.
                str = VRage.MyTexts.Get(MyStringId.TryGet("FurnaceStateWaiting")).ToString();
                str = str.Replace("\\n", "\n");
                return(str);

            //return @"      Drop\n     unwanted\n  vehicles and\n   large items\n  into furnace";
            case FurnaceState.LoadedUp:
                // we found replacement string in MyTexts.
                str = VRage.MyTexts.Get(MyStringId.TryGet("FurnaceStateLoadedUp")).ToString();
                str = str.Replace("\\n", "\n");
                return(str);

            //return @"\n   Close doors\n    to activate\n      furnace";
            case FurnaceState.Working:
                // we found replacement string in MyTexts.
                str = VRage.MyTexts.Get(MyStringId.TryGet("FurnaceStateWorking")).ToString();
                str = str.Replace("\\n", "\n");
                return(str);

            //return @"  ! Caution !\n   Furnace is\n      active\n\n      Extreme\n  temperatures";
            case FurnaceState.Off:
                throw new ArgumentException("Furnace should never change to state: " + state);

            default:
                throw new ArgumentException("Uncoped for state: " + state);
            }
        }
        internal static Action AddGps(string name, string description, Vector3D coords)
        {
            MyStringId nameID;
            MyStringId descriptionID;

            string _name        = name;
            string _description = description;

            if (MyStringId.TryGet(name, out nameID))
            {
                _name = VRage.MyTexts.Get(nameID).ToString();
//                ModLog.Info("Found GPS localization for " + name+ " as:" + _name);
            }
            else
            {
                ModLog.Info("No name found for GPS:" + name);
            }
            if (MyStringId.TryGet(description, out descriptionID))
            {
                _description = VRage.MyTexts.Get(descriptionID).ToString();
//                ModLog.Info("Found GPS localization for " + description + " as:" + _description);
            }

            return(() => { DuckUtils.AddGpsToAllPlayers(_name, _description, coords); });
        }
Exemple #4
0
        private void InitCue(int cueId)
        {
            if (cueId == 0)
            {
                CueId = cueId;
            }
            else
            {
                MyStringId stringId = MyStringId.TryGet(cueId);
                MySoundCategoryDefinition.SoundDescription soundDesc = null;
                var soundCategories = MyDefinitionManager.Static.GetSoundCategoryDefinitions();

                // check whether saved cue is in some category
                foreach (var category in soundCategories)
                {
                    foreach (var soundDescTmp in category.Sounds)
                    {
                        if (MySoundPair.GetCueId(soundDescTmp.SoundId) == stringId)
                        {
                            soundDesc = soundDescTmp;
                        }
                    }
                }

                if (soundDesc != null)
                {
                    SelectSound(stringId, false);
                }
                else
                {
                    CueId = 0;
                }
            }
        }
Exemple #5
0
        void cuesCombo_OnSelect()
        {
            m_currentCueSelectedItem = (int)m_cuesCombo.GetSelectedKey();
            var cue = MyStringId.TryGet(m_cuesCombo.GetSelectedValue().ToString());

            m_currentCue = MyAudio.Static.GetCue(cue);

            UpdateCueValues();
            //RecreateControls(false);
        }
Exemple #6
0
        internal Convoy(Vector3D destination, NpcGroupState initialState, NpcGroupArrivalObserver arrivalObserver,
                        QueuedAudioSystem audioSystem, IMyCubeGrid leader, DateTime groupSpawnTime)
            : base(leader.EntityId, initialState, destination, NpcGroupType.Convoy, groupSpawnTime, arrivalObserver)
        {
            this.audioSystem = audioSystem;
            this.leader      = leader;

            InterceptingBeaconSuffix = VRage.MyTexts.Get(MyStringId.TryGet("InterceptingBeaconSuffix")).ToString();
            FleeingBeaconSuffix      = VRage.MyTexts.Get(MyStringId.TryGet("FleeingBeaconSuffix")).ToString();
        }
        public static Type GetType(string typeId)
        {
            MyStringId typeIdInt;

            if (MyStringId.TryGet(typeId, out typeIdInt))
            {
                return(m_idToType[typeIdInt]);
            }

            throw new Exception("Unregistered component typeId! : " + typeId);
        }
        internal bool TryGetStorage(string name, out MyStorageBase result)
        {
            MyStringId id;

            if (MyStringId.TryGet(name, out id))
            {
                return(m_storageByName.TryGetValue(id, out result));
            }

            result = null;
            return(false);
        }
Exemple #9
0
 public void Get(int index, out Color color, out MyStringId 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 = MyStringId.TryGet(edges[index]);
         Debug.Assert(edges[index] == 0 || edgeModel != MyStringId.NullOrEmpty);
     }
 }
Exemple #10
0
        private static void OnSecondarySoundPlay(MySyncCharacter syncObject, ref PlaySecondarySoundMsg msg, MyNetworkClient sender)
        {
            if (!MySandboxGame.IsDedicated)
            {
                MyStringId soundId = MyStringId.TryGet(msg.CueIdHash);
                syncObject.Entity.StartSecondarySound(soundId, sync: false);
            }

            if (Sync.IsServer)
            {
                Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
            }
        }
Exemple #11
0
        public bool AssignBotToBehaviorTree(string behaviorName, IMyBot bot)
        {
            MyStringId treeId = MyStringId.TryGet(behaviorName);

            Debug.Assert(m_BTDataByName.ContainsKey(treeId), "The given tree does not exist in the collection.");
            if (treeId == MyStringId.NullOrEmpty || !m_BTDataByName.ContainsKey(treeId))
            {
                return(false);
            }
            else
            {
                return(AssignBotToBehaviorTree(m_BTDataByName[treeId].BehaviorTree, bot));
            }
        }
Exemple #12
0
        public static MyStringId GetCueId(this IMyAudio self, string cueName)
        {
            if (self == null)
            {
                return(MyStringId.NullOrEmpty);
            }

            MyStringId id;

            if (MyStringId.TryGet(cueName, out id))
            {
                return(id);
            }

            return(MyStringId.NullOrEmpty);
        }
Exemple #13
0
        public bool TryGetBehaviorTreeByName(string name, out MyBehaviorTree behaviorTree)
        {
            MyStringId stringId = MyStringId.NullOrEmpty;

            MyStringId.TryGet(name, out stringId);
            if (stringId != MyStringId.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);
            }
        }
Exemple #14
0
        private string ConvoyRecalled          = "Convoy Recalled";            // loaded my mytexts

        internal NpcGroupManager(int modBuildWhenSaved, HeatSystem heatSystem, QueuedAudioSystem audioSystem, BaseManager baseManager,
                                 ConvoySpawner convoySpawner)
        {
            this.heatSystem       = heatSystem;
            this.audioSystem      = audioSystem;
            this.baseManager      = baseManager;
            this.convoySpawner    = convoySpawner;
            modBuildWhenLastSaved = modBuildWhenSaved;

            MyAPIGateway.Entities.OnEntityAdd += NewEntityEvent;

            EscortName = VRage.MyTexts.Get(MyStringId.TryGet("EscortName")).ToString();

            var InvestigatingBackupCallID = MyStringId.TryGet("InvestigatingBackupCall");

            InvestigatingBackupCall = VRage.MyTexts.Get(InvestigatingBackupCallID).ToString();

            ConvoyRecalled = VRage.MyTexts.Get(MyStringId.TryGet("ConvoyRecalled")).ToString();
        }
        internal static Action AddObjectiveGps(string name, string description, Vector3D coords, Color color)
        {
            MyStringId nameID;
            MyStringId descriptionID;

            string _name        = name;
            string _description = description;

            if (MyStringId.TryGet(name, out nameID))
            {
                _name = VRage.MyTexts.Get(nameID).ToString();
            }
            if (MyStringId.TryGet(name, out descriptionID))
            {
                _description = VRage.MyTexts.Get(descriptionID).ToString();
            }

            return(() => { MyVisualScriptLogicProvider.AddGPSObjectiveForAll(_name, _description, coords, color); });
        }
Exemple #16
0
        void effects_ItemSelected()
        {
            foreach (var box in m_cues)
            {
                Controls.Remove(box);
            }
            m_cues.Clear();
            var eff = MyStringId.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);
                }
            }
        }
Exemple #17
0
        internal BackupGroup(NpcGroupState initialState, Vector3D destination, IMyCubeGrid leader,
                             HeatSystem heatSystem, QueuedAudioSystem audioSystem, DateTime groupSpawnTime)
            : base(leader.EntityId, initialState, destination, NpcGroupType.Backup, groupSpawnTime, heatSystem)
        {
            this.leader      = leader;
            this.audioSystem = audioSystem;
            this.heat        = heatSystem;

            var InterceptingBeaconSuffixID = MyStringId.TryGet("InterceptingBeaconSuffix");

            InterceptingBeaconSuffix = VRage.MyTexts.Get(InterceptingBeaconSuffixID).ToString();

            var ReturningToBaseID = MyStringId.TryGet("ReturningToBase");

            ReturningToBase = VRage.MyTexts.Get(ReturningToBaseID).ToString();

            var InvestigatingBackupCallID = MyStringId.TryGet("InvestigatingBackupCall");

            InvestigatingBackupCall = VRage.MyTexts.Get(InvestigatingBackupCallID).ToString();
        }
        internal ResearchHacking(ResearchControl researchControl, HudAPIv2 hudTextApi, NetworkComms networkComms)
        {
            this.researchControl = researchControl;

            /*
             * // V1
             * hackBar.options |= HUDTextAPI.Options.HideHud;
             *          hackInterrupted.options |= HUDTextAPI.Options.HideHud;
             *          this.hudTextApi = hudTextApi;
             */

            //V2
            TextAPI = hudTextApi;

            this.networkComms = networkComms;

            ConnectionLostID = MyStringId.TryGet("ConnectionLost");

            HackInProgressID = MyStringId.TryGet("HackInProgress");
            //            string sInit = VRage.MyTexts.Get(stringIdInit).ToString() + " " + CurrentModVersion;
        }
Exemple #19
0
        void OnPlaySelected(MyGuiControlButton button)
        {
            if ((m_sound != null) && (m_sound.IsPlaying))
            {
                m_sound.Stop(true);
            }
            var cue = MyStringId.TryGet(m_cuesCombo.GetSelectedValue().ToString());

            m_sound = MyAudio.Static.PlayTestSound(cue);
            var effect = MyStringId.TryGet(m_effects.GetSelectedValue().ToString());

            if (effect != MyStringId.NullOrEmpty)
            {
                foreach (var box in m_cues)
                {
                    var effCue = MyStringId.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();
            }
        }
Exemple #20
0
        private bool CallScriptInternal(string message)
        {
            Assembly ass;

            if (IlCompiler.Buffer.Length > 0)
            {
                if (IlCompiler.Compile(new string[] { IlCompiler.Buffer.ToString() }, out ass, true))
                {
                    var retval = ass.GetType("wrapclass").GetMethod("run").Invoke(null, null);
                    if (!string.IsNullOrEmpty(message))
                    {
                        Sandbox.Game.Gui.MyHud.Chat.ShowMessage("returned", retval.ToString());
                    }
                    return(true);

                    IlCompiler.Buffer.Clear();
                }
                else
                {
                    IlCompiler.Buffer.Clear();
                    return(false);
                }
            }
            var parts = message.Split(Separators, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length < 3)
            {
                MyAPIGateway.Utilities.ShowNotification("Not enought parameters for script please provide following paramaters : Sriptname Classname MethodName", 5000);
                return(false);
            }
            if (!Scripts.ContainsKey(MyStringId.TryGet(parts[1])))
            {
                string availableScripts = "";
                foreach (var scriptName in Scripts)
                {
                    availableScripts += scriptName.Key + "\n";
                }
                MyAPIGateway.Utilities.ShowMissionScreen("Script not found", "", "Available scripts:", availableScripts);
                return(false);
            }
            ass = Scripts[MyStringId.Get(parts[1])];
            var type = ass.GetType(parts[2]);

            if (type == null)
            {
                string availableScripts = "";
                var    types            = ass.GetTypes();
                foreach (var scriptType in types)
                {
                    availableScripts += scriptType.FullName + "\n";
                }
                MyAPIGateway.Utilities.ShowMissionScreen("Class not found", "", "Available classes:", availableScripts);
                return(false);
            }
            var method = type.GetMethod(parts[3]);

            if (method == null)
            {
                string availableScripts = "";
                var    types            = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
                foreach (var scriptType in types)
                {
                    availableScripts += scriptType.Name + "\n";
                }
                MyAPIGateway.Utilities.ShowMissionScreen("Method not found", "", "Available methods:", availableScripts);
                return(false);
            }
            var           paramInfos = method.GetParameters();
            List <object> parameters = new List <object>();

            for (int i = 4; i < paramInfos.Length + 4 && i < parts.Length; i++)
            {
                var paramType = paramInfos[i - 4].ParameterType;
                var parseMet  = paramType.GetMethod("TryParse", new Type[] { typeof(System.String), paramType.MakeByRefType() });
                if (parseMet != null)
                {
                    var output = Activator.CreateInstance(paramType);
                    var args   = new object[] { parts[i], output };
                    var par    = parseMet.Invoke(null, args);
                    parameters.Add(args[1]);
                }
                else
                {
                    parameters.Add(parts[i]);
                }
            }
            if (paramInfos.Length == parameters.Count)
            {
                var retval = method.Invoke(null, parameters.ToArray());
                if (retval != null)
                {
                    Sandbox.Game.Gui.MyHud.Chat.ShowMessage("return value", retval.ToString());
                }
                Sandbox.Game.Gui.MyHud.Chat.ShowMessage("Call", "Success");
                return(true);
            }
            return(false);
        }
Exemple #21
0
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            var    stringIdInit = MyStringId.TryGet("Init");
            string sInit        = VRage.MyTexts.Get(stringIdInit).ToString() + " " + CurrentModVersion;

            var    TranslationByID = MyStringId.TryGet("TranslationBy");
            string sTranslationBy  = VRage.MyTexts.Get(TranslationByID).ToString();

            if (!string.IsNullOrWhiteSpace(sTranslationBy))
            {
                sInit += "\n  " + sTranslationBy;
            }

            var    AudioByID = MyStringId.TryGet("AudioBy");
            string sAudioBy  = VRage.MyTexts.Get(AudioByID).ToString();

            if (!string.IsNullOrWhiteSpace(sAudioBy))
            {
                sInit += "\n  " + sAudioBy;
            }
            //            string sInit = "Initialising Escape From Mars build " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);
            MyLog.Default.Info("EFM Init" + sInit);

//            var gamelanguage = MySpaceTexts.ToolTipOptionsGame_Language;
            var gamelanguage = MyAPIGateway.Session.Config.Language;

            ModLog.Info("Game Language=" + gamelanguage.ToString());

            /*
             * var idString1=MyStringId.TryGet("String1");
             * var String1=VRage.MyTexts.Get(idString1);
             * ModLog.Info("idString1=" + idString1);
             * ModLog.Info("String1=" + String1);
             */

            if (MyAPIGateway.Session.IsServer)
            {
                MyVisualScriptLogicProvider.SendChatMessage(sInit, "Wicorel", 0, MyFontEnum.DarkBlue);
            }

            gameVersion = MyAPIGateway.Session.Version;
            ModLog.Info("SE Version=" + gameVersion.ToString());

            /*
             * ModLog.Info(" Major=" + gameVersion.Major.ToString());
             * ModLog.Info(" MajorRevision=" + gameVersion.MajorRevision.ToString());
             * ModLog.Info(" Minor=" + gameVersion.Minor.ToString());
             * ModLog.Info(" MinorRevision=" + gameVersion.MinorRevision.ToString());
             * ModLog.Info(" Build=" + gameVersion.Build.ToString());
             */
            /*
             * // TESTING: (they seem to be the same)
             * if (MyAPIGateway.Session.IsServer)
             *  ModLog.Info("MyAPIGateway.Session.IsServer.IsServer");
             * else
             *  ModLog.Info("MyAPIGateway.Session.NOT Server");
             * if (MyAPIGateway.Multiplayer.IsServer)
             *  ModLog.Info("MyAPIGateway.Multiplayer.IsServer");
             * else
             *  ModLog.Info("MyAPIGateway.Multiplayer.NOT Server");
             */
            bool bResearch = Session.SessionSettings.EnableResearch;

            // This works to change the setting.
            Session.SessionSettings.EnableResearch = true;

            Session.SessionSettings.EnableBountyContracts = false; // SE V1.192

            if ((gameVersion.Major == 1 && gameVersion.Minor >= 192) || gameVersion.Major > 1)
            {
                ModLog.Info("Economy items enabled");
                CargoType.AllowEconomyItems();
            }
            if ((gameVersion.Major == 1 && gameVersion.Minor >= 198) || gameVersion.Major > 1)
            {
                ModLog.Info("Warefare1 items enabled");
                CargoType.AllowWarefare1Items();
            }
            if ((gameVersion.Major == 1 && gameVersion.Minor >= 200) || gameVersion.Major > 1)
            {
                ModLog.Info("Warefare2 items enabled");
                CargoType.AllowWarefare2Items();
            }

            if (!bResearch)
            {
//                MyAPIGateway.Utilities.ShowNotification("Save, then Exit. Edit world /Advanced settings and Enable progression", 50000, MyFontEnum.Red);
                ModLog.Info("Research was not turned on");
            }
            TextAPI = new HudAPIv2();
//            if (modBuildWhenGameStarted > 4) V37
            {
                DuckUtils.PutPlayerIntoFaction("CRASH");
            }
            researchControl = new ResearchControl(audioSystem);
            researchControl.InitResearchRestrictions();
            researchHacking = new ResearchHacking(researchControl, TextAPI, networkComms);
            networkComms.Init(audioSystem, researchControl, researchHacking);
            modSystemRegistry.AddCloseableModSystem(networkComms);
            modSystemRegistry.AddUpatableModSystem(audioSystem);

            MyAPIGateway.Utilities.MessageEntered += MessageEntered;
        }
Exemple #22
0
        private void GiveOrdersToUnassignedShips()
        {
            bool bFoundBackup = false;

            while (unitialisedNewGrids.Count > 0)
            {
                var grid = unitialisedNewGrids.Dequeue();
                if (!grid.IsControlledByFaction("GCORP"))
                {
                    continue;
                }

                var roleAndUnitType = PrefabGrid.GetRoleAndUnitType(grid);
                if (roleAndUnitType == null)
                {
                    // V26 debug
                    ModLog.Info("Discarding grid because no role found");
                    continue;
                }

                var unitType = roleAndUnitType.Value.UnitType;

                switch (roleAndUnitType.Value.UnitRole)
                {
                case UnitRole.Delivery:
                    var cargoType = CargoType.GenerateRandomCargo(random);
                    LoadCargo(grid, cargoType);

                    if (cargoType.subtypeName == "SteelPlate")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.SteelPlateConvoyDispatched, AudioClip.ConvoyDispatched1);
                    }
                    else if (cargoType.subtypeName == "MetalGrid")
                    {
                        audioSystem.PlayAudioRandomChance(1, AudioClip.MetalGridConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Construction")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConstructionConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "InteriorPlate")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.InteriorPlateConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Girder")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.GirderConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "SmallTube")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.SmallTubeConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "LargeTube")
                    {
                        audioSystem.PlayAudioRandomChance(0.2, AudioClip.LargeTubeConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Motor")
                    {
                        audioSystem.PlayAudioRandomChance(0.75, AudioClip.MotorConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Display")
                    {
                        audioSystem.PlayAudioRandomChance(0.2, AudioClip.DisplayConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "BulletproofGlass")
                    {
                        audioSystem.PlayAudioRandomChance(0.3, AudioClip.BulletproofGlassConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Computer")
                    {
                        audioSystem.PlayAudioRandomChance(0.2, AudioClip.ComputerConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Reactor")
                    {
                        audioSystem.PlayAudioRandomChance(0.75, AudioClip.ReactorConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Medical")
                    {
                        audioSystem.PlayAudioRandomChance(0.7, AudioClip.MedicalConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "RadioCommunication")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.RadioCommunicationConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Explosives")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.ExplosivesConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "SolarCell")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.SolarCellConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "PowerCell")
                    {
                        audioSystem.PlayAudioRandomChance(0.75, AudioClip.PowerCellConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "NATO_5p56x45mm")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.NATO_5p56x45mmConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "NATO_25x184mm")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.NATO25x184mmConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Missile200mm")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.Missile200mmConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Uranium")
                    {
                        audioSystem.PlayAudioRandomChance(1, AudioClip.UraniumConvoyDispatched);
                    }
                    else      // we don't know what it is..
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConvoyDispatched1, AudioClip.ConvoyDispatched2, AudioClip.ConvoyDispatched3);
                    }

                    string sPrefix = "T";
                    if (unitType == UnitType.Air)
                    {
                        sPrefix += "A";
                    }
                    else
                    {
                        sPrefix += "G";
                    }

                    string     prepend = "";
                    string     append  = " Shipment";
                    MyStringId stringID;
                    if (MyStringId.TryGet("shipment_prepend", out stringID))
                    {
                        prepend = VRage.MyTexts.Get(stringID).ToString() + " ";
                    }
                    if (MyStringId.TryGet("shipment_append", out stringID))
                    {
                        append = " " + VRage.MyTexts.Get(stringID).ToString();
                    }

                    grid.SetAllBeaconNames(sPrefix + random.Next(10000, 99999) + " - " + prepend + cargoType.GetDisplayName() + append,
                                           200f);              // V31 set short until initialize check timeout
                    var destination = unitType == UnitType.Air ? airConvoyDestinationPosition : groundConvoyDestinationPosition;

//                        ModLog.Info("Air Destination=" + airConvoyDestinationPosition.ToString());
//                        ModLog.Info("GND Destination=" + groundConvoyDestinationPosition.ToString());
//                        ModLog.Info("Chosen Dest=" + destination.ToString());
                    SetDestination(grid, destination);
                    RegisterConvoy(grid, NpcGroupState.Travelling, unitType, destination, MyAPIGateway.Session.GameDateTime);

                    var planet = DuckUtils.FindPlanetInGravity(grid.GetPosition());
                    if (planet != null)
                    {
                        convoySpawner.SpawnConvoyEscorts(grid, unitType, planet);
                    }
                    break;

                case UnitRole.Escort:
                    var group = FindNearestJoinableNpcGroup(grid.GetPosition(), unitType);
                    if (group == null)
                    {
                        ModLog.Error("Escort ship spawned but can't find a group to join!");
                        grid.CloseAll();
                    }
                    else
                    {
                        grid.SetAllBeaconNames("E" + random.Next(10000, 99999) + " - " + EscortName, 2500f);                                 // V31 shorten escort beacon range to decrease hud spam
                        var nearestPlanet = DuckUtils.FindPlanetInGravity(grid.GetPosition());
                        if (nearestPlanet != null)
                        {
                            group.JoinAsEscort(grid, unitType, nearestPlanet);
                        }
                    }
                    break;

                case UnitRole.Backup:
                    var gCorpBase = baseManager.FindBaseWantingBackup();
                    // V26
                    bFoundBackup = true;

                    if (gCorpBase == null)
                    {
                        gCorpBase = baseManager.FindBaseNear(grid.GetPosition());
                    }

                    if (gCorpBase == null)
                    {
                        ModLog.Error("Backup ship spawned but can't find the base that asked for it!");
                        grid.CloseAll();
                        break;
                    }
                    var backupPosition = gCorpBase.GetBackupPosition();
                    grid.SendToPosition(backupPosition);
                    // backup debug
                    string sBeacon = "M" + random.Next(10000, 99999) + InvestigatingBackupCall;
//                        ModLog.Info("Backup Found:" + sBeacon);
//                        ModLog.Info(" Destination=" + backupPosition.ToString());
                    grid.SetAllBeaconNames(sBeacon, 20000f);
                    var backupGroup = new BackupGroup(NpcGroupState.Travelling, backupPosition, grid,
                                                      heatSystem, audioSystem, MyAPIGateway.Session.GameDateTime);
                    //damageSensor.RegisterDamageObserver(grid.EntityId, backupGroup);
                    npcGroups.Add(backupGroup);
                    break;

                case UnitRole.Bomb:
                    bool hasSensors = false;
                    var  slimBlocks = new List <IMySlimBlock>();
                    grid.GetBlocks(slimBlocks, b => b.FatBlock is IMySensorBlock);
                    if (slimBlocks.Count > 0)
                    {
                        hasSensors = true;
                    }


                    grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyWarhead);
                    foreach (var slim in slimBlocks)
                    {
                        var wh = slim.FatBlock as IMyWarhead;
                        wh.IsArmed = true;
                        if (!hasSensors)    // if no sensors, start the countdown
                        {
                            ModLog.Info("BOMB: no sensors: Starting timer");
                            wh.StartCountdown();
                        }
                    }
                    break;

                default:
                    continue;
                }
            }
            if (bFoundBackup)
            {
                baseManager.ClearBaseBackupRequests();
            }
        }
Exemple #23
0
 public void SelectSound(int cueId, bool sync)
 {
     SelectSound(MyStringId.TryGet(cueId), sync);
 }
Exemple #24
0
        /// <summary>
        /// Fix up the blocks in ALL grids to have correct values
        /// This routine could also be used to set text panels for other languages.
        ///
        /// </summary>
        /// <param name="grid"></param>
        void BlocksFixup(IMyCubeGrid grid)
        {
            if (bDumpLocalization)
            {
                ModLog.Info("Grid:" + grid.CustomName + "\n ID=" + grid.EntityId.ToString());
                Vector3D gridPos = grid.GetPosition();
                ModLog.Info(" GPS:" + grid.CustomName + ":" + gridPos.X.ToString("0.00") + ":" + gridPos.Y.ToString("0.00") + ":" + gridPos.Z.ToString("0.00") + ":");
            }

            MyStringId gridID;

            if (MyStringId.TryGet("G" + grid.EntityId.ToString(), out gridID))
            {
                // we found grid name
                string str = VRage.MyTexts.Get(gridID).ToString();
                grid.CustomName = str;
            }

            bool bMiki = false;

            if (grid.EntityId == 135216604045890710)
            {
                bMiki = true;
            }

            long medbayID      = 79910699489349926;
            var  slimBlocksMed = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocksMed, b => b.FatBlock is IMyMedicalRoom);
            foreach (var slim in slimBlocksMed)
            {
                var medbay = slim.FatBlock as IMyMedicalRoom;
                if (medbay.EntityId == medbayID)
                {
                    medbay.Enabled = true;
                }
            }

            // fix up the Gatling blocks to have max range //V28
            var slimBlocksG = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocksG, b => b.FatBlock is IMyLargeGatlingTurret);
            foreach (var slim in slimBlocksG)
            {
                var gatling = slim.FatBlock as IMyLargeGatlingTurret;
                //              gatling.Range get only :(
            }

            // fix up the beacon blocks  // V26
            //V 36: dump and get localization
            var slimBlocksB = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocksB, b => b.FatBlock is IMyBeacon);
            if (bDumpLocalization)
            {
                ModLog.Info("BEACON");
            }
            foreach (var slim in slimBlocksB)
            {
                var beacon = slim.FatBlock as IMyBeacon;
                if (beacon.CustomName.Contains("CLEANCE"))
                {
                    // beacon in HQ has spelling error
                    string sName = beacon.CustomName;
                    ModLog.Info("Fixing Beacon Text:" + sName);
                    beacon.CustomName = sName.Replace("CLEANCE", "CLEARANCE");
                }
                if (bDumpLocalization)
                {
                    ModLog.Info(" B" + beacon.EntityId.ToString() + " :" + beacon.CustomName);
                }
                MyStringId beaconID;
                if (MyStringId.TryGet("B" + beacon.EntityId.ToString(), out beaconID))
                {
                    // we found size setting
                    string str = VRage.MyTexts.Get(beaconID).ToString();
                    beacon.CustomName = str;
                }
            }


            //V 36: dump and get localization
            if (bDumpLocalization)
            {
                ModLog.Info("Antenna");
            }
            var slimBlocksA = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocksA, b => b.FatBlock is IMyRadioAntenna);
            foreach (var slim in slimBlocksA)
            {
                var antenna = slim.FatBlock as IMyRadioAntenna;
                if (bDumpLocalization)
                {
                    ModLog.Info(" A" + antenna.EntityId.ToString() + " : " + antenna.CustomName);
                }
                MyStringId antenaID;
                if (MyStringId.TryGet("A" + antenna.EntityId.ToString(), out antenaID))
                {
                    // we found size setting
                    string str = VRage.MyTexts.Get(antenaID).ToString();
                    antenna.CustomName = str;
                }
            }


            // fix up the text panel blocks
            var slimBlocks = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyTextPanel);
            if (bDumpLocalization)
            {
                ModLog.Info("TEXT PANEL");
            }
            foreach (var slim in slimBlocks)
            {
                var textPanel = slim.FatBlock as IMyTextPanel;

                textPanel.ShowOnHUD = false; // optimize; only one pass through textpanels

                //bool bShow = textPanel.GetValueBool("ShowTextOnScreen");
                // V 1.190
                bool bShow = textPanel.ContentType == VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
                //                bool bShow = textPanel.ShowOnScreen != VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.NONE;
                if (bShow)
                {
                    if (bDumpLocalization)
                    {
                        string txt = textPanel.GetText();
                        if (!string.IsNullOrWhiteSpace(txt))
                        {
                            ModLog.Info(" T" + textPanel.EntityId.ToString());
                            ModLog.Info(txt);
                        }
                    }
                    //V36: Get screen translations.
                    MyStringId textID;
                    if (MyStringId.TryGet("T" + textPanel.EntityId.ToString(), out textID))
                    {
                        // we found replacement string in MyTexts.
                        string str = VRage.MyTexts.Get(textID).ToString();
                        str = str.Replace("\\n", "\n");
                        textPanel.WriteText(str);
                    }
                    if (MyStringId.TryGet("T" + textPanel.EntityId.ToString() + "_size", out textID))
                    {
                        // we found size setting
                        float  size = textPanel.FontSize;
                        string str  = VRage.MyTexts.Get(textID).ToString();
                        if (float.TryParse(str, out size))
                        {
                            textPanel.FontSize = size;
                        }
                    }
                    if (MyStringId.TryGet("T" + textPanel.EntityId.ToString() + "_padding", out textID))
                    {
                        // we found size setting
                        float  size = textPanel.FontSize;
                        string str  = VRage.MyTexts.Get(textID).ToString();
                        if (float.TryParse(str, out size))
                        {
                            textPanel.TextPadding = size;
                        }
                    }
                    if (MyStringId.TryGet("T" + textPanel.EntityId.ToString() + "_alignment", out textID))
                    {
                        // we found alignment setting
                        string str = VRage.MyTexts.Get(textID).ToString();
                        if (str == "center")
                        {
                            textPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
                        }
                        else if (str == "left")
                        {
                            textPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.LEFT;
                        }
                        else if (str == "right")
                        {
                            textPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.RIGHT;
                        }
                    }
                }
                // V26                else
                {
                    var strings = new List <string>();
                    textPanel.GetSelectedImages(strings);
//                    textPanel.TextPadding = 0; //V26
                    if (strings.Count < 1)
                    {
                        // note: better method would be use use .CustomData of the textpanels.
                        // Using this EntityID method to be backward compatible with player's existing worlds.
                        switch (textPanel.EntityId)
                        {
                        //            long buildGuideID = 80461927256500036;
                        case 110371608100898677:     //TOOLS LOCKER
//                                textPanel.FontSize = 5;
//                                textPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
//                                if (textPanel.GetText().Length < 20)
//                                    textPanel.TextPadding = 20f; // 20%
//                                else textPanel.TextPadding = 1f;
                            break;

                        case 143319951822334717:     //143319951822334717:TEXT!                                SPARE PARTS STORAGE
//                                textPanel.FontSize = 5;

/*
 *                              textPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
 *                              if(textPanel.GetText().Length<20)
 *                                  textPanel.TextPadding = 20f; // 20%
 *                              else textPanel.TextPadding = 1f;
 */
                            break;

                        case 87005598531295535:     //87005598531295535TEXT!EMERGENCY SUPPLIES
                            /*
                             * /                                textPanel.FontSize = 5;
                             * textPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
                             * textPanel.TextPadding = 20f; // 20%
                             */
                            break;


                        case 80461927256500036:     // Crash ship build info screen
                                                    /* "old" text
                                                     * Mabel: Loading survival guide...
                                                     *
                                                     * > Recommend searching cargo
                                                     * and disassembling shuttle for
                                                     * rover parts
                                                     * > Recommend configuration:
                                                     * - Six wheels
                                                     * - Friction 10%
                                                     * - Damping 30%
                                                     * - Strength ~5%
                                                     * (Depends on load)
                                                     * - Speed Limit 100km/h
                                                     */
                                                    /*
                                                     *                              textPanel.WriteText("Mabel: Loading survival guide..."+
                                                     * "\n"+
                                                     * "\n> Recommend searching cargo"+
                                                     * "\n   and disassembling shuttle for"+
                                                     * "\n   rover parts"+
                                                     * "\n> Recommend configuration:"+
                                                     * "\n    -Six wheels"+
                                                     * "\n    - Friction 60%"+
                                                     * "\n    - *Strength 10%" +
                                                     * "\n    - *Power 50%" +
                                                     * "\n    - Speed Limit 50km/h" +
                                                     * "\n  * =Depends on load"
                                                     * );
                                                     */
                            break;

                        /*
                         * ((Ice Mine Entrance))
                         * Static Grid 1300:141864706275857195
                         * { X: 1869175.27852051 Y: -2004745.97266307 Z: 1316375.91819424}
                         * -----TEXTPANELS
                         * 74525033656413945:1:+LCD Panel 2
                         | Galactic Corporation Logo
                         */
                        case 74525033656413945:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        // MIKI FIXUP
                        case 81986956045310309:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 103164071082162108:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 120342266177165062:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 96762650175047086:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 78808963600022563:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 102592293973822089:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 93732106466977771:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 119196087123513740:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 115470908890383058:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 84905149027762603:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 73748511314883089:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 108707493869969783:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 107003280298094914:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 93717234609661072:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        case 100685062896355827:
                            textPanel.AddImageToSelection("MikiScrap");
                            break;

                        //green house
                        case 110846399081478285:
                            textPanel.AddImageToSelection("MRE Logo");
                            break;

                        //                                Signal Station:139030682896359375
                        //{ X: 1844500.54997961 Y: -1995403.72976435 Z: 1323630.52767273}
                        case 132717438306395557:
                            textPanel.AddImageToSelection("MRE Logo");
                            break;

                        //                                ((MRE MedBay 2))
                        //MRE Emergency Medical Station:120085596920753880
                        //{ X: 1844533.71376673 Y: -1995424.91354928 Z: 1323629.33162825}
                        case 104050761648970549:
                            textPanel.AddImageToSelection("MRE Logo");
                            break;

                        // {X:1856577.01869837 Y:-1999257.98373971 Z:1321414.17733138}
                        case 110250540272021112:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        //  {X:1857176.1781222 Y:-2000013.37619576 Z:1321553.01815169}
                        case 89933889116515952:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        //((and another HQ SAM))
                        //GCorp Mobile SAM: 89611551362269325
                        //{ X: 1857213.83363977 Y: -1998518.53635201 Z: 1320657.55013411}
                        case 95067624877541028:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        //((another HQ SAM))
                        //GCorp Mobile SAM: 104043950566026386
                        //{ X: 1858538.51759973 Y: -1999989.95859322 Z: 1320777.02901595}
                        case 120326586562634149:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        //((Bunker in weapons Research))
                        //GCorp Bunker:132649980418733079
                        //{ X: 1843291.04608973 Y: -1996439.44943181 Z: 1324491.09281518}
                        case 102565050409374890:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 76555655031247133:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 82207545563969038:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 140611613672853263:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        //((Air Research))
                        //GCorp Flight Research Center:76779347935557670
                        //{ X: 1854754.1883761 Y: -2005852.06052194 Z: 1325419.84578841}
                        case 91899503586440685:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 89540866723022250:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 139513180460721275:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 123742114812299814:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 72707843196346809:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 84058947393377852:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 124309978476859628:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 85895320964444780:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 117967784354173602:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 128468555565951583:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        case 107231006349635239:
                            textPanel.AddImageToSelection("Clouds");
                            break;

                        //((MRE hidden Base))
                        //MRE Experiment Base: 104361129531664144
                        //{ X: 1858398.21613573 Y: -1989137.98910994 Z: 1312706.48643797}
                        case 98971232666660757:
                            textPanel.AddImageToSelection("MRE Logo");
                            break;

                        case 97512105090353134:
                            textPanel.AddImageToSelection("MRE Logo");
                            break;

                        case 81228556864103207:
                            textPanel.AddImageToSelection("MRE Logo");
                            break;

                        //((HQ))
                        //GCorp HQ Tower: 144104082158837389
                        //{ X: 1857310.65834681 Y: -1999316.80991158 Z: 1321066.96761458}
                        case 125129893494374181:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 134131747655270782:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 74727284886995000:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 98708608904781783:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 138656136990359379:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 80870473015345748:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        case 98370398719554346:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 80724503483430325:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 87324639907322082:
                            textPanel.AddImageToSelection("White screen");
                            break;

                        case 110549946960318740:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 142860245424722839:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 117922822138601150:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        // ((HQ Rocket))
                        //GCorp Space Transport: 97585502667028994
                        //{ X: 1857324.30678431 Y: -1999293.08872018 Z: 1321075.17171614}
                        case 140237983630899577:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            break;

                        case 105805752262318800:
                            textPanel.AddImageToSelection("Arrow");
                            break;

                        case 104593951810486921:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 141641456443241951:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 101582007425482292:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;

                        case 80366112655444611:
                            textPanel.AddImageToSelection("Galactic Corporation Logo");
                            textPanel.AddImageToSelection("Automation Simplified");
                            break;
                        }
                    }
                }
                if (bMiki)
                {
                    if (
                        textPanel.CustomName == "LCD Panel 10" || // (there are two)
                        textPanel.CustomName == "LCD Panel 5" ||
                        textPanel.CustomName == "LCD Panel 6" ||
                        textPanel.CustomName == "LCD Panel 7" ||
                        textPanel.CustomName == "LCD Panel 9" ||
                        textPanel.CustomName == "LCD Panel 13" ||
                        textPanel.CustomName == "LCD Panel 14" ||
                        textPanel.CustomName == "LCD Panel 15"
                        )
                    {
                        textPanel.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
                        var strings = new List <string>();
                        textPanel.GetSelectedImages(strings);
                        //                    textPanel.TextPadding = 0; //V26
                        if (strings.Count < 1)
                        { // nothing is currently listed
                            textPanel.AddImageToSelection("MikiScrap");
                        }
                    }
                }
            }

            // fix up the sound blocks
            var slimBlocks2 = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocks2, b => b.FatBlock is IMySoundBlock);
            MyStringId soundblockID;

            foreach (var slim in slimBlocks2)
            {
                var soundBlock = slim.FatBlock as IMySoundBlock; // Fixed V21
                if (bDumpLocalization)
                {
                    ModLog.Info(" S" + soundBlock.EntityId.ToString());
                    ModLog.Info("  " + soundBlock.SelectedSound.ToString());
                }
                //                if (soundBlock == null) continue; // why do we need this?
                switch (soundBlock.EntityId)
                {
                // air base alpha:
                case 116378614635193269:
                    if (MyStringId.TryGet("WelcomeToGcorp", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "WelcomeToGcorp";
                    }
                    break;

                /*
                 * case XXXX:
                 * if (MyStringId.TryGet("IntruderDetectedGCorp", out soundblockID))
                 * {
                 *  soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                 * }
                 * else
                 *  soundBlock.SelectedSound = "IntruderDetectedGCorp";
                 * break;
                 */
                // ice mine entrance
                case 101979433782763108:
                    if (MyStringId.TryGet("NotAuthorisedDeployDefences", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "NotAuthorisedDeployDefences";
                    }
                    break;

                // ice mine shaft botom
                case 106640376870960334:
                    if (MyStringId.TryGet("MineClosed", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "MineClosed";
                    }
                    break;

                //((Upper Ice Mine Meeting Room))
                //{ X: 1869176.67818993 Y: -2004930.50366838 Z: 1316377.58089576}
                case 80185389104537910:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                // MRE HIdden base
                case 95206901925432014:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 100498114358496283:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 77589249328205128:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 104066113506074975:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 90866709199081947:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 141427853315146800:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 116242415031561830:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 110850485077900653:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;

                case 88298229398547791:
                    soundBlock.SelectedSound = "BigSwitch";
                    break;


                // wrecked drone
                case 102293828213773618:
                    soundBlock.SelectedSound = "PowerUpClipped";
                    break;

                //((old drone @ hangar 1))
                case 108074122634121508:
                    soundBlock.SelectedSound = "PowerUpClipped";
                    break;

                // air research
                case 84998344586050021:
                    soundBlock.SelectedSound = "SoundBlockAlert2";
                    break;

                case 91070301367474416:
                    soundBlock.SelectedSound = "AirplaneSound";
                    break;

                case 90629854631902381:
                    if (MyStringId.TryGet("FlightResearchExhibition", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "FlightResearchExhibition";
                    }
                    break;

                // air base beta
                case 130193226083241264:
                    if (MyStringId.TryGet("WelcomeToGcorp", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "WelcomeToGcorp";
                    }
                    break;

                // mech
                case 82762879450865423:
                    //            bodyGrid.SetSoundBlocks("Mech Intruders Must Be Destroyed"); // fix missing sound on sound block on mech
                    if (MyStringId.TryGet("IntruderRobot", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "IntruderRobot";
                    }
                    break;

                // HQ
                case 95872484442737911:
                    soundBlock.SelectedSound = "SoundBlockAlert1";
                    break;

                case 82604291774017685:
                    if (MyStringId.TryGet("WelcomeToGcorp", out soundblockID))
                    {
                        soundBlock.SelectedSound = VRage.MyTexts.Get(soundblockID).ToString();
                    }
                    else
                    {
                        soundBlock.SelectedSound = "WelcomeToGcorp";
                    }
                    break;

                // MIKI
                case 129379111872365143:
                    soundBlock.SelectedSound = "Carmen";
                    break;

                case 140249950038454545:
                    soundBlock.SelectedSound = "LavaLoop";
                    break;
                }
            }
        }