public override IEnumerable <StatDrawEntry> SpecialDisplayStats()
        {
            foreach (Faction allFaction in Find.FactionManager.AllFactions)
            {
                RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(parent.def, allFaction);
                if (minTitleToUse != null)
                {
                    yield return(new StatDrawEntry(StatCategoryDefOf.BasicsNonPawnImportant, "Stat_Thing_MinimumRoyalTitle_Name".Translate(allFaction.Named("FACTION")).Resolve(), minTitleToUse.GetLabelCapForBothGenders(), "Stat_Thing_Weapon_MinimumRoyalTitle_Desc".Translate(allFaction.Named("FACTION")).Resolve(), 2100));
                }
            }
            if (traits.NullOrEmpty())
            {
                yield break;
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Stat_Thing_PersonaWeaponTrait_Desc".Translate());
            stringBuilder.AppendLine();
            for (int i = 0; i < traits.Count; i++)
            {
                stringBuilder.AppendLine(traits[i].LabelCap + ": " + traits[i].description);
                if (i < traits.Count - 1)
                {
                    stringBuilder.AppendLine();
                }
            }
            yield return(new StatDrawEntry(StatCategoryDefOf.Weapon, "Stat_Thing_PersonaWeaponTrait_Label".Translate(), traits.Select((WeaponTraitDef x) => x.label).ToCommaList().CapitalizeFirst(), stringBuilder.ToString(), 5404));
        }
Esempio n. 2
0
 public void Notify_RoyalThingUseViolation(Def implantOrWeapon, Pawn pawn, string violationSourceName, float detectionChance, int violationSourceLevel = 0)
 {
     if (!this.HostileTo(OfPlayer))
     {
         RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(implantOrWeapon, this, violationSourceLevel);
         string        arg           = (minTitleToUse == null) ? ((string)"None".Translate()) : minTitleToUse.GetLabelCapFor(pawn);
         TryAffectGoodwillWith(pawn.Faction, -4, canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangedReason_UsedForbiddenThing".Translate(pawn.Named("PAWN"), violationSourceName.Named("CULPRIT")), pawn);
         Find.LetterStack.ReceiveLetter("LetterLawViolationDetectedLabel".Translate(pawn.Named("PAWN")).CapitalizeFirst(), "LetterLawViolationDetectedForbiddenThingUse".Translate(arg.Named("TITLE"), pawn.Named("PAWN"), violationSourceName.Named("CULPRIT"), this.Named("FACTION"), 4.ToString().Named("GOODWILL"), detectionChance.ToStringPercent().Named("CHANCE")), LetterDefOf.NegativeEvent, pawn);
     }
 }
Esempio n. 3
0
 public override IEnumerable <StatDrawEntry> SpecialDisplayStats()
 {
     foreach (Faction allFaction in Find.FactionManager.AllFactions)
     {
         RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(parent.def, allFaction);
         if (minTitleToUse != null)
         {
             yield return(new StatDrawEntry(StatCategoryDefOf.BasicsNonPawnImportant, "Stat_Thing_MinimumRoyalTitle_Name".Translate(allFaction.Named("FACTION")).Resolve(), minTitleToUse.GetLabelCapForBothGenders(), "Stat_Thing_Weapon_MinimumRoyalTitle_Desc".Translate(allFaction.Named("FACTION")).Resolve(), 2100));
         }
     }
 }
        public static IEnumerable <ThingDef> GetAllowedThingDefs(ThingSetMakerParams parms)
        {
            TechLevel techLevel           = parms.techLevel ?? TechLevel.Undefined;
            IEnumerable <ThingDef> source = parms.filter.AllowedThingDefs;

            if (techLevel != 0)
            {
                source = source.Where((ThingDef x) => (int)x.techLevel <= (int)techLevel);
            }
            RoyalTitleDef highestTitle = null;

            if (parms.makingFaction != null && parms.makingFaction.def.HasRoyalTitles)
            {
                foreach (Pawn allMapsCaravansAndTravelingTransportPods_Alive_Colonist in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists)
                {
                    RoyalTitleDef royalTitleDef = ((allMapsCaravansAndTravelingTransportPods_Alive_Colonist.royalty != null) ? allMapsCaravansAndTravelingTransportPods_Alive_Colonist.royalty.GetCurrentTitle(parms.makingFaction) : null);
                    if (royalTitleDef != null && (highestTitle == null || royalTitleDef.seniority > highestTitle.seniority))
                    {
                        highestTitle = royalTitleDef;
                    }
                }
            }
            source = source.Where(delegate(ThingDef x)
            {
                CompProperties_Techprint compProperties = x.GetCompProperties <CompProperties_Techprint>();
                if (compProperties != null)
                {
                    if (parms.makingFaction != null && !compProperties.project.heldByFactionCategoryTags.Contains(parms.makingFaction.def.categoryTag))
                    {
                        return(false);
                    }
                    if (compProperties.project.IsFinished || compProperties.project.TechprintRequirementMet)
                    {
                        return(false);
                    }
                }
                if (parms.makingFaction != null && parms.makingFaction.def.HasRoyalTitles)
                {
                    RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(x, parms.makingFaction);
                    if (minTitleToUse != null && (highestTitle == null || highestTitle.seniority < minTitleToUse.seniority))
                    {
                        return(false);
                    }
                }
                return(true);
            });
            return(source.Where((ThingDef x) => CanGenerate(x) && (!parms.maxThingMarketValue.HasValue || x.BaseMarketValue <= parms.maxThingMarketValue) && (parms.validator == null || parms.validator(x))));
        }
Esempio n. 5
0
        public override void OnGUI(LocalTargetInfo target)
        {
            bool      flag      = ability.EffectComps.Any((CompAbilityEffect e) => e.Props.psychic);
            Texture2D texture2D = UIIcon;

            if (!Psycast.CanApplyPsycastTo(target))
            {
                texture2D = TexCommand.CannotShoot;
                DrawIneffectiveWarning(target);
            }
            if (target.IsValid && CanHitTarget(target) && IsApplicableTo(target))
            {
                if (flag)
                {
                    foreach (LocalTargetInfo affectedTarget in ability.GetAffectedTargets(target))
                    {
                        if (Psycast.CanApplyPsycastTo(affectedTarget))
                        {
                            DrawSensitivityStat(affectedTarget);
                        }
                        else
                        {
                            DrawIneffectiveWarning(affectedTarget);
                        }
                    }
                }
                if (ability.EffectComps.Any((CompAbilityEffect e) => !e.Valid(target)))
                {
                    texture2D = TexCommand.CannotShoot;
                }
            }
            else
            {
                texture2D = TexCommand.CannotShoot;
            }
            if (ThingRequiringRoyalPermissionUtility.IsViolatingRulesOfAnyFaction_NewTemp(HediffDefOf.PsychicAmplifier, CasterPawn, Psycast.def.level, ignoreSilencer: true) && Psycast.def.DetectionChance > 0f)
            {
                TaggedString taggedString = ((string)"Illegal".Translate()).ToUpper() + "\n" + Psycast.def.DetectionChance.ToStringPercent() + " " + "DetectionChance".Translate();
                Text.Font = GameFont.Small;
                GenUI.DrawMouseAttachment(texture2D, taggedString, 0f, default(Vector2), null, drawTextBackground: true, new Color(0.25f, 0f, 0f));
            }
            else
            {
                GenUI.DrawMouseAttachment(texture2D);
            }
            DrawAttachmentExtraLabel(target);
        }
 public bool IsViolatingRulesOf(Faction faction, int violationSourceLevel = -1)
 {
     return(ThingRequiringRoyalPermissionUtility.IsViolatingRulesOf(base.Def, parent.pawn, faction, (violationSourceLevel == -1) ? GetImplantLevel(parent) : violationSourceLevel));
 }
Esempio n. 7
0
        public static TaggedString CheckForViolations(Pawn pawn, HediffDef hediff, int levelOffset)
        {
            if (levelOffset < 0)
            {
                return("");
            }
            if (pawn.Faction != Faction.OfPlayer || !hediff.HasComp(typeof(HediffComp_RoyalImplant)))
            {
                return("");
            }
            Hediff_ImplantWithLevel hediff_ImplantWithLevel = (Hediff_ImplantWithLevel)pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => h.def == hediff);
            int num = (levelOffset != 0 && hediff_ImplantWithLevel != null) ? (hediff_ImplantWithLevel.level + levelOffset) : 0;

            foreach (Faction item in Find.FactionManager.AllFactionsListForReading)
            {
                if (pawn.Faction != null && !item.def.hidden && !item.HostileTo(Faction.OfPlayer) && ThingRequiringRoyalPermissionUtility.IsViolatingRulesOf(hediff, pawn, item, num))
                {
                    RoyalTitleDef minTitleForImplant = item.GetMinTitleForImplant(hediff, num);
                    HediffCompProperties_RoyalImplant hediffCompProperties_RoyalImplant = hediff.CompProps <HediffCompProperties_RoyalImplant>();
                    string       arg          = hediff.label + ((num == 0) ? "" : (" (" + num + "x)"));
                    TaggedString taggedString = hediffCompProperties_RoyalImplant.violationTriggerDescriptionKey.Translate(pawn.Named("PAWN"));
                    TaggedString t            = "RoyalImplantIllegalUseWarning".Translate(pawn.Named("PAWN"), arg.Named("IMPLANT"), item.Named("FACTION"), minTitleForImplant.GetLabelCapFor(pawn).Named("TITLE"), taggedString.Named("VIOLATIONTRIGGER"));
                    if (levelOffset != 0)
                    {
                        return(t + ("\n\n" + "RoyalImplantUpgradeConfirmation".Translate()));
                    }
                    return(t + ("\n\n" + "RoyalImplantInstallConfirmation".Translate()));
                }
            }
            return("");
        }