Beispiel #1
0
 // Token: 0x0600264C RID: 9804 RVA: 0x00123070 File Offset: 0x00121470
 public override void Tick()
 {
     this.ticksSinceSpawn++;
     if (Warpfire.lastFireCountUpdateTick != Find.TickManager.TicksGame)
     {
         Warpfire.fireCount = base.Map.listerThings.ThingsOfDef(this.def).Count;
         Warpfire.lastFireCountUpdateTick = Find.TickManager.TicksGame;
     }
     if (this.sustainer != null)
     {
         this.sustainer.Maintain();
     }
     else if (!base.Position.Fogged(base.Map))
     {
         SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.PerTick);
         this.sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, SoundDefOf.FireBurning, info);
     }
     this.ticksUntilSmoke--;
     if (this.ticksUntilSmoke <= 0)
     {
         this.SpawnSmokeParticles();
     }
     Rand.PushState();
     if (Warpfire.fireCount < 15 && this.fireSize > 0.7f && Rand.Value < this.fireSize * 0.01f)
     {
         ThrowMicroSparks(this.DrawPos, base.Map);
     }
     Rand.PopState();
     if (this.fireSize > 1f)
     {
         this.ticksSinceSpread++;
         if ((float)this.ticksSinceSpread >= this.SpreadInterval)
         {
             this.TrySpread();
             this.ticksSinceSpread = 0;
         }
     }
     if (this.IsHashIntervalTick(150))
     {
         this.DoComplexCalcs();
     }
     if (this.ticksSinceSpawn >= 7500)
     {
         this.TryBurnFloor();
     }
     if (this.IsHashIntervalTick(150))
     {
         Rand.PushState();
         bool despawn = Rand.Chance(0.25f);
         Rand.PopState();
         if (despawn && this.Spawned)
         {
             this.DeSpawn();
         }
     }
 }
Beispiel #2
0
    public override void SpawnSetup()
    {
        base.SpawnSetup();
        RecalcPathsOnAndAroundMe();
        Find.ConceptTracker.TeachOpportunity(ConceptDefOf.HomeRegion, this, OpportunityType.Important);


        SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.PerTick);

        sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, BurningSoundDef, info);
    }
        public override string LabelNoCount => "occult " + GenLabel.ThingLabel(this, 1);         // Doesn't work!

        // Make it harder to extinguish

        //---------------------------

        public override void Tick()
        {
            ticksSinceSpawn++;

            // Probably the best way is to use reflection and modify base class field [ticksSinceSpawn]
            // [ticksSinceSpawn] is used in [ExposeData] and [Rimworld.Verb_BeatFire]
            // Vanilla code passes fire as [Fire] class, therefore it's important to [ticksSinceSpawn] variable
            FieldInfo fieldInfo = typeof(Fire).GetField("ticksSinceSpawn", BindingFlags.Instance | BindingFlags.NonPublic);

            fieldInfo.SetValue(this as Fire, ticksSinceSpawn);

            if (lastFireCountUpdateTick != Find.TickManager.TicksGame)
            {
                fireCount = base.Map.listerThings.ThingsOfDef(def).Count;
                lastFireCountUpdateTick = Find.TickManager.TicksGame;
            }
            if (sustainer != null)
            {
                sustainer.Maintain();
            }
            else if (!base.Position.Fogged(base.Map))
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map), MaintenanceType.PerTick);
                sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, SoundDefOf.FireBurning, info);
            }
            ticksUntilSmoke--;
            if (ticksUntilSmoke <= 0)
            {
                //SpawnSmokeParticles();
            }
            if (fireCount < 15 && fireSize > 0.7f && Rand.Value < fireSize * 0.01f)
            {
                MoteMaker.ThrowMicroSparks(DrawPos, base.Map);
            }
            if (fireSize > 1f)
            {
                ticksSinceSpread++;
                if ((float)ticksSinceSpread >= SpreadInterval)
                {
                    TrySpread();
                    ticksSinceSpread = 0;
                }
            }
            if (this.IsHashIntervalTick(150))
            {
                DoComplexCalcs();
            }
            if (ticksSinceSpawn >= 7500)
            {
                TryBurnFloor();
            }
        }
Beispiel #4
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.RecalcPathsOnAndAroundMe(map);
     LessonAutoActivator.TeachOpportunity(ConceptDefOf.HomeArea, this, OpportunityType.Important);
     this.ticksSinceSpread = (int)(this.SpreadInterval * Rand.Value);
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         SoundDef def   = SoundDef.Named("FireBurning");
         SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, map, false), MaintenanceType.PerTick);
         this.sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, def, info);
     });
 }
