Example #1
0
        public static Assembly LoadPlugingWithSymbols(string dllPath)
        {
            try {
                Assembly assembly;
                string   symPath = dllPath + ".mdb";
                if (File.Exists(symPath))
                {
                    CODebugBase <InternalLogChannel> .Log(InternalLogChannel.Mods, "Loading " + dllPath + "\nSymbols " + symPath);

                    assembly = Assembly.Load(File.ReadAllBytes(dllPath), File.ReadAllBytes(symPath));
                }
                else
                {
                    CODebugBase <InternalLogChannel> .Log(InternalLogChannel.Mods, "Loading " + dllPath);

                    assembly = Assembly.Load(File.ReadAllBytes(dllPath));
                }
                if (assembly != null)
                {
                    CODebugBase <InternalLogChannel> .Log(InternalLogChannel.Mods, "Assembly " + assembly.FullName + " loaded.");
                }
                else
                {
                    CODebugBase <InternalLogChannel> .Error(InternalLogChannel.Mods, "Assembly at " + dllPath + " failed to load.");
                }
                return(assembly);
            } catch (Exception ex) {
                CODebugBase <InternalLogChannel> .Error(InternalLogChannel.Mods, "Assembly at " + dllPath + " failed to load.\n" + ex.ToString());

                return(null);
            }
        }
Example #2
0
        public static void Generic(PluginManager.MessageType messageType, string text)
        {
            var msg = FormatMessage(messageType, text);

//      DebugOutputPanel.AddMessage(messageType, msg);

            CODebugBase <LogChannel> .Log(LogChannel.Modding, msg);
        }
        public new bool UnlockArea(int index)
        {
            _unlockingField.SetValue(this, true);
            try
            {
                //begin mod
                int x1 = index % GRID;
                int z  = index / GRID;
                //end mod
                if (this.CanUnlock(x1, z))
                {
                    this.m_areaNotUnlocked.Deactivate();
                    CODebugBase <LogChannel> .Log(LogChannel.Core, "Unlocking new area");

                    this.m_areaGrid[index] = ++this.m_areaCount;
                    _areasUpdatedField.SetValue(this, true);
                    //begin mod
                    if (this.m_areaCount == 9)
                    {
                        //end mod
                        ThreadHelper.dispatcher.Dispatch((System.Action)(() =>
                        {
                            if (PlatformService.achievements["SIMulatedCity"].achieved)
                            {
                                return;
                            }
                            PlatformService.achievements["SIMulatedCity"].Unlock();
                        }));
                    }
                    //begin mod
                    float x2 = (float)(((double)x1 - HALFGRID) * 1920.0);
                    float x3 = (float)(((double)(x1 + 1) - HALFGRID) * 1920.0);
                    float y1 = (float)(((double)z - HALFGRID) * 1920.0);
                    float y2 = (float)(((double)(z + 1) - HALFGRID) * 1920.0);
                    //end mod
                    Singleton <ZoneManager> .instance.UpdateBlocks(new Quad2(new Vector2(x2, y1), new Vector2(x2, y2), new Vector2(x3, y2), new Vector2(x3, y1)));


                    if (Singleton <TerrainManager> .instance.SetDetailedPatch(x1, z))
                    {
                        Singleton <MessageManager> .instance.TryCreateMessage(this.m_properties.m_unlockMessage, Singleton <MessageManager> .instance.GetRandomResidentID());

                        //begin mod
                        //end mod
                        return(true);
                    }
                    --this.m_areaCount;
                    this.m_areaGrid[index] = 0;

                    _areasUpdatedField.SetValue(this, true);
                }
                return(false);
            }
            finally
            {
                _unlockingField.SetValue(this, false);
            }
        }
