public virtual void DoEffect(CompVampire sireComp, CompVampire childeComp) { if (childeComp.AbilityUser is Pawn p) { Pawn temp = p; IntVec3 tempLoc = p.PositionHeld; Faction f = p.Faction; Map tempMap = p.MapHeld; if (childeComp?.BloodPool is Need_Blood b && sireComp?.BloodPool is Need_Blood tempB) { b.TransferBloodTo(9999, tempB); } Pawn newPawn = ResurrectedPawnUtility.DoGeneratePawnFromSource(temp, false); if (!p.Dead) { p.Kill(null); } GenSpawn.Spawn(newPawn, tempLoc, tempMap); newPawn.workSettings.EnableAndInitialize(); if (p.Corpse != null) { p.Corpse.DeSpawn(); } if (sireComp?.BloodPool is Need_Blood sB && newPawn?.BloodNeed() is Need_Blood cB) { cB.CurBloodPoints = 0; sB.TransferBloodTo(1, cB); cB.CurBloodPoints = 1; } newPawn.VampComp().Notify_Embraced(sireComp); } }
public virtual void DoEffect(CompVampire sireComp, CompVampire childeComp) { if (childeComp.AbilityUser is Pawn p) { Pawn vampToBe = p; if (childeComp?.BloodPool is Need_Blood bloodOfVampToBe && sireComp?.BloodPool is Need_Blood bloodOfVampMaster) { bloodOfVampToBe.TransferBloodTo(9999, bloodOfVampMaster); } bool wasColonist = p.Faction == Faction.OfPlayer; ResurrectionUtility.Resurrect(vampToBe); if (vampToBe.Faction != sireComp?.AbilityUser?.Faction) { vampToBe.SetFaction(sireComp.AbilityUser.Faction, sireComp.AbilityUser); } RemoveColonistDiedThoughts(vampToBe, wasColonist); if (sireComp?.BloodPool is Need_Blood sB && vampToBe?.BloodNeed() is Need_Blood cB) { cB.CurBloodPoints = 0; sB.TransferBloodTo(1, cB); cB.CurBloodPoints = 1; } vampToBe.VampComp().Notify_Embraced(sireComp); } }
public static void DrawLevelBar(Rect rect, CompVampire compVampire) { if (rect.height > 70f) { float num = (rect.height - 70f) / 2f; rect.height = 70f; rect.y += num; } if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } TooltipHandler.TipRegion(rect, new TipSignal(() => XPTipString(compVampire), rect.GetHashCode())); float num2 = 14f; if (rect.height < 50f) { num2 *= Mathf.InverseLerp(0f, 50f, rect.height); } Text.Anchor = TextAnchor.UpperLeft; Rect 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); Color colorToUse = new Color(1.0f, 0.91f, 0f); Color colorToUseTwo = new Color(0.4f, 0.1f, 0.1f); Widgets.FillableBar(rect3, (float)compVampire.XPTillNextLevelPercent, SolidColorMaterials.NewSolidColorTexture(colorToUse), SolidColorMaterials.NewSolidColorTexture(colorToUseTwo), false); }
public static void DrawLevelBar(Rect rect, CompVampire compVampire) { ////base.DrawOnGUI(rect, maxThresholdMarkers, customMargin, drawArrows, doTooltip); if (rect.height > 70f) { float num = (rect.height - 70f) / 2f; rect.height = 70f; rect.y += num; } if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } TooltipHandler.TipRegion(rect, new TipSignal(() => XPTipString(compVampire), rect.GetHashCode())); float num2 = 14f; if (rect.height < 50f) { num2 *= Mathf.InverseLerp(0f, 50f, rect.height); } Text.Anchor = TextAnchor.UpperLeft; Rect 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); Color colorToUse = new Color(1.0f, 0.91f, 0f); Widgets.FillableBar(rect3, (float)compVampire.XPTillNextLevelPercent, SolidColorMaterials.NewSolidColorTexture(colorToUse), BaseContent.GreyTex, false); //Widgets.FillableBar(rect3, (float)compVampire.XPTillNextLevelPercent, (Texture2D)AccessTools.Field(typeof(Widgets), "BarFullTexHor").GetValue(null), BaseContent.GreyTex, false); //compVampire.XPTillNextLevelPercent }
public override bool InRelation(Pawn me, Pawn other) { if (me.IsVampire() && other.IsVampire()) { CompVampire compVamp = other.GetComp <CompVampire>(); return(me != other && (other.GetSire() == me)); } return(false); }
//private Dictionary<Hediff, int> carriedBloodInfectors = null; //private Dictionary<Hediff, int> carriedBloodDrugEffects = null; //public bool IsInfectionCarrier => carriedBloodInfectors != null; //public bool IsDrugCarrier => carriedBloodDrugEffects != null; public override void PostTick() { base.PostTick(); if (this.pawn.VampComp() is CompVampire v) { if (!initialized) { initialized = true; if (!firstVampire) { if (sire == null) { sire = VampireRelationUtility.FindSireFor(this.pawn, this.bloodline, this.generation).VampComp(); } if (generation < 0) { generation = sire.Generation + 1; } if (bloodline == null) { bloodline = sire.Bloodline; } } if (v.IsVampire && v.Sire == null) { v.InitializeVampirism(sire?.AbilityUser ?? null, bloodline, generation, firstVampire); } this.pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } if (Find.TickManager.TicksGame % 60 == 0) { if (v.InSunlight) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_SunExposure, 0.001f); } if (v.BloodPool?.CurLevelPercentage < 0.3f) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_TheBeast, 0.001f); } if (this.pawn.health.hediffSet is HediffSet hdSet) { if (hdSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia) is Hediff hypoThermia) { hdSet.hediffs.Remove(hypoThermia); } else if (hdSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke) is Hediff heatStroke) { hdSet.hediffs.Remove(heatStroke); } } } } }
public virtual bool CanEmbrace(CompVampire sire, CompVampire childe) { if (sire == null || childe == null) { return(false); } if (childe.AbilityUser.RaceProps.Humanlike && !childe.IsVampire && childe.Sire == null && sire.IsVampire) { return(true); } return(false); }
public static void LevelPane(Rect inRect, CompVampire compVampire) { Rect rectLevelBar = new Rect(inRect.x, inRect.y, inRect.width, HeaderSize * 0.6f); DrawLevelBar(rectLevelBar, compVampire); //rectPointsAvail.yMax + 3f //[||||||||||||||||||||||||||||||||||||||||||||||||||||||||||] string levelText = "ROMV_Level".Translate().CapitalizeFirst() + " " + compVampire.Level.ToString(); float levelTextLength = Text.CalcSize(levelText).x; Rect rectLevel = new Rect(inRect.x + (inRect.width / 2) - (levelTextLength / 2), rectLevelBar.yMax + 3, inRect.width, TextSize); Text.Font = GameFont.Tiny; Widgets.Label(rectLevel, levelText); Text.Font = GameFont.Small; // Level 1 string pointsAvailableText = compVampire.AbilityPoints + " " + "ROMV_PointsAvailable".Translate(); float pointsAvailableTextLength = Text.CalcSize(pointsAvailableText).x; Rect rectPointsAvail = new Rect(inRect.x + (inRect.width / 2) - (pointsAvailableTextLength / 2), rectLevel.yMax, inRect.width, TextSize); Text.Font = GameFont.Tiny; Widgets.Label(rectPointsAvail, pointsAvailableText); Text.Font = GameFont.Small; //0 points available if (DebugSettings.godMode) { Rect rectDebugPlus = new Rect(rectLevelBar.xMax - 30, rectLevelBar.yMin, inRect.width * 0.1f, TextSize); if (Widgets.ButtonText(rectDebugPlus, "+")) { compVampire.Notify_LevelUp(false); } if (compVampire.Level > 0) { Rect rectDebugReset = new Rect(rectDebugPlus.x, rectDebugPlus.yMax + 1, rectDebugPlus.width, TextSize); if (Widgets.ButtonText(rectDebugReset, "~")) { compVampire.Notify_ResetAbilities(); } } } }
public static void LevelPane(Rect inRect, CompVampire compVampire) { Rect rectLevel = new Rect(inRect.x, inRect.y, inRect.width * 0.7f, TextSize); Text.Font = GameFont.Small; Widgets.Label(rectLevel, "ROMV_Level".Translate().CapitalizeFirst() + " " + compVampire.Level.ToString()); Text.Font = GameFont.Small; if (DebugSettings.godMode) { Rect rectDebugPlus = new Rect(rectLevel.xMax, inRect.y, inRect.width * 0.3f, TextSize); if (Widgets.ButtonText(rectDebugPlus, "+")) { compVampire.Notify_LevelUp(false); } if (compVampire.Level > 0) { Rect rectDebugReset = new Rect(rectDebugPlus.x, rectDebugPlus.yMax + 1, rectDebugPlus.width, TextSize); if (Widgets.ButtonText(rectDebugReset, "~")) { compVampire.Notify_ResetAbilities(); } } } //Level 0 Rect rectPointsAvail = new Rect(inRect.x, rectLevel.yMax, inRect.width, TextSize); Text.Font = GameFont.Tiny; Widgets.Label(rectPointsAvail, compVampire.AbilityPoints + " " + "ROMV_PointsAvailable".Translate()); Text.Font = GameFont.Small; //0 points available Rect rectLevelBar = new Rect(rectPointsAvail.x, rectPointsAvail.yMax + 3f, inRect.width - 10f, HeaderSize * 0.6f); DrawLevelBar(rectLevelBar, compVampire); //[|||||||||||||] }
public static void SetSireChildeRelations(Pawn thisChilde, CompVampire sireComp, int optionalGeneration = -1) { //Log.Message("2" + thisChilde.LabelShort + " " + optionalGeneration.ToString()); if (sireComp == null) { if (thisChilde.relations.GetFirstDirectRelationPawn(VampDefOf.ROMV_Sire) is Pawn discoveredSire) { thisChilde.VampComp().Sire = discoveredSire; if (sireComp?.Childer is List <Pawn> childer && !childer.NullOrEmpty() && !childer.Contains(thisChilde)) { childer.Add(thisChilde); } return; } else { //Log.Warning("Vampires must have a sire. Choosing one."); BloodlineDef bloodlineToApply = thisChilde.VampComp().Bloodline; if (bloodlineToApply == null) { Log.Warning("Vampires must have a blood line. Choosing one."); bloodlineToApply = VampireUtility.RandBloodline; thisChilde.VampComp().Bloodline = bloodlineToApply; } Pawn sire = FindSireFor(thisChilde, bloodlineToApply, optionalGeneration); //Find.World.GetComponent<WorldComponent_VampireTracker>().GetLaterGenerationVampire(thisChilde, bloodlineToApply, optionalGeneration); sireComp = sire.VampComp(); thisChilde.VampComp().Sire = sire; } } CompVampire childeComp = thisChilde.GetComp <CompVampire>(); sireComp.AbilityUser.relations.AddDirectRelation(VampDefOf.ROMV_Childe, thisChilde); thisChilde.relations.AddDirectRelation(VampDefOf.ROMV_Sire, sireComp.AbilityUser); childeComp.Sire = sireComp.AbilityUser; sireComp.Childer.Add(thisChilde); }
// RimWorld.CharacterCardUtility public static void DrawVampCard(Rect rect, Pawn pawn) { AdjustForLanguage(); GUI.BeginGroup(rect); CompVampire compVampire = pawn.GetComp <CompVampire>(); if (compVampire != null && (compVampire.IsVampire || compVampire.IsGhoul)) { Rect rect7 = new Rect(CharacterCardUtility.BasePawnCardSize.x - 105f, 0f, 30f, 30f); TooltipHandler.TipRegion(rect7, new TipSignal("ROMV_CharacterSheet".Translate())); if (Widgets.ButtonImage(rect7, TexButton.ROMV_HumanIcon)) { HarmonyPatches.isSwitched = false; } if (compVampire.IsVampire) { Rect rectVampOptions = new Rect(CharacterCardUtility.BasePawnCardSize.x - 105f, 150f, 30f, 30f); switch (compVampire.CurrentSunlightPolicy) { case SunlightPolicy.Relaxed: TooltipHandler.TipRegion(rectVampOptions, new TipSignal("ROMV_SP_Relaxed".Translate())); if (Widgets.ButtonImage(rectVampOptions, TexButton.ROMV_SunlightPolicyRelaxed)) { compVampire.CurrentSunlightPolicy = SunlightPolicy.Restricted; } break; case SunlightPolicy.Restricted: TooltipHandler.TipRegion(rectVampOptions, new TipSignal("ROMV_SP_Restricted".Translate())); if (Widgets.ButtonImage(rectVampOptions, TexButton.ROMV_SunlightPolicyRestricted)) { compVampire.CurrentSunlightPolicy = SunlightPolicy.NoAI; } break; case SunlightPolicy.NoAI: TooltipHandler.TipRegion(rectVampOptions, new TipSignal("ROMV_SP_NoAI".Translate())); if (Widgets.ButtonImage(rectVampOptions, TexButton.ROMV_SunlightPolicyNoAI)) { compVampire.CurrentSunlightPolicy = SunlightPolicy.Relaxed; } break; } } NameTriple nameTriple = pawn.Name as NameTriple; Rect rectSkillsLabel = new Rect(rect.xMin, rect.yMin - 15, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rectSkillsLabel, pawn.Name.ToStringFull); Text.Font = GameFont.Small; string label = (compVampire.IsGhoul) ? GhoulUtility.MainDesc(pawn) : VampireUtility.MainDesc(pawn); Rect rectDesc = new Rect(0f, 45f, rect.width, 60f); Widgets.Label(rectDesc, label); // Skills //Widgets.DrawLineHorizontal(rect.x - 10, rectSkillsLabel.yMax + Padding, rect.width - 15f); //--------------------------------------------------------------------- Rect rectSkills = new Rect(rect.x, rectDesc.yMax - 42 + Padding, rectSkillsLabel.width, SkillsColumnHeight); Rect rectInfoPane = new Rect(rectSkills.x, rectSkills.y + Padding, rect.width * 0.9f, SkillsColumnHeight); //Rect rectSkillsPane = new Rect(rectSkills.x + SkillsColumnDivider, rectSkills.y + Padding, rectSkills.width - SkillsColumnDivider, SkillsColumnHeight); LevelPane(rectInfoPane, compVampire); //InfoPane(rectSkillsPane, compVampire); // LEVEL ________________ | // |||||||||||||||||||||| | // Points Available 1 | // float powersTextSize = Text.CalcSize("ROMV_Disciplines".Translate()).x; Rect rectPowersLabel = new Rect((rect.width / 2 - powersTextSize / 2) - 15f, rectSkills.yMax + SectionOffset - 5, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rectPowersLabel, "ROMV_Disciplines".Translate().CapitalizeFirst()); // Disciplines Text.Font = GameFont.Small; //Powers Widgets.DrawLineHorizontal(rect.x - 10, rectPowersLabel.yMax, rect.width - 15f); //--------------------------------------------------------------------- float curY = rectPowersLabel.yMax; var outRect = new Rect(rect.x, curY + 3f, rect.width, (rectSkills.height * 4f) + 16f); //rectSkills.width -= 10f; var viewRect = new Rect(rect.x, curY + 3f, rect.width, scrollViewHeight);//rectSkills.height * 4f); float scrollViewY = 0f; Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true); if (compVampire.Sheet.Pawn == null) { compVampire.Sheet.Pawn = pawn; } if (compVampire.Sheet.Disciplines.NullOrEmpty()) { compVampire.Sheet.InitializeDisciplines(); } for (int i = 0; i < compVampire.Sheet.Disciplines.Count; i++) { Rect rectDisciplines = new Rect(rect.x, curY, rectPowersLabel.width, ButtonSize + Padding); PowersGUIHandler(rectDisciplines, compVampire, compVampire.Sheet.Disciplines[i]); var y = ButtonSize + Padding * 2 + TextSize * 2; curY += y; scrollViewY += y; } if (Event.current.type == EventType.Layout) { scrollViewHeight = scrollViewY + (ButtonSize + Padding * 2 + TextSize * 2) + 30f; } Widgets.EndScrollView(); } GUI.EndGroup(); }
public override void PostTick() { base.PostTick(); if (!(pawn.VampComp() is CompVampire v)) { return; } if (!initialized) { initialized = true; if (!firstVampire) { if (sire == null) { sire = VampireRelationUtility.FindSireFor(pawn, bloodline, generation).VampComp(); } if (generation < 0) { generation = sire.Generation + 1; } if (bloodline == null) { bloodline = sire.Bloodline; } } if (v.IsVampire && v.Sire == null) { v.InitializeVampirism(sire?.AbilityUser ?? null, bloodline, generation, firstVampire); } pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } if (Find.TickManager.TicksGame % 60 != 0) { return; } if (v.InSunlight) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_SunExposure, 0.001f); } if (v.BloodPool?.CurLevelPercentage < 0.3f) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_TheBeast, 0.001f); } //Remove nonsensical hediffs if (pawn.health.hediffSet is HediffSet hdSet) { if (hdSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia) is Hediff hypoThermia) { hdSet.hediffs.Remove(hypoThermia); } else if (hdSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke) is Hediff heatStroke) { hdSet.hediffs.Remove(heatStroke); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.GutWorms) is Hediff gutWorms) { hdSet.hediffs.Remove(gutWorms); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.MuscleParasites) is Hediff muscleParasites) { hdSet.hediffs.Remove(muscleParasites); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.FibrousMechanites) is Hediff fibrousMechanites) { hdSet.hediffs.Remove(fibrousMechanites); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.SensoryMechanites) is Hediff sensoryMechanites) { hdSet.hediffs.Remove(sensoryMechanites); } } //If no generational bonus exists... if (!pawn.health.hediffSet.HasHediff(pawn.GenerationDef())) { HealthUtility.AdjustSeverity(pawn, pawn.GenerationDef(), 1.0f); } }
public static void PowersGUIHandler(Rect inRect, CompVampire compVampire, Discipline discipline) { float buttonXOffset = inRect.x; if (discipline?.Def?.abilities is List <VitaeAbilityDef> abilities && !abilities.NullOrEmpty()) { Rect rectLabel = new Rect(inRect.x, inRect.y, inRect.width * 0.7f, TextSize); Text.Font = GameFont.Small; Widgets.Label(rectLabel, discipline.Def.LabelCap); Text.Font = GameFont.Small; int count = 0; int pntCount = 0; foreach (VitaeAbilityDef ability in discipline.Def.abilities) { Rect buttonRect = new Rect(buttonXOffset, rectLabel.yMax, VampButtonSize, VampButtonSize); TooltipHandler.TipRegion(buttonRect, () => ability.LabelCap + "\n\n" + ability.description, 398452); //"\n\n" + "PJ_CheckStarsForMoreInfo".Translate() Texture2D abilityTex = ability.uiIcon; bool disabledForGhouls = compVampire.IsGhoul && (int)compVampire.GhoulHediff.ghoulPower < discipline.Level; if (disabledForGhouls) { GUI.color = Color.gray; } if (compVampire.AbilityPoints == 0 || discipline.Level >= 4) { Widgets.DrawTextureFitted(buttonRect, abilityTex, 1.0f); } else if (Widgets.ButtonImage(buttonRect, abilityTex) && compVampire.AbilityUser.Faction == Faction.OfPlayer) { if (compVampire.AbilityUser.story != null && compVampire.AbilityUser.story.DisabledWorkTagsBackstoryAndTraits.HasFlag(WorkTags.Violent) && ability.MainVerb.isViolent) { Messages.Message("IsIncapableOfViolenceLower".Translate(new object[] { compVampire.parent.LabelShort }), MessageTypeDefOf.RejectInput); return; } if (disabledForGhouls) { Messages.Message("ROMV_DomitorVitaeIsTooWeak".Translate(new object[] { compVampire.parent.LabelShort }), MessageTypeDefOf.RejectInput); return; } discipline.Notify_PointsInvested(1); //LevelUpPower(power); compVampire.Notify_UpdateAbilities(); compVampire.AbilityPoints -= 1; //powerDef.abilityPoints; } float drawXOffset = buttonXOffset; float modifier = 0f; switch (count) { case 0: break; case 1: modifier = 0.75f; break; case 2: modifier = 0.72f; break; case 3: modifier = 0.60f; break; } if (count != 0) { drawXOffset -= VampButtonPointSize * count * modifier; } else { drawXOffset -= 2; } for (int j = 0; j < count + 1; j++) { ++pntCount; float drawYOffset = VampButtonSize + TextSize + Padding; Rect powerRegion = new Rect(inRect.x + drawXOffset + VampButtonPointSize * j, inRect.y + drawYOffset, VampButtonPointSize, VampButtonPointSize); if (discipline.Points >= pntCount) { Widgets.DrawTextureFitted(powerRegion, TexButton.ROMV_PointFull, 1.0f); } else { Widgets.DrawTextureFitted(powerRegion, TexButton.ROMV_PointEmpty, 1.0f); } TooltipHandler.TipRegion(powerRegion, () => ability.GetDescription() + "\n" + compVampire.PostAbilityVerbCompDesc(ability.MainVerb), 398462); } ++count; buttonXOffset += ButtonSize * 3f + Padding; if (disabledForGhouls) { GUI.color = Color.white; } } } }
public static void InfoPane(Rect inRect, CompVampire compVampire) { float currentYOffset = inRect.y; }
public static void PowersGUIHandler(Rect inRect, CompVampire compVampire, Discipline discipline) { float buttonXOffset = inRect.x; if (discipline?.Def?.abilities is List <VitaeAbilityDef> abilities && !abilities.NullOrEmpty()) { Rect rectLabel = new Rect(inRect.x - ButtonSize, inRect.y, inRect.width * 0.7f, TextSize); Text.Font = GameFont.Small; Widgets.Label(rectLabel, discipline.Def.LabelCap); Text.Font = GameFont.Small; int count = 0; int pntCount = 0; foreach (VitaeAbilityDef ability in discipline.Def.abilities) { Rect buttonRect = new Rect(buttonXOffset, rectLabel.yMax, VampButtonSize, VampButtonSize); TooltipHandler.TipRegion(buttonRect, () => ability.LabelCap + "\n\n" + ability.description, 398452); //"\n\n" + "PJ_CheckStarsForMoreInfo".Translate() if (compVampire.AbilityPoints == 0 || discipline.Level >= 4) { Widgets.DrawTextureFitted(buttonRect, ability.uiIcon, 1.0f); } else if (Widgets.ButtonImage(buttonRect, ability.uiIcon) && (compVampire.AbilityUser.Faction == Faction.OfPlayer)) { //if (compVampire.AbilityPoints < ability.abilityCost) //{ // Messages.Message("ROMV_NotEnoughAbilityPoints".Translate(new object[] // { // compVampire.AbilityPoints, // ability.abilityCost // }), MessageSound.RejectInput); // return; //} if (compVampire.AbilityUser.story != null && (compVampire.AbilityUser.story.WorkTagIsDisabled(WorkTags.Violent) && ability.MainVerb.isViolent)) { Messages.Message("IsIncapableOfViolenceLower".Translate(new object[] { compVampire.parent.LabelShort }), MessageSound.RejectInput); return; } discipline.Notify_PointsInvested(1); //LevelUpPower(power); compVampire.Notify_UpdateAbilities(); compVampire.AbilityPoints -= 1; //powerDef.abilityPoints; } float drawXOffset = buttonXOffset - ButtonSize; float modifier = 0f; switch (count) { case 0: break; case 1: modifier = 0.75f; break; case 2: modifier = 0.72f; break; case 3: modifier = 0.60f; break; } if (count != 0) { drawXOffset -= ((VampButtonPointSize * count) * modifier); } else { drawXOffset -= 2; } for (int j = 0; j < count + 1; j++) { ++pntCount; float drawYOffset = VampButtonSize + TextSize + Padding; Rect powerRegion = new Rect(inRect.x + drawXOffset + (VampButtonPointSize * j), inRect.y + drawYOffset, VampButtonPointSize, VampButtonPointSize); if (discipline.Points >= pntCount) { Widgets.DrawTextureFitted(powerRegion, TexButton.ROMV_PointFull, 1.0f); } else { Widgets.DrawTextureFitted(powerRegion, TexButton.ROMV_PointEmpty, 1.0f); } TooltipHandler.TipRegion(powerRegion, () => ability.GetDescription() + "\n" + compVampire.PostAbilityVerbCompDesc(ability.MainVerb), 398462); } ++count; buttonXOffset += (ButtonSize * 3f) + Padding; } } }
public static string XPTipString(CompVampire compVampire) { return(compVampire.XP.ToString() + " / " + compVampire.XPTillNextLevel.ToString() + "\n" + ((compVampire.IsGhoul) ? "ROMV_XPDescGhoul".Translate() : "ROMV_XPDesc".Translate())); }
// RimWorld.CharacterCardUtility public static void DrawVampCard(Rect rect, Pawn pawn) { AdjustForLanguage(); GUI.BeginGroup(rect); CompVampire compVampire = pawn.GetComp <CompVampire>(); if (compVampire != null && compVampire.IsVampire) { Rect rect7 = new Rect(CharacterCardUtility.PawnCardSize.x - 105f, 0f, 30f, 30f); TooltipHandler.TipRegion(rect7, new TipSignal("ROMV_CharacterSheet".Translate())); if (Widgets.ButtonImage(rect7, TexButton.ROMV_HumanIcon)) { HarmonyPatches.isSwitched = false; } NameTriple nameTriple = pawn.Name as NameTriple; Rect rectSkillsLabel = new Rect(rect.xMin, rect.yMin - 15, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rectSkillsLabel, pawn.Name.ToStringFull); Text.Font = GameFont.Small; string label = VampireUtility.MainDesc(pawn); Rect rectDesc = new Rect(0f, 45f, rect.width, 60f); Widgets.Label(rectDesc, label); // Skills //Widgets.DrawLineHorizontal(rect.x - 10, rectSkillsLabel.yMax + Padding, rect.width - 15f); //--------------------------------------------------------------------- Rect rectSkills = new Rect(rect.x, rectDesc.yMax - 30 + 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); LevelPane(rectInfoPane, compVampire); InfoPane(rectSkillsPane, compVampire); // LEVEL ________________ | // |||||||||||||||||||||| | // Points Available 1 | // float powersTextSize = Text.CalcSize("ROMV_Disciplines".Translate()).x; Rect rectPowersLabel = new Rect((rect.width / 2) - (powersTextSize / 2), rectSkills.yMax + SectionOffset - 5, rect.width, HeaderSize); Text.Font = GameFont.Medium; Widgets.Label(rectPowersLabel, "ROMV_Disciplines".Translate().CapitalizeFirst()); Text.Font = GameFont.Small; //Powers Widgets.DrawLineHorizontal(rect.x - 10, rectPowersLabel.yMax, rect.width - 15f); //--------------------------------------------------------------------- float curY = rectPowersLabel.yMax; for (int i = 0; i < compVampire.Sheet.Disciplines.Count; i++) { Rect rectDisciplines = new Rect(rect.x + ButtonSize, curY, rectPowersLabel.width, ButtonSize + Padding); PowersGUIHandler(rectDisciplines, compVampire, compVampire.Sheet.Disciplines[i]); curY += ButtonSize + (Padding * 2) + (TextSize * 2); } } GUI.EndGroup(); }
// RimWorld.FloatMenuMakerMap private static void Vamp_FloatMenus_Consume(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); CompVampire selVampComp = pawn.VampComp(); bool pawnIsVampire = pawn.IsVampire(); if (selVampComp != null && pawnIsVampire) { //Hide food consumption from menus. Thing food = c.GetThingList(pawn.Map) .FirstOrDefault(t => t.GetType() != typeof(Pawn) && t?.def?.ingestible != null); if (food != null) { //string text = (!food.def.ingestible.ingestCommandString.NullOrEmpty()) ? string.Format(food.def.ingestible.ingestCommandString, food.LabelShort) : ((string)"ConsumeThing".Translate(food.LabelShort, food)); string text = ""; if (food?.def?.ingestible?.ingestCommandString == null || food.def.ingestible.ingestCommandString == "") { text = ((string)"ConsumeThing".Translate(food.LabelShort, food)); } else { text = string.Format(food.def.ingestible.ingestCommandString, food.LabelShort); } FloatMenuOption o = opts.FirstOrDefault(x => x.Label.Contains(text)); if (o != null) { opts.Remove(o); } } //Hide corpse consumption from menus. Thing corpse = c.GetThingList(pawn.Map).FirstOrDefault(t => t is Corpse); if (corpse != null) { string text; if (corpse.def.ingestible.ingestCommandString.NullOrEmpty()) { text = "ConsumeThing".Translate(new object[] { corpse.LabelShort }); } else { text = string.Format(corpse.def.ingestible.ingestCommandString, corpse.LabelShort); } FloatMenuOption o = opts.FirstOrDefault(x => x.Label.Contains(text)); if (o != null) { opts.Remove(o); } } //Add blood consumption Thing bloodItem = c.GetThingList(pawn.Map) .FirstOrDefault(t => t.def.GetCompProperties <CompProperties_BloodItem>() != null); if (bloodItem != null) { string text = ""; if (bloodItem.def.ingestible.ingestCommandString.NullOrEmpty()) { text = "ConsumeThing".Translate(new object[] { bloodItem.LabelShort }); } else { text = string.Format(bloodItem.def.ingestible.ingestCommandString, bloodItem.LabelShort); } if (!bloodItem.IsSociallyProper(pawn)) { text = text + " (" + "ReservedForPrisoners".Translate() + ")"; } FloatMenuOption item5; if (bloodItem.def.IsPleasureDrug && pawn.IsTeetotaler()) { item5 = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null); } else if (!pawn.CanReach(bloodItem, PathEndMode.OnCell, Danger.Deadly)) { item5 = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null); } else { MenuOptionPriority priority = !(bloodItem is Corpse) ? MenuOptionPriority.Default : MenuOptionPriority.Low; item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate { bloodItem.SetForbidden(false); Job job = new Job(VampDefOf.ROMV_ConsumeBlood, bloodItem); job.count = BloodUtility.WillConsumeStackCountOf(pawn, bloodItem.def); pawn.jobs.TryTakeOrderedJob(job); }, priority), pawn, bloodItem); } opts.Add(item5); } } }
public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > FloatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition feedCondition = new _Condition(_ConditionType.IsType, typeof(Pawn)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > feedFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); bool pawnIsVampire = pawn.IsVampire(); if (pawnIsVampire && curThing is Pawn victim && victim != pawn && !victim.RaceProps.IsMechanoid) { CompVampire selVampComp = pawn.GetComp <CompVampire>(); int curBloodVictim = victim?.BloodNeed()?.CurBloodPoints ?? 0; int curBloodActor = pawn?.BloodNeed()?.CurBloodPoints ?? 0; bool victimIsVampire = victim.IsVampire(); // FEED ////////////////////////// if (!victimIsVampire || (selVampComp?.Bloodline?.canFeedOnVampires ?? false)) { Action action = delegate { Job job = new Job(VampDefOf.ROMV_Feed, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_Feed".Translate(new object[] { victim.LabelCap }) + (curBloodVictim == 1 ? new TaggedString(" ") + "ROMV_LethalWarning".Translate() : new TaggedString("")), action, MenuOptionPriority.High, null, victim)); // SIP ////////////////////////// if (curBloodVictim > 1) { Action action2 = delegate { Job job = new Job(VampDefOf.ROMV_Sip, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_Sip".Translate(new object[] { victim.LabelCap }), action2, MenuOptionPriority.High, null, victim)); } } ; if (!victimIsVampire && (victim?.RaceProps?.Humanlike ?? false)) { //EMBRACE ///////////////////// if (selVampComp.Thinblooded) { opts.Add(new FloatMenuOption("ROMV_CannotEmbrace".Translate(new object[] { victim.LabelCap } +" (" + "ROMV_Thinblooded".Translate() + ")"), null, MenuOptionPriority.High, null, victim)); } else { Action actionTwo = delegate { Job job = new Job(VampDefOf.ROMV_Embrace, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_Embrace".Translate(new object[] { victim.LabelCap }), actionTwo, MenuOptionPriority.High, null, victim)); } //GIVE BLOOD (Ghoul) //////////////////// if (curBloodActor > 0) { Action actionThree = delegate { Job job = new Job(VampDefOf.ROMV_GhoulBloodBond, victim); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption( "ROMV_GiveVitae".Translate() + (!victim.IsGhoul() ? new TaggedString(" (") + "ROMV_CreateGhoul".Translate() + ")" : new TaggedString("")), actionThree, MenuOptionPriority.High, null, victim)); } } //Diablerie //////////////////// if (victimIsVampire) { Action action = delegate { Job job = new Job(VampDefOf.ROMV_FeedVampire, victim); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROMV_FeedVampire".Translate(new object[] { victim.LabelCap }), action, MenuOptionPriority.High, null, victim)); Action action2 = delegate { Job job = new Job(VampDefOf.ROMV_Diablerie, victim); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); }; string benefitWarning = (selVampComp.Generation <= victim.VampComp().Generation) ? new TaggedString(" ") + "ROMV_DiablerieNoBenefit".Translate() : new TaggedString(""); opts.Add(new FloatMenuOption("ROMV_Diablerie".Translate(new object[] { victim.LabelCap }) + benefitWarning, action2, MenuOptionPriority.High, null, victim)); } } return(opts); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(feedCondition, feedFunc); FloatMenus.Add(curSec); return(FloatMenus); }