Example #1
0
        public static void ApplyTechshards(ResearchProjectDef proj, Pawn applyingPawn, int amount)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("LetterTechshardAppliedPartIntro".Translate(amount, proj.Named("PROJECT")));
            stringBuilder.AppendLine();
            string letter = "";

            if (ApplyShardsToUnlock(proj, amount, stringBuilder, applyingPawn))
            {
                return;
            }
            else if (!TechprintingSettings.enableUnlockedTechPrinting)
            {
                stringBuilder.AppendLine("LetterTechshardAppliedPartAlreadyResearched".Translate(proj.Named("PROJECT")));
                stringBuilder.AppendLine();
                letter = "LetterTechsardNoEffectLabel".Translate(amount, proj.Named("PROJECT"));
            }
            else if (proj.IsFinished)
            {
                stringBuilder.AppendLine("LetterTechshardAppliedPartResearchDisabled".Translate(proj.Named("PROJECT")));
                stringBuilder.AppendLine();
                letter = "LetterTechsardNoEffectLabel".Translate(amount, proj.Named("PROJECT"));
            }
            else if (ApplyShardsToResearch(proj, amount, stringBuilder, applyingPawn))
            {
                return;
            }
            if (stringBuilder.Length > 0)
            {
                Find.LetterStack.ReceiveLetter(letter, stringBuilder.ToString().TrimEndNewlines(), LetterDefOf.PositiveEvent, null);
            }
        }
Example #2
0
        public override void Execute([NotNull] Viewer viewer, Pawn pawn)
        {
            if (!viewer.username.Equals("scavenging_mechanic", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            if (!pawn.story.traits.HasTrait(TraitDefOf.Transhumanist))
            {
                if (pawn.story.traits.allTraits.Count >= AddTraitSettings.maxTraits)
                {
                    Trait trait = pawn.story.traits.allTraits.RandomElement();
                    TraitHelper.RemoveTraitFromPawn(pawn, trait);
                }

                TraitHelper.GivePawnTrait(pawn, new Trait(TraitDefOf.Transhumanist));
            }

            if (ResearchProjectDef.Named("Bionics")?.IsFinished == true)
            {
                ApplyBionics(pawn);

                return;
            }

            if (ResearchProjectDef.Named("SimpleProsthetics")?.IsFinished == true)
            {
                ApplyProsthetics(pawn);

                return;
            }

            ApplyMedieval(pawn);
        }
        /// <summary>
        /// Display the scan range of built mobile mineral sonar and the max scan range (according to research level) at the tested position.
        /// </summary>
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            base.DrawGhost(def, center, rot, ghostCol, thing);

            IEnumerable <Building> mobileMineralSonarList = Find.CurrentMap.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("MobileMineralSonar"));

            if (mobileMineralSonarList != null)
            {
                foreach (Building mobileMineralSonar in mobileMineralSonarList)
                {
                    (mobileMineralSonar as Building_MobileMineralSonar).DrawMaxScanRange();
                }
            }

            if (ResearchProjectDef.Named("ResearchMobileMineralSonarEnhancedScan").IsFinished)
            {
                Material  scanRange50       = MaterialPool.MatFrom("Effects/ScanRange50");
                Vector3   scanRangeScale50  = new Vector3(100f, 1f, 100f);
                Matrix4x4 scanRangeMatrix50 = default(Matrix4x4);
                // The 10f offset on Y axis is mandatory to be over the fog of war.
                scanRangeMatrix50.SetTRS(center.ToVector3ShiftedWithAltitude(AltitudeLayer.Blueprint) + new Vector3(0f, 15f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale50);
                Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix50, scanRange50, 0);
            }
            else
            {
                Material  scanRange30       = MaterialPool.MatFrom("Effects/ScanRange30");
                Vector3   scanRangeScale30  = new Vector3(60f, 1f, 60f);
                Matrix4x4 scanRangeMatrix30 = default(Matrix4x4);
                // The 10f offset on Y axis is mandatory to be over the fog of war.
                scanRangeMatrix30.SetTRS(center.ToVector3ShiftedWithAltitude(AltitudeLayer.Blueprint) + new Vector3(0f, 15f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale30);
                Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix30, scanRange30, 0);
            }
        }
