示例#1
0
        public static bool Prefix(ResearchManager __instance, ResearchProjectDef proj, Pawn applyingPawn)
        {
            var expertise = applyingPawn.TryGetComp <CompKnowledge>()?.expertise;

            if (ModLister.RoyaltyInstalled && !expertise.EnumerableNullOrEmpty())
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("LetterTechprintAppliedPartIntro".Translate(proj.Named("PROJECT")));
                stringBuilder.AppendLine();
                if (proj.techprintCount > __instance.GetTechprints(proj))
                {
                    __instance.AddTechprints(proj, 1);
                    if (proj.techprintCount == __instance.GetTechprints(proj))
                    {
                        stringBuilder.AppendLine("LetterTechprintAppliedPartJustUnlocked".Translate(proj.Named("PROJECT")));
                        stringBuilder.AppendLine();
                    }
                    else
                    {
                        stringBuilder.AppendLine("LetterTechprintAppliedPartNotUnlockedYet".Translate(__instance.GetTechprints(proj), proj.techprintCount.ToString(), proj.Named("PROJECT")));
                        stringBuilder.AppendLine();
                    }
                }
                //else if (expertise.ContainsKey(proj) && expertise[proj] >= 1f)
                else if (proj.IsKnownBy(applyingPawn))
                {
                    stringBuilder.AppendLine("LetterTechprintAppliedPartAlreadyResearched".Translate(proj.Named("PROJECT")));
                    stringBuilder.AppendLine();
                }
                else
                {
                    float num = 0f;
                    if (expertise.ContainsKey(proj))
                    {
                        num              = (1 - expertise[proj]) * 0.5f;
                        expertise[proj] += num;
                    }
                    else
                    {
                        expertise.Add(proj, 0.5f);
                        num = 0.5f;
                    }
                    stringBuilder.AppendLine("LetterTechprintAppliedPartAlreadyUnlocked".Translate(num * 100, proj.Named("PROJECT")));
                    stringBuilder.AppendLine();
                }
                if (applyingPawn != null)
                {
                    stringBuilder.AppendLine("LetterTechprintAppliedPartExpAwarded".Translate(2000.ToString(), SkillDefOf.Intellectual.label, applyingPawn.Named("PAWN")));
                    applyingPawn.skills.Learn(SkillDefOf.Intellectual, 2000f, false);
                }
                if (stringBuilder.Length > 0)
                {
                    Find.LetterStack.ReceiveLetter("LetterTechprintAppliedLabel".Translate(proj.Named("PROJECT")), stringBuilder.ToString().TrimEndNewlines(), LetterDefOf.PositiveEvent, null);
                }
                return(false);
            }
            return(true);
        }
示例#2
0
        public void InitNewGame()
        {
            string str = LoadedModManager.RunningMods.Select((ModContentPack mod) => mod.PackageIdPlayerFacing).ToLineList("  - ");

            Log.Message("Initializing new game with mods:\n" + str);
            if (maps.Any())
            {
                Log.Error("Called InitNewGame() but there already is a map. There should be 0 maps...");
                return;
            }
            if (initData == null)
            {
                Log.Error("Called InitNewGame() but init data is null. Create it first.");
                return;
            }
            MemoryUtility.UnloadUnusedUnityAssets();
            DeepProfiler.Start("InitNewGame");
            try
            {
                //InitMap
                Current.ProgramState = ProgramState.MapInitializing;
                IntVec3           intVec      = new IntVec3(initData.mapSize, 1, initData.mapSize);
                Settlement        settlement  = null;
                List <Settlement> settlements = Find.WorldObjects.Settlements;
                for (int i = 0; i < settlements.Count; i++)
                {
                    if (settlements[i].Faction == Faction.OfPlayer)
                    {
                        settlement = settlements[i];
                        break;
                    }
                }
                if (settlement == null)
                {
                    Log.Error("Could not generate starting map because there is no any player faction base.");
                }
                tickManager.gameStartAbsTick = GenTicks.ConfiguredTicksAbsAtGameStart;

                //--------------
                //Map currentMap=Map

                //Map currentMap = MapGenerator.GenerateMap(intVec, settlement, settlement.MapGeneratorDef, settlement.ExtraGenStepDefs);

                //Map currentMap=MapGenerator.GenerateMap(intVec,settlement,settlement.MapGeneratorDef,settlement.ExtraGenStepDefs)

                Map currentMap = MapGenerator.GenerateMap(intVec, settlement, settlement.MapGeneratorDef, settlement.ExtraGenStepDefs);
                worldInt.info.initialMapSize = intVec;
                if (initData.permadeath)
                {
                    info.permadeathMode           = true;
                    info.permadeathModeUniqueName = PermadeathModeUtility.GeneratePermadeathSaveName();
                }
                PawnUtility.GiveAllStartingPlayerPawnsThought(ThoughtDefOf.NewColonyOptimism);
                FinalizeInit();
                Current.Game.CurrentMap = currentMap;
                Find.CameraDriver.JumpToCurrentMapLoc(MapGenerator.PlayerStartSpot);
                Find.CameraDriver.ResetSize();
                if (Prefs.PauseOnLoad && initData.startedFromEntry)
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        tickManager.DoSingleTick();
                        tickManager.CurTimeSpeed = TimeSpeed.Paused;
                    });
                }

                //--------------end
                Find.Scenario.PostGameStart();
                if (Faction.OfPlayer.def.startingResearchTags != null)
                {
                    foreach (ResearchProjectTagDef startingResearchTag in Faction.OfPlayer.def.startingResearchTags)
                    {
                        foreach (ResearchProjectDef allDef in DefDatabase <ResearchProjectDef> .AllDefs)
                        {
                            if (allDef.HasTag(startingResearchTag))
                            {
                                researchManager.FinishProject(allDef);
                            }
                        }
                    }
                }
                if (Faction.OfPlayer.def.startingTechprintsResearchTags != null)
                {
                    foreach (ResearchProjectTagDef startingTechprintsResearchTag in Faction.OfPlayer.def.startingTechprintsResearchTags)
                    {
                        foreach (ResearchProjectDef allDef2 in DefDatabase <ResearchProjectDef> .AllDefs)
                        {
                            if (allDef2.HasTag(startingTechprintsResearchTag))
                            {
                                int techprints = researchManager.GetTechprints(allDef2);
                                if (techprints < allDef2.techprintCount)
                                {
                                    researchManager.AddTechprints(allDef2, allDef2.techprintCount - techprints);
                                }
                            }
                        }
                    }
                }
                GameComponentUtility.StartedNewGame();
                initData = null;
            }
            finally
            {
                DeepProfiler.End();
            }
        }