public static void patchLogisticImport(ref GameHistoryData __instance)
 {
     __instance.logisticDroneSpeedScale = DroneSpeed.Value;
     __instance.logisticShipSpeedScale  = ShipSpeed.Value;
     __instance.logisticDroneCarries    = DroneCarries.Value;
     __instance.logisticShipCarries     = ShipCarries.Value;
 }
Esempio n. 2
0
        private static void GameHistoryDataPostPatch(GameHistoryData __instance)
        {
            ProtoRegister.Logger.LogInfo("GameHistoryDataPatch.Postfix invoked.");

            ProtoRegister.AddRecipeProtos
            .Where(proto => proto.preTech != null && __instance.TechState(proto.preTech.ID).unlocked&& !__instance.RecipeUnlocked(proto.ID))
            .ForEach(proto => __instance.UnlockRecipe(proto.ID));
        }
        public static bool Prefix4(GameHistoryData __instance, long addcnt)
        {
            //Host in multiplayer can do normal research in the mecha
            if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient)
            {
                return(true);
            }

            //Clients just sends contributing packet to the server
            LocalPlayer.SendPacket(new GameHistoryResearchContributionPacket(addcnt, __instance.currentTech));
            return(false);
        }
Esempio n. 4
0
        public static bool AddTechHash_Prefix(GameHistoryData __instance, long addcnt)
        {
            //Host in multiplayer can do normal research in the mecha
            if (!Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost)
            {
                return(true);
            }

            //Clients just sends contributing packet to the server
            Multiplayer.Session.Network.SendPacket(new GameHistoryResearchContributionPacket(addcnt, __instance.currentTech));
            return(false);
        }
Esempio n. 5
0
        public void ProcessPacket(GameHistoryResearchUpdatePacket packet, NebulaConnection conn)
        {
            GameHistoryData data = GameMain.data.history;

            if (packet.TechId != data.currentTech)
            {
                //Wait for the authoritative packet to enqueu new tech first
                return;
            }
            TechState state = data.techStates[data.currentTech];

            state.hashUploaded = packet.HashUploaded;
            data.techStates[data.currentTech] = state;
        }
Esempio n. 6
0
            private static void OriginalSetTextActive(UIStarmapStar __instance, ref Text nameText)
            {
                GameHistoryData historyData = Traverse.Create((object)__instance).Field("gameHistory").GetValue <GameHistoryData>();

                Vector2 rectPoint = Vector2.zero;
                bool    flag      = __instance.starmap.WorldPointIntoScreen(__instance.starObject.vpos, out rectPoint) && ((UnityEngine.Object)__instance.starmap.mouseHoverStar == (UnityEngine.Object)__instance || historyData.HasFeatureKey(1001001) || historyData.HasFeatureKey(1010000 + __instance.star.id));

                float num = Mathf.Max(1f, __instance.starObject.vdist / __instance.starObject.vscale.x);

                __instance.projectedCoord = rectPoint;
                rectPoint.x += (float)(8.0f + 600f / (float)num);
                rectPoint.y += 4.0f;
                nameText.rectTransform.anchoredPosition = rectPoint;

                __instance.projected = true;
                nameText.gameObject.SetActive(true);
            }
Esempio n. 7
0
 private static void HistoryPatch(GameHistoryData __instance)
 {
     foreach (var proto in TotalDict[ProtoType.Recipe])
     {
         var recipe = proto as RecipeProto;
         if (recipe.preTech != null)
         {
             if (__instance.TechState(recipe.preTech.ID).unlocked)
             {
                 if (!__instance.RecipeUnlocked(recipe.ID))
                 {
                     __instance.UnlockRecipe(recipe.ID);
                 }
             }
         }
     }
 }
Esempio n. 8
0
        public static bool TutorialUnlocked_Prefix(GameHistoryData __instance, ref bool __result, int tutorialId)
        {
            // do nothing in single player mode
            if (!SimulatedWorld.Initialized && !SimulatedWorld.ExitingMultiplayerSession)
            {
                return(true);
            }

            if (Config.Options.TutorialDisabled)
            {
                __result = true;
                __instance.UnlockTutorial(tutorialId);
                return(false);
            }

            return(true);
        }
        public override void ProcessPacket(GameHistoryResearchUpdatePacket packet, NebulaConnection conn)
        {
            GameHistoryData data = GameMain.data.history;

            if (packet.TechId != data.currentTech)
            {
                NebulaModel.Logger.Log.Warn($"CurrentTech mismatch! Server:{packet.TechId} Local:{data.currentTech}");
                //Replace currentTech to match with server
                data.currentTech  = packet.TechId;
                data.techQueue[0] = packet.TechId;
            }
            TechState state = data.techStates[data.currentTech];

            state.hashUploaded = packet.HashUploaded;
            state.hashNeeded   = packet.HashNeeded;
            data.techStates[data.currentTech] = state;
        }
