public override void Close()
 {
     ModLog.Info("Close Called");
     base.Close();
     MyAPIGateway.Utilities.MessageEntered -= MessageEntered;
     TextAPI.Close();
 }
        public override SaveData GetSaveData()
        {
            if (modBuildWhenGameStarted == 0)
            {
                modBuildWhenGameStarted = CurrentModVersion;
            }

            if (researchControl == null)
            {
                ModLog.Info("RC NULL!");
            }
            if (networkComms == null)
            {
                ModLog.Info("NC NULL!");
            }
            if (researchHacking == null)
            {
                ModLog.Info("RH NULL");
            }

            var saveData = new SaveData
            {
                UnlockedTechs          = researchControl.UnlockedTechs
                , RegisteredPlayers    = networkComms.RegisteredPlayers
                , HackingData          = researchHacking.GetSaveData()
                , BuildWhenGameStarted = modBuildWhenGameStarted
                , BuildWhenSaved       = CurrentModVersion
            };

            return(saveData);
        }
        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); });
        }
Beispiel #4
0
        private void SendMessageToAllClients(Message message)
        {
            var players = new List <IMyPlayer>();

            MyAPIGateway.Multiplayer.Players.GetPlayers(players);

            // V26.  Add checks for no local player
            ulong steamID = 0;
            long  me      = 0;

            if (MyAPIGateway.Session.Player != null)
            {
                steamID = MyAPIGateway.Session.Player.SteamUserId;
                me      = MyAPIGateway.Session.Player.IdentityId;
            }
            message.SenderSteamId = steamID;
            foreach (var player in players)
            {
                if (player.IdentityId == me)
                {
                    continue;
                }
                var steamId = MyAPIGateway.Multiplayer.Players.TryGetSteamId(player.IdentityId);
                if (steamId > 0)
                {
                    var msgBytes = Encoding.UTF8.GetBytes(MyAPIGateway.Utilities.SerializeToXML(message));
                    MyAPIGateway.Multiplayer.SendMessageTo(ModId, msgBytes, steamId);
                }
                else
                {
                    ModLog.Info("Found player with no steam ID:" + player.DisplayName);
                }
            }
        }
