static bool Prefix(Thing t)
        {
            if (Multiplayer.Client == null || t.Map == null)
            {
                return(true);
            }

            MapAsyncTimeComp comp       = t.Map.AsyncTime();
            TickerType       tickerType = t.def.tickerType;

            if (tickerType == TickerType.Normal)
            {
                comp.tickListNormal.RegisterThing(t);
            }
            else if (tickerType == TickerType.Rare)
            {
                comp.tickListRare.RegisterThing(t);
            }
            else if (tickerType == TickerType.Long)
            {
                comp.tickListLong.RegisterThing(t);
            }

            return(false);
        }
Esempio n. 2
0
        static void Postfix(Map __instance)
        {
            if (Multiplayer.Client == null)
            {
                return;
            }

            var asyncTime = __instance.AsyncTime();
            var comp      = __instance.MpComp();

            if (Scribe.mode == LoadSaveMode.LoadingVars || Scribe.mode == LoadSaveMode.Saving)
            {
                Scribe_Deep.Look(ref asyncTime, "mpAsyncTime", __instance);
                Scribe_Deep.Look(ref comp, "mpMapComp", __instance);
            }

            if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                if (asyncTime == null)
                {
                    Log.Error($"{typeof(MapAsyncTimeComp)} missing during loading");
                    // This is just so the game doesn't completely freeze
                    asyncTime = new MapAsyncTimeComp(__instance);
                }

                Multiplayer.game.asyncTimeComps.Add(asyncTime);

                if (comp == null)
                {
                    Log.Error($"{typeof(MultiplayerMapComp)} missing during loading");
                    comp = new MultiplayerMapComp(__instance);
                }

                Multiplayer.game.mapComps.Add(comp);
            }
        }
Esempio 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();
        }