Esempio n. 10
0
        private static void UnlockTechRecursive(int techId, GameHistoryData history)
        {
            TechState state = history.TechState(techId);
            TechProto proto = LDB.techs.Select(techId);

            foreach (var techReq in proto.PreTechs)
            {
                if (!history.TechState(techReq).unlocked)
                {
                    UnlockTechRecursive(techReq, history);
                }
            }
            foreach (var techReq in proto.PreTechsImplicit)
            {
                if (!history.TechState(techReq).unlocked)
                {
                    UnlockTechRecursive(techReq, history);
                }
            }
            foreach (var itemReq in proto.itemArray)
            {
                if (itemReq.preTech is not null && !history.TechState(itemReq.preTech.ID).unlocked)
                {
                    UnlockTechRecursive(itemReq.preTech.ID, history);
                }
            }

            int current = state.curLevel;

            for (; current < state.maxLevel; current++)
            {
                for (int j = 0; j < proto.UnlockFunctions.Length; j++)
                {
                    history.UnlockTechFunction(proto.UnlockFunctions[j], proto.UnlockValues[j], current);
                }
            }

            history.UnlockTech(techId);
        }
Esempio n. 11
0
        public static void GameTick_Postfix(GameData __instance, long time)
        {
            if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient)
            {
                if (SimulatedWorld.Initialized)
                {
                    StationUIManager.DecreaseCooldown();
                }
                return;
            }
            // call StationComponent::InternalTickRemote() from here, see StationComponent_Patch.cs for info
            int timeGene = (int)(time % 60L);

            if (timeGene < 0)
            {
                timeGene += 60;
            }
            float           dt            = 0.016666668f;
            GameHistoryData history       = GameMain.history;
            float           shipSailSpeed = history.logisticShipSailSpeedModified;
            float           shipWarpSpeed = (!history.logisticShipWarpDrive) ? shipSailSpeed : history.logisticShipWarpSpeedModified;
            int             shipCarries   = history.logisticShipCarries;

            StationComponent[] gStationPool = __instance.galacticTransport.stationPool;
            AstroPose[]        astroPoses   = __instance.galaxy.astroPoses;
            VectorLF3          relativePos  = __instance.relativePos;
            Quaternion         relativeRot  = __instance.relativeRot;
            bool starmap = UIGame.viewMode == EViewMode.Starmap;

            foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool)
            {
                if (stationComponent != null && stationComponent.isStellar)
                {
                    //Debug.Log("enter " + stationComponent.gid + " (" + GameMain.galaxy.PlanetById(stationComponent.planetId).displayName + ")");
                    StationComponent_Transpiler.ILSUpdateShipPos(stationComponent, timeGene, dt, shipSailSpeed, shipWarpSpeed, shipCarries, gStationPool, astroPoses, relativePos, relativeRot, starmap, null);
                }
            }
        }
Esempio n. 12
0
 public static void PatchSorterImport(ref GameHistoryData __instance)
 {
     __instance.inserterStackCount = sorterCount.Value;
 }
Esempio n. 13
0
 public static bool Prefix(GameHistoryData __instance, ref bool __result)
 {
     __result = true;
     return(false);
 }
Esempio n. 14
0
 public static void SetForNewGame_Postfix(GameHistoryData __instance)
 {
     __instance.dysonNodeLatitude = 90f;
 }
Esempio n. 15
0
 public static bool DysonSphereSystemUnlocked_Prefix(GameHistoryData __instance, ref bool __result)
 {
     __result = true;
     return(false);
 }
Esempio n. 16
0
 public static void EnqueueTech_Postfix(GameHistoryData __instance, int techId)
 {
     __instance.UnlockTech(techId);
     GameMain.mainPlayer.mecha.corePowerGen = 10000000;
 }