Beispiel #5
0
        // after loading of saved data
        protected override void InitHostPostLoading(IModSystemRegistry modSystemRegistry)
        {
            ModLog.Info("Original world was loaded by Version:" + modBuildWhenGameStarted.ToString());
            ModLog.Info("Loaded world was saved by Version:" + modBuildWhenLastSaved.ToString());

            npcGroupManager.SetBuildWhenSaved(modBuildWhenLastSaved);

            researchHacking.InitHackingLocations(); // Uses research restrictions and save data
            DuckUtils.MakePeaceBetweenFactions("MIKI", "CRASH");
            DuckUtils.MakePeaceBetweenFactions("MIKI", "GCORP");

            //V27 for SE 1.192
            DuckUtils.RemoveFaction("SPRT");
            DuckUtils.SetAllPlayerReputation("MIKI", 0);

            audioSystem.AudioRelay = networkComms;
            networkComms.StartWipeHostToolbar();
            modSystemRegistry.AddRapidUpdatableModSystem(turretManager);
            modSystemRegistry.AddUpatableModSystem(researchHacking);
            modSystemRegistry.AddUpatableModSystem(missionSystem);
            modSystemRegistry.AddUpatableModSystem(mikiScrapManager);
            modSystemRegistry.AddUpatableModSystem(npcGroupManager);
            modSystemRegistry.AddUpatableModSystem(baseManager);
            modSystemRegistry.AddUpatableModSystem(convoySpawner);
        }
        public override void AllGridsInitialised()
        {
            // add unlock points
            ModLog.Info("Found " + unlockLocationList.Count().ToString() + " Unlock locations");
            foreach (var unlockLocation in unlockLocationList)
            {
                AddHackingLocation((TechGroup)unlockLocation.techGroup, unlockLocation.location, unlockLocation.unlockradius);

                if (researchControl.bDebugLocations)
                {
                    string name = "PBUnlock " + unlockLocation.techGroup.ToString();
                    DuckUtils.AddGpsToAllPlayers(name, "PB Unlock location", unlockLocation.location);
                }
            }
            // all grids have been loaded during game load.
            researchControl.AllowUnlockedTechs();


            //
            if (researchControl.bDebugLocations)
            {
                foreach (var unlockLocation in hackingLocations)
                {
                    string name = "Unlock " + unlockLocation.TechGroup.ToString();
                    DuckUtils.AddGpsToAllPlayers(name, "Unlock location", unlockLocation.Coords);
                }
            }
        }
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            string sInit = "Initialising Wico Research. Version: " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);

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

            bool bResearch = Session.SessionSettings.EnableResearch;

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

            if (!bResearch)
            {
                ModLog.Info("Research was not turned on");
            }

            TextAPI         = new HudAPIv2();
            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;
        }
 // UNTESTED:
 void FunctionalityChanged(long entityId, long gridid, string entityName, string gridName, string typeid, string subtypeid, bool becameFunctional)
 {
     if (subtypeid.Contains("Hydrogen"))
     { // it's likely a hydrogen tank
         ModLog.Info(" It looks like a hydrogen tank just got built.");
         KeepTechsLocked();
     }
 }
        internal void InitHudMesages(bool bForce = false)
        {
            if (TextAPI == null)
            {
                ModLog.Error("Text HUD API not loaded");
                return;
            }
            if (TextAPI.Heartbeat)
            {
//                ModLog.Info("Have Heartbeat");

                if (hackInterruptedV2 == null || bForce)
                {
//                    ModLog.Info("Creating Interrupted HUD");
                    sbInterruptedMessage = new StringBuilder(SeTextColor + "CONNECTION LOST");
                    hackInterruptedV2    = new HudAPIv2.HUDMessage(sbInterruptedMessage, new Vector2D(-0.5, 0.5));
                    if (hackInterruptedV2 != null)
                    {
                        hackInterruptedV2.Message  = sbInterruptedMessage;
                        hackInterruptedV2.Scale    = 2;
                        hackInterruptedV2.Options  = HudAPIv2.Options.Shadowing;
                        hackInterruptedV2.Options |= HudAPIv2.Options.HideHud;
                        //                        hackInterruptedV2.TimeToLive = 45;
                        hackInterruptedV2.Visible = false;
                    }
                    else
                    {
                        ModLog.Info("Could not create Interrupted HUD");
                    }
                }
                if (hackBarV2 == null || bForce)
                {
//                    ModLog.Info("Creating Hacking HUD");
                    if (sbHackBarMessage == null)
                    {
                        sbHackBarMessage = new StringBuilder("Initial Research Bar");
                    }
                    hackBarV2 = new HudAPIv2.HUDMessage(sbHackBarMessage, new Vector2D(-0.5, 0.5));
                    if (hackBarV2 != null)
                    {
                        hackBarV2.Message  = sbHackBarMessage;
                        hackBarV2.Scale    = 2;
                        hackBarV2.Options  = HudAPIv2.Options.Shadowing;
                        hackBarV2.Options |= HudAPIv2.Options.HideHud;
                        hackBarV2.Visible  = false;
//                        hackBarV2.TimeToLive = 45;
                    }
                    else
                    {
                        ModLog.Info("Could not create Research HUD");
                    }
                }
            }
            else
            {
                ModLog.Info("NO TextHud HEARTBEAT");
            }
        }
        // after loading of saved data
        protected override void InitHostPostLoading(IModSystemRegistry modSystemRegistry)
        {
            ModLog.Info("Original world was loaded by Version:" + modBuildWhenGameStarted.ToString());
            ModLog.Info("Loaded world was saved by Version:" + modBuildWhenLastSaved.ToString());
            researchHacking.InitHackingLocations(); // Uses research restrictions and save data
            audioSystem.AudioRelay = networkComms;
//			networkComms.StartWipeHostToolbar();
            modSystemRegistry.AddUpatableModSystem(researchHacking);
        }
