public double GetAssginedWorkPower(RepairData repair) { if (part.protoModuleCrew.Count == 1) { ProtoCrewMember kerbal = part.protoModuleCrew[0]; if (kerbal != null) { return(KerbalReconstructionTapeAddon.GetRepairSpeed(kerbal.trait, kerbal.experienceLevel) * KerbalReconstructionTapeAddon.GetRepairQuality(kerbal.trait, kerbal.experienceLevel)); } else { Debug.LogError($"[KRT] Bungler module at part {part.name} has found a null ProtoCrewMember"); return(0); } } else { Debug.LogError($"[KRT] Bungler module has found out that his part {part.name} has not 1 crew member. It seems it is not an EVA Kerbal."); return(0); } }
public double GetAssignedQuality(RepairData repair) // Making it repair-dependent for further possible features { if (part.protoModuleCrew.Count == 1) { ProtoCrewMember kerbal = part.protoModuleCrew[0]; if (kerbal != null) { return(KerbalReconstructionTapeAddon.GetRepairQuality(kerbal.trait, kerbal.experienceLevel)); } else { Debug.LogError($"[KRT] Bungler module at part {part.name} has found a null ProtoCrewMember"); return(0); } } else { Debug.LogError($"[KRT] Bungler module has found out that his part {part.name} has not 1 crew member. It seems it is not an EVA Kerbal."); return(0); } }
public void Start() { instance = this; ConfigNode configNode = GameDatabase.Instance.GetConfigNodes("REPAIR_TRAITS")?[0]; if (configNode == null) { Debug.LogWarning("[KRT] Could not find REPAIR_TRAITS node in the game database"); return; } foreach (ConfigNode traitNode in configNode.GetNodes("TRAIT")) { if (!traitNode.HasValue("name")) { Debug.LogError("[KRT] Found a TRAIT node without \"name\" field"); } else { string traitName = traitNode.GetValue("name"); if (traitRepairQualities.ContainsKey(traitName)) { Debug.LogWarning($"[KRT] Found multiple repair configs for {traitName} trait, ignoring all but the first one"); } else { traitRepairQualities[traitName] = new List <double> { }; traitRepairSpeeds[traitName] = new List <double> { }; int i = 0; while (traitNode.HasNode($"LEVEL{i}")) { ConfigNode levelNode = traitNode.GetNode($"LEVEL{i}"); if (levelNode.HasValue("quality") && levelNode.HasValue("speed")) { string qualString = levelNode.GetValue("quality"); string speedString = levelNode.GetValue("speed"); double qual, speed; // Not embedding defs for readability if (double.TryParse(qualString, out qual) && double.TryParse(speedString, out speed)) { traitRepairQualities[traitName].Add(qual); traitRepairSpeeds[traitName].Add(speed); } else { Debug.LogError($"[KRT] Level node LEVEL{i} for trait {traitName} has misformatted values \"quality\" \"speed\""); break; } } else { Debug.LogError($"[KRT] Level node LEVEL{i} for trait {traitName} misses needed values (\"quality\" and \"speed\")"); break; } i++; } } } } }
public void OnDestroy() { instance = null; }