Esempio n. 17
0
        static void Miner(FactorySystem __instance)
        {
            GameHistoryData history = GameMain.history;



            float miningSpeedScale = history.miningSpeedScale;

            if (miningSpeedScale <= 0)
            {
                return;
            }
            int baseSpeed = (int)(120 / (miningSpeedScale));

            if (baseSpeed <= 0)
            {
                baseSpeed = 1;
            }

            if (frame % baseSpeed != 0)
            {
                return;
            }


            var veinPool = __instance.factory.veinPool;
            Dictionary <int, List <int> > veins = new Dictionary <int, List <int> >();


            if (__instance.minerPool[0].seed == 0)
            {
                var rondom = new System.Random();
                __instance.minerPool[0].seed = (uint)(__instance.planet.id * 100000 + rondom.Next(1, 9999));
            }
            else
            {
                seed = __instance.minerPool[0].seed;
            }



            for (int i = 0; i < veinPool.Length; i++)
            {
                var d = veinPool[i];
                if (d.amount > 0 && d.productId > 0)
                {
                    AddVeinData(veins, d.productId, i);
                }
            }

            float           miningCostRate = 0;
            PlanetTransport transport      = null;

            int[] productRegister = null;

            miningCostRate = history.miningCostRate;
            transport      = __instance.planet.factory.transport;

            FactoryProductionStat factoryProductionStat = GameMain.statistics.production.factoryStatPool[__instance.factory.index];

            bool h = false;

            if (factoryProductionStat != null)
            {
                productRegister = factoryProductionStat.productRegister;
                h = true;
            }


            for (int i = 1; i < transport.stationCursor; i++)
            {
                var sc = transport.stationPool[i];
                if (sc != null && sc.storage != null)
                {
                    for (int j = 0; j < sc.storage.Length; j++)
                    {
                        var da = sc.storage[j];
                        if (da.localLogic == ELogisticStorage.Demand && da.max > da.count)
                        {
                            if (veins.ContainsKey(da.itemId) || da.itemId == __instance.planet.waterItemId)
                            {
                                //当能量不足一半时
                                if (sc.energyMax / 2 > sc.energy)
                                {
                                    //获取倒数第二个物品栏
                                    var lastup = sc.storage[sc.storage.Length - 2];
                                    //如果物品数量大于0
                                    if (lastup.count > 0)
                                    {
                                        //获取物品的能量值
                                        long en = LDB.items.Select(lastup.itemId).HeatValue;
                                        //如果物品的能量大于0
                                        if (en > 0)
                                        {
                                            //获取需要充电的能量
                                            long needen = sc.energyMax - sc.energy;
                                            //计算需要的数量
                                            int needcount = (int)(needen / en);
                                            //如果需要是数量大于有的数量
                                            if (needcount > lastup.count)
                                            {
                                                //将需求数量改为当前数量
                                                needcount = sc.storage[sc.storage.Length - 2].count;
                                            }
                                            //消耗物品
                                            sc.storage[sc.storage.Length - 2].count -= needcount;
                                            //充能
                                            sc.energy += needcount * en;
                                        }
                                    }
                                }
                            }
                            if (veins.ContainsKey(da.itemId))
                            {
                                if (sc.energy >= uesEnergy)
                                {
                                    var vein = veins[da.itemId].First();
                                    if (veinPool[vein].type == EVeinType.Oil)
                                    {
                                        float count = 0;
                                        foreach (int index in veins[da.itemId])
                                        {
                                            if (veinPool.Length > index && veinPool[index].productId > 0)
                                            {
                                                count += veinPool[index].amount / 6000f;
                                            }
                                        }
                                        sc.storage[j].count += (int)count;
                                        if (h)
                                        {
                                            productRegister[da.itemId] += (int)count;
                                        }
                                        sc.energy -= uesEnergy;
                                    }
                                    else
                                    {
                                        int count = 0;
                                        foreach (int index in veins[da.itemId])
                                        {
                                            if (GetMine(veinPool, index, miningCostRate, __instance.planet.factory))
                                            {
                                                count++;
                                            }
                                        }
                                        sc.storage[j].count += count;
                                        if (h)
                                        {
                                            productRegister[da.itemId] += count;
                                        }
                                        sc.energy -= uesEnergy;
                                    }
                                }
                            }
                            else if (da.itemId == __instance.planet.waterItemId)
                            {
                                sc.storage[j].count += waterSpeed;
                                if (h)
                                {
                                    productRegister[da.itemId] += waterSpeed;
                                }
                                sc.energy -= uesEnergy;
                            }
                        }
                    }
                }
            }
        }