Beispiel #11
0
 public override void AllGridsInitialised()
 {
     // log to remind that they are on..
     if (DebugConvoys)
     {
         ModLog.Info("Convoy Debug is ON");
     }
     if (ForceAirOnly)
     {
         ModLog.Info(" Force Air only is ON");
     }
     if (ForceGroundOnly)
     {
         ModLog.Info(" Force Ground only is ON");
     }
 }
Beispiel #12
0
        internal MissionSystem(int modBuildWhenLastSaved, Version gameVersion, long missionStartTimeBinary, HashSet <int> alreadyExecutedPrompts,
                               QueuedAudioSystem audioSystem, ResearchControl researchControl)
        {
            this.gameVersion           = gameVersion;
            this.audioSystem           = audioSystem;
            this.researchControl       = researchControl;
            this.modBuildWhenLastSaved = modBuildWhenLastSaved; //V27

            missionStartTime = DateTime.FromBinary(missionStartTimeBinary);
            excludedIDs      = alreadyExecutedPrompts;
            desiredEntityIDs = new HashSet <long>();
            GeneratePrompts();
            timeBasedPrompts.Sort((x, y) => - x.TriggerTime.CompareTo(y.TriggerTime));

//            ModLog.Info("Start Time = " + missionStartTime.ToString());
            ModLog.Info("Current Mission Length: " + (MyAPIGateway.Session.GameDateTime - missionStartTime).ToString(@"hh\:mm\:ss")); //V27
        }
Beispiel #13
0
 public override void AllGridsInitialised()
 {
     // log to remind that they are on..
     if (DebugConvoys)
     {
         ModLog.Info("Convoy Debug is ON");
         MyAPIGateway.Utilities.ShowNotification("Convoy Debug is ON", 5000, MyFontEnum.Red);
     }
     if (ForceAirOnly)
     {
         ModLog.Info(" Force Air only is ON");
         MyAPIGateway.Utilities.ShowNotification(" Force Air only is ON", 5000, MyFontEnum.Red);
     }
     if (ForceGroundOnly)
     {
         ModLog.Info(" Force Ground only is ON");
         MyAPIGateway.Utilities.ShowNotification("Force Ground only is ON", 5000, MyFontEnum.Red);
     }
 }