Example #4
0
        public void RevealDeityCheck()
        {
            //Cthulhu.Utility.DebugReport("Reveal Deity Check");
            ResearchProjectDef deityResearch = ResearchProjectDef.Named("Forbidden_Deities");

            if (deityResearch.IsFinished && undiscoveredEntities().Count > 0)
            {
                foreach (CosmicEntity entity in undiscoveredEntities())
                {
                    entity.discovered = true;
                    Cthulhu.Utility.DebugReport("Change research should be called.");
                    Cthulhu.Utility.ChangeResearchProgress(deityResearch, 0f, true);
                    var message = "Cults_DiscoveredDeityMessage".Translate(entity.Label);
                    Messages.Message(message, MessageTypeDefOf.PositiveEvent);

                    StringBuilder s = new StringBuilder();
                    s.AppendLine(message);
                    s.AppendLine();
                    s.AppendLine(entity.Info());
                    Find.LetterStack.ReceiveLetter("Cults_Discovered".Translate(), s.ToString(),
                                                   LetterDefOf.NeutralEvent, null);
                    break;
                }
            }
            else if (undiscoveredEntities().Count == 0)
            {
                Cthulhu.Utility.ChangeResearchProgress(deityResearch, deityResearch.baseCost);
            }
        }
        private void GiveInteractionSanityLoss()
        {
            Pawn temp = InteractingPawn;
            ResearchProjectDef currentProject = Find.ResearchManager.currentProj;
            float modifier = 0.0040f;

            if (temp == null)
            {
                return;
            }
            if (currentProject == null)
            {
                return;
            }
            if (!IsThisCultistResearch(currentProject))
            {
                return;
            }
            UsageWarning(temp);
            if (Find.ResearchManager.currentProj == ResearchProjectDef.Named("Forbidden_Lore"))
            {
                modifier *= 1.2f;
                temp.skills.Learn(SkillDefOf.Social, SocialSkillBoost);
            }
            Cthulhu.Utility.ApplySanityLoss(temp, modifier, MaxSanityLoss);
            CultUtility.AffectCultMindedness(temp, modifier, MaxCultMindedBoost);
        }
        /// <summary>
        /// Display the scan range of built mobile mineral sonar and the max scan range at the tested position.
        /// Allow placement nearly anywhere.
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null)
        {
            IEnumerable <Building> mobileMineralSonarList = map.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("MobileMineralSonar"));

            if (mobileMineralSonarList != null)
            {
                foreach (Building mobileMineralSonar in mobileMineralSonarList)
                {
                    (mobileMineralSonar as Building_MobileMineralSonar).DrawMaxScanRange();
                }
            }

            if (ResearchProjectDef.Named("ResearchMobileMineralSonarEnhancedScan").IsFinished)
            {
                Material  scanRange50       = MaterialPool.MatFrom("Effects/ScanRange50");
                Vector3   scanRangeScale50  = new Vector3(100f, 1f, 100f);
                Matrix4x4 scanRangeMatrix50 = default(Matrix4x4);
                // The 10f offset on Y axis is mandatory to be over the fog of war.
                scanRangeMatrix50.SetTRS(loc.ToVector3ShiftedWithAltitude(AltitudeLayer.Blueprint) + new Vector3(0f, 15f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale50);
                Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix50, scanRange50, 0);
            }
            else
            {
                Material  scanRange30       = MaterialPool.MatFrom("Effects/ScanRange30");
                Vector3   scanRangeScale30  = new Vector3(60f, 1f, 60f);
                Matrix4x4 scanRangeMatrix30 = default(Matrix4x4);
                // The 10f offset on Y axis is mandatory to be over the fog of war.
                scanRangeMatrix30.SetTRS(loc.ToVector3ShiftedWithAltitude(AltitudeLayer.Blueprint) + new Vector3(0f, 15f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale30);
                Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix30, scanRange30, 0);
            }

            return(true);
        }
Example #7
0
 public ThingDef GetPlantDefToGrow()
 {
     if (ResearchProjectDef.Named("BR_Xenobotany").IsFinished)
     {
         return(this.plantDefToGrow);
     }
     return(ThingDefOf.Plant_Potato);
 }
 // ===================== Static functions =====================
 public static void TryUpdateScanParameters()
 {
     if (ResearchProjectDef.Named("ResearchMobileMineralSonarEnhancedScan").IsFinished)
     {
         maxScanRange    = enhancedMaxScanRange;
         detectionChance = enhancedDetectionChance;
     }
 }
