コード例 #1
0
        public void Update()
        {
            if (!IndustrySaveDataManager.IsLoadCompleted)
            {
                return;
            }

            if (waitingForLoadComplete)
            {
                // need to grab saved state of resources before starting processing
                foreach (IndustryResource resource in AllResources)
                {
                    resource.Amount = IndustrySaveDataManager.GetSavedStockpileAmount(StationId, resource.Key);
                }

                waitingForLoadComplete = false;
            }

            foreach (var process in processes)
            {
                if (process.IsWorking && process.IsFinished)
                {
                    // process completed, yeet products
                    foreach (IndustryResource output in process.Outputs)
                    {
                        StoreResource(output);
                    }

                    process.IsWorking = false;
                }

                if (!process.IsWorking)
                {
                    // try to start idle process
                    if (AreIngredientsAvailable(process))
                    {
                        process.IsWorking = true;
                        process.StartTime = Time.time;
                    }
                }
            }
        }
コード例 #2
0
        public void Initialize()
        {
            if (StationController == null)
            {
                StationController = gameObject.GetComponent <StationController>();
            }

            processes = IndustryConfigManager.GetProcesses(StationId);
            if (processes == null)
            {
                DVIndustry.ModEntry.Logger.Error($"Failed to set processes on industry at {StationId}");
                return;
            }

            // Create stockpiles for each process I/O resource
            inputStockpile  = processes.SelectMany(proc => proc.Inputs.Select(r => r.CloneEmpty())).ToArray();
            outputStockpile = processes.SelectMany(proc => proc.Outputs.Select(r => r.CloneEmpty())).ToArray();

            // Add references for all stockpiles to the map
            stockpileMap = inputStockpile.Union(outputStockpile).ToDictionary(res => res.Key, res => res);

            IndustrySaveDataManager.RegisterIndustry(this);
        }
コード例 #3
0
 // inject our save data before the IO is performed
 static void Prefix()
 {
     IndustrySaveDataManager.SaveIndustryData();
 }
コード例 #4
0
 static void Postfix()
 {
     IndustrySaveDataManager.LoadIndustryData();
 }