Beispiel #14
0
        private void NeedsResearch(MyDefinitionId techDef, TechGroup techgroup)
        {
            if (techDef == null)
            {
                ModLog.Info("Request for NULL techDef");
                return;
            }

            MyVisualScriptLogicProvider.ResearchListAddItem(techDef);

            HashSet <MyDefinitionId> techsInGroup;

            if (!techsForGroup.TryGetValue(techgroup, out techsInGroup))
            {
                techsInGroup = new HashSet <MyDefinitionId>();
                techsForGroup.Add(techgroup, techsInGroup);
            }
            techsInGroup.Add(techDef);
        }
        public override void GridInitialising(IMyCubeGrid grid)
        {
            // check all loading grids and check for research control

//            ModLog.Info("Checking grid: " + grid.CustomName);

            // TODO: Limit to certain owners?
            // TODO: prevent player from pasting or building and then game loading something with unlock codes.

            // find unlock points
            var slimBlocks = new List <IMySlimBlock>();

            // limit to PBs for now..  could do it from ANYTHING, really...
            grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyProgrammableBlock);
            foreach (var slim in slimBlocks)
            {
                var tb = slim.FatBlock as IMyTerminalBlock;

//                ModLog.Info("Checking PB:" + pb.CustomName);

                string data = tb.CustomData;
                if (data.Contains("[WICORESEARCH]"))
                {
                    int    techgroup     = -1;
                    double researchrange = 5;

                    Vector3D location = tb.GetPosition();
                    //                    ModLog.Info("Found our section");
                    // get an array of the all of lines
                    string[] aLines = data.Split('\n');

                    // walk through all of the lines
                    for (int iLine = 0; iLine < aLines.Count(); iLine++)
                    {
                        if (aLines[iLine].Contains("[WICORESEARCH]"))
                        {
                            //                          ModLog.Info("Found our section  2");
                            int foundCount = 0;
                            // we found our section
                            int iSectionLine = iLine + 1;
                            for (; iSectionLine < aLines.Count(); iSectionLine++)
                            {
                                if (aLines[iSectionLine].StartsWith("["))
                                {
                                    iSectionLine--;
                                    break;
                                }
                                string   sLine     = aLines[iSectionLine].Trim();
                                string[] aKeyValue = sLine.Split('=');
                                if (aKeyValue.Count() > 1)
                                {
                                    // key is 0 value is 1
                                    if (aKeyValue[0] == "Group")
                                    {
//                                        ModLog.Info("Found Group:"+aLines[iSectionLine]);
                                        int  iTest;
                                        bool bOK = int.TryParse(aKeyValue[1], out iTest);
                                        if (bOK)
                                        {
                                            techgroup = iTest;
                                            foundCount++;
                                        }
                                        else
                                        {
                                            ModLog.Info("group parse fail");
                                        }
                                    }
                                    if (aKeyValue[0] == "Range")
                                    {
                                        //                                        ModLog.Info("Found Group:"+aLines[iSectionLine]);
                                        double dTest;
                                        bool   bOK = double.TryParse(aKeyValue[1], out dTest);
                                        if (bOK)
                                        {
                                            researchrange = dTest;
                                        }
                                        else
                                        {
                                            ModLog.Info("group parse fail");
                                        }
                                    }
                                    if (aKeyValue[0] == "Location")
                                    {
                                        Vector3D testLocation;
                                        bool     bOK = Vector3D.TryParse(aKeyValue[1], out testLocation);
                                        if (bOK)
                                        {
                                            location = testLocation;
                                        }
                                        foundCount++;
                                    }
                                }
                            }
                            iLine = iSectionLine;
//                            ModLog.Info("Foundcount=" + foundCount.ToString());
                            if (foundCount > 0)
                            {
                                UnlockLocation ul = new UnlockLocation();
                                ul.location     = location;
                                ul.techGroup    = techgroup;
                                ul.unlockradius = researchrange;

//                                ModLog.Info("Adding research unlock from: " + pb.CustomName);
                                unlockLocationList.Add(ul);
                            }
                        }
                    }
                }
            }
        }
Beispiel #16
0
        internal override void Update()
        {
            CheckEscortsAlive();
            if (!leader.IsControlledByFaction("GCORP"))
            {
                GroupState = NpcGroupState.Disbanding;
                InitiateDisbandProtocols();
            }
            else if ((GroupState == NpcGroupState.Travelling || GroupState == NpcGroupState.InCombat) &&
                     Vector3D.DistanceSquared(Destination, leader.GetPosition()) < 300.0 * 300)    // increase to 300 to allow for variations in height. V26
//                     && Vector3D.DistanceSquared(Destination, leader.GetPosition()) < 200.0*200) // increase to 200 to allow for variations in height.
//                     && Vector3D.Distance(Destination, leader.GetPosition()) < 100.0)
            {
                string sBeacons    = "";
                var    slimBlocks2 = new List <IMySlimBlock>();
                leader.GetBlocks(slimBlocks2, b => b.FatBlock is IMyBeacon);
                foreach (var slim2 in slimBlocks2)
                {
                    var beacon = slim2.FatBlock as IMyBeacon;
                    sBeacons += beacon.CustomName;
                }

                ModLog.Info("Group Arrived at destination: " + leader.CustomName + " " + sBeacons);
                ArrivalObserver.GroupArrivedIntact();
                audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConvoyArrivedSafely);
                GroupState = NpcGroupState.Disbanding;
                InitiateDisbandProtocols();
                ResetBeaconNames();
            }

            // ModLogs are for DEBUG nav script