Example #9
0
 protected override void BeforeWork()
 {
     amount = BaseDamagePerPickHit;
     if (ResearchProjectDef.Named("PneumaticPicks").IsFinished)
     {
         amount = (int)Math.Round((double)amount * 1.2f);
     }
 }
Example #10
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);
        }
        public override void CompPostMake()
        {
            // Check to see if they've unlocked the MK2 version of this drug
            ResearchProjectDef Psychan2 = ResearchProjectDef.Named("PanPsychanMK2");
            bool completedResearch      = Psychan2.IsFinished;

            List <Hediff> Hediffs        = base.Pawn.health.hediffSet.GetHediffs <Hediff>().ToList();
            bool          overdosed      = false;
            bool          illegalDrug    = false;
            Hediff        overdoseHediff = null;

            foreach (Hediff hediff in Hediffs)
            {
                var StrHediff = hediff.ToString();
                if (StrHediff.Contains("High"))
                {
                    if (completedResearch == true)
                    {
                        if (!StrHediff.Contains("GoJuice") && !StrHediff.Contains("Luciferium"))
                        {
                            base.Pawn.health.RemoveHediff(hediff);
                        }
                        else
                        {
                            // Don't treat overdoses for Luciferium or Go-Juice
                            illegalDrug = true;
                        }
                    }
                    else
                    {
                        if (!StrHediff.Contains("GoJuice") && !StrHediff.Contains("Luciferium") && !StrHediff.Contains("Flake") && !StrHediff.Contains("Yayo"))
                        {
                            base.Pawn.health.RemoveHediff(hediff);
                        }
                        else
                        {
                            // Don't treat overdoses for Luciferium or Go-Juice
                            illegalDrug = true;
                        }
                    }
                }

                if (StrHediff.Contains("Overdose"))
                {
                    overdosed      = true;
                    overdoseHediff = hediff;
                }

                if (overdosed == true && illegalDrug == false)
                {
                    if (overdoseHediff != null)
                    {
                        overdoseHediff.Severity -= 0.75f;
                    }
                }
            }
        }
Example #12
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 intVec;

            return(base.CanFireNowSub(parms) &&
                   this.TryFindEntryCell(map, out intVec) && AlphaAnimalsEvents_Mod.settings.flagAlphaMechanoidsSappers &&
                   ResearchProjectDef.Named("Fabrication").IsFinished);
        }
Example #13
0
        public static bool ApplyShardsToUnlock(ResearchProjectDef proj, int numShards, StringBuilder sb = null, Pawn applyingPawn = null)
        {
            ResearchProjectDef unlockTarget = FindBestProjectToUnlock(proj);

            if (unlockTarget == null)
            {
                return(false);
            }

            if (applyingPawn != null)
            {
                RefundUnlock(unlockTarget, applyingPawn, numShards);
            }
            AdvanceShardReq(unlockTarget, numShards, proj);


            if (sb == null)
            {
                sb = new StringBuilder();
            }
            bool   unlocked = false;
            string letter;

            if (unlockTarget.techprintCount <= Current.Game.researchManager.GetTechprints(unlockTarget))
            {
                sb.AppendLine("LetterTechshardAppliedPartJustUnlocked".Translate(unlockTarget.Named("PROJECT")));
                sb.AppendLine();
                unlocked = true;
                letter   = "LetterTechshardAppliedLabel".Translate(numShards, unlockTarget.Named("PROJECT"));
            }
            else
            {
                sb.AppendLine("LetterTechshardAppliedPartNotUnlockedYet".Translate(Current.Game.researchManager.GetTechprints(unlockTarget), unlockTarget.techprintCount.ToString(), unlockTarget.Named("PROJECT")));
                sb.AppendLine();
                letter = "LetterTechshardAppliedLabel".Translate(numShards, unlockTarget.Named("PROJECT"));
            }
            Find.LetterStack.ReceiveLetter(letter, sb.ToString().TrimEndNewlines(), LetterDefOf.PositiveEvent, null);
            if (unlocked)
            {
                Find.LetterStack.ReceiveLetter("LetterTechshardUnlockedLabel".Translate(unlockTarget.LabelCap.Named("PROJECT")), "LetterTechshardAppliedPartJustUnlocked".Translate(unlockTarget.Named("PROJECT")), LetterDefOf.PositiveEvent, null);
                Base.UpdateTechshardRecipes();
            }
            return(true);
        }
        // ===================== Static functions =====================
        public static void TryUpdateScanParameters()
        {
            ResearchProjectDef mmsResearch = ResearchProjectDef.Named("ResearchMobileMineralSonarEnhancedScan");

            if (Find.ResearchManager.GetProgress(mmsResearch) >= mmsResearch.baseCost)
            {
                maxScanRange    = enhancedMaxScanRange;
                detectionChance = enhancedDetectionChance;
            }
        }