Beispiel #5
0
        public static bool Tick(Fire __instance)
        {
            Map map = __instance.Map;

            if (null != map)
            {
                ++ticksSinceSpawn(__instance);
                if (lastFireCountUpdateTick != Find.TickManager.TicksGame)
                {
                    fireCount = __instance.Map.listerThings.ThingsOfDef(__instance.def).Count;
                    lastFireCountUpdateTick = Find.TickManager.TicksGame;
                }
                if (sustainer(__instance) != null)
                {
                    sustainer(__instance).Maintain();
                }
                else if (!__instance.Position.Fogged(__instance.Map))
                {
                    SoundInfo info = SoundInfo.InMap(new TargetInfo(__instance.Position, __instance.Map, false), MaintenanceType.PerTick);
                    sustainer(__instance) = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor((ISizeReporter)__instance, SoundDefOf.FireBurning, info);
                }
                --ticksUntilSmoke(__instance);
                if (ticksUntilSmoke(__instance) <= 0)
                {
                    SpawnSmokeParticles(__instance);
                }
                if (fireCount < 15 && (double)__instance.fireSize > 0.699999988079071 && (double)Rand.Value < (double)__instance.fireSize * 0.00999999977648258)
                {
                    MoteMaker.ThrowMicroSparks(__instance.DrawPos, __instance.Map);
                }
                if ((double)__instance.fireSize > 1.0)
                {
                    ++ticksSinceSpread(__instance);
                    if ((double)ticksSinceSpread(__instance) >= (double)get_SpreadInterval(__instance))
                    {
                        TrySpread(__instance);
                        ticksSinceSpread(__instance) = 0;
                    }
                }
                if (__instance.IsHashIntervalTick(150))
                {
                    DoComplexCalcs(__instance);
                }
                if (ticksSinceSpawn(__instance) < 7500)
                {
                    return(false);
                }
                TryBurnFloor(__instance);
            }
            return(false);
        }
Beispiel #6
0
 public override void Tick()
 {
     ticksSinceSpawn++;
     if (lastFireCountUpdateTick != Find.TickManager.TicksGame)
     {
         fireCount = base.Map.listerThings.ThingsOfDef(def).Count;
         lastFireCountUpdateTick = Find.TickManager.TicksGame;
     }
     if (sustainer != null)
     {
         sustainer.Maintain();
     }
     else if (!base.Position.Fogged(base.Map))
     {
         SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map), MaintenanceType.PerTick);
         sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, SoundDefOf.FireBurning, info);
     }
     ticksUntilSmoke--;
     if (ticksUntilSmoke <= 0)
     {
         SpawnSmokeParticles();
     }
     if (fireCount < 15 && fireSize > 0.7f && Rand.Value < fireSize * 0.01f)
     {
         MoteMaker.ThrowMicroSparks(DrawPos, base.Map);
     }
     if (fireSize > 1f)
     {
         ticksSinceSpread++;
         if ((float)ticksSinceSpread >= SpreadInterval)
         {
             TrySpread();
             ticksSinceSpread = 0;
         }
     }
     if (this.IsHashIntervalTick(150))
     {
         DoComplexCalcs();
     }
     if (ticksSinceSpawn >= 7500)
     {
         TryBurnFloor();
     }
 }
Beispiel #7
0
        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();
                    }
                }
            }
Beispiel #8
0
        public override void Tick()
        {
            //Update ticks
            ticksSinceSpawn++;

            //Update fire count
            if (lastFireCountUpdateTick != Find.TickManager.TicksGame)
            {
                fireCount = Map.listerThings.ThingsOfDef(def).Count;
                lastFireCountUpdateTick = Find.TickManager.TicksGame;
            }

            //Maintain sustainer
            if (sustainer != null)
            {
                sustainer.Maintain();
            }
            else
            {
                // Do we need to make a sustainer?
                if (!Position.Fogged(Map))
                {
                    // Yes. Yes we do.

                    // we use the current cell instead of "this" as the target, because this sustainer can outlive this Fire instance
                    // (because we use AggregateOrSpawnSustainerFor so something else can use it)
                    var info = SoundInfo.InMap(new TargetInfo(Position, Map), MaintenanceType.PerTick);

                    sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, SoundDefOf.FireBurning, info);
                }
            }
            // Since "re-fogging" isn't currently a thing, we don't bother dealing with fires that are now invisible

            //Spawn particles
            Profiler.BeginSample("Spawn particles");
            {
                //Do smoke and glow
                ticksUntilSmoke--;
                if (ticksUntilSmoke <= 0)
                {
                    SpawnSmokeParticles();
                }

                //Do visual micro sparks
                if (fireCount < FireCountParticlesOff && fireSize > 0.7f && Rand.Value < fireSize * 0.01f)
                {
                    MoteMaker.ThrowMicroSparks(DrawPos, Map);
                }
            }
            Profiler.EndSample();     //Spawn particles

            //Spread fire
            Profiler.BeginSample("Spread");
            if (fireSize > MinSizeForSpark)
            {
                ticksSinceSpread++;
                if (ticksSinceSpread >= SpreadInterval)
                {
                    TrySpread();
                    ticksSinceSpread = 0;
                }
            }
            Profiler.EndSample();     //Spread

            //Do complex calcs
            if (Gen.IsHashIntervalTick(this, ComplexCalcsInterval))
            {
                DoComplexCalcs();
            }

            if (ticksSinceSpawn >= TicksToBurnFloor)
            {
                TryBurnFloor();
            }
        }