// Token: 0x06000026 RID: 38 RVA: 0x00002E0C File Offset: 0x0000100C public static void TryAttachFire(this Thing t, float fireSize) { if (t.Map == null) { return; } if (!t.Spawned) { return; } if (!t.CanEverAttachFire()) { return; } if (t.HasAttachment(ThingDefOf.GreenFire)) { return; } Fire fire = (Fire)ThingMaker.MakeThing(ThingDefOf.GreenFire, null); fire.fireSize = fireSize; fire.AttachTo(t); GenSpawn.Spawn(fire, t.Position, t.Map, Rot4.North, WipeMode.Vanish, false); if (t is Pawn pawn) { pawn.jobs.StopAll(false); pawn.records.Increment(RecordDefOf.TimesOnFire); } }
private Toil Ignite(Thing target) { Toil toil = new Toil(); toil.initAction = delegate { Pawn feenix = pawn; if (target.FlammableNow && !target.IsBurning()) { if (target.CanEverAttachFire()) { target.TryAttachFire(1f); } else { FireUtility.TryStartFireIn(target.Position, target.Map, 1f); } PawnUtility.ForceWait(feenix, 250, target); } else { return; } }; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = 250; return(toil); }
private Toil Ignite(Thing target) { Toil toil = new Toil(); toil.initAction = delegate { Pawn feenix = this.pawn; if (target.FlammableNow && !target.IsBurning()) { if (target.CanEverAttachFire()) { target.TryAttachFire(1f); } else { FireUtility.TryStartFireIn(target.Position, 1f); } PawnUtility.ForceWait(feenix, 250, target); } else { return; } }; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = 250; return toil; }
public static float ChanceToAttachFireCumulative(Thing t, float freqInTicks) { if (!t.CanEverAttachFire()) { return(0f); } if (t.HasAttachment(ThingDefOf.Fire)) { return(0f); } float num = ChanceToCatchFirePerSecondForPawnFromFlammability.Evaluate(t.GetStatValue(StatDefOf.Flammability)); return(1f - Mathf.Pow(1f - num, freqInTicks / 60f)); }
public static void TryAttachFire(this Thing t, float fireSize) { if (t.CanEverAttachFire() && !t.HasAttachment(ThingDefOf.Fire)) { Fire fire = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire, null); fire.fireSize = fireSize; fire.AttachTo(t); GenSpawn.Spawn(fire, t.Position, t.Map, Rot4.North, false); Pawn pawn = t as Pawn; if (pawn != null) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true); pawn.records.Increment(RecordDefOf.TimesOnFire); } } }
public static void TryAttachFire(this Thing t, float fireSize) { if (t.CanEverAttachFire() && !t.HasAttachment(ThingDefOf.Fire)) { Fire fire = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire); fire.fireSize = fireSize; fire.AttachTo(t); GenSpawn.Spawn(fire, t.Position, t.Map, Rot4.North); Pawn pawn = t as Pawn; if (pawn != null) { pawn.jobs.StopAll(); pawn.records.Increment(RecordDefOf.TimesOnFire); } } }
public static void TryAttachOccultFire(this Thing t, float fireSize) { if (t.CanEverAttachFire() && !t.HasAttachment(ThingDefOf.Fire)) // ThingDefOf.Fire { OccultFire obj = (OccultFire)ThingMaker.MakeThing(ThingDefOf.Fire); obj.fireSize = fireSize; obj.occult = true; // make occult fire obj.AttachTo(t); GenSpawn.Spawn(obj, t.Position, t.Map, Rot4.North); Pawn pawn = t as Pawn; if (pawn != null) { pawn.jobs.StopAll(); pawn.records.Increment(RecordDefOf.TimesOnFire); } } }
public static bool TryAttachFire(Thing t, float fireSize) { if (!t.CanEverAttachFire() || t.HasAttachment(ThingDefOf.Fire)) { return(false); } Fire fire = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire); fire.fireSize = fireSize; fire.AttachTo(t); GenSpawn.Spawn(fire, t.Position, t.Map, Rot4.North); if (!(t is Pawn pawn)) { return(false); } Verse.AI.Pawn_JobTracker jobs = pawn.jobs; if (jobs != null) { jobs.StopAll(); } pawn.records.Increment(RecordDefOf.TimesOnFire); return(false); }
public static void TryAttachPsychicFire(this Thing t, float fireSize) { if (!t.CanEverAttachFire()) { return; } if (t.HasAttachment(ThingDef.Named("PsychicFire"))) { return; } PsychicFire fire = (PsychicFire)ThingMaker.MakeThing(ThingDef.Named("PsychicFire"), null); fire.fireSize = fireSize; fire.AttachTo(t); GenSpawn.Spawn(fire, t.Position, t.Map, Rot4.North, WipeMode.Vanish, false); Pawn pawn = t as Pawn; if (pawn != null) { pawn.jobs.StopAll(false, true); pawn.records.Increment(RecordDefOf.TimesOnFire); } }
public override void Tick() { sustainer.Maintain(); //Do micro sparks if (fireSize > 0.7f) { if (Random.value < fireSize * 0.01f) { MoteMaker.ThrowMicroSparks(DrawPos); } } //Do smoke and glow ticksUntilSmoke--; if (ticksUntilSmoke <= 0) { MoteMaker.ThrowSmoke(DrawPos, fireSize); if (parent == null) //No fire glow for moving things (it trails them) { Vector3 glowLoc = DrawPos + fireSize * (new Vector3(Random.value - 0.5f, 0, Random.value - 0.5f)); MoteMaker.ThrowFireGlow(glowLoc, fireSize); } float firePct = fireSize / 2; if (firePct > 1) { firePct = 1; } firePct = 1f - firePct; ticksUntilSmoke = SmokeIntervalRange.Lerped(firePct) + (int)(SmokeIntervalRandomAddon * Random.value); } ticksUntilFrameChange--; if (ticksUntilFrameChange <= 0) { ticksUntilFrameChange = FrameChangeIntervalRange.RandomInRange; //Choose a new draw frame Material oldFrame = curDrawFrame; while (curDrawFrame == oldFrame) { curDrawFrame = def.folderDrawMats.RandomListElement(); } //Apply random offset (it adds some life) const float MaxOff = 0.05f; curDrawOffset = new Vector3(Random.Range(-MaxOff, MaxOff), 0, Random.Range(-MaxOff, MaxOff)); } //Static fires: Ignite pawns in my square if (parent == null) { if (fireSize > MinSizeForSquareIgnite) { float igniteChance = fireSize * SquareIgniteChancePerTickPerSize; foreach (Thing t in Find.ThingGrid.ThingsAt(Position).ToList()) { if (Random.value < igniteChance && t.CanEverAttachFire()) { t.TryIgnite(fireSize / 2f); } } } } //Perhaps I should unify the below with square ignition //Damage whatever I'm burning ticksSinceDamage++; if (ticksSinceDamage >= TicksBeforeDamage) { Thing damTarget = null; if (parent != null) { damTarget = parent; } else { //Burn random flammable thing in square List <Thing> burnables = Find.ThingGrid.ThingsAt(Position) .Where(t => t.def.Flammable) .ToList(); if (burnables.Count > 0) { damTarget = burnables.RandomListElement(); } //Destroy if nothing to burn in square if (damTarget == null) { Destroy(); return; } } //If it's a mobile burner, we only ignite it when we are above minimum square ignite size if (!damTarget.CanEverAttachFire() || fireSize > MinSizeForSquareIgnite) { damTarget.TakeDamage(new DamageInfo(DamageTypeDefOf.Flame, 1, this)); } ticksSinceDamage = 0; } //Emit sparks ticksSinceSpark++; if (ticksSinceSpark >= TicksBeforeSpark) { ThrowSpark(); ticksSinceSpark = 0; } //Try to grow the fire fireSize += FireBaseGrowthPerTick; if (fireSize > MaxFireSize) { fireSize = MaxFireSize; } //Extinguish from sky (rain etc) if (Find.WeatherManager.RainRate > 0.01f) { Thing building = Position.GetBuilding(); bool roofHolderIsHere = building != null && building.def.holdsRoof; if (roofHolderIsHere || !Find.RoofGrid.Roofed(Position)) { if (Random.value < BaseSkyExtinguishChance) { TakeDamage(new DamageInfo(DamageTypeDefOf.Extinguish, BaseSkyExtinguishDamage, null)); } } } }
private void ChooseRangedVerb(Thing target) { List <VerbEntry> updatedAvailableVerbsList = GetRangedVerbs; if (updatedAvailableVerbsList.NullOrEmpty()) { SetCurRangedVerb(null, null); } else if (updatedAvailableVerbsList.Count == 1 || VEF_ModCompatibilityCheck.enabled_CombatExtended) { SetCurRangedVerb(updatedAvailableVerbsList[0].verb, target); } else { float highestScore = 0f; int highestScoreIndex = -1; for (int i = 0; i < updatedAvailableVerbsList.Count; i++) { Verb verb = updatedAvailableVerbsList[i].verb; float currentScore; if (verb.verbProps is VEF_VerbProperties_Explode verbPropsExplode) { int explosionDamageAmount = Mathf.RoundToInt(verbPropsExplode.AdjustedExplosionDamageAmount(verb, verb.CasterPawn)); float explosionRadius = verbPropsExplode.explosionRadius; float detonationRange = verb.verbProps.range; currentScore = explosionDamageAmount + explosionRadius - (detonationRange * 0.5f); if (currentScore > highestScore) { highestScore = currentScore; highestScoreIndex = i; } } else if (verb.verbProps.spawnDef != null) { currentScore = 50 + i; } else if (target == null) { ThingDef verbProjectile = verb.GetProjectile(); int projectileDamageAmount = (verb.EquipmentSource == null) ? verbProjectile.projectile.GetDamageAmount(1f) : verbProjectile.projectile.GetDamageAmount(verb.EquipmentSource); List <float> accuracyList = (verb.EquipmentSource == null) ? new List <float>() { verb.verbProps.accuracyLong, verb.verbProps.accuracyMedium, verb.verbProps.accuracyShort } : new List <float>() { verb.EquipmentCompSource.parent.GetStatValue(StatDefOf.AccuracyLong), verb.EquipmentCompSource.parent.GetStatValue(StatDefOf.AccuracyMedium), verb.EquipmentCompSource.parent.GetStatValue(StatDefOf.AccuracyShort) }; accuracyList.Sort(); accuracyList.Reverse(); float accuracyValue = (accuracyList[0] + accuracyList[1]) / 2; int burstShotCount = (verb.verbProps.burstShotCount == 0) ? 1 : verb.verbProps.burstShotCount; float fullCycleTime = verb.verbProps.AdjustedFullCycleTime(verb, this.Pawn); currentScore = ((accuracyValue * projectileDamageAmount * burstShotCount) / (fullCycleTime)) + verbProjectile.projectile.explosionRadius - (verb.verbProps.forcedMissRadius / burstShotCount); if (currentScore > highestScore) { highestScore = currentScore; highestScoreIndex = i; } } else { ThingDef verbProjectile = verb.GetProjectile(); int projectileDamageAmount = (verb.EquipmentSource == null) ? verbProjectile.projectile.GetDamageAmount(1f) : verbProjectile.projectile.GetDamageAmount(verb.EquipmentSource); float accuracyValue = Verse.ShotReport.HitReportFor(Pawn, verb, target).TotalEstimatedHitChance; int burstShotCount = (verb.verbProps.burstShotCount == 0) ? 1 : verb.verbProps.burstShotCount; float fullCycleTime = verb.verbProps.AdjustedFullCycleTime(verb, this.Pawn); currentScore = ((accuracyValue * projectileDamageAmount * burstShotCount) / (fullCycleTime)) + verbProjectile.projectile.explosionRadius - (verb.verbProps.forcedMissRadius / burstShotCount); if (verb.IsIncendiary() && target.CanEverAttachFire() && !target.IsBurning()) { currentScore += 10; } Pawn targetPawn = target as Pawn; if (targetPawn != null && verb.IsEMP() && !targetPawn.RaceProps.IsFlesh) { currentScore += 10; } if (currentScore > highestScore) { highestScore = currentScore; highestScoreIndex = i; } } } if (highestScoreIndex != -1) { SetCurRangedVerb(updatedAvailableVerbsList[highestScoreIndex].verb, target); } } }