Example #4
0
        private static void OnSaveData()
        {
            FastList <byte> data = new FastList <byte>();

            try
            {
                SerializableDataExtension.WriteString(TransportLineMod._dataVersion, data);
                for (ushort lineID = 0; (int)lineID < 256; ++lineID)
                {
                    SerializableDataExtension.AddToData(
                        BitConverter.GetBytes(TransportLineMod.GetTargetVehicleCount(lineID)), data);
                    SerializableDataExtension.AddToData(
                        BitConverter.GetBytes(Mathf.Max(
                                                  TransportLineMod.GetNextSpawnTime(lineID) - SimHelper.SimulationTime, 0.0f)),
                        data);
                    SerializableDataExtension.AddToData(
                        BitConverter.GetBytes(TransportLineMod.GetBudgetControlState(lineID)), data);
                    SerializableDataExtension.AddToData(BitConverter.GetBytes(TransportLineMod.GetDepot(lineID)), data);
                    int num = 0;
                    HashSet <string> prefabs = TransportLineMod.GetPrefabs(lineID);
                    if (prefabs != null)
                    {
                        num = prefabs.Count;
                    }
                    SerializableDataExtension.AddToData(BitConverter.GetBytes(num), data);
                    if (num > 0)
                    {
                        foreach (string s in prefabs)
                        {
                            SerializableDataExtension.WriteString(s, data);
                        }
                    }
                    string[] enqueuedVehicles = TransportLineMod.GetEnqueuedVehicles(lineID);
                    SerializableDataExtension.AddToData(BitConverter.GetBytes(enqueuedVehicles.Length), data);
                    if (enqueuedVehicles.Length != 0)
                    {
                        foreach (string s in enqueuedVehicles)
                        {
                            SerializableDataExtension.WriteString(s, data);
                        }
                    }
                    SerializableDataExtension.WriteBool(TransportLineMod.GetUnbunchingState(lineID), data);
                }
                SerializableDataExtension.instance.SerializableData.SaveData(TransportLineMod._dataID, data.ToArray());
            }
            catch (Exception ex)
            {
                string msg = "Error while saving transport line data! " + ex.Message + " " + (object)ex.InnerException;
                Utils.LogError((object)msg);
                CODebugBase <LogChannel> .Log(LogChannel.Modding, msg, ErrorLevel.Error);
            }
        }
Example #5
0
        public static void Generic(ErrorLevel errorLevel, string text)
        {
            var msg = $"[ToggleTrafficLights] {text}";

            CODebugBase <LogChannel> .Log(LogChannel.Modding, msg, errorLevel);
        }
Example #6
0
        private static void Awake()
        {
            if (Mod.DEBUG_LOG_ON)
            {
                Helper.dbgLog("I never ever fire. " + DateTime.Now.ToString());
            }
            UIView.eventExceptionForwarded += new UIView.ForwardExceptionHandler(OnExceptionForwarded);
            try
            {
                string sc = "colossal";
                string ft = "firstTime";
                sc = (string)typeof(Settings).GetField("colossal", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(sc);
                ft = (string)typeof(Settings).GetField("firstTime", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(ft);
                GameSettings.AddSettingsFile(new SettingsFile[]
                {
                    new SettingsFile
                    {
                        systemFileName = sc
                    }
                });
                SavedBool savedBool = new SavedBool(ft, sc, true);
                CODebugBase <LogChannel> .Log(LogChannel.Core, "Telemetry enabled");

                TelemetryKH telemetry = new TelemetryKH();
                if (savedBool)
                {
                    telemetry.AddEvent(Telemetry.Event.FirstLaunch, new Telemetry.Pair[0]);
                    savedBool.value = false;
                }

                if (Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableAll) == false |
                    Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableOnAppStart) == false)
                {
                    telemetry.AddEvent(Telemetry.Event.StartGame, new Telemetry.Pair[0]);
                }


                if (Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableAll) == false |
                    Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableMachineInfo) == false)
                {
                    telemetry.AddEvent(Telemetry.Event.Meta, new Telemetry.Pair[]
                    {
                        new Telemetry.Pair("machineid", SystemInfo.deviceUniqueIdentifier),
                        new Telemetry.Pair("machinemodel", SystemInfo.deviceModel),
                        new Telemetry.Pair("gfxdevice", SystemInfo.graphicsDeviceName),
                        new Telemetry.Pair("gfxversion", SystemInfo.graphicsDeviceVersion),
                        new Telemetry.Pair("gfxmemory", SystemInfo.graphicsMemorySize),
                        new Telemetry.Pair("gfxshadermodel", SystemInfo.graphicsShaderLevel),
                        new Telemetry.Pair("os", SystemInfo.operatingSystem),
                        new Telemetry.Pair("oslanguage", Application.systemLanguage),
                        new Telemetry.Pair("cpu", SystemInfo.processorType),
                        new Telemetry.Pair("cpucount", SystemInfo.processorCount),
                        new Telemetry.Pair("sysmemory", SystemInfo.systemMemorySize)
                    });
                }
                if (Mod.DEBUG_LOG_ON)
                {
                    Helper.dbgLog("TMKH Awake doing startup push");
                }
                telemetry.Push();
            }
            catch (GameSettingsException ex)
            {
                CODebugBase <LogChannel> .Warn(LogChannel.HTTP, ex.GetType() + ": Game Settings error " + ex.Message);
            }
            catch (Exception ex2)
            {
                CODebugBase <LogChannel> .Warn(LogChannel.HTTP, ex2.GetType() + ": Telemetry event failed " + ex2.Message);
            }
        }