Example #15
0
 public Zone_GrowingBotanics()
 {
     if (ResearchProjectDef.Named("BR_Xenobotany").IsFinished)
     {
         this.plantDefToGrow = ThingDef.Named("BR_NutrientBrothPlant");
     }
     else
     {
         plantDefToGrow = ThingDefOf.Plant_Potato;
     }
 }
Example #16
0
        public static void TryAddRecipeMakeHighPrecisionLasgun()
        {
            ThingDef securityWorkbench = DefDatabase <ThingDef> .GetNamed("SecurityWorkbench");

            if ((Find.ResearchManager.IsFinished(ResearchProjectDef.Named("ResearchHighPrecisionLasgun")) == true) &&
                (securityWorkbench.recipes.Contains(DefDatabase <RecipeDef> .GetNamed("MakeHighPrecisionLasgun")) == false))
            {
                securityWorkbench.recipes.Add(DefDatabase <RecipeDef> .GetNamed("MakeHighPrecisionLasgun"));
                typeof(ThingDef).GetField("allRecipesCached", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(securityWorkbench, null);
            }
        }
        protected void BurstComplete()
        {
            if (this.def.building.turretBurstCooldownTime >= 0f)
            {
                this.burstCooldownTicksLeft = this.def.building.turretBurstCooldownTime.SecondsToTicks();
            }
            else
            {
                this.burstCooldownTicksLeft = this.GunCompEq.PrimaryVerb.verbProps.defaultCooldownTime.SecondsToTicks();
            }
            this.loaded = false;


            if (cooldownResearchName.NullOrEmpty() ||
                DefDatabase <ResearchProjectDef> .GetNamedSilentFail(cooldownResearchName) == null ||
                !ResearchProjectDef.Named(cooldownResearchName).IsFinished)
            {
                // Research for reduction not found or not finished
                if (cooldownMultiplicator >= 0.1f)
                {
                    burstCooldownTicksLeft = (int)Math.Round(burstCooldownTicksLeft * cooldownMultiplicator + cooldownAddition);
                }
                else
                {
                    burstCooldownTicksLeft = (int)Math.Round(burstCooldownTicksLeft + cooldownAddition);
                }
            }
            else
            {
                // Research for reduction finished
                if (cooldownResearchMultiplicator >= 0.1f)
                {
                    burstCooldownTicksLeft = (int)Math.Round(burstCooldownTicksLeft * cooldownResearchMultiplicator + cooldownResearchAddition);
                }
                else
                {
                    burstCooldownTicksLeft = (int)Math.Round(burstCooldownTicksLeft + cooldownResearchAddition);
                }
            }

            if (GunCompEq.PrimaryVerb.verbProps.consumeFuelPerShot > 0f)
            {
                this.TryGetComp <CompRefuelable>()?.ConsumeFuel(GunCompEq.PrimaryVerb.verbProps.consumeFuelPerShot);
            }
            else
            if (GunCompEq.PrimaryVerb.verbProps.burstShotCount >= 1)
            {
                this.TryGetComp <CompRefuelable>()?.ConsumeFuel(1 * GunCompEq.PrimaryVerb.verbProps.burstShotCount);
            }
            else
            {
                this.TryGetComp <CompRefuelable>()?.ConsumeFuel(1);
            }
        }
Example #18
0
        public static void TryAddRecipeMakeMineralSonarModule()
        {
            if (ModsConfig.IsActive("M&Co. MMS"))
            {
                ThingDef electronicWorkbench = DefDatabase <ThingDef> .GetNamed("ElectronicWorkbench");

                if ((Find.ResearchManager.IsFinished(ResearchProjectDef.Named("ResearchMobileMineralSonar")) == true) &&
                    (electronicWorkbench.recipes.Contains(DefDatabase <RecipeDef> .GetNamed("MakeMineralSonarModule")) == false))
                {
                    electronicWorkbench.recipes.Add(DefDatabase <RecipeDef> .GetNamed("MakeMineralSonarModule"));
                    typeof(ThingDef).GetField("allRecipesCached", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(electronicWorkbench, null);
                }
            }
        }
Example #19
0
        //Adds a marker to research projects that unlock NV stuff so people know how cool I am
        public void AddNightVisionMarkerToVanillaResearch()
        {
            ResearchProjectDef complexClothing  = ResearchProjectDef.Named(defName: "ComplexClothing");
            ResearchProjectDef microelectronics = ResearchProjectDef.Named(defName: "MicroelectronicsBasics");
            ResearchProjectDef powerArmour      = ResearchProjectDef.Named(defName: "PoweredArmor");

            complexClothing.label  += " NV+";
            microelectronics.label += " NV+";
            powerArmour.label      += " NV+";

            complexClothing.description  += $"\n{"NVResClothAddition".Translate()}";
            microelectronics.description += $"\n{"NVResMicroAddition".Translate()}";
            powerArmour.description      += $"\n{"NVResPowerAddition".Translate()}";
        }
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            bool result;

            if (!base.CanFireNowSub(parms))
            {
                result = false;
            }
            else
            {
                Map map = (Map)parms.target;
                //Find.FactionManager.OfPlayer.);
                return(ResearchProjectDef.Named("MicroelectronicsBasics").IsFinished);
            }
            return(result);
        }
Example #21
0
        public override IEnumerable <Command> GetCommands()
        {
            IEnumerable <Command> commands;
            IList <Command>       commands1     = new List <Command>();
            Command_Action        commandAction = new Command_Action();

            commandAction.icon = Table_Medium.Ui_Change;
            if (this.roll <= 0 && Find.ResearchManager.IsFinished(ResearchProjectDef.Named("TableCustom")))
            {
                commandAction.defaultDesc = "Next: Spacer with clutter";
            }
            if (this.roll <= 1 && roll > 0)
            {
                commandAction.defaultDesc = "Next: Midworld clean";
            }
            if (this.roll <= 2 && roll > 1 && Find.ResearchManager.IsFinished(ResearchProjectDef.Named("TableCustom")))
            {
                commandAction.defaultDesc = "Next: Midworld with clutter";
            }
            if (this.roll <= 3 && roll > 2)
            {
                commandAction.defaultDesc = "Next: Spacer clean";
            }
            if (this.roll >= 4)
            {
                roll = 0;
            }
            if (this.roll <= 0 && !Find.ResearchManager.IsFinished(ResearchProjectDef.Named("TableCustom")))
            {
                commandAction.defaultDesc = "Next: Midworld clean";
            }

            if (this.roll <= 2 && roll > 1 && !Find.ResearchManager.IsFinished(ResearchProjectDef.Named("TableCustom")))
            {
                commandAction.defaultDesc = "Next: Spacer clean";
            }
            commandAction.activateSound = SoundDef.Named("Click");
            commandAction.action        = new Action(SwitchTextureState);
            commandAction.groupKey      = 887765321;
            commands1.Add(commandAction);

            IEnumerable <Command> commands2 = base.GetCommands();

            commands = (commands2 == null ? commands1.AsEnumerable <Command>() : commands1.AsEnumerable <Command>().Concat <Command>(commands2));
            return(commands);
        }
Example #22
0
        public void SwitchTextureState()
        {
            if (this.roll >= 4)
            {
                roll = 0;
            }
            if (this.roll < 4 && Find.ResearchManager.IsFinished(ResearchProjectDef.Named("TableCustom")))
            {
                roll++;
            }
            if (this.roll < 4 && !Find.ResearchManager.IsFinished(ResearchProjectDef.Named("TableCustom")))
            {
                roll = roll + 2;
            }



            Find.MapDrawer.MapChanged(Position, MapChangeType.Things);
        }
Example #23
0
        public override void SpawnSetup()
        {
            base.SpawnSetup();
            AFS.UI_Son = ContentFinder <Texture2D> .Get("Clutter/Ui/Ui_Switch_on", true);

            AFS.UI_Soff = ContentFinder <Texture2D> .Get("Clutter/Ui/Ui_Switch_off", true);

            glowerComp = base.GetComp <CompGlower>();
            Afs_On     = MaterialPool.MatFrom("Clutter/Devices/AFS_ON", true);
            Afs_Off    = MaterialPool.MatFrom("Clutter/Devices/AFS_OFF", true);
            charge     = 20;
            if (Find.ResearchManager.IsFinished(ResearchProjectDef.Named("AFSLife")))
            {
                charge = (charge + 5);
            }
            if (Find.ResearchManager.IsFinished(ResearchProjectDef.Named("AFSCore")))
            {
                charge = (charge + 10);
            }
        }
Example #24
0
        public void FinishWeatherControllerExtraction()
        {
            string eventText = "   You have successfully extracted the weather controller from the mechanoid terraformer.\n\n"
                               + "You can now build your own one to unleash the sky's wrath on your ennemies.";

            Find.LetterStack.ReceiveLetter("Extraction", eventText, LetterType.Good, this.Position);
            this.Destroy(DestroyMode.Deconstruct);
            GenSpawn.Spawn(ThingMaker.MakeThing(Util_MechanoidTerraformer.WeatherControllerCoreDef), this.Position);
            if (Find.ResearchManager.IsFinished(ResearchProjectDef.Named("ResearchSkywrathController")) == false)
            {
                Find.ResearchManager.currentProj = ResearchProjectDef.Named("ResearchSkywrathController");
                Find.ResearchManager.InstantFinish(ResearchProjectDef.Named("ResearchSkywrathController"));
            }

            // Beacon has not been disabled, anticipated invasion is launched.
            if (this.invasionIsDone == false)
            {
                string eventTextInvasion = "   Before its extraction, the mechanoid terraformer AI core controller somehow detected your attempts at shutting it down.\n"
                                           + "It had enough time to emit an emergency call. Be prepared to welcome the incoming terrafomer defending force.";
                this.LaunchInvasion("Invasion", eventTextInvasion, 0.8f, 4, LetterType.BadUrgent);
            }
        }
Example #25
0
        public void ResetResearchCheck()
        {
            try
            {
                ResearchProjectDef repeatableResearch = ResearchProjectDef.Named("Forbidden_Lore");

                if (repeatableResearch != null)
                {
                    if (ModSettings_Data.cultsStudySuccessfulCultsIsRepeatable == true)
                    {
                        if (repeatableResearch.IsFinished)
                        {
                            Cthulhu.Utility.ChangeResearchProgress(repeatableResearch, 0f, true);
                            Messages.Message("RepeatableResearch".Translate(
                                                 repeatableResearch.LabelCap
                                                 ), MessageTypeDefOf.PositiveEvent);
                        }
                    }
                }
            }
            catch (NullReferenceException) { }
        }
Example #26
0
        public override void SpawnSetup()
        {
            base.SpawnSetup();
            FireKill();


            PlasmaF1       = MaterialPool.MatFrom("Clutter/Devices/IcePlasmaF1", true);
            PlasmaF2       = MaterialPool.MatFrom("Clutter/Devices/IcePlasmaF2", true);
            PlasmaF3       = MaterialPool.MatFrom("Clutter/Devices/IcePlasmaF3", true);
            glowerComp     = base.GetComp <CompGlower>();
            glowerComp.Lit = true;
            this.grow      = 0.1f;
            if (Find.ResearchManager.IsFinished(ResearchProjectDef.Named("AFSLife")))
            {
                this.lifeline = 1000;
            }
            else
            {
                this.lifeline = 300;
            }


            Vector3 spawnLoc = this.DrawPos * 0.1f;
        }
Example #27
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo g in base.GetGizmos())
            {
                yield return(g);
            }
            if (ResearchProjectDef.Named("BR_Xenobotany").IsFinished)
            {
                yield return(PlantToGrowSettableUtility.SetPlantToGrowCommand(this));

                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandAllowSow".Translate(),
                    defaultDesc = "CommandAllowSowDesc".Translate(),
                    hotKey = KeyBindingDefOf.Command_ItemForbid,
                    icon = TexCommand.ForbidOff,
                    isActive = (() => this.allowSow),
                    toggleAction = delegate
                    {
                        this.allowSow = !this.allowSow;
                    }
                });
            }
        }
