Example #1
0
 public static void Warning(String message)
 {
     try {
         DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Warning, prefix + message);
         if (inFile)
         {
             ChirpLog.Warning(prefix + message);
         }
     } catch (Exception e) {
         ChirpLog.Error("Error during Console.Warning: " + e);
     }
 }
Example #2
0
        public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            if (_terminated)
            {
                return;
            }

            try
            {
                if (!_initialized)
                {
                    if (!IsOverwatched())
                    {
                        ChirpLogger.ChirpLog.Error("Skylines Overwatch not found. Terminating...");
                        ChirpLog.Flush();
                        _terminated = true;

                        return;
                    }
                    SkylinesOverwatch.Settings.Instance.Enable.BuildingMonitor = true;
                    SkylinesOverwatch.Settings.Instance.Enable.HumanMonitor    = true;
                    SkylinesOverwatch.Settings.Instance.Enable.Residents       = true;
                    // TODO: Is this needed ?
                    SkylinesOverwatch.Settings.Instance.Debug.HumanMonitor = true;

                    _initialized = true;
                }
                else
                {
                    ProcessHumansUpdated();
                }
            }
            catch (Exception e)
            {
                string error = "Failed to initialize\r\n";
                error += String.Format("Error: {0}\r\n", e.Message);
                error += "\r\n";
                error += "==== STACK TRACE ====\r\n";
                error += e.StackTrace;

                ChirpLog.Error(error);
                ChirpLog.Flush();

                _terminated = true;
            }

            base.OnUpdate(realTimeDelta, simulationTimeDelta);
        }
Example #3
0
        public static void SetFieldValue(MonoBehaviour monoObject, string fieldName, object value)
        {
            try
            {
                BindingFlags bindingFlags = BindingFlags.Public |
                                            BindingFlags.NonPublic |
                                            BindingFlags.Instance |
                                            BindingFlags.Static;

                FieldInfo fieldInfo = monoObject.GetType().GetField(fieldName, bindingFlags);
                fieldInfo.SetValue(monoObject, value);
            }
            catch (Exception e)
            {
                ChirpLog.Error("Unable to set value:" + monoObject.GetType().Name + ":" + fieldName + ":" + e.Message);
                ChirpLog.Flush();
            }
        }
Example #4
0
        public static object CallMethod(MonoBehaviour monoObject, string methodName, object[] value = null)
        {
            object returnValue = null;

            try
            {
                MethodInfo[] methods = monoObject.GetType().GetMethods();
                foreach (MethodInfo info in methods)
                {
                    if (info.Name == methodName)
                    {
                        returnValue = info.Invoke(monoObject, value); // [2]
                    }
                }
                return(returnValue);
            }
            catch (Exception e)
            {
                ChirpLog.Error("Unable to Call Method: " + monoObject.GetType().Name + ":" + methodName + ":" + e.Message);
                ChirpLog.Flush();
                return(returnValue);
            }
        }