示例#1
0
        static void Prefix(Pawn __instance)
        {
            var trait = __instance.story?.traits?.GetTrait(RFDefOf.RF_ZirsCorruption);

            if (trait == null)
            {
                return;
            }

            //Core.Warn("PAWN WITH TRAIT DIED");

            if (Settings.HateWaveRadius <= 0f)
            {
                return;
            }

            WaveOfHate.StartAt(__instance);
        }
示例#2
0
        public override void WorldComponentTick()
        {
            base.WorldComponentTick();

            // TODO move this to a better place?
            try
            {
                HEShellKillTracker.Tick();
            }
            catch (Exception e)
            {
                Core.Error($"Exception ticking HE Shell kill tracker:\n{e}");
            }

            const float TICKS_TO_EXPLODE = 480;

            for (int i = 0; i < explosionEffects.Count; i++)
            {
                var   item = explosionEffects[i];
                float p    = item.TicksAlive / TICKS_TO_EXPLODE;

                if (p >= 1f)
                {
                    if (item.MapId >= 0 && item.MapId < Find.Maps.Count)
                    {
                        Map map2 = Find.Maps[item.MapId];
                        WaveOfHate.WorkAt(map2, new IntVec3((int)item.Center.x, 0, (int)item.Center.y), Settings.HateWaveRadius, Settings.HateWaveStunDuration);
                    }

                    explosionEffects.RemoveAt(i);
                    i--;
                    continue;
                }
                item.TicksAlive++;

                if (item.MapId < 0 || item.MapId >= Find.Maps.Count)
                {
                    continue;
                }
                Map map = Find.Maps[item.MapId];

                int   toSpawn = (int)Mathf.Lerp(1, 4, p);
                float vel     = Mathf.Lerp(1.5f, 11f, p);

                for (int j = 0; j < toSpawn; j++)
                {
                    // Spawn particles.
                    var     sparks = new RitualSparks();
                    Vector2 target = item.Center;
                    sparks.Position         = target + Rand.InsideUnitCircle.normalized * 0.6f;
                    sparks.GravitateTowards = target;
                    sparks.Velocity         = Rand.InsideUnitCircle.normalized * vel;
                    sparks.Color            = Rand.Chance(0.5f) ? new Color(0.25f, 0.18f, 0.18f, 0.65f) : new Color(0.18f, 0.25f, 0.18f, 0.6f);
                    sparks.Spawn(map);
                }
            }

            gearRot += GearRotSpeed;

            if (!Rand.Chance(0.15f))
            {
                return;
            }

            // Cursed pawn effects.
            foreach (var pawn in cursedPawns)
            {
                var map = pawn?.Map;
                if (map == null)
                {
                    continue;
                }
                if (pawn.DestroyedOrNull() || pawn.Dead)
                {
                    continue;
                }

                // Spawn particles.
                var     sparks = new RitualSparks();
                Vector2 target = pawn.DrawPos.WorldToFlat();
                sparks.Position         = target + Rand.InsideUnitCircle * 2f;
                sparks.GravitateTowards = target;
                sparks.Velocity         = Rand.InsideUnitCircle.normalized * 1.5f;
                sparks.Color            = Rand.Chance(0.5f) ? new Color(0.25f, 0.18f, 0.18f, 0.65f) : new Color(0.18f, 0.25f, 0.18f, 0.6f);
                sparks.Spawn(map);
            }
        }