Example #28
0
 public static bool IsResearched(this string name)
 {
     return(Find.ResearchManager.IsFinished(ResearchProjectDef.Named(name)));
 }
Example #29
0
        internal static ThingDef CreateNanoBedDefFromSupportedBed(this ThingDef bed, Action <ThingDef> fnAdditionalProcessing, List <ThingDef> linkableBuildings, List <CompProperties_Facility> facilities)
        {
            Type typeRimworldBed = typeof(Building_Bed);
            Type bedToClone      = bed.GetType();

            if (typeRimworldBed.IsAssignableFrom(bedToClone))
            {
                throw new Exception("Type [" + bedToClone.Name + "] is not supported.");
            }

            FieldInfo[] fields = typeof(ThingDef).GetFields(BindingFlags.Public | BindingFlags.Instance);
            ThingDef    nBed   = new ThingDef();

            foreach (FieldInfo field in fields)
            {
                field.SetValue(nBed, field.GetValue(bed));
            }

            nBed.comps = new List <CompProperties>();
            for (int i = 0; i < bed.comps.Count; i++)
            {
                ConstructorInfo constructor = bed.comps[i].GetType().GetConstructor(Type.EmptyTypes);
                CompProperties  comp        = (CompProperties)constructor.Invoke(null);

                fields = comp.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
                foreach (FieldInfo field in fields)
                {
                    field.SetValue(comp, field.GetValue(bed.comps[i]));
                }

                nBed.comps.Add(comp);
            }

            nBed.statBases.Add(new StatModifier()
            {
                stat = StatDef.Named("Ogre_NanoApparelRate"), value = 0
            });
            nBed.statBases.Add(new StatModifier()
            {
                stat = StatDef.Named("Ogre_NanoWeaponsRate"), value = 0
            });

            CompProperties_Power power = new CompProperties_Power();

            power.compClass            = typeof(CompPowerTrader);
            power.basePowerConsumption = 60f;
            power.shortCircuitInRain   = false;
            nBed.comps.Add(power);

            CompProperties_Flickable flick = new CompProperties_Flickable();

            flick.compClass = typeof(CompFlickable);
            nBed.comps.Add(flick);

            CompProperties_Refuelable fuel = new CompProperties_Refuelable();

            fuel.fuelConsumptionRate     = 0;
            fuel.fuelCapacity            = 25.0f * bed.size.x;  // same way it calculates in BedUtility
            fuel.consumeFuelOnlyWhenUsed = true;
            fuel.fuelFilter = new ThingFilter();
            fuel.fuelFilter.SetAllow(ThingDef.Named("Ogre_NanoTechFuel"), true);
            nBed.comps.Add(fuel);

            Dictionary <string, int> cost = new Dictionary <string, int>()
            {
                { "ComponentIndustrial", 1 },
                { "Steel", 5 }
            };

            if (nBed.costList == null)
            {
                nBed.costList = new List <ThingDefCountClass>();
            }

            Dictionary <string, ThingDefCountClass> current = nBed.costList.ToDictionary(x => x.thingDef.defName, y => y);


            foreach (string item in cost.Keys)
            {
                ThingDefCountClass count = null;
                if (!current.TryGetValue(item, out count))
                {
                    count = new ThingDefCountClass(ThingDef.Named(item), (cost[item] * nBed.size.x));
                    nBed.costList.Add(count);
                }
                else
                {
                    count.count += (cost[item] * nBed.size.x);
                }
            }

            bool found = false;

            nBed.researchPrerequisites = new List <ResearchProjectDef>();
            if (bed.researchPrerequisites != null && bed.researchPrerequisites.Count > 0)
            {
                foreach (ResearchProjectDef d in bed.researchPrerequisites)
                {
                    if (d.defName == "Ogre_NanoTech")
                    {
                        found = true;
                    }
                    nBed.researchPrerequisites.Add(d);
                }
            }

            if (!found)
            {
                nBed.researchPrerequisites.Add(ResearchProjectDef.Named("Ogre_NanoTech"));
            }


            nBed.defName                      += "_NanoBed";
            nBed.description                  += "\n\n" + TranslatorFormattedStringExtensions.Translate("NanoTech.Description.Short");
            nBed.label                         = TranslatorFormattedStringExtensions.Translate("NanoTech.ModName.Short") + " " + nBed.label;
            nBed.thingClass                    = typeof(NanoBed);
            nBed.tradeability                  = Tradeability.None;
            nBed.scatterableOnMapGen           = false;
            nBed.tickerType                    = TickerType.Rare;
            nBed.constructionSkillPrerequisite = bed.constructionSkillPrerequisite < 2 ? 2 : bed.constructionSkillPrerequisite;
            nBed.uiIconScale                   = 0.9f;
            nBed.techLevel                     = TechLevel.Industrial;
            nBed.shortHash                     = 0;

            // as of 1.3 without this, it wont
            // show the out of fuel icon
            nBed.drawerType = DrawerType.RealtimeOnly;

            nBed.designationCategory = DefDatabase <DesignationCategoryDef> .AllDefsListForReading.Find(x => x.defName == "Ogre_NanoRepairTech_DesignationCategory");

            MethodInfo newBluePrintDef = typeof(RimWorld.ThingDefGenerator_Buildings).GetMethod("NewBlueprintDef_Thing", BindingFlags.Static | BindingFlags.NonPublic);

            nBed.blueprintDef = (ThingDef)newBluePrintDef.Invoke(null, new object[] { nBed, false, null });

            MethodInfo newFrameDef = typeof(RimWorld.ThingDefGenerator_Buildings).GetMethod("NewFrameDef_Thing", BindingFlags.Static | BindingFlags.NonPublic);

            nBed.frameDef = (ThingDef)newFrameDef.Invoke(null, new object[] { nBed });

            if (bed.building.bed_humanlike)
            {
                CompProperties_AffectedByFacilities abf = nBed.GetCompProperties <CompProperties_AffectedByFacilities>();
                if (abf == null)
                {
                    abf = new CompProperties_AffectedByFacilities();
                    nBed.comps.Add(abf);
                }

                if (abf.linkableFacilities == null)
                {
                    abf.linkableFacilities = new List <ThingDef>();
                }

                abf.linkableFacilities.AddRange(linkableBuildings);

                foreach (CompProperties_Facility f in facilities)
                {
                    f.linkableBuildings.Add(nBed);
                }
            }

            if (fnAdditionalProcessing != null)
            {
                fnAdditionalProcessing.Invoke(nBed);
            }

            typeof(ShortHashGiver).GetMethod("GiveShortHash", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { nBed, typeof(ThingDef) });

            return(nBed);
        }
