private unsafe static bool Prefix(int message_id, IntPtr data)
        {
            SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                                  message_id, data);

            switch (message_id)
            {
            case 1:
            {
                Sim.DLLReportMessageMessage *ptr2 = (Sim.DLLReportMessageMessage *)(void *) data;
                string msg         = "SimMessage: " + Marshal.PtrToStringAnsi(ptr2->message);
                string arg         = Marshal.PtrToStringAnsi(ptr2->file);
                int    line        = ptr2->line;
                string stack_trace = arg + ":" + line;
                Debug.Log(msg);
                Debug.Log(stack_trace);
                break;
            }

            case 0:
            {
                Sim.DLLExceptionHandlerMessage *ptr = (Sim.DLLExceptionHandlerMessage *)(void *) data;
                string text         = Marshal.PtrToStringAnsi(ptr->callstack);
                string dmp_filename = Marshal.PtrToStringAnsi(ptr->dmpFilename);
                Debug.Log(text);
                Debug.Log(dmp_filename);
                break;
            }

            default:
                break;
            }
            return(true);
        }
 private static bool Prefix(Extents extents, float mass, float temperature, float thermal_conductivity, float operating_kw, byte elem_idx, int callbackIdx)
 {
     //Debug.Log(" === SimMessages_AddBuildingHeatExchange === " + temperature);
     //Debug.Log(" === SimMessages_AddBuildingHeatExchange === " + operating_kw);
     //Debug.Log(" === SimMessages_AddBuildingHeatExchange === " + callbackIdx);
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           extents, mass, temperature, thermal_conductivity, operating_kw, elem_idx, callbackIdx);
     return(true);
 }
 private static bool Prefix(int gameCell, SimHashes element, float mass, byte radius, int callbackIdx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, element, mass, radius, callbackIdx);
     if (Grid.IsValidCell(gameCell))
     {
         Vector2I v = Grid.CellToXY(gameCell);
         Debug.Log("(" + v.x + "," + v.y + ")");
     }
     return(true);
 }
        private static void Postfix(CellSelectionObject __instance)
        {
            SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                                  __instance);

            FieldInfo fi = AccessTools.Field(typeof(CellSelectionObject), "selectedCell");

            if (Grid.IsValidCell((int)fi.GetValue(__instance)))
            {
                //__instance.Mass = Grid.Mass[(int)fi.GetValue(__instance)];
                __instance.ElementName = __instance.ElementName + " " + (int)fi.GetValue(__instance);
            }
        }
 private static bool Prefix(int gameCell, float value)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, value);
     return(true);
 }
 private static bool Prefix(int sim_handle, float temperature, float heat_capacity)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, temperature, heat_capacity);
     return(true);
 }
 private static bool Prefix(int gameCell, byte properties)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, properties);
     return(true);
 }
 private static bool Prefix(int cb_handle, int sim_handle)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           cb_handle, sim_handle);
     return(true);
 }
 private static bool Prefix(float elapsed_seconds, Vector2I min, Vector2I max)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           elapsed_seconds, min, max);
     return(true);
 }
 private static bool Prefix(int sim_handle, float delta_kj, float min_temperature, float max_temperature)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, delta_kj, min_temperature, max_temperature);
     return(true);
 }
 private static bool Prefix(int gameCell, byte element_idx, float mass, float temperature, byte disease_idx, int disease_count, int callbackIdx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, element_idx, mass, temperature, disease_idx, disease_count, callbackIdx);
     return(true);
 }
 private static bool Prefix(int gameCell, int callbackIdx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, callbackIdx);
     return(true);
 }
 private static bool Prefix(List <string> diseaseIds)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           diseaseIds);
     return(true);
 }
 private static bool Prefix(List <Element> elements)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           elements);
     return(true);
 }
 private static bool Prefix(ElementInteraction[] interactions)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           interactions);
     return(true);
 }
 private static bool Prefix(int gameCell, float kilojoules, float max_temperature, EnergySourceID id)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, kilojoules, max_temperature, id);
     return(true);
 }
 private static bool Prefix(int gameCell, float mass, byte disease_idx, int disease_count, CellModifyMassEvent ev, float temperature, SimHashes element)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, mass, disease_idx, disease_count, ev, temperature, element);
     return(true);
 }
 private static bool Prefix(int sim_handle, Extents extents, float mass, float temperature, float thermal_conductivity, float overheat_temperature, float operating_kw, byte element_idx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, extents, mass, temperature, thermal_conductivity, overheat_temperature, operating_kw, element_idx);
     return(true);
 }
 private static bool Prefix(SimMessageHashes sim_msg_id, int msg_length, byte[] msg)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_msg_id, msg_length, msg);
     return(true);
 }
 private static bool Prefix(int gameCell, int elementIdx, float temperature, float mass, byte disease_idx, int disease_count, ReplaceType replace_type, bool do_vertical_solid_displacement, int callbackIdx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, elementIdx, temperature, mass, disease_idx, disease_count, replace_type, do_vertical_solid_displacement, callbackIdx);
     return(true);
 }
 private static bool Prefix(int gameCell, SimHashes new_element, CellElementEvent ev, float mass, float temperature, byte diseaseIdx, int diseaseCount, int callbackIdx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, new_element, ev, mass, temperature, diseaseIdx, diseaseCount, callbackIdx);
     return(true);
 }
 private static bool Prefix(int cell, byte zone_id)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           cell, zone_id);
     return(true);
 }
 private static bool Prefix(Sim.DebugProperties properties)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           properties);
     return(true);
 }
 private static bool Prefix(int sim_handle, int cell, byte range, byte disease_idx, float emit_interval, int emit_count)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, cell, range, disease_idx, emit_interval, emit_count);
     return(true);
 }
 private static bool Prefix(int sim_handle, int cell, float consumptionRate)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, cell, consumptionRate);
     return(true);
 }
 private static bool Prefix(int gameCell, byte disease_idx, int disease_count)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, disease_idx, disease_count);
     return(true);
 }
 private static bool Prefix(int gameCell, int weight, float strengthMultiplier)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, weight, strengthMultiplier);
     return(true);
 }
 private static bool Prefix(int sim_handle, float delta_kj)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, delta_kj);
     return(true);
 }
 private static bool Prefix(int width, int height, Sim.Cell[] cells, float[] bgTemp, Sim.DiseaseCell[] dc)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           width, height, cells, bgTemp, dc);
     return(true);
 }
 private static bool Prefix(int sim_handle, int game_cell, int max_depth, SimHashes element, float emit_interval, float emit_mass, float emit_temperature, float max_pressure, byte disease_idx, int disease_count)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           sim_handle, game_cell, max_depth, element, emit_interval, emit_mass, emit_temperature, max_pressure, disease_idx, disease_count);
     return(true);
 }