public void Register(ResourceSuppliableModule suppliable) { if (!suppliable_modules.Contains(suppliable)) { suppliable_modules.Add(suppliable); } }
public void Unregister(ResourceSuppliableModule suppliable) { if (!suppliable_modules.Contains(suppliable)) { suppliable_modules.Remove(suppliable); } }
public void UpdatePartModule(ResourceSuppliableModule pm) { if (pm != null) { Vessel = pm.vessel; part = pm.part; PartModule = pm; if (resourceName == ResourceSettings.Config.ElectricPowerInMegawatt) { SetWindowPosition(pm.epx, pm.epy, (int)WindowPosition.x, (int)WindowPosition.y); } else if (resourceName == ResourceSettings.Config.WasteHeatInMegawatt) { SetWindowPosition(pm.whx, pm.why, (int)WindowPosition.x, (int)WindowPosition.y); } else if (resourceName == ResourceSettings.Config.ChargedPowerInMegawatt) { SetWindowPosition(pm.cpx, pm.cpy, (int)WindowPosition.x, (int)WindowPosition.y); } else if (resourceName == ResourceSettings.Config.ThermalPowerInMegawatt) { SetWindowPosition(pm.tpx, pm.tpy, (int)WindowPosition.x, (int)WindowPosition.y); } } else { Vessel = null; part = null; PartModule = null; } }
public ResourceManager CreateManagerForVessel(ResourceSuppliableModule pm) { var resourceManager = ResourceManagerFactory.Create(Id, pm, resourceName); managers.Add(pm.vessel, resourceManager); return(resourceManager); }
protected ResourceManager(Guid overmanagerId, ResourceSuppliableModule pm, string resourceName, int flowType) { OverManagerId = overmanagerId; Id = Guid.NewGuid(); this.flowType = flowType; this.resourceName = resourceName; Vessel = pm.vessel; part = pm.part; PartModule = pm; renderWindow = false; _windowId = new System.Random(resourceName.GetHashCode()).Next(int.MinValue, int.MaxValue); WindowPosition = new Rect(0, 0, LabelWidth + ValueWidth + PriorityWidth, 50); currentDistributed = new double[MaxPriority]; stableDistributed = new double[MaxPriority]; // Cannot use SortedDictionary as the priority for some items is dynamic consumptionRequests = new Dictionary <IResourceSuppliable, PowerDistribution>(64); // Must be kept separately as the producer list gets rebuilt every update productionTemp = new Dictionary <IResourceSupplier, PowerGenerated>(64); productionRequests = new Dictionary <IResourceSupplier, PowerGenerated>(64); powerConsumers = new List <PowerDistributionPair>(64); powerProducers = new List <PowerGeneratedPair>(64); resourceDefinition = PartResourceLibrary.Instance.GetDefinition(resourceName); last = new PowerStats(); current = new PowerStats(); ResourceFillFraction = 0.0; }
// Create the appropriate instance public static ResourceManager Create(Guid id, ResourceSuppliableModule pm, string resourceName) { ResourceManager result; if (resourceName == ResourceSettings.Config.ElectricPowerInMegawatt) { result = new MegajoulesResourceManager(id, pm); } else if (resourceName == ResourceSettings.Config.WasteHeatInMegawatt) { result = new WasteHeatResourceManager(id, pm); } else if (resourceName == ResourceSettings.Config.ChargedPowerInMegawatt) { result = new ChargedPowerResourceManager(id, pm); } else if (resourceName == ResourceSettings.Config.ThermalPowerInMegawatt) { result = new ThermalPowerResourceManager(id, pm); } else { result = new DefaultResourceManager(id, pm, resourceName); } return(result); }
public MegajoulesResourceManager(Guid overmanagerId, ResourceSuppliableModule pm) : base(overmanagerId, pm, ResourceSettings.Config.ElectricPowerInMegawatt, FnResourceFlowTypeSmallestFirst) { SetWindowPosition(pm.epx, pm.epy, 50, 50); electricResourceDefinition = PartResourceLibrary.Instance.GetDefinition(ResourceSettings.Config.ElectricPowerInKilowatt); _lastEcNeeded = 0.0; _lastMjConverted = 0.0; _mjConverted = 0.0; }
public WasteHeatResourceManager(Guid overmanagerId, ResourceSuppliableModule pm) : base(overmanagerId, pm, ResourceSettings.Config.WasteHeatInMegawatt, FnResourceFlowTypeEven) { SetWindowPosition(pm.whx, pm.why, 600, 600); TemperatureRatio = 0.0; RadiatorEfficiency = 0.0; }
public DefaultResourceManager(Guid overmanagerId, ResourceSuppliableModule pm, string resource) : base(overmanagerId, pm, resource, FnResourceFlowTypeEven) { WindowPosition = new Rect(100, 100, LabelWidth + ValueWidth + PriorityWidth, 50); }
public ThermalPowerResourceManager(Guid overmanagerId, ResourceSuppliableModule pm) : base(overmanagerId, pm, ResourceSettings.Config.ThermalPowerInMegawatt, FnResourceFlowTypeEven) { SetWindowPosition(pm.tpx, pm.tpy, 600, 50); }
public ChargedPowerResourceManager(Guid overmanagerId, ResourceSuppliableModule pm) : base(overmanagerId, pm, ResourceSettings.Config.ChargedPowerInMegawatt, FnResourceFlowTypeEven) { SetWindowPosition(pm.cpx, pm.cpy, 50, 600); }