Example #30
0
        public static bool ApplyShardsToResearch(ResearchProjectDef proj, int numShards, StringBuilder sb = null, Pawn applyingPawn = null)
        {
            ResearchProjectDef xpTarget = FindBestProjectToAdvance(proj);

            if (xpTarget == null)
            {
                return(false);
            }
            int xpGained = ConvertShardsToProgress(xpTarget, numShards, proj);

            if (applyingPawn != null)
            {
                RefundXP(xpTarget, applyingPawn, proj, numShards, xpGained);
            }
            AdvanceResearch(xpTarget, xpGained);

            if (sb == null)
            {
                sb = new StringBuilder();
            }
            sb.AppendLine("LetterTechshardAppliedPartAlreadyUnlocked".Translate(xpGained, xpTarget.Named("PROJECT")));;
            sb.AppendLine();
            string letter = "LetterTechshardAppliedToResearchLabel".Translate(xpGained, xpTarget.Named("PROJECT"));

            Find.LetterStack.ReceiveLetter(letter, sb.ToString().TrimEndNewlines(), LetterDefOf.PositiveEvent, null);
            if (xpTarget.IsFinished)
            {
                Find.ResearchManager.FinishProject(xpTarget, doCompletionDialog: false, researcher: applyingPawn);
                Find.LetterStack.ReceiveLetter("LetterTechshardResearchedLabel".Translate(xpTarget.LabelCap.Named("PROJECT")), "LetterTechshardAppliedPartJustResearched".Translate(xpTarget.LabelCap.Named("PROJECT")), LetterDefOf.PositiveEvent, null);
                Base.UpdateTechshardRecipes();
            }

            return(true);
        }