public static void ReloadTankDefs() { tankTypes.Clear(); // Structural tank type is hard coded tankTypes.Add(structuralTankName, StructuralTankType); foreach (var node in GameDatabase.Instance.GetConfigNodes("B9_TANK_TYPE")) { TankType t = new TankType(); OperationContext context = new OperationContext(Operation.LoadPrefab, t); try { t.Load(node, context); } catch (Exception ex) { Exception ex2 = new Exception($"Fatal exception while loading tank type {t.tankName ?? "<unknown>"}", ex); FatalErrorHandler.HandleFatalError(ex2); throw ex2; } if (tankTypes.ContainsKey(t.tankName)) { Log.error("B9TankSettings: The tank type {0} already exists", t.tankName); continue; } tankTypes.Add(t.tankName, t); Log.info("B9TankSettings: registered tank type {0}", t.tankName); } LoadedTankDefs = true; }
public static void Spawn(ModuleB9PartSwitch module) { try { MaybeCreateResourceRemovalWarning(module, () => CreateDialogue(module)); } catch (Exception ex) { Log.error(ex, ex.Message); FatalErrorHandler.HandleFatalError(ex); } }
public static void Spawn(ModuleB9PartSwitch module) { try { MaybeCreateResourceRemovalWarning(module, () => CreateDialogue(module)); } catch (Exception ex) { UnityEngine.Debug.LogException(ex); FatalErrorHandler.HandleFatalError(ex); } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (!moduleID.IsNullOrEmpty() && node.HasValue(nameof(moduleID))) { string newID = node.GetValue(nameof(moduleID)); if (!string.Equals(moduleID, newID)) { var correctModule = part.Modules.OfType <CustomPartModule>().FirstOrDefault(m => m != this && m.GetType() == this.GetType() && m.moduleID == newID); if (correctModule.IsNotNull()) { LogWarning("OnLoad was called with the wrong ModuleID ('" + newID + "'), but found the correct module to load"); correctModule.Load(node); } else { LogError("OnLoad was called with the wrong ModuleID and the correct module could not be found"); } return; } } bool loadingPrefab = part.partInfo.IsNull() || node.name == CURRENT_UPGRADE; Operation operation = loadingPrefab ? Operation.LoadPrefab : Operation.LoadInstance; OperationContext context = new OperationContext(operation, this); try { this.LoadFields(node, context); } catch (Exception ex) { Exception ex2 = new Exception($"Fatal exception while loading fields on module {this}", ex); FatalErrorHandler.HandleFatalError(ex2); throw ex2; } if (loadingPrefab) { OnLoadPrefab(node); } else { OnLoadInstance(node); } }
public override void OnSave(ConfigNode node) { base.OnSave(node); OperationContext context = new OperationContext(Operation.Save, this); try { this.SaveFields(node, context); } catch (Exception ex) { Exception ex2 = new Exception($"Fatal exception while saving fields on module {this}", ex); FatalErrorHandler.HandleFatalError(ex2); throw ex2; } }