mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 00:53:39 +08:00
work in progress
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
|
||||||
using UXAssist.Common;
|
using UXAssist.Common;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
using GameLogicProc = UXAssist.Common.GameLogic;
|
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||||
@@ -72,7 +71,6 @@ public class Miner : PatchImpl<Miner>
|
|||||||
|
|
||||||
private static void OnGameBegin()
|
private static void OnGameBegin()
|
||||||
{
|
{
|
||||||
VeinManager.Clear();
|
|
||||||
_frame = 0L;
|
_frame = 0L;
|
||||||
UpdateMiningCostRate();
|
UpdateMiningCostRate();
|
||||||
UpdateSpeedScale();
|
UpdateSpeedScale();
|
||||||
@@ -135,7 +133,6 @@ public class Miner : PatchImpl<Miner>
|
|||||||
var frameCounter = _frame / 1200000L;
|
var frameCounter = _frame / 1200000L;
|
||||||
if (frameCounter <= 0) return;
|
if (frameCounter <= 0) return;
|
||||||
_frame -= frameCounter * 1200000L;
|
_frame -= frameCounter * 1200000L;
|
||||||
// LogisticHub.Logger.LogDebug($"FrameCounter: {frameCounter}");
|
|
||||||
|
|
||||||
DeepProfiler.BeginSample(DPEntry.Miner);
|
DeepProfiler.BeginSample(DPEntry.Miner);
|
||||||
var data = GameMain.data;
|
var data = GameMain.data;
|
||||||
@@ -155,6 +152,7 @@ public class Miner : PatchImpl<Miner>
|
|||||||
{
|
{
|
||||||
foreach (var storageIndex in demands[itemIndex])
|
foreach (var storageIndex in demands[itemIndex])
|
||||||
{
|
{
|
||||||
|
LogisticHub.Logger.LogDebug($"StorageIndex: {storageIndex}");
|
||||||
var station = planetTransport.stationPool[storageIndex / 100];
|
var station = planetTransport.stationPool[storageIndex / 100];
|
||||||
if (station == null)
|
if (station == null)
|
||||||
continue;
|
continue;
|
||||||
@@ -195,7 +193,7 @@ public class Miner : PatchImpl<Miner>
|
|||||||
for (var i = planetTransport.stationCursor - 1; i > 0; i--)
|
for (var i = planetTransport.stationCursor - 1; i > 0; i--)
|
||||||
{
|
{
|
||||||
var stationComponent = planetTransport.stationPool[i];
|
var stationComponent = planetTransport.stationPool[i];
|
||||||
if (stationComponent.isCollector || stationComponent.isVeinCollector || stationComponent.energy * 2 >= stationComponent.energyMax) continue;
|
if (stationComponent == null || stationComponent.isCollector || stationComponent.isVeinCollector || stationComponent.energy * 2 >= stationComponent.energyMax) continue;
|
||||||
var index = (stationComponent.isStellar ? FuelIlsSlot.Value : FuelPlsSlot.Value) - 1;
|
var index = (stationComponent.isStellar ? FuelIlsSlot.Value : FuelPlsSlot.Value) - 1;
|
||||||
var storage = stationComponent.storage;
|
var storage = stationComponent.storage;
|
||||||
if (index < 0 || index >= storage.Length)
|
if (index < 0 || index >= storage.Length)
|
||||||
|
|||||||
@@ -54,7 +54,17 @@ public class StationManager : PatchImpl<StationManager>
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
GameLogicProc.OnGameBegin += () =>
|
GameLogicProc.OnGameBegin += OnGameBegin;
|
||||||
|
Enable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Uninit()
|
||||||
|
{
|
||||||
|
GameLogicProc.OnGameBegin -= OnGameBegin;
|
||||||
|
Enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnGameBegin()
|
||||||
{
|
{
|
||||||
_stations = null;
|
_stations = null;
|
||||||
var data = GameMain.data;
|
var data = GameMain.data;
|
||||||
@@ -73,13 +83,6 @@ public class StationManager : PatchImpl<StationManager>
|
|||||||
UpdateStationInfo(stations, station);
|
UpdateStationInfo(stations, station);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
Enable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Uninit()
|
|
||||||
{
|
|
||||||
Enable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int ItemIdToIndex(int itemId)
|
private static int ItemIdToIndex(int itemId)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UXAssist.Common;
|
using UXAssist.Common;
|
||||||
|
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||||
|
|
||||||
namespace LogisticHub.Module;
|
namespace LogisticHub.Module;
|
||||||
|
|
||||||
@@ -19,16 +20,25 @@ public class VeinManager : PatchImpl<VeinManager>
|
|||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
Enable(true);
|
Enable(true);
|
||||||
|
GameLogicProc.OnGameBegin += OnGameBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Uninit()
|
public static void Uninit()
|
||||||
{
|
{
|
||||||
|
GameLogicProc.OnGameBegin -= OnGameBegin;
|
||||||
Enable(false);
|
Enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Clear()
|
private static void OnGameBegin()
|
||||||
{
|
{
|
||||||
_veins = null;
|
_veins = null;
|
||||||
|
var data = GameMain.data;
|
||||||
|
for (var index = data.factoryCount - 1; index >= 0; index--)
|
||||||
|
{
|
||||||
|
var factory = data.factories[index];
|
||||||
|
if (factory == null || factory.index != index) continue;
|
||||||
|
RecalcVeins(factory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProductVeinData[] GetVeins(int planetIndex)
|
public static ProductVeinData[] GetVeins(int planetIndex)
|
||||||
|
|||||||
Reference in New Issue
Block a user