//            ModLog.Info("Convoy update:" + leader.CustomName+" ID:"+leader.EntityId.ToString() + " State:"+GroupState.ToString());
            if ((GroupState == NpcGroupState.Travelling))
            {
                var currentTime = MyAPIGateway.Session.GameDateTime;
                if (GroupSpawnTime + convoyInitiateTime < currentTime)
                {
                    leader.SetAllBeaconNames(null, 20000f);
                }
                bool bKeenAutopilotActive = false;
                var  slimBlocks           = new List <IMySlimBlock>();
                leader.GetBlocks(slimBlocks, b => b.FatBlock is IMyRemoteControl);
                IMyRemoteControl remoteControl = null;
                foreach (var slim in slimBlocks)
                {
                    remoteControl        = slim.FatBlock as IMyRemoteControl;
                    bKeenAutopilotActive = remoteControl.IsAutoPilotEnabled;
//                    ModLog.Info("Keen Autopilot:" + bKeenAutopilotActive.ToString());
                    break;
                }

                slimBlocks.Clear();
                leader.GetBlocks(slimBlocks, b => b.FatBlock is IMyProgrammableBlock);
                foreach (var slim in slimBlocks)
                {
                    var block = slim.FatBlock as IMyProgrammableBlock;
                    if (block == null)
                    {
                        continue;
                    }

                    if (block.CustomName.Contains("NAV"))
                    {
                        if (!bKeenAutopilotActive &&
                            GroupSpawnTime + convoyInitiateTime < currentTime    // delay check for mode change.
                            )
                        {
                            if (//!bKeenAutopilotActive &&
                                block.DetailedInfo.Contains("mode=0") || block.DetailedInfo.Contains("mode=-1"))
                            {
                                if (remoteControl == null)
                                {
                                    // nothing left to do.  Remove it (and try again)
                                    GroupState = NpcGroupState.Inactive; // this will cause NpcGroupManager to spawn a new convoy to replace this one.
                                    return;
                                }
                                // force it to use Keen Autopilot
                                remoteControl.ClearWaypoints();
                                remoteControl.AddWaypoint(Destination, "Target");
                                remoteControl.SpeedLimit = 10;
                                remoteControl.SetAutoPilotEnabled(true);

                                /*
                                 * // debug output
                                 * var slimBlocks2 = new List<IMySlimBlock>();
                                 * leader.GetBlocks(slimBlocks2, b => b.FatBlock is IMyBeacon);
                                 * string sBeacons = "";
                                 * foreach(var slim2 in slimBlocks2)
                                 * {
                                 *  var beacon = slim2.FatBlock as IMyBeacon;
                                 *  sBeacons += beacon.CustomName;
                                 * }
                                 *
                                 * // it didn't get the command!
                                 * //                                GroupState = NpcGroupState.Inactive; // this will cause NpcGroupManager to spawn a new convoy to replace this one.
                                 * ModLog.Info("Autopilot recovery because leader NAV not in correct mode: "+ sBeacons);
                                 */
                            }
                            break;
                        }
//                        ModLog.Info("PB:"+block.CustomName+"\n"+"DetailedInfo=:\n" + block.DetailedInfo);
                    }
                }

                // Following is just debug info

                /*
                 * leader.GetBlocks(slimBlocks, b => b.FatBlock is IMyGyro);
                 * foreach (var slim in slimBlocks)
                 * {
                 *  var block = slim.FatBlock as IMyGyro;
                 *  if (block!=null && block.CustomName.Contains("NAV"))
                 *  {
                 *      ModLog.Info("G:"+block.CustomName + "\n");
                 *  }
                 * }
                 */
            }

            if (GroupState == NpcGroupState.Disbanding)
            {
                AttemptDespawning();
                return;
            }

            if (DuckUtils.IsAnyPlayerNearPosition(leader.GetPosition(), 1000) && GroupState == NpcGroupState.Travelling)
            {
                GroupState = NpcGroupState.InCombat;
                InitiateAttackProtocols();
            }

            if (GroupState == NpcGroupState.InCombat)
            {
                var player = DuckUtils.GetNearestPlayerToPosition(leader.GetPosition(), 4000);
                if (player == null)
                {
                    GroupState = NpcGroupState.Travelling;       // Return to normal, cowardly players have run off or died
                    ResetBeaconNames();
                    if (escortDic.Count > 0)                     //todo maybe check if the escorts are actually alive? Dunno if doing this already
                    {
                        audioSystem.PlayAudio(AudioClip.DisengagingFromHostile, AudioClip.TargetLost);
                    }
                    else
                    {
                        audioSystem.PlayAudio(AudioClip.PursuitEvaded, AudioClip.SensorsLostTrack);
                    }
                }
                else
                {
                    SendArmedEscortsNearPosition(player.GetPosition());                     // Use same position as when escorting, to avoid collisions
                }
            }

            if (GroupState == NpcGroupState.Travelling)
            {
                foreach (var entry in escortDic)
                {
                    SendEscortToGrid(entry.Key, entry.Value, leader);
                }
            }
        }
