// RimWorld.Scenario public static void Vamp_DontGenerateVampsInDaylight(Scenario __instance, Pawn pawn, PawnGenerationContext context) { if (!pawn.IsVampire()) { return; } Map currentMap = Find.CurrentMap; if (currentMap == null) { return; } var recentVampires = Find.World.GetComponent <WorldComponent_VampireTracker>().recentVampires; if (VampireUtility.IsDaylight(currentMap) && pawn.Faction != Faction.OfPlayerSilentFail && pawn?.health?.hediffSet?.hediffs is List <Hediff> hdiffs) { hdiffs.RemoveAll(x => x.def == VampDefOf.ROM_Vampirism); if (recentVampires?.ContainsKey(pawn) ?? false) { recentVampires.Remove(pawn); } } else { //Log.Message("Added " + pawn.Label + " to recent vampires list"); recentVampires?.Add(pawn, 1); } }
public override void Effect(Pawn target) { base.Effect(target); VampireUtility.SummonEffect(target.PositionHeld, CasterPawn.Map, CasterPawn, 2f); HealthUtility.AdjustSeverity(target, VampDefOf.ROMV_NightwispRavens, 1.0f); }
// RimWorld.JoyUtility public static void EnjoyableOutsideNow_Vampire(Pawn pawn, ref bool __result, StringBuilder outFailReason = null) { if (pawn.IsVampire() && VampireUtility.IsDaylight(pawn)) { __result = false; } }
// RimWorld.ForbidUtility public static void Vamp_StopThePoopStorm(IntVec3 c, Pawn pawn, ref bool __result) { if (pawn.IsVampire() && VampireUtility.IsDaylight(pawn) && !c.Roofed(pawn.Map)) { __result = true; } }
// RimWorld.PawnUtility public static void KnownDangerAt_Vamp(IntVec3 c, Pawn forPawn, ref bool __result) { if (forPawn.IsVampire() && forPawn.MapHeld != null && VampireUtility.IsDaylight(forPawn) && !c.Roofed(forPawn.MapHeld)) { __result = true; return; } }
// RimWorld.ForbidUtility public static void Vamp_IsForbidden(IntVec3 c, Pawn pawn, ref bool __result) { if (pawn.IsVampire() && (pawn.VampComp().CurrentSunlightPolicy != SunlightPolicy.NoAI && VampireUtility.IsDaylight(pawn)) && !c.Roofed(pawn.Map)) { __result = true; } }
// Verse.ReachabilityUtility public static void CanReach_Vampire(ref bool __result, Pawn pawn, LocalTargetInfo dest, PathEndMode peMode, Danger maxDanger, bool canBash = false, TraverseMode mode = TraverseMode.ByPawn) { if (__result && pawn.IsVampire() && VampireUtility.IsDaylight(pawn) && (pawn.Faction == Faction.OfPlayerSilentFail && !pawn.Drafted)) { if (!dest.Cell.Roofed(pawn.MapHeld)) { __result = false; } } }
public virtual void Effect() { //target.Drawer.Notify_DebugAffected(); MoteMaker.ThrowText(CasterPawn.DrawPos, CasterPawn.Map, AbilityUser.StringsToTranslate.AU_CastSuccess); if (TargetsAoE[0] is LocalTargetInfo t && t.Cell != default(IntVec3)) { PawnTemporary p = (PawnTemporary)PawnGenerator.GeneratePawn(VampDefOf.ROMV_WolfSpectral, Faction.OfPlayer); VampireUtility.SummonEffect(t.Cell, CasterPawn.Map, CasterPawn, 2f); GenSpawn.Spawn(p, t.Cell, CasterPawn.Map); } }
public override void Effect(Pawn target) { if (VampireUtility.CanGrapple(this.CasterPawn, target)) { base.Effect(target); int boolSel = Rand.Range(0, 2); string tagOne = ""; string tagTwo = ""; HediffDef hediffDefOne = null; HediffDef hediffDefTwo = null; switch (boolSel) { case 0: tagOne = "MovingLimbCore"; tagTwo = "SightSource"; hediffDefOne = VampDefOf.ROMV_CorruptFormHediff_Legs; hediffDefTwo = VampDefOf.ROMV_CorruptFormHediff_Sight; break; case 1: tagOne = "ManipulationLimbCore"; tagTwo = "SightSource"; hediffDefOne = VampDefOf.ROMV_CorruptFormHediff_Arms; hediffDefTwo = VampDefOf.ROMV_CorruptFormHediff_Sight; break; case 2: tagOne = "ManipulationLimbCore"; tagTwo = "MovingLimbCore"; hediffDefOne = VampDefOf.ROMV_CorruptFormHediff_Arms; hediffDefTwo = VampDefOf.ROMV_CorruptFormHediff_Legs; break; } IEnumerable <BodyPartRecord> recs = target.health.hediffSet.GetNotMissingParts(); if (recs.FirstOrDefault(x => (x.def.tags.Contains(tagOne))) is BodyPartRecord bp) { HediffGiveUtility.TryApply(target, hediffDefOne, new List <BodyPartDef> { bp.def }); } if (recs.FirstOrDefault(x => (x.def.tags.Contains(tagTwo))) is BodyPartRecord bpII) { HediffGiveUtility.TryApply(target, hediffDefTwo, new List <BodyPartDef> { bpII.def }); } } }
/// <summary> /// Daylight occurs when glow levels rise above 60%. /// I used a stopwatch to determine the average time between /// the percentage raises is about 161 ticks. /// For instance, if the current glow is 40%, 60% - 40% = 20%. /// Then 20 multiplied by 161, which yields 3220 total ticks until daylight. /// </summary> /// <param name="map"></param> /// <returns></returns> public static int DetermineTicksUntilDaylight(Map map) { int result = Int32.MaxValue; if (VampireUtility.IsSunRisingOrDaylight(map)) { int curLightLevel = (int)(GenCelestial.CurCelestialSunGlow(map) * 100); int maxLightLevel = 60; int diffLightLevel = maxLightLevel - curLightLevel; int ticksLeftForTravel = TicksBetweenLightChanges * diffLightLevel; result = ticksLeftForTravel; } return(result); }
public override void Effect(Pawn target) { base.Effect(target); if (VampireUtility.CanGrapple(this.CasterPawn, target)) { IntVec3 curLoc = target.PositionHeld; Map curMap = target.MapHeld; Name tempName = target.Name; target.DeSpawn(); Pawn p = PawnGenerator.GeneratePawn(VampDefOf.ROMV_MonstrosityA, this.CasterPawn.Faction); GenSpawn.Spawn(p, curLoc, curMap); p.Name = tempName; } }
// RimWorld.Need_Rest public static void Vamp_SleepyDuringDaylight(Need_Rest __instance) { Pawn pawn = (Pawn)AccessTools.Field(typeof(Need_Rest), "pawn").GetValue(__instance); if (pawn != null && pawn.IsVampire()) { if (VampireUtility.IsDaylight(pawn)) { __instance.CurLevel = Mathf.Min(0.1f, __instance.CurLevel); } else { __instance.CurLevel = 1.0f; } } }
/// <summary> /// Creates a fake path to test the number of cells in sunlight vs ticks to survive sunlight damage. /// </summary> /// <param name="dest"></param> /// <param name="pawn"></param> /// <returns></returns> public static bool CanSurviveTimeInSunlight(IntVec3 dest, Pawn pawn) { if (!VampireUtility.IsSunRisingOrDaylight(pawn.MapHeld)) { return(true); } if (!dest.IsValid) { return(false); //Avoids downed/dead/despawned pathing issues. } if (dest == pawn.PositionHeld) { if (VampireUtility.IsDaylight(pawn)) { return(false); } return(true); } PawnPath path = pawn.MapHeld.pathFinder.FindPath(pawn.PositionHeld, dest, pawn); IntVec3 curVec; int cellsInSunlight = 0; while (path.NodesLeftCount > 1) { curVec = path.ConsumeNextNode(); if (!curVec.Roofed(pawn.MapHeld)) { cellsInSunlight++; } } path.Dispose(); if (cellsInSunlight > 0) { int sunExpTicks = 0; if (pawn?.health?.hediffSet?.GetFirstHediffOfDef(VampDefOf.ROMV_SunExposure) is HediffWithComps_SunlightExposure sunExp) { sunExpTicks = (int)(TicksOfSurvivingSunlight * 0.75f * sunExp.CurStageIndex); } int ticksToArrive = cellsInSunlight * pawn.TicksPerMoveDiagonal + sunExpTicks; if (ticksToArrive > TicksOfSurvivingSunlight) { return(false); } } return(true); }
public static bool CanGrapple(this Pawn grappler, Pawn victim) { if (victim == null || victim.Dead) { return(true); } //Check downed if (victim.Downed) { MoteMaker.ThrowText(grappler.DrawPos, grappler.Map, "ROMV_DownedGrapple".Translate(), -1f); return(true); } if (victim.IsPrisonerOfColony && RestraintsUtility.InRestraints(victim)) { MoteMaker.ThrowText(grappler.DrawPos, grappler.Map, "ROMV_PrisonerGrapple".Translate(), -1f); return(true); } //Check line of sight. //if (!victim.CanSee(grappler)) //{ // MoteMaker.ThrowText(grappler.DrawPos, grappler.Map, "ROMV_SneakGrapple".Translate(), -1f); // return true; //} //Grapple check. int roll = Rand.Range(1, 20); int modifier = (int)grappler.RaceProps.baseBodySize; modifier += (grappler.RaceProps.Humanlike) ? grappler.skills.GetSkill(SkillDefOf.Melee).Level : 0; modifier += VampireUtility.GrapplerModifier(grappler); int difficulty = (int)victim.RaceProps.baseBodySize; difficulty += (victim.RaceProps.Humanlike) ? victim?.skills?.GetSkill(SkillDefOf.Melee)?.Level ?? 1 : 1; if (roll + modifier > difficulty) { MoteMaker.ThrowText(grappler.DrawPos, grappler.Map, roll + " + " + modifier + " = " + (roll + modifier) + " vs " + difficulty + " : " + StringsToTranslate.AU_CastSuccess, -1f); return(true); } MoteMaker.ThrowText(grappler.DrawPos, grappler.Map, roll + " + " + modifier + " = " + (roll + modifier) + " vs " + difficulty + " : " + StringsToTranslate.AU_CastFailure, -1f); return(false); }
// Verse.ReachabilityUtility public static void CanReach_Vampire(ref bool __result, Pawn pawn, LocalTargetInfo dest, PathEndMode peMode, Danger maxDanger, bool canBashDoors = false, bool canBashFences = false, TraverseMode mode = TraverseMode.ByPawn) { var inBeastMentalState = pawn?.MentalStateDef == DefDatabase <MentalStateDef> .GetNamed("ROMV_VampireBeast"); var inRestrictedSunlightAIMode = pawn?.VampComp()?.CurrentSunlightPolicy == SunlightPolicy.Restricted; var isDaylight = VampireUtility.IsDaylight(pawn); var isPlayerCharacter = pawn?.Faction == Faction.OfPlayerSilentFail; var isNotDrafted = !pawn?.Drafted ?? false; var destIsNotRoofed = !dest.Cell.Roofed(pawn?.MapHeld ?? Find.CurrentMap); if (__result && pawn.IsVampire() && (inRestrictedSunlightAIMode || inBeastMentalState) && isDaylight && isPlayerCharacter && isNotDrafted && destIsNotRoofed) { __result = false; } }
public override void Effect(Pawn target) { base.Effect(target); int count = new IntRange(15, 25).RandomInRange; IntVec3 loc; if (RCellFinder.TryFindRandomPawnEntryCell(out loc, target.Map, CellFinder.EdgeRoadChance_Animal)) { VampireUtility.SummonEffect(loc, CasterPawn.Map, CasterPawn, 10f); for (int i = 0; i < count; i++) { target.Map.wildAnimalSpawner.SpawnRandomWildAnimalAt(loc); } } Find.LetterStack.ReceiveLetter("ROMV_AnimalHerd".Translate(), "ROMV_AnimalHerdDesc".Translate(), LetterDefOf.PositiveEvent, new RimWorld.Planet.GlobalTargetInfo(loc, target.Map)); }
// public override float GetPriority(Pawn pawn) // { // Log.Message("VampJobPriority"); // // if (pawn.VampComp() is CompVampire v && v.IsVampire && // GenLocalDate.HourInteger(pawn) >= 6 && GenLocalDate.HourInteger(pawn) <= 17 && // !pawn.PositionHeld.Roofed(pawn.MapHeld)) // { // return 9.5f; // } // return 0f; // } protected override Job TryGiveJob(Pawn pawn) { try { if (pawn.MapHeld is Map map && pawn.PositionHeld is IntVec3 pos && pos.IsValid && !pos.Roofed(map) && VampireUtility.IsForcedDarknessConditionInactive(map)) { if (VampSunlightPathUtility.GetSunlightPathJob(pawn) is Job j) { return(j); } } } catch (Exception e) { Log.Error(e.ToString()); } return(null); }
//JobGiver_GetRest public static void FindGroundSleepSpotFor_Vampire(Pawn pawn, ref IntVec3 __result) { if (pawn.IsVampire() && VampireUtility.IsDaylight(pawn)) { Map map = pawn.Map; for (int i = 0; i < 2; i++) { int radius = i != 0 ? 12 : 4; IntVec3 result; if (CellFinder.TryRandomClosewalkCellNear(pawn.Position, map, radius, out result, (IntVec3 x) => !x.IsForbidden(pawn) && !x.GetTerrain(map).avoidWander&& x.Roofed(pawn.MapHeld))) { __result = result; return; } } __result = CellFinder.RandomClosewalkCellNearNotForbidden(pawn, 4); return; //return CellFinder.RandomClosewalkCellNearNotForbidden(pawn.Position, map, 4, pawn); } }
/// <summary> /// Uses some guestimates to figure out if going home is safe now. /// </summary> /// <param name="targ"></param> /// <param name="pawn"></param> /// <param name="leewayFactor"></param> /// <returns></returns> public static bool CanArriveBeforeSunlight(this IntVec3 targ, Pawn pawn, float leewayFactor = 1f) { if (VampireUtility.IsDaylight(pawn)) { return(false); } int ticksUntilDaylight = DetermineTicksUntilDaylight(pawn.MapHeld); int ticksUntilArrival = targ.GetTicksUntilArrivalFor(pawn); int ticksLeeway = (int)(ticksUntilArrival * leewayFactor); // if (Find.TickManager.TicksGame % 100 == 0) // { // Log.Message("TicksUntilArrival: " + ticksUntilArrival); // Log.Message("TicksLeeway: " + ticksLeeway); // Log.Message("TicksUntilDaylight: " + ticksUntilDaylight); // } if (ticksUntilArrival + ticksLeeway < ticksUntilDaylight) { return(true); } return(false); }
public override void Effect(Pawn target) { base.Effect(target); VampireUtility.RegenerateRandomPart(target); }
public override void Effect(Pawn target) { base.Effect(target); VampireGen.RemoveMortalHediffs(target); VampireUtility.Heal(target); }
public static bool IsAcceptableVictimFor(Pawn vampire, Pawn victim, bool desperate) { if (victim == null || vampire == null) { return(false); } if (victim.Dead || vampire.Dead) { return(false); } if (!victim.Spawned || !vampire.Spawned) { return(false); } if (victim.RaceProps.IsMechanoid) { return(false); } if (victim.def == ThingDef.Named("Boomalope")) { return(false); } if (victim.def == ThingDef.Named("Boomrat")) { return(false); } if (victim?.RaceProps?.FleshType == FleshTypeDefOf.Insectoid) { return(false); } if (!victim.PositionHeld.CanArriveBeforeSunlight(vampire)) { return(false); } if (victim?.BloodNeed() is Need_Blood targetBlood) { if (vampire?.BloodNeed() is Need_Blood eaterBlood) { if (VampireUtility.IsDaylight(victim) && !victim.PositionHeld.Roofed(victim.Map)) { return(false); } if (victim.IsVampire()) { return(false); } if (!vampire.CanReserve(victim)) { return(false); } if (vampire.MentalStateDef == HediffWithComps_BeastHunger.MentalState_VampireBeast) { return(true); } if (eaterBlood.preferredFeedMode == PreferredFeedMode.None) { return(false); } if (victim.RaceProps.Animal) { //Prevents caravan animals from being eaten. if (victim.Faction != null && victim.Faction != Faction.OfPlayerSilentFail) { return(false); } if (eaterBlood.preferredFeedMode > PreferredFeedMode.AnimalLethal) { return(false); } if (eaterBlood.preferredFeedMode == PreferredFeedMode.AnimalNonLethal) { if (targetBlood.CurBloodPoints == 1) { return(false); } } Pawn firstDirectRelationPawn = victim.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, (Pawn x) => !x.Dead); if (firstDirectRelationPawn != null) { return(false); } } if (victim.RaceProps.Humanlike) { if (eaterBlood.preferredFeedMode < PreferredFeedMode.HumanoidNonLethal) { return(false); } if (eaterBlood.preferredFeedMode == PreferredFeedMode.HumanoidNonLethal && targetBlood.CurBloodPoints <= 2) { return(false); } if ((victim.IsPrisoner || victim.IsPrisonerOfColony) && eaterBlood.preferredHumanoidFeedType == PreferredHumanoidFeedType.PrisonersOnly) { return(true); } if (!victim.IsPrisoner && !victim.IsPrisonerOfColony) { if (eaterBlood.preferredHumanoidFeedType == PreferredHumanoidFeedType.PrisonersOnly) { return(false); } //Don't bite guests! if (!desperate && victim.Faction != vampire.Faction && !victim.HostileTo(vampire)) { return(false); } } //if (!desperate && (int)BloodTypeUtility.BloodType(victim) < (int)vampire.VampComp().Bloodline.minBloodPref) // return false; //else if ((int)BloodTypeUtility.BloodType(victim) < (int)vampire.VampComp().Bloodline.desperateBloodPref) // return false; } return(true); } } return(false); }
public override void Effect(Pawn target) { base.Effect(target); VampireUtility.Heal(target, 4, 2, true); }
public override void Tick() { base.Tick(); if (this.pawn == null && this.pawn?.Corpse?.InnerPawn == null) { return; } if (this.sustainer != null && !this.sustainer.Ended) { this.sustainer.Maintain(); } else { //LongEventHandler.ExecuteWhenFinished(delegate //{ SoundDef def = SoundDef.Named("FireBurning"); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.pawn.Position, this.pawn.Map, false), MaintenanceType.PerTick); info.volumeFactor *= 2; //this.sustainer = def.TrySpawnSustainer(info); //SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, def, info); this.sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, def, info); //}); } if (sunBurningEffect != null) { sunBurningEffect.EffectTick(this.pawn, this.pawn); if (Find.TickManager.TicksGame % 20 == 0) { if (this.CurStageIndex > 1 && Rand.Value > 0.5f) { MoteMaker.ThrowSmoke(this.pawn.DrawPos, this.pawn.Map, 1f); } if (this.CurStageIndex > 1 && Rand.Value < (this.CurStageIndex * 0.31f)) { MoteMaker.ThrowFireGlow(this.pawn.PositionHeld, this.pawn.Map, 1f); } } } if (Find.TickManager.TicksGame % checkRate == 0) { if (pawn?.PositionHeld is IntVec3 pos && pos != default(IntVec3) && pos.Roofed(pawn?.MapHeld ?? Find.VisibleMap) == false && VampireUtility.IsDaylight(pawn)) { if (sunBurningEffect == null) { EffecterDef effecterDef = EffecterDefOf.RoofWork; if (effecterDef != null) { sunBurningEffect = effecterDef.Spawn(); } } if (this.CurStageIndex > 1) { Burn(); } this.Severity += 0.017f; } else { curSunDamage = 5; this.Severity -= 0.2f; if (sunBurningEffect != null) { sunBurningEffect = null; } if (pawn?.MentalStateDef == VampDefOf.ROMV_Rotschreck) { pawn.MentalState.RecoverFromState(); } if (pawn?.CurJob?.def == VampDefOf.ROMV_DigAndHide) { pawn.jobs.StopAll(); } } }
private Pawn FindPawnTarget(Pawn pawn) { return((Pawn)AttackTargetFinder.BestAttackTarget(pawn, TargetScanFlags.NeedReachable, (Thing x) => x is Pawn p && p.Spawned && !p.Dead && p?.BloodNeed()?.CurBloodPoints > 0 && !p.IsVampire() && (p.PositionHeld.Roofed(p.Map) || !VampireUtility.IsDaylight(p)), 0f, 9999f, default(IntVec3), 3.40282347E+38f, true)); }
protected override Job TryGiveJob(Pawn pawn) { Room room = pawn.GetRoom(RegionType.Set_Passable); if (room != null) { if (room.PsychologicallyOutdoors) { Area area = pawn.MapHeld.areaManager.Home; if (area != null) { if (area.ActiveCells.FirstOrDefault(x => x.Roofed(pawn.Map) && x.Walkable(pawn.Map)) is IntVec3 safePlace && !IsZero(safePlace) && safePlace.IsValid) { //Log.Message("Safe Place"); return(new Job(JobDefOf.Goto, safePlace) { locomotionUrgency = LocomotionUrgency.Sprint }); } } Thing thing = GenClosest.ClosestThingReachable(pawn.PositionHeld, pawn.Map, ThingRequest.ForDef(ThingDefOf.Fire), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 23, null, null, 0, -1, false, RegionType.Set_Passable, false); if (thing != null) { //Log.Message("Flee Place"); IntVec3 fleeLoc = CellFinderLoose.GetFleeDest(pawn, new List <Thing>() { thing }, 23); return(new Job(JobDefOf.FleeAndCower, thing)); } Region region; CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn), (x => !x.Room.PsychologicallyOutdoors), 9999, out region, RegionType.Set_All); //.ClosestRegionIndoors(pawn.Position, pawn.Map, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), RegionType.Set_Passable); if (region != null) { IntVec3 result; if (region.TryFindRandomCellInRegion(x => !IsZero(x) && x.IsValid && x.InBounds(pawn.MapHeld) && x.GetDoor(pawn.MapHeld) == null, out result)) { //Log.Message("Region Place"); return(new Job(JobDefOf.Goto, result) { locomotionUrgency = LocomotionUrgency.Sprint }); } } IntVec3?cellResult = null; cellResult = CellFinderLoose.RandomCellWith(x => !IsZero(x) && x.IsValid && x.InBounds(pawn.MapHeld) && x.Roofed(pawn.MapHeld) && x.Walkable(pawn.MapHeld) && pawn.Map.reachability.CanReach(pawn.PositionHeld, x, PathEndMode.OnCell, TraverseMode.ByPawn, Danger.Deadly), pawn.MapHeld, 1000); if (cellResult != null && cellResult.Value.IsValid && !IsZero(cellResult.Value)) { //Log.Message("Random Place"); return(new Job(JobDefOf.Goto, cellResult.Value) { locomotionUrgency = LocomotionUrgency.Sprint }); } if (pawn.Faction != pawn.Map.ParentFaction) { bool flag = false; if (pawn.mindState.duty != null && pawn.mindState.duty.canDig) { flag = true; } IntVec3 c; if (RCellFinder.TryFindBestExitSpot(pawn, out c, (!flag) ? TraverseMode.ByPawn : TraverseMode.PassAllDestroyableThings)) { if (flag) { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell)) { IntVec3 cellBeforeBlocker; Thing thingY = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn); if (thingY != null) { Job job = DigUtility.PassBlockerJob(pawn, thingY, cellBeforeBlocker, true); if (job != null) { return(job); } } } } return(new Job(JobDefOf.Goto, c) { exitMapOnArrival = true, locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, LocomotionUrgency.Sprint, LocomotionUrgency.Jog), expiryInterval = 400, canBash = true }); } } IntVec3?hideyHoleResult = null; hideyHoleResult = VampireUtility.FindHideyHoleSpot(VampDefOf.ROMV_HideyHole, Rot4.Random, pawn.PositionHeld, pawn.MapHeld); if (hideyHoleResult != null && hideyHoleResult.Value.IsValid) { //Log.Message("Hidey Place"); return(new Job(VampDefOf.ROMV_DigAndHide, hideyHoleResult.Value) { locomotionUrgency = LocomotionUrgency.Sprint }); } } //bool nextMoveOrderIsWait = pawn.mindState.nextMoveOrderIsWait; //pawn.mindState.nextMoveOrderIsWait = !pawn.mindState.nextMoveOrderIsWait; //if (nextMoveOrderIsWait) //{ // return new Job(JobDefOf.WaitWander) // { // expiryInterval = this.ticksBetweenWandersRange.RandomInRange // }; //} //IntVec3 exactWanderDest = this.GetExactWanderDest(pawn); //if (!exactWanderDest.IsValid) //{ // pawn.mindState.nextMoveOrderIsWait = false; // return null; //} //pawn.Map.pawnDestinationManager.ReserveDestinationFor(pawn, exactWanderDest); //return new Job(JobDefOf.GotoWander, exactWanderDest) //{ // locomotionUrgency = this.locomotionUrgency //}; } return(null); }
// 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 static bool IsAcceptableVictimFor(Pawn vampire, Pawn victim, bool desperate) { if (victim == null || vampire == null) { return(false); } if (victim.Dead || vampire.Dead) { return(false); } if (!victim.Spawned || !vampire.Spawned) { return(false); } if (victim?.BloodNeed() is Need_Blood targetBlood) { if (vampire?.BloodNeed() is Need_Blood eaterBlood) { if (VampireUtility.IsDaylight(victim) && !victim.PositionHeld.Roofed(victim.Map)) { return(false); } if (victim.IsVampire()) { return(false); } if (!vampire.CanReserve(victim)) { return(false); } if (victim.RaceProps.Animal) { if (eaterBlood.preferredFeedMode > PreferredFeedMode.AnimalLethal) { return(false); } if (eaterBlood.preferredFeedMode == PreferredFeedMode.AnimalNonLethal && targetBlood.CurBloodPoints == 1) { return(false); } } if (victim.RaceProps.Humanlike) { if (eaterBlood.preferredFeedMode < PreferredFeedMode.HumanoidNonLethal) { return(false); } if (eaterBlood.preferredFeedMode == PreferredFeedMode.HumanoidNonLethal && targetBlood.CurBloodPoints <= 2) { return(false); } } if (!desperate && (int)BloodTypeUtility.BloodType(victim) < (int)vampire.VampComp().Bloodline.minBloodPref) { return(false); } else if ((int)BloodTypeUtility.BloodType(victim) < (int)vampire.VampComp().Bloodline.desperateBloodPref) { return(false); } return(true); } } return(false); }
// 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(); }