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; }
private void OnLoad(ConfigNode node, OperationContext context) { if (Name.IsNullOrEmpty()) { throw new Exception("Subtype has no name"); } if (tankType == null) { tankType = B9TankSettings.StructuralTankType; } if (context.Operation == Operation.LoadPrefab) { if (title.IsNullOrEmpty()) { title = subtypeName; } ConfigNode[] resourceNodes = node.GetNodes("RESOURCE"); if (resourceNodes.Length > 0) { LoadAdditionalResources(resourceNodes, context); } } }
public void AssignStructuralTankType() { if (!tankType.IsStructuralTankType) { tankType = B9TankSettings.StructuralTankType; } }
private void OnLoad(ConfigNode node, OperationContext context) { if (Name.IsNullOrEmpty()) { SeriousWarningHandler.DisplaySeriousWarning($"Subtype has no name: {this}"); LogError("Subtype has no name"); } if (tankType == null) { tankType = B9TankSettings.StructuralTankType; } if (context.Operation == Operation.LoadPrefab) { if (title.IsNullOrEmpty()) { title = subtypeName; } ConfigNode[] resourceNodes = node.GetNodes("RESOURCE"); if (resourceNodes.Length > 0) { LoadAdditionalResources(resourceNodes, context); } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (tankType == null) { tankType = B9TankSettings.StructuralTankType; } if (string.IsNullOrEmpty(title)) { title = subtypeName; } }
private void OnLoad(ConfigNode node, OperationContext context) { if (Name.IsNullOrEmpty()) { SeriousWarningHandler.DisplaySeriousWarning($"Subtype has no name: {this}"); LogError("Subtype has no name"); } if (HasUpgradeRequired && PartUpgradeManager.Handler.GetUpgrade(upgradeRequired).IsNull()) { SeriousWarningHandler.DisplaySeriousWarning($"Upgrade does not exist: {upgradeRequired} on: {this}"); LogError("Upgrade does not exist: " + upgradeRequired); upgradeRequired = null; } if (tankType == null) { tankType = B9TankSettings.StructuralTankType; } if (mirrorSymmetrySubtype == null) { mirrorSymmetrySubtype = Name; } if (context.Operation == Operation.LoadPrefab) { if (title.IsNullOrEmpty()) { title = subtypeName; } ConfigNode[] resourceNodes = node.GetNodes("RESOURCE"); if (resourceNodes.Length > 0) { LoadAdditionalResources(resourceNodes, context); } } }
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(); t.Load(node); if (tankTypes.ContainsKey(t.tankName)) { Debug.LogError($"B9TankSettings: The tank type {t.tankName} already exists"); continue; } tankTypes.Add(t.tankName, t); Debug.Log($"B9TankSettings: registered tank type {t.tankName}"); } LoadedTankDefs = true; }
public static void ReloadTankDefs() { tankTypes.Clear(); // Structural tank type is hard coded tankTypes.Add(StructuralTankType.tankName, StructuralTankType); ConfigNode[] nodes = GameDatabase.Instance.GetConfigNodes("B9_TANK_TYPE"); for (int i = 0; i < nodes.Length; i++) { TankType t = new TankType(); t.Load(nodes[i]); if (tankTypes.ContainsKey(t.tankName)) { Debug.LogError("The tank type " + t.tankName + " already exists"); continue; } tankTypes.Add(t.tankName, t); Debug.Log("B9TankSettings: registered tank type " + t.tankName); } LoadedTankDefs = true; }
private void SetupSubtypes() { managedResourceNames = new List <string>(); managedTransformNames = new List <string>(); managedStackNodeIDs = new List <string>(); foreach (var subtype in subtypes) { subtype.Setup(this); TankType tank = subtype.tankType; if (tank == null) { LogError($"Tank is null on subtype {subtype.Name}"); } if (tank.ResourcesCount > 0 && (subtype.TotalVolume <= 0f)) { LogError($"Subtype {subtype.Name} has a tank type with resources, but no volume is specifified"); subtype.tankType = tank = B9TankSettings.StructuralTankType; } if (tank != null) { managedResourceNames.AddRange(tank.ResourceNames); } managedTransformNames.AddRange(subtype.transformNames); managedStackNodeIDs.AddRange(subtype.NodeIDs); } if (PartFieldManaged(SubtypePartFields.SrfAttachNode) && !part.attachRules.allowSrfAttach || part.srfAttachNode.IsNull()) { LogError($"Error: One or more subtypes have an attach node defined, but part does not allow surface attachment (or the surface attach node could not be found)"); subtypes.ForEach(subtype => subtype.attachNode = null); } }
public override void OnStart(PartModule.StartState state) { base.OnStart(state); // Initialize stuff managedResourceNames = new List <string>(); managedTransformNames = new List <string>(); managedStackNodeIDs = new List <string>(); MaxTempManaged = false; SkinMaxTempManaged = false; AttachNodeManaged = false; for (int i = 0; i < subtypes.Count; i++) { PartSubtype subtype = subtypes[i]; subtype.SetParent(this); subtype.OnStart(); TankType tank = subtype.tankType; if (tank == null) { LogError("Tank is null on subtype " + subtype.Name); } if (tank.ResourcesCount > 0 && (TankVolumeForSubtype(i) <= 0f)) { LogError("Subtype " + subtype.Name + " has a tank type with resources, but no volume is specifified"); subtype.tankType = tank = B9TankSettings.StructuralTankType; } if (tank != null) { managedResourceNames.AddRange(tank.ResourceNames); } managedTransformNames.AddRange(subtype.transformNames); managedStackNodeIDs.AddRange(subtype.NodeIDs); if (subtype.maxTemp > 0f) { MaxTempManaged = true; } if (subtype.skinMaxTemp > 0f) { SkinMaxTempManaged = true; } if (subtype.attachNode.IsNotNull()) { if (part.attachRules.allowSrfAttach && part.srfAttachNode != null) { AttachNodeManaged = true; } else { LogError("Error: Part subtype '" + subtype.Name + "' has an attach node defined, but part does not allow surface attachment (or the surface attach node could not be found)"); } } } if (currentSubtypeIndex >= subtypes.Count || currentSubtypeIndex < 0) { currentSubtypeIndex = 0; } bool editor = (state == StartState.Editor); SetupGUI(); for (int i = 0; i < subtypes.Count; i++) { subtypes[i].DeactivateObjects(); if (editor) { subtypes[i].DeactivateNodes(); } else { subtypes[i].ActivateNodes(); } } UpdateSubtype(false); }