Beispiel #17
0
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            string sInit = "Initialising Escape From Mars build " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);

            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 (!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)
            {
                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;
        }
Beispiel #18
0
        private static void SetDestination(IMyCubeGrid grid, Vector3D destination)
        {
            bool bOldNav = false; // true=old way of NAV, false= new way
            // old= set gyro customname to NAV:
            // new = run PB directly with argument

            bool bKeenAutopilot = false; // force using keen autopilot

            if (ConvoySpeed != 10f)
            {
                ModLog.Info("Using test convoy speed of " + ConvoySpeed.ToString());
            }

            var slimBlocks = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyProgrammableBlock);
            IMyProgrammableBlock NavPB = null;

            foreach (var slim in slimBlocks)
            {
                //                var block = slim.FatBlock as IMyGyro;
                var block = slim.FatBlock as IMyProgrammableBlock;
                //                    ModLog.Info(" Found PB:" + block.CustomName);
                if (block.CustomName.Contains("NAV"))
                {
                    if (block.CustomData.Contains("Assembly not found."))
                    {
                        ModLog.Info("NAV computer not compiling:" + grid.CustomName);
                        continue;
                    }
                    NavPB = block as IMyProgrammableBlock;
                }
            }
            //            ModLog.Info("Set Destinatiion of:" + grid.CustomName);

            // C <comment>
            // S <max speed>
            // D <arrival distance>
            // W x:y:z
            // W <GPS>
            // set destination
            //                block.CustomName = "NAV: C STARTED_DELIVERY; S 80; D 80 ; W " + destination.X + ":" + destination.Y + ":" + destination.Z;
            //                ModLog.Info("Set Waypoint to: " + block.CustomName);
            string sCommand = "S " + ConvoySpeed.ToString("0") + "; D 80; W " + destination.X + ":" + destination.Y + ":" + destination.Z;


            if (!bOldNav && !bKeenAutopilot && NavPB != null)
            { // new way & not override keen autopilot and we found working nav pb
                // V31 Change to calling Nav module directly
                NavPB.Run(sCommand);
                bKeenAutopilot = false;
            }
            else if (!bKeenAutopilot && NavPB != null)
            { // old way and we found working nav PB
                bool bFound = false;

                slimBlocks.Clear();
                grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyGyro);
                foreach (var slim in slimBlocks)
                {
                    var block = slim.FatBlock as IMyGyro;
                    // using STARTED_DELIVERY as a way to find our grids! For autopilot it's a harmless comment.
                    // NOTE: comment is not correct: it's not used as a way to find our grids

                    // C <comment>
                    // S <max speed>
                    // D <arrival distance>
                    // W x:y:z
                    // W <GPS>
                    // set destination

                    block.CustomName = "NAV: " + sCommand;// C STARTED_DELIVERY; S 80; D 80 ; W " + destination.X + ":" + destination.Y + ":" + destination.Z;
                    ModLog.Info("oldnav. Setting Destination for:" + grid.CustomName + " to:" + block.CustomName);
                    //                ModLog.Info("Set Waypoint to: " + block.CustomName);
                    bFound = true;
                    break;
                }
                if (!bFound)
                {
                    ModLog.Info("No Gyro Found! Defaulting to Keen Autopilot. " + grid.CustomName);
                    bKeenAutopilot = true;
                }
            }
            if (bKeenAutopilot || NavPB == null)
            { // force keen autopilot or didn't find working nav pb
                grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyRemoteControl);
                foreach (var slim in slimBlocks)
                {
                    var remoteControl = slim.FatBlock as IMyRemoteControl;
                    remoteControl.ClearWaypoints();
                    remoteControl.AddWaypoint(destination, "Target");
                    remoteControl.SpeedLimit = ConvoySpeed;
                    remoteControl.SetAutoPilotEnabled(true);
                }
                // throw exception if no remote found? (change to Inactive state...)
            }
        }
