public static bool PlanetFactory_BuildFinally_Prefix(Player player, int prebuildId) { if (player.factory != null && prebuildId != 0) { PrebuildData prebuild = player.factory.prebuildPool[prebuildId]; if (isDroneClearingPrebuild(prebuild)) { // This will never happen unless DSP Cheats' Instant-Build feature is enabled. So, let's do what it's telling us to. if (configEnableInstantClearing) { player.factory.RemovePrebuildData(prebuildId); player.factory.RemoveVegeWithComponents(prebuild.upEntity); for (int activeMissionIdx = 0; activeMissionIdx < activeMissions.Count; ++activeMissionIdx) { DroneClearingMissionData missionData = activeMissions[activeMissionIdx]; if (missionData.prebuildId == prebuildId) { if (missionData.mineAction.miningType == EObjectType.Entity) { activeMissions.RemoveAt(activeMissionIdx); } } } } return(false); } } return(true); }
public static void MechaDrone_Update_Postfix(MechaDrone __instance, ref int __result, PrebuildData[] prebuildPool, Vector3 playerPos, float dt, ref double energy, ref double energyChange, double energyRate) { if (__result == 1) // If the Prebuild would normally complete... { int prebuildId = -__instance.targetObject; PrebuildData prebuild = prebuildPool[prebuildId]; if (isDroneClearingPrebuild(prebuild)) { PlanetFactory factory = GameMain.mainPlayer.factory; DroneClearingMissionData missionData = null; for (int activeMissionIdx = 0; activeMissionIdx < activeMissions.Count; ++activeMissionIdx) { missionData = activeMissions[activeMissionIdx]; if (missionData.prebuildId == prebuildId) { if (missionData.mineAction.miningType == EObjectType.Entity) { // Clearing completed activeMissions.RemoveAt(activeMissionIdx); factory.RemovePrebuildData(prebuildId); } else { __result = 0; } return; } } if (configCollectResourcesFlag) { missionData = new DroneClearingMissionData(); missionData.prebuildId = prebuildId; missionData.forward = __instance.forward; missionData.position = __instance.position; missionData.mineAction = new DroneAction_Mine(); missionData.mineAction.player = GameMain.mainPlayer; missionData.mineAction.miningType = EObjectType.Vegetable; missionData.mineAction.miningId = prebuild.upEntity; missionData.mineAction.miningTick = 0; activeMissions.Add(missionData); } else { factory.RemovePrebuildData(prebuildId); factory.RemoveVegeWithComponents(prebuild.upEntity); } __result = 0; return; } } }