Exemplo n.º 1
0
        public static void TickResearch()
        {
            MultiplayerWorldComp comp = Multiplayer.WorldComp;

            foreach (FactionWorldData factionData in comp.factionData.Values)
            {
                if (factionData.researchManager.currentProj == null)
                {
                    continue;
                }

                Extensions.PushFaction(null, factionData.factionId);

                foreach (var kv in factionData.researchSpeed.data)
                {
                    Pawn pawn = PawnsFinder.AllMaps_Spawned.FirstOrDefault(p => p.thingIDNumber == kv.Key);
                    if (pawn == null)
                    {
                        dummyPawn.factionInt = Faction.OfPlayer;
                        pawn = dummyPawn;
                    }

                    Find.ResearchManager.ResearchPerformed(kv.Value, pawn);

                    dummyPawn.factionInt = null;
                }

                Extensions.PopFaction();
            }
        }
Exemplo n.º 2
0
        private static void SetupGameFromSingleplayer()
        {
            MultiplayerWorldComp comp = new MultiplayerWorldComp(Find.World);

            Faction NewFaction(int id, string name, FactionDef def)
            {
                Faction faction = Find.FactionManager.AllFactions.FirstOrDefault(f => f.loadID == id);

                if (faction == null)
                {
                    faction = new Faction()
                    {
                        loadID = id, def = def
                    };

                    foreach (Faction other in Find.FactionManager.AllFactionsListForReading)
                    {
                        faction.TryMakeInitialRelationsWith(other);
                    }

                    Find.FactionManager.Add(faction);

                    comp.factionData[faction.loadID] = FactionWorldData.New(faction.loadID);
                }

                faction.Name = name;
                faction.def  = def;

                return(faction);
            }

            Faction.OfPlayer.Name = $"{Multiplayer.username}'s faction";
            //comp.factionData[Faction.OfPlayer.loadID] = FactionWorldData.FromCurrent();

            Multiplayer.game = new MultiplayerGame
            {
                gameComp = new MultiplayerGameComp(Current.Game)
                {
                    globalIdBlock = new IdBlock(GetMaxUniqueId(), 1_000_000_000)
                },
Exemplo n.º 3
0
        private static void SetupGame()
        {
            MultiplayerWorldComp comp = new MultiplayerWorldComp(Find.World);
            Faction dummyFaction      = Find.FactionManager.AllFactions.FirstOrDefault(f => f.loadID == -1);

            if (dummyFaction == null)
            {
                dummyFaction = new Faction()
                {
                    loadID = -1, def = Multiplayer.DummyFactionDef
                };

                foreach (Faction other in Find.FactionManager.AllFactionsListForReading)
                {
                    dummyFaction.TryMakeInitialRelationsWith(other);
                }

                Find.FactionManager.Add(dummyFaction);

                comp.factionData[dummyFaction.loadID] = FactionWorldData.New(dummyFaction.loadID);
            }

            dummyFaction.Name = "Multiplayer dummy faction";
            dummyFaction.def  = Multiplayer.DummyFactionDef;

            Faction.OfPlayer.Name = $"{Multiplayer.username}'s faction";
            comp.factionData[Faction.OfPlayer.loadID] = FactionWorldData.FromCurrent();

            Multiplayer.game = new MultiplayerGame
            {
                dummyFaction = dummyFaction,
                worldComp    = comp
            };

            comp.globalIdBlock = new IdBlock(GetMaxUniqueId(), 1_000_000_000);

            foreach (FactionWorldData data in comp.factionData.Values)
            {
                foreach (DrugPolicy p in data.drugPolicyDatabase.policies)
                {
                    p.uniqueId = Multiplayer.GlobalIdBlock.NextId();
                }

                foreach (Outfit o in data.outfitDatabase.outfits)
                {
                    o.uniqueId = Multiplayer.GlobalIdBlock.NextId();
                }

                foreach (FoodRestriction o in data.foodRestrictionDatabase.foodRestrictions)
                {
                    o.id = Multiplayer.GlobalIdBlock.NextId();
                }
            }

            foreach (Map map in Find.Maps)
            {
                //mapComp.mapIdBlock = localServer.NextIdBlock();

                BeforeMapGeneration.SetupMap(map);

                MapAsyncTimeComp async = map.AsyncTime();
                async.mapTicks  = Find.TickManager.TicksGame;
                async.TimeSpeed = Find.TickManager.CurTimeSpeed;
            }
            Multiplayer.WorldComp.UpdateTimeSpeed();
        }