protected ResourceManager(Guid overmanagerId, PartModule pm, string resource_name, int flow_type)
        {
            OverManagerId = overmanagerId;
            Id            = Guid.NewGuid();

            flowType     = flow_type;
            resourceName = resource_name;
            Vessel       = pm.vessel;
            part         = pm.part;
            PartModule   = pm;
            renderWindow = false;

            windowID       = new System.Random(resource_name.GetHashCode()).Next(int.MinValue, int.MaxValue);
            WindowPosition = new Rect(0, 0, LABEL_WIDTH + VALUE_WIDTH + PRIORITY_WIDTH, 50);

            currentDistributed = new double[MAX_PRIORITY];
            stableDistributed  = new double[MAX_PRIORITY];
            // 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(resource_name);
            last    = new PowerStats();
            current = new PowerStats();
            ResourceFillFraction = 0.0;
        }
Beispiel #2
0
 public void CopyTo(PowerStats other)
 {
     // Avoids allocating on the heap, versus reassigning and instantiating
     other.Demand             = Demand;
     other.DemandHighPriority = DemandHighPriority;
     other.StableSupply       = StableSupply;
     other.Supply             = Supply;
     other.TotalSupplied      = TotalSupplied;
 }