public static void AntennaUpdate(Vessel v, bool refresh = false) { // get vessel id UInt32 id = Lib.VesselID(v); bool hasEC = ResourceCache.Info(v, "ElectricCharge").amount > double.Epsilon; // get the info from the cache, if it exist update if (antennasCache.TryGetValue(id, out Antenna_Info info)) { // EC state changed since last update? if (info.hasECChanged != hasEC || info.isTimeToUpdate) { // Update old cache Lib.Debug("Triggered: Update existing antenna cache"); // Update Antenna antennasCache[id] = new Antenna_Info(v) { hasECChanged = hasEC }; } } else // Create a new entry { Lib.Debug("New antenna cache"); info = new Antenna_Info(v) { hasECChanged = hasEC }; antennasCache.Add(id, info); } }
public static Antenna_Info AntennaInfo(Vessel v) { // get vessel id UInt32 id = Lib.VesselID(v); // get the info from the cache, if it exist update if (antennasCache.TryGetValue(id, out Antenna_Info info)) { // isTimeToUpdate is altered when Vessel was changed(stage, break), antenna has extended/retracted if (!info.isTimeToUpdate) { return(info); } } else // Create a new entry { Lib.Debug("New antenna cache"); info = new Antenna_Info(v); antennasCache.Add(id, info); } return(info); }