public void SpawnMutation(Pawn pawn, BodyPartRecord part, float ratio, HediffRadiation radiation = null) { Mutation mutation; var mutatedParts = RadiationHelper.MutatePawn(pawn, part, ratio, out mutation); lastMutation = mutation.def; lastMutationTick = Find.TickManager.TicksGame; if (mutatedParts == null) { return; } foreach (var anotherRadiation in pawn.health.hediffSet.GetHediffs <HediffRadiation>()) { if (mutatedParts.Contains(anotherRadiation.Part) && radiation != anotherRadiation) { anotherRadiation.normal -= def.mutateThreshold.min * (1f - ratio); anotherRadiation.rare -= def.mutateThreshold.min * ratio; } } }
public void Irradiate(Pawn pawn, int ticksCooldown) { this.ticksCooldown = ticksCooldown; currentUser = pawn; radiationTracker.Clear(); Room room = Position.GetRoom(Map); Pawn actualPawn = Map.mapPawns.AllPawns.Where(x => x.GetRoom() == room).RandomElementWithFallback(pawn); foreach (CompIrradiator comp in GetIrradiators()) { RadiationInfo info = new RadiationInfo { chamberDef = def, pawn = actualPawn, part = GetBodyPart(actualPawn), secondHand = actualPawn != pawn, visited = new HashSet <CompIrradiator>() }; comp.Irradiate(this, info, ticksCooldown); radiationTracker.burn += info.burn; radiationTracker.normal += info.normal; radiationTracker.rare += info.rare; if (actualPawn.IsShielded()) { continue; } HediffRadiation radiation = RadiationHelper.GetHediffRadition(info.part, info.pawn); if (radiation == null) { continue; } radiation.burn += info.burn; radiation.normal += info.normal; radiation.rare += info.rare; ApplyBurn(actualPawn, radiation); ApplyMutation(actualPawn, radiation); } }
public void Irradiate(RadiationInfo info, int ticks) { Chamber chamber = parent.Linked <Chamber>(); SoundDefOf.RadiologyIrradiateBasic.PlayOneShot(new TargetInfo(parent.Position, parent.Map, false)); ticksCooldown = ticks; if (info.pawn.IsShielded()) { return; } info.part = GetBodyPart(info.chamber, info.pawn); info.burn = props.burn.perSecond.RandomInRange; info.normal = props.mutate.perSecond.RandomInRange; info.rare = props.mutateRare.perSecond.RandomInRange; if (info.secondHand) { info.rare /= 2; } motesReflectAt.Clear(); foreach (ThingComp comp in GetModifiers <ThingComp, IRadiationModifier>(info.chamber)) { if (comp is CompBlocker) { motesReflectAt.Add((parent.Rotation.IsHorizontal ? comp.parent.Position.x : comp.parent.Position.z) + 0.5f); } if (info.secondHand) { continue; } IRadiationModifier modifier = comp as IRadiationModifier; modifier.Modify(ref info); } if (info.burn <= 0 && info.normal <= 0 && info.rare <= 0) { return; } HediffRadiation radiation = GetHediffRadition(info.part, info.chamber, info.pawn); if (radiation == null) { return; } radiation.burn += info.burn; radiation.normal += info.normal; radiation.rare += info.rare; float burnThreshold = info.chamber.def.burnThreshold.RandomInRange; float burnAmount = radiation.burn - burnThreshold; if (burnAmount > 0) { radiation.burn -= info.chamber.def.burnThreshold.min; DamageInfo dinfo = new DamageInfo(DamageDefOf.Burn, burnAmount * props.burn.multiplier, 999999f, -1f, info.chamber, radiation.Part, null, DamageInfo.SourceCategory.ThingOrUnknown, null); info.pawn.TakeDamage(dinfo); if (chamber != null) { RadiologyEffectSpawnerDef.Spawn(chamber.def.burnEffect, info.pawn); } } float mutateThreshold = info.chamber.def.mutateThreshold.RandomInRange; float mutateAmount = radiation.normal + radiation.rare - mutateThreshold; if (mutateAmount > 0) { float ratio = radiation.rare / (radiation.normal + radiation.rare); radiation.rare -= info.chamber.def.mutateThreshold.min * ratio; radiation.normal -= info.chamber.def.mutateThreshold.min * (1f - ratio); Mutation mutation; var mutatedParts = RadiationHelper.MutatePawn(info.pawn, radiation, mutateAmount * props.mutate.multiplier, ratio, out mutation); if (mutatedParts != null) { foreach (var anotherRadiation in info.pawn.health.hediffSet.GetHediffs <HediffRadiation>()) { if (mutatedParts.Contains(anotherRadiation.Part) && radiation != anotherRadiation) { anotherRadiation.normal -= info.chamber.def.mutateThreshold.min * (1f - ratio); anotherRadiation.rare -= info.chamber.def.mutateThreshold.min * ratio; } } } } }