public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) { Need_ForcePool forcePool = pawn.needs.TryGetNeed<Need_ForcePool>(); if (forcePool == null) { return ThinkResult.NoJob; } CompForceUser compForce = pawn.TryGetComp<CompForceUser>(); if (compForce == null) { return ThinkResult.NoJob; } Trait sensitiveTrait = pawn.story.traits.GetTrait(ProjectJediDefOf.PJ_ForceSensitive); if (sensitiveTrait != null) { return ThinkResult.NoJob; } if (compForce.ForceData.TicksUntilMeditate > Find.TickManager.TicksAbs) { return ThinkResult.NoJob; } if (forcePool.CurCategory > ForcePoolCategory.Strong) { return ThinkResult.NoJob; } return base.TryIssueJobPackage(pawn, jobParams); }
public static void InfoPaneSensitive(Rect inRect, CompForceUser compForce) { var rectLevel = new Rect(inRect.x, inRect.y, inRect.width * 0.7f, TextSize); Text.Font = GameFont.Small; Widgets.Label(rectLevel, "PJ_SensitiveMessage".Translate(compForce.AbilityUser.LabelShort)); Text.Font = GameFont.Small; if (DebugSettings.godMode) { var rectDebugPlus = new Rect(rectLevel.xMax, inRect.y, inRect.width * 0.3f, TextSize); if (Widgets.ButtonText(rectDebugPlus, "+", true, false)) { compForce.LevelUp(true); } } //Something is awakening... var rectPointsAvail = new Rect(inRect.x, rectLevel.yMax, inRect.width, TextSize); var rectLevelBar = new Rect(rectPointsAvail.x, rectPointsAvail.yMax + 3f, inRect.width - 10f, HeaderSize * 0.6f); DrawLevelBar(rectLevelBar, compForce, true); }
public static void DrawLevelBar(Rect rect, CompForceUser compForce, bool sensitive = false) { ////base.DrawOnGUI(rect, maxThresholdMarkers, customMargin, drawArrows, doTooltip); if (rect.height > 70f) { var num = (rect.height - 70f) / 2f; rect.height = 70f; rect.y += num; } if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } TooltipHandler.TipRegion(rect, new TipSignal(() => ForceXPTipString(compForce, sensitive), rect.GetHashCode())); var num2 = 14f; if (rect.height < 50f) { num2 *= Mathf.InverseLerp(0f, 50f, rect.height); } Text.Anchor = TextAnchor.UpperLeft; var rect3 = new Rect(rect.x, rect.y + (rect.height / 2f), rect.width, rect.height); rect3 = new Rect(rect3.x, rect3.y, rect3.width, rect3.height - num2); Widgets.FillableBar(rect3, compForce.XPTillNextLevelPercent, (Texture2D)AccessTools.Field(typeof(Widgets), "BarFullTexHor").GetValue(null), BaseContent.GreyTex, false); }
// RimWorld.StorytellerUtility public static void DefaultParmsNow_PostFix(ref IncidentParms __result, StorytellerDef tellerDef, IncidentCategory incCat, IIncidentTarget target) { Map map = target as Map; if (map != null) { if (__result.points > 0) { try { List <Pawn> forceUsers = map.mapPawns.FreeColonistsSpawned.ToList().FindAll(p => p.GetComp <CompForceUser>() != null); if (forceUsers != null) { foreach (Pawn pawn in forceUsers) { CompForceUser compForce = pawn.GetComp <CompForceUser>(); if (compForce.ForceUserLevel > 0) { __result.points += (5 * compForce.ForceUserLevel); } } } } catch (NullReferenceException) { } } } }
public override float GetPriority(Pawn pawn) { //Log.Message("Priority"); Need_ForcePool forcePool = pawn.needs.TryGetNeed <Need_ForcePool>(); if (forcePool == null) { return(0f); } CompForceUser compForce = pawn.TryGetComp <CompForceUser>(); if (compForce.canMeditateTicks > Find.TickManager.TicksAbs) { return(0f); } if (forcePool.CurCategory > ForcePoolCategory.Steady) { return(0f); } if (forcePool.CurLevelPercentage < 0.5) { return(9.5f); } return(0f); }
public void PowersSetup() { CompForceUser forcePowers = this.GetComp <CompForceUser>(); if (forcePowers == null) { ThingComp thingComp = (ThingComp)Activator.CreateInstance(typeof(CompForceUser)); thingComp.parent = this; var comps = AccessTools.Field(typeof(ThingWithComps), "comps").GetValue(this); if (comps != null) { ((List <ThingComp>)comps).Add(thingComp); } thingComp.Initialize(null); } forcePowers = this.GetComp <CompForceUser>(); if (forcePowers != null) { forcePowers.AlignmentValue = 0.99f; for (int o = 0; o < 10; o++) { forcePowers.ForceUserLevel += 1; forcePowers.ForceData.Skills.InRandomOrder <ForceSkill>().First((ForceSkill x) => x.level < 4).level++; forcePowers.ForceData.AbilityPoints -= 1; } for (int i = 0; i < 8; i++) { forcePowers.ForceUserLevel += 1; forcePowers.LevelUpPower(forcePowers.ForceData.PowersLight.InRandomOrder <ForcePower>().First((ForcePower x) => x.level < 2)); forcePowers.ForceData.AbilityPoints -= 1; } } }
protected override Job TryGiveJob(Pawn pawn) { Thing padResult = null; IntVec3 c = ResolveMeditationLocation(pawn, out padResult); CompForceUser compForce = pawn.TryGetComp<CompForceUser>(); compForce.ForceData.TicksUntilMeditate = Find.TickManager.TicksGame + 6000; if (padResult != null) return new Job(DefDatabase<JobDef>.GetNamed("PJ_ForceMeditationJob"), padResult); else return new Job(DefDatabase<JobDef>.GetNamed("PJ_ForceMeditationJob"), c); }
public static void AlignmentOnGUI(Rect rect, CompForceUser compForce) { ////base.DrawOnGUI(rect, maxThresholdMarkers, customMargin, drawArrows, doTooltip); if (rect.height > 70f) { var num = (rect.height - 70f) / 2f; rect.height = 70f; rect.y += num; } var num2 = 14f; if (rect.height < 50f) { num2 *= Mathf.InverseLerp(0f, 50f, rect.height); } Text.Anchor = TextAnchor.UpperLeft; var rect3 = new Rect(rect.x, rect.y + (rect.height / 2f), rect.width - 10f, rect.height); rect3 = new Rect(rect3.x + 20, rect3.y, rect3.width - 35, rect3.height - num2); if (Mouse.IsOver(rect3)) { Widgets.DrawHighlight(rect3); } TooltipHandler.TipRegion(rect3, new TipSignal(() => AlignmentTipString(compForce, false), rect.GetHashCode())); Widgets.FillableBar(rect3, 1.0f, TexButton.PJTex_AlignmentBar); var curInstantLevelPercentage = compForce.AlignmentValue; if (curInstantLevelPercentage >= 0f) { DrawBarInstantMarkerAt(rect3, curInstantLevelPercentage); } if (!DebugSettings.godMode) { return; } var rectDebugPlus = new Rect(rect3.xMax + 10, rect3.y, 10, 10); if (Widgets.ButtonText(rectDebugPlus, "+", true, false)) { compForce.AlignmentValue += 0.025f; } var rectDebugMinus = new Rect(rect3.xMin - 15, rect3.y, 10, 10); if (Widgets.ButtonText(rectDebugMinus, "-", true, false)) { compForce.AlignmentValue -= 0.025f; } }
public static void SkillsPane(Rect inRect, CompForceUser compForce) { var currentYOffset = inRect.y; if (!(!compForce?.ForceData.Skills.NullOrEmpty() ?? false)) { return; } foreach (var skill in compForce.ForceData.Skills) { var unused = new Rect(inRect.x, currentYOffset, inRect.width, TextSize); var lightsaberOffenseLabel = new Rect(inRect.x, currentYOffset, SkillsTextWidth, TextSize); Widgets.Label(lightsaberOffenseLabel, skill.label.Translate()); TooltipHandler.TipRegion(lightsaberOffenseLabel, new TipSignal(() => skill.desc.Translate(), lightsaberOffenseLabel.GetHashCode())); var lightsaberOffensiveBoxes = new Rect(lightsaberOffenseLabel.xMax, currentYOffset, inRect.width - SkillsTextWidth, TextSize); for (var i = 1; i <= 5; i++) { var lightsaberCheckbox = new Rect(lightsaberOffensiveBoxes.x + (SkillsBoxSize * i), lightsaberOffensiveBoxes.y, SkillsBoxSize, TextSize); if (skill.level >= i) { Widgets.DrawTextureFitted( new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize), TexButton.PJTex_SkillBoxFull, 1f); } else if (i - skill.level == 1 && compForce.ForceData.AbilityPoints > 0 && skill.level < 5 && compForce.AbilityUser.Faction == Faction.OfPlayer) { //TooltipHandler.TipRegion(rectRename, "RenameTemple".Translate()); if (!Widgets.ButtonImage( new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize - 4), TexButton.PJTex_SkillBoxAdd)) { continue; } compForce.ForceData.AbilityPoints--; skill.level++; //Widgets.DrawTextureFitted(new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize), TexButton.PJTex_SkillBoxAdd, 1f); } else { Widgets.DrawTextureFitted( new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize), TexButton.PJTex_SkillBox, 1f); } } currentYOffset += TextSize; } }
public static string ForceXPTipString(CompForceUser compForce, bool sensitive) { if (!sensitive) { return(compForce.ForceUserXP + " / " + compForce.ForceUserXPTillNextLevel + "\n" + "PJ_ForceXPDesc".Translate()); } return("PJ_ForceSensitiveDesc".Translate(compForce.AbilityUser.LabelShort)); }
public static string ForceXPTipString(CompForceUser compForce, bool sensitive) { if (!sensitive) { return(compForce.ForceUserXP.ToString() + " / " + compForce.ForceUserXPTillNextLevel.ToString() + "\n" + "PJ_ForceXPDesc".Translate()); } return("PJ_ForceSensitiveDesc".Translate(new object[] { compForce.abilityUser.LabelShort })); }
public static void InfoPane(Rect inRect, CompForceUser compForce) { var rectLevel = new Rect(inRect.x, inRect.y, inRect.width * 0.7f, TextSize); Text.Font = GameFont.Small; Widgets.Label(rectLevel, "PJ_Level".Translate().CapitalizeFirst() + " " + compForce.ForceUserLevel.ToString()); Text.Font = GameFont.Small; if (DebugSettings.godMode) { var rectDebugPlus = new Rect(rectLevel.xMax, inRect.y, inRect.width * 0.3f, TextSize); if (Widgets.ButtonText(rectDebugPlus, "+", true, false)) { compForce.LevelUp(true); } if (compForce.ForceUserLevel > 0) { var rectDebugReset = new Rect(rectDebugPlus.x, rectDebugPlus.yMax + 1, rectDebugPlus.width, TextSize); if (Widgets.ButtonText(rectDebugReset, "~", true, false)) { compForce.ResetPowers(); } } } //Level 0 var rectPointsAvail = new Rect(inRect.x, rectLevel.yMax, inRect.width, TextSize); Text.Font = GameFont.Tiny; Widgets.Label(rectPointsAvail, compForce.ForceData.AbilityPoints + " " + "PJ_PointsAvail".Translate()); Text.Font = GameFont.Small; //0 points available var rectLevelBar = new Rect(rectPointsAvail.x, rectPointsAvail.yMax + 3f, inRect.width - 10f, HeaderSize * 0.6f); DrawLevelBar(rectLevelBar, compForce); //[|||||||||||||] //Rect rectAffiliation = new Rect(rectPointsAvail.x, rectLevelBar.yMax + 3f, inRect.width - 10f, HeaderSize + 5f); //Text.Font = GameFont.Small; //string affiliation = "None"; //if (compForce.affiliation != null) affiliation = compForce.affiliation.Name; //Widgets.Label(rectAffiliation, "PJ_Affiliation".Translate().CapitalizeFirst() + ": " + affiliation); //Text.Font = GameFont.Small; }
public static void GetNonMissChance_PostFix(Verb_MeleeAttack __instance, LocalTargetInfo target, ref float __result) { //if (target.Thing != null && target.Thing is Pawn) //{ Pawn attacker = __instance.CasterPawn; if (attacker != null) { Pawn_EquipmentTracker pawn_EquipmentTracker = attacker.equipment; if (pawn_EquipmentTracker != null) { foreach (ThingWithComps thingWithComps in pawn_EquipmentTracker.AllEquipmentListForReading) { if (thingWithComps != null) { if (thingWithComps.def.IsMeleeWeapon) { if (thingWithComps.def.defName.Contains("SWSaber_")) { CompForceUser compForce = attacker.TryGetComp <CompForceUser>(); if (compForce == null) { __result = 0.5f; } else if (!compForce.IsForceUser) { __result = 0.5f; } else { float newAccuracy = (float)(__result / 2); int accuracyPoints = compForce.ForceSkillLevel("PJ_LightsaberAccuracy"); if (accuracyPoints > 0) { for (int i = 0; i < accuracyPoints; i++) { newAccuracy += 0.2f; } } __result = newAccuracy; } } } } } } } //} }
/// Add Force XP every time a pawn learns a skill. public static void Learn_PostFix(SkillRecord __instance, float xp, bool direct = false) { Pawn pawn = (Pawn)AccessTools.Field(typeof(SkillRecord), "pawn").GetValue(__instance); CompForceUser compForce = pawn.TryGetComp <CompForceUser>(); if (compForce != null) { if (Find.TickManager.TicksGame > ticksUntilNextXP) { ticksUntilNextXP = Find.TickManager.TicksGame + 70; compForce.ForceUserXP++; } } }
public static void TakeDamage_PreFix(Thing __instance, ref DamageInfo dinfo) { if (dinfo.Instigator != null) { Pawn attacker = dinfo.Instigator as Pawn; if (attacker != null) { Pawn_EquipmentTracker pawn_EquipmentTracker = attacker.equipment; if (pawn_EquipmentTracker != null) { foreach (ThingWithComps thingWithComps in pawn_EquipmentTracker.AllEquipmentListForReading) { if (thingWithComps != null) { if (thingWithComps.def.IsMeleeWeapon) { if (thingWithComps.def.defName.Contains("SWSaber_")) { CompForceUser compForce = attacker.TryGetComp <CompForceUser>(); if (compForce == null) { dinfo.SetAmount(10); } else if (!compForce.IsForceUser) { dinfo.SetAmount(10); } else { int newDamage = (int)(dinfo.Amount / 2); int offensePoints = compForce.ForceSkillLevel("PJ_LightsaberOffense"); if (offensePoints > 0) { for (int i = 0; i < offensePoints; i++) { newDamage += (int)(dinfo.Amount / 5); } } dinfo.SetAmount(newDamage); } } } } } } } } }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn) { foreach (FloatMenuOption c in base.GetFloatMenuOptions(selPawn)) { yield return(c); } if (selPawn.RaceProps.Humanlike && !selPawn.Drafted && base.Faction == Faction.OfPlayer) { CompForceUser compForce = selPawn.TryGetComp <CompForceUser>(); Action meditate = delegate { if (selPawn.CanReserveAndReach(this, PathEndMode.ClosestTouch, Danger.Deadly)) { compForce.ForceData.TicksUntilMeditate = Find.TickManager.TicksGame + 6000; Job newJob = new Job(DefDatabase <JobDef> .GetNamed("PJ_ForceMeditationJob"), this); selPawn.jobs.TryTakeOrderedJob(newJob); selPawn.mindState.ResetLastDisturbanceTick(); } }; if (!selPawn.CanReserve(this)) { yield return(new FloatMenuOption("PJ_ForceMeditate".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (compForce == null || (compForce != null && compForce.ForceUserLevel < 1)) { yield return(new FloatMenuOption("PJ_ForceMeditate".Translate() + " (" + "PJ_ForceMeditate_NeedForceUsersOnly".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (compForce != null && compForce.ForceData.TicksUntilMeditate > Find.TickManager.TicksGame) { yield return(new FloatMenuOption("PJ_ForceMeditate".Translate() + " (" + "PJ_ForceMeditate_NeedRest".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { yield return(new FloatMenuOption("PJ_ForceMeditate".Translate(), meditate, MenuOptionPriority.Default, null, null, 0f, null, null)); } //if (Verse.DebugSettings.godMode) //{ // yield return new FloatMenuOption("DEBUG" + "PJ_ForceMeditate".Translate(), meditate, MenuOptionPriority.Default, null, null, 0f, null, null); //} } }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A, 1)); yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell)); yield return(new Toil { initAction = delegate { this.faceDir = ((!this.CurJob.def.faceDir.IsValid) ? Rot4.Random : this.CurJob.def.faceDir); }, tickAction = delegate { this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + this.faceDir.FacingCell); this.pawn.GainComfortFromCellIfPossible(); if (this.pawn.TryGetComp <CompForceUser>() != null) { CompForceUser forceComp = this.pawn.GetComp <CompForceUser>(); if (Find.TickManager.TicksGame % 60 == 0) { forceComp.ForceUserXP++; } Need_ForcePool poolForce = this.pawn.needs.TryGetNeed <Need_ForcePool>(); if (poolForce != null) { if (poolForce.CurLevel < 0.99f) { poolForce.CurLevel += 0.0005f; } else { this.EndJobWith(JobCondition.Succeeded); } } } //JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f); }, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = 1800 }); }
public static void SkillsPane(Rect inRect, CompForceUser compForce) { float currentYOffset = inRect.y; foreach (ForceSkill skill in compForce.ForceSkills) { Rect lightsaberOffense = new Rect(inRect.x, currentYOffset, inRect.width, TextSize); Rect lightsaberOffenseLabel = new Rect(inRect.x, currentYOffset, SkillsTextWidth, TextSize); Widgets.Label(lightsaberOffenseLabel, skill.label.Translate()); TooltipHandler.TipRegion(lightsaberOffenseLabel, new TipSignal(() => skill.desc.Translate(), lightsaberOffenseLabel.GetHashCode())); Rect lightsaberOffensiveBoxes = new Rect(lightsaberOffenseLabel.xMax, currentYOffset, inRect.width - SkillsTextWidth, TextSize); for (int i = 1; i <= 5; i++) { Rect lightsaberCheckbox = new Rect(lightsaberOffensiveBoxes.x + (SkillsBoxSize * i), lightsaberOffensiveBoxes.y, SkillsBoxSize, TextSize); if (skill.level >= i) { Widgets.DrawTextureFitted(new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize), TexButton.PJTex_SkillBoxFull, 1f); continue; } else if ((i - skill.level == 1 && compForce.abilityPoints > 0 && skill.level < 5) && (compForce.abilityUser.Faction == Faction.OfPlayer)) { //TooltipHandler.TipRegion(rectRename, "RenameTemple".Translate()); if (Widgets.ButtonImage(new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize - 4), TexButton.PJTex_SkillBoxAdd)) { compForce.abilityPoints--; skill.level++; } //Widgets.DrawTextureFitted(new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize), TexButton.PJTex_SkillBoxAdd, 1f); continue; } else { Widgets.DrawTextureFitted(new Rect(lightsaberCheckbox.x, lightsaberCheckbox.y, lightsaberCheckbox.width - 2, TextSize), TexButton.PJTex_SkillBox, 1f); continue; } } currentYOffset += TextSize; } }
public void FixedUpdate() { try { if (Find.TickManager != null) { if (Find.TickManager.TicksGame > lastTicks + 200) { lastTicks = Find.TickManager.TicksGame; reinjectTime -= Time.fixedDeltaTime; if (reinjectTime <= 0) { reinjectTime = 0; if (Find.Maps != null) { Find.Maps.ForEach(delegate(Map map) { List <Pawn> pawns = map.mapPawns.AllPawnsSpawned.Where((Pawn p) => p.story != null).ToList(); pawns.Where((Pawn p) => p.Name != null && p.TryGetComp <CompForceUser>() == null && (p.story.traits.HasTrait(ProjectJediDefOf.PJ_JediTrait) || p.story.traits.HasTrait(ProjectJediDefOf.PJ_SithTrait))).ToList().ForEach( delegate(Pawn p) { Log.Message("CompForceUser Added"); CompForceUser pca = new CompForceUser(); pca.parent = p; p.AllComps.Add(pca); }); }); } } } } } catch (Exception) { } }
public ForceData(CompForceUser newUser) { pawn = newUser.Pawn; }
// RimWorld.CharacterCardUtility public static void DrawForceCard(Rect rect, Pawn pawn) { AdjustForLanguage(); GUI.BeginGroup(rect); CompForceUser compForce = pawn.GetComp <CompForceUser>(); if (compForce != null) { if (compForce.ForceUserLevel > 0) { float alignmentTextSize = Text.CalcSize("PJ_Alignment".Translate()).x; Rect rect2 = new Rect(((rect.width / 2) - alignmentTextSize) + SpacingOffset, rect.y, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rect2, "PJ_Alignment".Translate().CapitalizeFirst()); Text.Font = GameFont.Small; // Alignment Widgets.DrawLineHorizontal(rect.x - 10, rect2.yMax, rect.width - 15f); //--------------------------------------------------------------------- float grayTextSize = Text.CalcSize("PJ_Gray".Translate()).x; float lightTextSize = Text.CalcSize("PJ_Light".Translate()).x; Rect rectAlignmentLabels = new Rect(0 + SpacingOffset, 0 + rect2.yMax + 2, ForceCardSize.x, ForceCardUtility.ButtonSize * 1.15f); Rect rectAlignmentDark = new Rect(rectAlignmentLabels.x, rectAlignmentLabels.y, rectAlignmentLabels.width / 3, rectAlignmentLabels.height); Rect rectAlignmentGray = new Rect((rectAlignmentLabels.x + (rectAlignmentLabels.width / 2)) - grayTextSize, rectAlignmentLabels.y, rectAlignmentLabels.width / 3, rectAlignmentLabels.height); Rect rectAlignmentLight = new Rect(rectAlignmentLabels.width - (lightTextSize * 2), rectAlignmentLabels.y, rectAlignmentLabels.width / 3, rectAlignmentLabels.height); Widgets.Label(rectAlignmentDark, "PJ_Dark".Translate().CapitalizeFirst()); Widgets.Label(rectAlignmentGray, "PJ_Gray".Translate().CapitalizeFirst()); Widgets.Label(rectAlignmentLight, "PJ_Light".Translate().CapitalizeFirst()); //Dark Gray Light Rect rectAlignment = new Rect(rect.x, rectAlignmentLabels.yMax / 1.5f, rectAlignmentLabels.width - 20f, TextSize); AlignmentOnGUI(rectAlignment, pawn.GetComp <CompForceUser>()); // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| float skillsTextSize = Text.CalcSize("PJ_Skills".Translate()).x; Rect rectSkillsLabel = new Rect((rectAlignmentLabels.width / 2) - skillsTextSize, rectAlignment.yMax + SectionOffset, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rectSkillsLabel, "PJ_Skills".Translate().CapitalizeFirst()); Text.Font = GameFont.Small; // Skills Widgets.DrawLineHorizontal(rect.x - 10, rectSkillsLabel.yMax + Padding, rect.width - 15f); //--------------------------------------------------------------------- Rect rectSkills = new Rect(rect.x, rectSkillsLabel.yMax + Padding, rectSkillsLabel.width, SkillsColumnHeight); Rect rectInfoPane = new Rect(rectSkills.x, rectSkills.y + Padding, SkillsColumnDivider, SkillsColumnHeight); Rect rectSkillsPane = new Rect(rectSkills.x + SkillsColumnDivider, rectSkills.y + Padding, rectSkills.width - SkillsColumnDivider, SkillsColumnHeight); InfoPane(rectInfoPane, pawn.GetComp <CompForceUser>()); SkillsPane(rectSkillsPane, pawn.GetComp <CompForceUser>()); // LEVEL ________________ | Lightsaber Offense [X][X][+][_][_] // |||||||||||||||||||||| | Lightsaber Defense [+][_][_][_][_] // Points Available 1 | Lightsaber Accuracy [X][+][_][_][_] // float powersTextSize = Text.CalcSize("PJ_Powers".Translate()).x; Rect rectPowersLabel = new Rect((rect.width / 2) - (powersTextSize / 2), rectSkills.yMax + SectionOffset, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rectPowersLabel, "PJ_Powers".Translate().CapitalizeFirst()); Text.Font = GameFont.Small; //Powers Widgets.DrawLineHorizontal(rect.x - 10, rectPowersLabel.yMax, rect.width - 15f); //--------------------------------------------------------------------- Rect rectPowers = new Rect(rect.x, rectPowersLabel.yMax + SectionOffset, rectPowersLabel.width, PowersColumnHeight); Rect rectPowersDark = new Rect(rectPowers.x, rectPowers.y, PowersColumnWidth, PowersColumnHeight); Rect rectPowersGray = new Rect(rectPowers.x + PowersColumnWidth, rectPowers.y, PowersColumnWidth, PowersColumnHeight); Rect rectPowersLight = new Rect(rectPowers.x + PowersColumnWidth + PowersColumnWidth, rectPowers.y, PowersColumnWidth, PowersColumnHeight); PowersGUIHandler(rectPowersDark, pawn.GetComp <CompForceUser>(), pawn.GetComp <CompForceUser>().ForceData.PowersDark, TexButton.PJTex_ForcePointDark); PowersGUIHandler(rectPowersGray, pawn.GetComp <CompForceUser>(), pawn.GetComp <CompForceUser>().ForceData.PowersGray, TexButton.PJTex_ForcePointGray); PowersGUIHandler(rectPowersLight, pawn.GetComp <CompForceUser>(), pawn.GetComp <CompForceUser>().ForceData.PowersLight, TexButton.PJTex_ForcePointLight); } else { Rect rectInfoPane = new Rect(rect.x, rect.y, rect.width, rect.height); InfoPaneSensitive(rectInfoPane, pawn.GetComp <CompForceUser>()); } } GUI.EndGroup(); }
public ForceData(CompForceUser newUser) { pawn = newUser.AbilityUser; }
public static void PowersGUIHandler(Rect inRect, CompForceUser compForce, List <ForcePower> forcePowers, Texture2D pointTexture) { var buttonYOffset = inRect.y; foreach (var power in forcePowers) { var buttonRect = new Rect(inRect.x, buttonYOffset, ForceButtonSize, ForceButtonSize); TooltipHandler.TipRegion(buttonRect, () => power.AbilityDef.label + "\n\n" + power.AbilityDef.description + "\n\n" + "PJ_CheckStarsForMoreInfo".Translate(), 398462); if (compForce.ForceData.AbilityPoints == 0 || power.level >= 3) { Widgets.DrawTextureFitted(buttonRect, power.Icon, 1.0f); } else if (Widgets.ButtonImage(buttonRect, power.Icon) && compForce.AbilityUser.Faction == Faction.OfPlayer) { var powerDef = power.NextLevelAbilityDef as ForceAbilityDef; if (powerDef != null && powerDef.requiredAlignmentType != ForceAlignmentType.None && powerDef.requiredAlignmentType != compForce.ForceAlignmentType) { Messages.Message( "PJ_NextLevelAlignmentMismatch".Translate(powerDef.requiredAlignmentType.ToString(), compForce.ForceAlignmentType.ToString()), MessageTypeDefOf.RejectInput); return; } if (powerDef != null && compForce.LightsidePoints < powerDef.lightsideTreePointsRequired) { Messages.Message("PJ_LightsidePointsRequired".Translate(powerDef.lightsideTreePointsRequired), MessageTypeDefOf.RejectInput); return; } if (powerDef != null && compForce.DarksidePoints < powerDef.darksideTreePointsRequired) { Messages.Message("PJ_DarksidePointsRequired".Translate(powerDef.darksideTreePointsRequired), MessageTypeDefOf.RejectInput); return; } if (powerDef != null && compForce.ForceData.AbilityPoints < powerDef.abilityPoints) { Messages.Message( "PJ_NotEnoughAbilityPoints".Translate(compForce.ForceData.AbilityPoints, powerDef.abilityPoints), MessageTypeDefOf.RejectInput); return; } if (compForce.AbilityUser.story != null && compForce.AbilityUser.WorkTagIsDisabled(WorkTags.Violent) && power.AbilityDef.MainVerb.isViolent) { Messages.Message("IsIncapableOfViolenceLower".Translate(compForce.parent.LabelShort), MessageTypeDefOf.RejectInput); return; } compForce.LevelUpPower(power); if (powerDef != null) { compForce.ForceData.AbilityPoints -= powerDef.abilityPoints; } } for (var i = 0; i < 3; i++) { var drawXOffset = ForceButtonSize + 1f; if (i != 0) { drawXOffset += ForceButtonPointSize * i; } var drawYOffset = buttonYOffset + (ForceButtonSize / 3f); var powerRegion = new Rect(inRect.x + drawXOffset, drawYOffset, ForceButtonPointSize, ForceButtonPointSize); Widgets.DrawTextureFitted(powerRegion, power.level > i ? pointTexture : TexButton.PJTex_ForcePointDim, 1.0f); if (power.GetAbilityDef(i) is ForceAbilityDef powerDef) { TooltipHandler.TipRegion(powerRegion, () => powerDef.GetDescription() + "\n" + compForce.PostAbilityVerbCompDesc(powerDef.MainVerb) + "\n" + powerDef.GetPointDesc(), 398462); } } buttonYOffset += ForceButtonSize + 1; } }
public override DamageResult Apply(DamageInfo dinfo, Thing thing) { DamageResult result = DamageResult.MakeNew(); result.totalDamageDealt = 0f; if (thing is ProjectJedi.PawnGhost) { Messages.Message("PJ_ForceGhostResisted".Translate(), MessageTypeDefOf.NegativeEvent); return result; } Pawn pawn = thing as Pawn; if (pawn != null) { if (dinfo.Instigator != null) { Pawn caster = dinfo.Instigator as Pawn; if (caster != null) { CompForceUser victimForce = pawn.GetComp<CompForceUser>(); int maxInjuries = 2; int maxHeals = 0; int maxPoolDamage = 30; if (victimForce != null) { if (victimForce.IsForceUser) { Need_ForcePool victimForcePool = victimForce.ForcePool; if (victimForcePool != null) { if (victimForcePool.CurLevel > 0.1f) { //Turn 0.01f into 1, or 1.0 into 100. int victimForceInt = System.Convert.ToInt32(victimForcePool.CurLevel * 100); //Log.Message("Victim Force Pool = " + victimForceInt.ToString()); Need_ForcePool casterPool = caster.needs.TryGetNeed<Need_ForcePool>(); if (casterPool != null) { Messages.Message("PJ_ForceDrainOne".Translate(new object[] { caster.Label, pawn.Label }), MessageTypeDefOf.SilentInput); for (int i = 0; i < Mathf.Min(victimForceInt, maxPoolDamage); i++) { if (casterPool.CurLevel >= 0.99f) break; casterPool.CurLevel += 0.01f; victimForcePool.CurLevel -= 0.05f; } return result; } } } } } Messages.Message("PJ_ForceDrainTwo".Translate(new object[] { caster.Label, pawn.Label }), MessageTypeDefOf.SilentInput); foreach (BodyPartRecord rec in pawn.health.hediffSet.GetNotMissingParts().InRandomOrder<BodyPartRecord>()) { if (maxInjuries > 0) { pawn.TakeDamage(new DamageInfo(DamageDefOf.Burn, new IntRange(5, 10).RandomInRange, -1, caster, rec)); maxInjuries--; maxHeals++; } } int maxInjuriesPerBodypart; foreach (BodyPartRecord rec in caster.health.hediffSet.GetInjuredParts()) { if (maxHeals > 0) { maxInjuriesPerBodypart = 2; foreach (Hediff_Injury current in from injury in caster.health.hediffSet.GetHediffs<Hediff_Injury>() where injury.Part == rec select injury) { if (maxInjuriesPerBodypart > 0) { if (current.CanHealNaturally() && !current.IsOld()) // basically check for scars and old wounds { current.Heal((int)current.Severity + 1); maxHeals--; maxInjuriesPerBodypart--; } } } } } } } } return result; }
public static string AlignmentTipString(CompForceUser compForce, bool sensitive) { return("PJ_AlignmentDesc".Translate()); }