Beispiel #19
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";
                    }

                    grid.SetAllBeaconNames(sPrefix + random.Next(10000, 99999) + " - " + cargoType.GetDisplayName() + " Shipment",
                                           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) + " Investigating Backup Call";
//                        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();
            }
        }
Beispiel #20
0
        private void OfferPotentialNpcShip(IMyCubeGrid grid)
        {
            //            ModLog.Info("Potentential NPC:" + grid.CustomName);
            NpcGroupSaveData npcGroupSaveData;

            if (restoredNpcGroupData.TryGetValue(grid.EntityId, out npcGroupSaveData))
            {
                //                ModLog.Info(" Potentential NPC: Found in restored NPC Group data:" + npcGroupSaveData.NpcGroupType.ToString() + " Type="+ npcGroupSaveData.LeaderUnitType.ToString());
                if (npcGroupSaveData.NpcGroupType == NpcGroupType.Backup)
                {
                    npcGroups.Add(new BackupGroup(npcGroupSaveData.State, npcGroupSaveData.GroupDestination,
                                                  grid, heatSystem, audioSystem, DateTime.FromBinary(npcGroupSaveData.SpawnTime)));
                }
                else // Must be convoy
                {
                    if (modBuildWhenLastSaved > 30 || !bInitialInit)
                    {
                        restoredConvoys.Add(grid.EntityId,
                                            RegisterConvoy(grid, npcGroupSaveData.State, npcGroupSaveData.LeaderUnitType,
                                                           npcGroupSaveData.GroupDestination, DateTime.FromBinary(npcGroupSaveData.SpawnTime)));
                    }
                    else
                    {
                        // else old drones with scripts that don't work on 1.193.100

                        if (grid.IsControlledByFaction("GCORP")) // see npcgroup.AttemptDespawn()
                        {
                            ModLog.Info("save build#:" + modBuildWhenLastSaved.ToString() + " Initial=" + bInitialInit.ToString());
                            ModLog.Info("Removing dead drone Grid:" + grid.CustomName);
                            bOldRemovals = true;
                            grid.CloseAll();
                        }
                    }
                }
            }
            else
            {
                //                ModLog.Info(" Potentential NPC: NOT in restored NPC Group data:" + grid.CustomName);
                if (modBuildWhenLastSaved > 30 || !bInitialInit)
                {
                    possibleEscorts.Add(grid);
                }
                else
                {
                    // Need better discernment to not delete placed G-Corp grids like G-Corp AP Turret and GCorp Experimental Mech
                    if (grid.IsControlledByFaction("GCORP")) // see npcgroup.AttemptDespawn()
                    {
                        var slimBlocks = new List <IMySlimBlock>();
                        grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyBeacon);
                        foreach (var slim in slimBlocks)
                        {
                            var fb = slim.FatBlock as IMyBeacon;
                            if (fb.CustomName.Contains(EscortName))
                            {
                                ModLog.Info("Removing dead escort drone Grid:" + grid.CustomName);
                                bOldRemovals = true;
                                grid.CloseAll();
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #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;
        }
Beispiel #22
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;
                }
            }
        }
Beispiel #23
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)
        {
            // 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 LCD blocks with show on hud // V27
            var slimBlocksT = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocksT, b => b.FatBlock is IMyTextPanel);
            foreach (var slim in slimBlocksT)
            {
                var textPanel = slim.FatBlock as IMyTextPanel;
                textPanel.ShowOnHUD = false;
            }

            // fix up the beacon blocks  // V26
            var slimBlocksB = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocksB, b => b.FatBlock is IMyBeacon);
            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");
                }
            }

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

            grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyTextPanel);
            foreach (var slim in slimBlocks)
            {
                var textPanel = slim.FatBlock as IMyTextPanel;
                //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)
                {
                    // We've already set this up once before (or world was created post 1.189

                    /* Try to fix text not showing on text panels
                     *
                     * (on further testing, panels are showing.. maybe Keen fixed this themselves?)
                     *
                     * Saw on Rity's stream that they were NOT showing in all places.
                     * And on EpikTek's https://www.youtube.com/watch?v=CkpGGPZd78k
                     * */
//                    textPanel.SetValue("ShowTextOnScreen", false);
//                    textPanel.SetValue("ShowTextOnScreen", true);
                    //                      textPanel.SetShowOnScreen(VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.PUBLIC);


                    // Could set text of text panels here to be language specific
                    //                  switch (textPanel.EntityId)
                    {
                        //Crashed Shuttle:92770753627258475
                        //{ X: 1868088.00058876 Y: -2003485.99356789 Z: 1316645.85240929}

                        /* Example of setting text:
                         * case 121786820996539580: //TEXT!
                         *  textPanel.WritePublicText(
                         *      "OUTGOING TRANSMISSION\n"
                         + "ERROR: FAILED TO SEND\n"
                         + "\n"
                         + "M,\n"
                         + "I'm going to Mars to talk to\n"
                         + "he CEO about what that\n"
                         + "weasel Bhaskar has been up to.\n"
                         + "I think we can trust him.\n"
                         + "                                \n"
                         + "-T\n"
                         +  );
                         +  break;
                         */
                    }
                }
// 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;
                            textPanel.TextPadding = 20f;         // 20%
                            textPanel.WriteText("TOOLS LOCKER"); // remove left padding from text
                            break;

                        case 143319951822334717:     //143319951822334717:TEXT!                                SPARE PARTS STORAGE
                            textPanel.FontSize    = 5;
                            textPanel.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
                            textPanel.TextPadding = 20f;     // 20%
//                                textPanel.WriteText("SPARE PARTS STORAGE");
                            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;
                        }
                    }
                }
            }

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

            grid.GetBlocks(slimBlocks2, b => b.FatBlock is IMySoundBlock);
            foreach (var slim in slimBlocks2)
            {
                var soundBlock = slim.FatBlock as IMySoundBlock; // Fixed V21
//                if (soundBlock == null) continue; // why do we need this?
                switch (soundBlock.EntityId)
                {
                // air base alpha:
                case 116378614635193269:
                    soundBlock.SelectedSound = "WelcomeToGcorp";
                    break;

                // ice mine entrance
                case 101979433782763108:
                    soundBlock.SelectedSound = "NotAuthorisedDeployDefences";
                    break;

                // ice mine shaft botom
                case 106640376870960334:
                    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:
                    soundBlock.SelectedSound = "FlightResearchExhibition";
                    break;

                // air base beta
                case 130193226083241264:
                    soundBlock.SelectedSound = "WelcomeToGcorp";
                    break;

                // mech
                case 82762879450865423:
                    //            bodyGrid.SetSoundBlocks("Mech Intruders Must Be Destroyed"); // fix missing sound on sound block on mech
                    soundBlock.SelectedSound = "IntruderRobot";
                    break;

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

                case 82604291774017685:
                    soundBlock.SelectedSound = "WelcomeToGcorp";
                    break;

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

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