public void Notify_MemberDied(Pawn member, DamageInfo?dinfo, bool wasWorldPawn, Map map) { if (IsPlayer) { return; } if (!wasWorldPawn && !PawnGenerator.IsBeingGenerated(member) && Current.ProgramState == ProgramState.Playing && map != null && map.IsPlayerHome && !this.HostileTo(OfPlayer)) { if (dinfo.HasValue && dinfo.Value.Category == DamageInfo.SourceCategory.Collapse) { bool canSendMessage = MessagesRepeatAvoider.MessageShowAllowed("FactionRelationAdjustmentCrushed-" + Name, 5f); TryAffectGoodwillWith(OfPlayer, member.RaceProps.Humanlike ? (-25) : (-15), canSendMessage, canSendHostilityLetter: true, "GoodwillChangedReason_PawnCrushed".Translate(member.LabelShort, member), new TargetInfo(member.Position, map)); } else if (dinfo.HasValue && (dinfo.Value.Instigator == null || dinfo.Value.Instigator.Faction == null)) { Pawn pawn = dinfo.Value.Instigator as Pawn; if (pawn == null || !pawn.RaceProps.Animal || pawn.mindState.mentalStateHandler.CurStateDef != MentalStateDefOf.ManhunterPermanent) { TryAffectGoodwillWith(OfPlayer, member.RaceProps.Humanlike ? (-5) : (-3), canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangedReason_PawnDied".Translate(member.LabelShort, member), member); } } } if (member == leader) { Notify_LeaderDied(); } }
public void Notify_MemberDied(Pawn member, DamageInfo?dinfo, bool wasWorldPawn, Map map) { if (this.IsPlayer) { return; } if (!wasWorldPawn && !PawnGenerator.IsBeingGenerated(member) && Current.ProgramState == ProgramState.Playing && map != null && map.IsPlayerHome && !this.HostileTo(Faction.OfPlayer)) { if (dinfo.HasValue && dinfo.Value.Category == DamageInfo.SourceCategory.Collapse) { bool flag = MessagesRepeatAvoider.MessageShowAllowed("FactionRelationAdjustmentCrushed-" + this.Name, 5f); Faction ofPlayer = Faction.OfPlayer; int goodwillChange = (!member.RaceProps.Humanlike) ? -15 : -25; bool canSendMessage = flag; string reason = "GoodwillChangedReason_PawnCrushed".Translate(member.LabelShort, member); this.TryAffectGoodwillWith(ofPlayer, goodwillChange, canSendMessage, true, reason, new GlobalTargetInfo?(new TargetInfo(member.Position, map, false))); } else if (dinfo.HasValue && (dinfo.Value.Instigator == null || dinfo.Value.Instigator.Faction == null)) { Faction ofPlayer = Faction.OfPlayer; int goodwillChange = (!member.RaceProps.Humanlike) ? -3 : -5; string reason = "GoodwillChangedReason_PawnDied".Translate(member.LabelShort, member); GlobalTargetInfo?lookTarget = new GlobalTargetInfo?(member); this.TryAffectGoodwillWith(ofPlayer, goodwillChange, true, true, reason, lookTarget); } } if (member == this.leader) { this.Notify_LeaderDied(); } }
public override void TickLong() { CheckTemperatureMakeLeafless(); if (!base.Destroyed) { if (PlantUtility.GrowthSeasonNow(base.Position, base.Map)) { float num = growthInt; bool flag = LifeStage == PlantLifeStage.Mature; growthInt += GrowthPerTick * 2000f; if (growthInt > 1f) { growthInt = 1f; } if (((!flag && LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(growthInt * 10f)) && CurrentlyCultivated()) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } } if (!HasEnoughLightToGrow) { unlitTicks += 2000; } else { unlitTicks = 0; } ageInt += 2000; if (Dying) { Map map = base.Map; bool isCrop = IsCrop; bool harvestableNow = HarvestableNow; bool dyingBecauseExposedToLight = DyingBecauseExposedToLight; int num2 = Mathf.CeilToInt(CurrentDyingDamagePerTick * 2000f); TakeDamage(new DamageInfo(DamageDefOf.Rotting, (float)num2)); if (base.Destroyed) { if (isCrop && def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + def.defName, 240f)) { string key = harvestableNow ? "MessagePlantDiedOfRot_LeftUnharvested" : ((!dyingBecauseExposedToLight) ? "MessagePlantDiedOfRot" : "MessagePlantDiedOfRot_ExposedToLight"); Messages.Message(key.Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(base.Position, map), MessageTypeDefOf.NegativeEvent); } return; } } cachedLabelMouseover = null; if (def.plant.dropLeaves) { MoteLeaf moteLeaf = MoteMaker.MakeStaticMote(Vector3.zero, base.Map, ThingDefOf.Mote_Leaf) as MoteLeaf; if (moteLeaf != null) { float num3 = def.plant.visualSizeRange.LerpThroughRange(growthInt); float treeHeight = def.graphicData.drawSize.x * num3; Vector3 b = Rand.InsideUnitCircleVec3 * LeafSpawnRadius; moteLeaf.Initialize(base.Position.ToVector3Shifted() + Vector3.up * Rand.Range(LeafSpawnYMin, LeafSpawnYMax) + b + Vector3.forward * def.graphicData.shadowData.offset.z, Rand.Value * 2000.TicksToSeconds(), b.z > 0f, treeHeight); } } } }
public override void TickLong() { if (base.Destroyed) { return; } float num = this.growthInt; bool flag = this.LifeStage == PlantLifeStage.Mature; this.growthInt += this.GrowthPerTick * 2000f; if (this.growthInt > 1f) { this.growthInt = 1f; } if (((!flag && this.LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(this.growthInt * 10f)) && this.CurrentlyCultivated()) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } if (!this.HasEnoughLightToGrow) { this.unlitTicks += 2000; } else { this.unlitTicks = 0; } this.ageInt += 2000; if (this.Dying) { Map map = base.Map; bool isCrop = this.IsCrop; bool harvestableNow = this.HarvestableNow; bool dyingBecauseExposedToLight = this.DyingBecauseExposedToLight; int num2 = Mathf.CeilToInt(this.CurrentDyingDamagePerTick * 2000f); base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, (float)num2, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); if (base.Destroyed) { if (isCrop && this.def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + this.def.defName, 240f)) { string key; if (harvestableNow) { key = "MessagePlantDiedOfRot_LeftUnharvested"; } else if (dyingBecauseExposedToLight) { key = "MessagePlantDiedOfRot_ExposedToLight"; } else { key = "MessagePlantDiedOfRot"; } Messages.Message(key.Translate(this.GetCustomLabelNoCount(false)).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent, true); } return; } } }
public void SendMessage() { if (!Props.spawnMessageKey.NullOrEmpty() && MessagesRepeatAvoider.MessageShowAllowed(Props.spawnMessageKey, 0.1f)) { Messages.Message(Props.spawnMessageKey.Translate(), parent, MessageTypeDefOf.NegativeEvent); } }
public void Notify_MemberDied(Pawn member, DamageInfo?dinfo, bool wasWorldPawn, Map map) { if (!this.IsPlayer) { if (!wasWorldPawn && !PawnGenerator.IsBeingGenerated(member) && Current.ProgramState == ProgramState.Playing && map != null && map.IsPlayerHome && !this.HostileTo(Faction.OfPlayer)) { if (dinfo.HasValue && dinfo.Value.Category == DamageInfo.SourceCategory.Collapse) { float num = (float)(member.RaceProps.body.corePart.def.GetMaxHealth(member) * 1.2999999523162842 * 0.5 * -1.0); if (this.AffectGoodwillWith(Faction.OfPlayer, num) && MessagesRepeatAvoider.MessageShowAllowed("FactionRelationAdjustmentCrushed-" + this.Name, 5f)) { Messages.Message("MessageFactionPawnCrushed".Translate(this.Name, Mathf.RoundToInt(num)), member, MessageTypeDefOf.NegativeEvent); } } else if (dinfo.HasValue && (dinfo.Value.Instigator == null || dinfo.Value.Instigator.Faction == null)) { float num2 = (float)(member.RaceProps.body.corePart.def.GetMaxHealth(member) * 1.2999999523162842 * 0.10000000149011612 * -1.0); if (this.AffectGoodwillWith(Faction.OfPlayer, num2)) { Messages.Message("MessageFactionPawnLost".Translate(this.Name, member.NameStringShort, Mathf.RoundToInt(num2)), member, MessageTypeDefOf.NegativeEvent); } } } if (member == this.leader) { this.Notify_LeaderDied(); } } }
public override void TickLong() { CheckTemperatureMakeLeafless(); if (Destroyed) { return; } if (GrowthSeasonNow(Position, Map)) { if (!HasEnoughLightToGrow) { unlitTicks += 2000; } else { unlitTicks = 0; } float num = growthInt; bool flag = LifeStage == PlantLifeStage.Mature; growthInt += GrowthPerTick * 2000f; if (growthInt > 1f) { growthInt = 1f; } if (((!flag && LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(growthInt * 10f)) && CurrentlyCultivated()) { Map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things); } if (def.plant.LimitedLifespan) { ageInt += 2000; if (Dying) { Map map = Map; bool isCrop = IsCrop; int amount = Mathf.CeilToInt(10f); TakeDamage(new DamageInfo(DamageDefOf.Rotting, amount, -1f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown)); if (Destroyed) { if (isCrop && def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfRot".Translate(Label).CapitalizeFirst(), new TargetInfo(Position, map, false), MessageTypeDefOf.NegativeEvent); } return; } } } //Spawn new plants //if (def.plant.reproduces && growthInt >= 0.6f && Rand.MTBEventOccurs(def.plant.reproduceMtbDays, 60000f, 2000f)) //{ // if (!PlantUtility.SnowAllowsPlanting(Position, Map)) // { // return; // } // GenSpawn.Spawn(plant, Position, Map); //} } hardyCachedLabelMouseover = null; }
public static void AddFoodPoisoningHediff(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { pawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.FoodPoisoning, pawn)); if (PawnUtility.ShouldSendNotificationAbout(pawn) && MessagesRepeatAvoider.MessageShowAllowed("MessageFoodPoisoning-" + pawn.thingIDNumber, 0.1f)) { string text = "MessageFoodPoisoning".Translate(pawn.LabelShort, ingestible.LabelCapNoCount, cause.ToStringHuman().CapitalizeFirst(), pawn.Named("PAWN"), ingestible.Named("FOOD")).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NegativeEvent); } }
public virtual void MakeLeafless(Plant.LeaflessCause cause) { bool flag = !this.LeaflessNow; Map map = base.Map; if (cause == Plant.LeaflessCause.Poison && this.def.plant.leaflessGraphic == null) { if (this.IsCrop) { if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + this.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(new object[] { this.GetCustomLabelNoCount(false) }).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent, true); } } base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); } else if (this.def.plant.dieIfLeafless) { if (this.IsCrop) { if (cause == Plant.LeaflessCause.Cold) { if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfCold-" + this.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfCold".Translate(new object[] { this.GetCustomLabelNoCount(false) }).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent, true); } } else if (cause == Plant.LeaflessCause.Poison) { if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + this.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(new object[] { this.GetCustomLabelNoCount(false) }).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent, true); } } } base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); } else { this.madeLeaflessTick = Find.TickManager.TicksGame; } if (flag) { map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } }
public virtual void MakeLeafless(LeaflessCause cause) { bool changed = !LeaflessNow; var map = Map; // before applying damage if (cause == LeaflessCause.Poison && def.plant.leaflessGraphic == null) { //Poisoned a plant without a leafless graphic - we have to kill it if (IsCrop) { if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(Position, map), MessageTypeDefOf.NegativeEvent); } } TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999)); } else if (def.plant.dieIfLeafless) { //Plant dies if ever leafless if (IsCrop) { if (cause == LeaflessCause.Cold) { if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfCold-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfCold".Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(Position, map), MessageTypeDefOf.NegativeEvent); } } else if (cause == LeaflessCause.Poison) { if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(Position, map), MessageTypeDefOf.NegativeEvent); } } } TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999)); } else { //Just become visually leafless madeLeaflessTick = Find.TickManager.TicksGame; } if (changed) { map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things); } }
public override void DoAction(Transition trans) { if (repeatAvoiderTag.NullOrEmpty() || MessagesRepeatAvoider.MessageShowAllowed(repeatAvoiderTag, repeatAvoiderSeconds)) { TargetInfo target = (lookTargetGetter != null) ? lookTargetGetter() : lookTarget; if (!target.IsValid) { target = trans.target.lord.ownedPawns.FirstOrDefault(); } Messages.Message(message, target, type); } }
public override void DoAction(Transition trans) { if (this.repeatAvoiderTag.NullOrEmpty() || MessagesRepeatAvoider.MessageShowAllowed(this.repeatAvoiderTag, this.repeatAvoiderSeconds)) { TargetInfo target = (this.lookTargetGetter == null) ? this.lookTarget : this.lookTargetGetter(); if (!target.IsValid) { target = trans.target.lord.ownedPawns.FirstOrDefault <Pawn>(); } Messages.Message(this.message, target, this.type, true); } }
private void HarmPlant(Plant plant) { bool isCrop = plant.IsCrop; IntVec3 position = base.Position; Map map = base.Map; plant.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 5f)); if (plant.Destroyed && isCrop && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfBlight-" + plant.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfBlight".Translate(plant.Label, plant).CapitalizeFirst(), new TargetInfo(position, map), MessageTypeDefOf.NegativeEvent); } }
private void HarmPlant(Plant plant) { bool isCrop = plant.IsCrop; IntVec3 position = base.Position; Map map = base.Map; plant.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 5f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); if (plant.Destroyed && isCrop && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfBlight-" + plant.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfBlight".Translate(new object[] { plant.Label }).CapitalizeFirst(), new TargetInfo(position, map, false), MessageTypeDefOf.NegativeEvent, true); } }
public static bool OnIntervalPassed(HediffGiver_Heat __instance, Pawn pawn, Hediff cause) { float ambientTemperature = pawn.AmbientTemperature; float comfortableTemperatureMax = pawn.GetStatValue(StatDefOf.ComfyTemperatureMax, true); float maxTemp = comfortableTemperatureMax + 10f; Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(__instance.hediff, false); if (ambientTemperature > maxTemp) { float x = ambientTemperature - maxTemp; float sevOffset = Mathf.Max(HediffGiver_Heat.TemperatureOverageAdjustmentCurve.Evaluate(x) * 6.45E-05f, 0.000375f); HealthUtility.AdjustSeverity(pawn, __instance.hediff, sevOffset); } else if (firstHediffOfDef != null && ambientTemperature < comfortableTemperatureMax) { float num = Mathf.Clamp(firstHediffOfDef.Severity * 0.027f, 0.0015f, 0.015f); firstHediffOfDef.Severity -= num; } if (pawn.Dead || !pawn.IsNestedHashIntervalTick(60, 420)) { return(false); } float num4 = comfortableTemperatureMax + 150f; if (ambientTemperature <= num4) { return(false); } float x1 = ambientTemperature - num4; int num2 = Mathf.Max(GenMath.RoundRandom(HediffGiver_Heat.TemperatureOverageAdjustmentCurve.Evaluate(x1) * 0.06f), 3); DamageInfo dinfo = new DamageInfo(DamageDefOf.Burn, num2, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null); dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); pawn.TakeDamage(dinfo); if (pawn.Faction == Faction.OfPlayer) { Find.TickManager.slower.SignalForceNormalSpeed(); if (MessagesRepeatAvoider.MessageShowAllowed("PawnBeingBurned", 60f)) { Messages.Message("MessagePawnBeingBurned".Translate(pawn.LabelShort, pawn), pawn, MessageTypeDefOf.ThreatSmall, true); } } pawn.GetLord()?.ReceiveMemo(HediffGiver_Heat.MemoPawnBurnedByAir); return(false); }
public virtual void MakeLeafless(LeaflessCause cause) { bool flag = !this.LeaflessNow; Map map = base.Map; if (cause == LeaflessCause.Poison && base.def.plant.leaflessGraphic == null) { if (this.IsCrop && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + base.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(this.Label).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent); } base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown)); } else if (base.def.plant.dieIfLeafless) { if (this.IsCrop) { switch (cause) { case LeaflessCause.Cold: if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfCold-" + base.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfCold".Translate(this.Label).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent); } break; case LeaflessCause.Poison: if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + base.def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(this.Label).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent); } break; } } base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown)); } else { this.madeLeaflessTick = Find.TickManager.TicksGame; } if (flag) { map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } }
public virtual void MakeLeafless(LeaflessCause cause) { bool flag = !LeaflessNow; Map map = base.Map; if (cause == LeaflessCause.Poison && def.plant.leaflessGraphic == null) { if (IsCrop && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(base.Position, map), MessageTypeDefOf.NegativeEvent); } TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999f)); } else if (def.plant.dieIfLeafless) { if (IsCrop) { switch (cause) { case LeaflessCause.Cold: if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfCold-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfCold".Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(base.Position, map), MessageTypeDefOf.NegativeEvent); } break; case LeaflessCause.Poison: if (MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfPoison-" + def.defName, 240f)) { Messages.Message("MessagePlantDiedOfPoison".Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(base.Position, map), MessageTypeDefOf.NegativeEvent); } break; } } TakeDamage(new DamageInfo(DamageDefOf.Rotting, 99999f)); } else { madeLeaflessTick = Find.TickManager.TicksGame; } if (flag) { map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } }
public static void AddFoodPoisoningHediff(Pawn pawn, Thing ingestible, FoodPoisonCause cause) { Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.FoodPoisoning); if (firstHediffOfDef != null) { if (firstHediffOfDef.CurStageIndex != 2) { firstHediffOfDef.Severity = HediffDefOf.FoodPoisoning.stages[2].minSeverity - 0.001f; } } else { pawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.FoodPoisoning, pawn)); } if (PawnUtility.ShouldSendNotificationAbout(pawn) && MessagesRepeatAvoider.MessageShowAllowed("MessageFoodPoisoning-" + pawn.thingIDNumber, 0.1f)) { Messages.Message("MessageFoodPoisoning".Translate(pawn.LabelShort, ingestible.LabelCapNoCount, cause.ToStringHuman().CapitalizeFirst(), pawn.Named("PAWN"), ingestible.Named("FOOD")).CapitalizeFirst(), pawn, MessageTypeDefOf.NegativeEvent); } }
public override void DoAction(Transition trans) { try { if (!repeatAvoiderTag.NullOrEmpty() && !MessagesRepeatAvoider.MessageShowAllowed(repeatAvoiderTag, repeatAvoiderSeconds)) { return; } var targetInfo = lookTargetGetter?.Invoke() ?? lookTarget; if (!targetInfo.IsValid) { if (trans == null) { Log.Message($"trans == null"); } if (trans?.target == null) { Log.Message($"target == null"); } if (trans?.target?.lord == null) { Log.Message($"lord == null"); } if (trans?.target?.lord?.ownedPawns == null) { Log.Message($"ownedPawns == null"); } targetInfo = trans.target.lord.ownedPawns.FirstOrDefault(); } Messages.Message(message, targetInfo, type); } catch (Exception e) { Log.Error($"Exception: {e}"); Log.Error($"Message failed ({message})"); } }
public override void TickLong() { this.CheckTemperatureMakeLeafless(); if (!base.Destroyed) { if (GenPlant.GrowthSeasonNow(base.Position, base.Map, false)) { float num = this.growthInt; bool flag = this.LifeStage == PlantLifeStage.Mature; this.growthInt += this.GrowthPerTick * 2000f; if (this.growthInt > 1f) { this.growthInt = 1f; } if ((!flag && this.LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(this.growthInt * 10f)) { if (this.CurrentlyCultivated()) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } } } if (!this.HasEnoughLightToGrow) { this.unlitTicks += 2000; } else { this.unlitTicks = 0; } this.ageInt += 2000; if (this.Dying) { Map map = base.Map; bool isCrop = this.IsCrop; bool harvestableNow = this.HarvestableNow; bool dyingBecauseExposedToLight = this.DyingBecauseExposedToLight; int num2 = Mathf.CeilToInt(this.CurrentDyingDamagePerTick * 2000f); base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, (float)num2, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); if (base.Destroyed) { if (isCrop && this.def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + this.def.defName, 240f)) { string key; if (harvestableNow) { key = "MessagePlantDiedOfRot_LeftUnharvested"; } else if (dyingBecauseExposedToLight) { key = "MessagePlantDiedOfRot_ExposedToLight"; } else { key = "MessagePlantDiedOfRot"; } Messages.Message(key.Translate(new object[] { this.GetCustomLabelNoCount(false) }).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent, true); } return; } } this.cachedLabelMouseover = null; if (this.def.plant.dropLeaves) { MoteLeaf moteLeaf = MoteMaker.MakeStaticMote(Vector3.zero, base.Map, ThingDefOf.Mote_Leaf, 1f) as MoteLeaf; if (moteLeaf != null) { float num3 = this.def.plant.visualSizeRange.LerpThroughRange(this.growthInt); float treeHeight = this.def.graphicData.drawSize.x * num3; Vector3 b = Rand.InsideUnitCircleVec3 * Plant.LeafSpawnRadius; moteLeaf.Initialize(base.Position.ToVector3Shifted() + Vector3.up * Rand.Range(Plant.LeafSpawnYMin, Plant.LeafSpawnYMax) + b + Vector3.forward * this.def.graphicData.shadowData.offset.z, Rand.Value * 2000.TicksToSeconds(), b.z > 0f, treeHeight); } } } }
public override void TickLong() { this.CheckTemperatureMakeLeafless(); if (!base.Destroyed) { if (GenPlant.GrowthSeasonNow(base.Position, base.Map)) { float num = this.growthInt; bool flag = this.LifeStage == PlantLifeStage.Mature; this.growthInt += (float)(this.GrowthPerTick * 2000.0); if (this.growthInt > 1.0) { this.growthInt = 1f; } if (!flag && this.LifeStage == PlantLifeStage.Mature) { goto IL_0099; } if ((int)(num * 10.0) != (int)(this.growthInt * 10.0)) { goto IL_0099; } goto IL_00bb; } goto IL_0103; } return; IL_0103: if (!this.HasEnoughLightToGrow) { this.unlitTicks += 2000; } else { this.unlitTicks = 0; } this.ageInt += 2000; if (this.Dying) { Map map = base.Map; bool isCrop = this.IsCrop; bool harvestableNow = this.HarvestableNow; bool dyingBecauseExposedToLight = this.DyingBecauseExposedToLight; int amount = Mathf.CeilToInt((float)(this.CurrentDyingDamagePerTick * 2000.0)); base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, amount, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown)); if (base.Destroyed) { if (isCrop && base.def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + base.def.defName, 240f)) { string key = (!harvestableNow) ? ((!dyingBecauseExposedToLight) ? "MessagePlantDiedOfRot" : "MessagePlantDiedOfRot_ExposedToLight") : "MessagePlantDiedOfRot_LeftUnharvested"; Messages.Message(key.Translate(this.Label).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent); } return; } } this.cachedLabelMouseover = null; return; IL_00bb: if (this.CanReproduceNow && Rand.MTBEventOccurs(base.def.plant.reproduceMtbDays, 60000f, 2000f)) { GenPlantReproduction.TryReproduceFrom(base.Position, base.def, SeedTargFindMode.Reproduce, base.Map); } goto IL_0103; IL_0099: if (this.CurrentlyCultivated()) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } goto IL_00bb; }
/// <summary> /// Intercepts FloatMenuMakerMap call to restrict by size and call through to custom water based pathing requirements /// </summary> /// <param name="clickCell"></param> /// <param name="pawn"></param> /// <param name="__result"></param> /// <returns></returns> public static bool GotoLocationShips(IntVec3 clickCell, Pawn pawn, ref FloatMenuOption __result) { if (pawn is VehiclePawn vehicle) { if (vehicle.Faction != Faction.OfPlayer || !vehicle.CanMoveFinal) { return(false); } if (VehicleMod.settings.main.fullVehiclePathing && vehicle.LocationRestrictedBySize(clickCell)) { Messages.Message("VehicleCannotFit".Translate(), MessageTypeDefOf.RejectInput); return(false); } if (vehicle.CompFueledTravel != null && vehicle.CompFueledTravel.EmptyTank) { Messages.Message("VehicleOutOfFuel".Translate(), MessageTypeDefOf.RejectInput); return(false); } Debug.Message("-> " + clickCell + " | " + vehicle.Map.terrainGrid.TerrainAt(clickCell).LabelCap + " | " + vehicle.Map.GetCachedMapComponent <VehicleMapping>().VehiclePathGrid.CalculatedCostAt(clickCell) + " - " + vehicle.Map.GetCachedMapComponent <VehicleMapping>().VehiclePathGrid.pathGrid[vehicle.Map.cellIndices.CellToIndex(clickCell)]); if (vehicle.IsBoat() && !VehicleMod.settings.debug.debugDisableWaterPathing) { int num = GenRadial.NumCellsInRadius(2.9f); int i = 0; IntVec3 curLoc; while (i < num) { curLoc = GenRadial.RadialPattern[i] + clickCell; if (GenGridVehicles.Standable(curLoc, vehicle.Map)) { if (curLoc == vehicle.Position || vehicle.beached) { __result = null; return(false); } if (!ShipReachabilityUtility.CanReachShip(vehicle, curLoc, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { Debug.Message($"Cant Reach {curLoc} with {vehicle.Label}"); __result = new FloatMenuOption("CannotSailToCell".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); return(false); } Action action = delegate() { Job job = new Job(JobDefOf.Goto, curLoc); if (vehicle.Map.exitMapGrid.IsExitCell(Verse.UI.MouseCell())) { job.exitMapOnArrival = true; } else if (!vehicle.Map.IsPlayerHome && !vehicle.Map.exitMapGrid.MapUsesExitGrid && CellRect.WholeMap(vehicle.Map).IsOnEdge(Verse.UI.MouseCell(), 3) && vehicle.Map.Parent.GetComponent <FormCaravanComp>() != null && MessagesRepeatAvoider.MessageShowAllowed("MessagePlayerTriedToLeaveMapViaExitGrid-" + vehicle.Map.uniqueID, 60f)) { FormCaravanComp component = vehicle.Map.Parent.GetComponent <FormCaravanComp>(); if (component.CanFormOrReformCaravanNow) { Messages.Message("MessagePlayerTriedToLeaveMapViaExitGrid_CanReform".Translate(), vehicle.Map.Parent, MessageTypeDefOf.RejectInput, false); } else { Messages.Message("MessagePlayerTriedToLeaveMapViaExitGrid_CantReform".Translate(), vehicle.Map.Parent, MessageTypeDefOf.RejectInput, false); } } if (vehicle.jobs.TryTakeOrderedJob(job, JobTag.Misc)) { MoteMaker.MakeStaticMote(curLoc, vehicle.Map, ThingDefOf.Mote_FeedbackGoto, 1f); } }; __result = new FloatMenuOption("GoHere".Translate(), action, MenuOptionPriority.GoHere, null, null, 0f, null, null) { autoTakeable = true, autoTakeablePriority = 10f }; return(false); } else { i++; } } } else { int num = GenRadial.NumCellsInRadius(2.9f); int i = 0; IntVec3 curLoc; while (i < num) { curLoc = GenRadial.RadialPattern[i] + clickCell; if (GenGrid.Standable(curLoc, pawn.Map)) { if (curLoc == pawn.Position) { __result = null; return(false); } if (!ReachabilityUtility.CanReach(pawn, curLoc, PathEndMode.OnCell, Danger.Deadly, false)) { Debug.Message($"Cant Reach {curLoc} with {vehicle.Label}"); __result = new FloatMenuOption("CannotSailToCell".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); return(false); } Action action = delegate() { Job job = new Job(JobDefOf.Goto, curLoc); if (pawn.Map.exitMapGrid.IsExitCell(Verse.UI.MouseCell())) { job.exitMapOnArrival = true; } else if (!pawn.Map.IsPlayerHome && !pawn.Map.exitMapGrid.MapUsesExitGrid && CellRect.WholeMap(pawn.Map).IsOnEdge(Verse.UI.MouseCell(), 3) && pawn.Map.Parent.GetComponent <FormCaravanComp>() != null && MessagesRepeatAvoider.MessageShowAllowed("MessagePlayerTriedToLeaveMapViaExitGrid-" + pawn.Map.uniqueID, 60f)) { FormCaravanComp component = pawn.Map.Parent.GetComponent <FormCaravanComp>(); if (component.CanFormOrReformCaravanNow) { Messages.Message("MessagePlayerTriedToLeaveMapViaExitGrid_CanReform".Translate(), pawn.Map.Parent, MessageTypeDefOf.RejectInput, false); } else { Messages.Message("MessagePlayerTriedToLeaveMapViaExitGrid_CantReform".Translate(), pawn.Map.Parent, MessageTypeDefOf.RejectInput, false); } } if (pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc)) { MoteMaker.MakeStaticMote(curLoc, pawn.Map, ThingDefOf.Mote_FeedbackGoto, 1f); } }; __result = new FloatMenuOption("GoHere".Translate(), action, MenuOptionPriority.GoHere, null, null, 0f, null, null) { autoTakeable = true, autoTakeablePriority = 10f }; return(false); } else { i++; } } } __result = null; return(false); } else { if (PathingHelper.VehicleInCell(pawn.Map, clickCell)) { __result = new FloatMenuOption("CannotGoNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); return(false); } } return(true); }
public override void TickLong() { CheckTemperatureMakeLeafless(); if (Destroyed) { return; } if (PlantUtility.GrowthSeasonNow(Position, Map)) { //Grow float prevGrowth = growthInt; bool wasMature = LifeStage == PlantLifeStage.Mature; growthInt += GrowthPerTick * GenTicks.TickLongInterval; if (growthInt > 1f) { growthInt = 1f; } //Regenerate layers if ((!wasMature && LifeStage == PlantLifeStage.Mature) || (int)(prevGrowth * 10f) != (int)(growthInt * 10f)) { if (CurrentlyCultivated()) { Map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things); } } } bool hasLight = HasEnoughLightToGrow; //Record light starvation if (!hasLight) { unlitTicks += GenTicks.TickLongInterval; } else { unlitTicks = 0; } //Age ageInt += GenTicks.TickLongInterval; //Dying if (Dying) { var map = Map; bool isCrop = IsCrop; // before applying damage! bool harvestableNow = HarvestableNow; bool dyingBecauseExposedToLight = DyingBecauseExposedToLight; int dyingDamAmount = Mathf.CeilToInt(CurrentDyingDamagePerTick * GenTicks.TickLongInterval); TakeDamage(new DamageInfo(DamageDefOf.Rotting, dyingDamAmount)); if (Destroyed) { if (isCrop && def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + def.defName, 240f)) { string messageKey; if (harvestableNow) { messageKey = "MessagePlantDiedOfRot_LeftUnharvested"; } else if (dyingBecauseExposedToLight) { messageKey = "MessagePlantDiedOfRot_ExposedToLight"; } else { messageKey = "MessagePlantDiedOfRot"; } Messages.Message(messageKey.Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(Position, map), MessageTypeDefOf.NegativeEvent); } return; } } //State has changed, label may have to as well //Also, we want to keep this null so we don't have useless data sitting there a long time in plants that never get looked at cachedLabelMouseover = null; // Drop a leaf if (def.plant.dropLeaves) { var mote = MoteMaker.MakeStaticMote(Vector3.zero, Map, ThingDefOf.Mote_Leaf) as MoteLeaf; if (mote != null) { float size = def.plant.visualSizeRange.LerpThroughRange(growthInt); float graphicSize = def.graphicData.drawSize.x * size; //Plants don't support non-square drawSizes var disc = Rand.InsideUnitCircleVec3 * LeafSpawnRadius; // Horizontal alignment mote.Initialize(Position.ToVector3Shifted() // Center of the tile + Vector3.up * Rand.Range(LeafSpawnYMin, LeafSpawnYMax) // Vertical alignment + disc // Horizontal alignment + Vector3.forward * def.graphicData.shadowData.offset.z, // Move to the approximate base of the tree Rand.Value * GenTicks.TickLongInterval.TicksToSeconds(), disc.z > 0, graphicSize ); } } }