Exemple #1
0
        public static bool Impact(Bullet __instance, Thing hitThing)
        {
            Quaternion ExactRotation = Quaternion.LookRotation((Projectile_Patch.destination(__instance) - Projectile_Patch.origin(__instance)).Yto0());
            Map        map           = __instance.Map;
            IntVec3    position      = __instance.Position;

            Projectile_Patch.Base_Impact(__instance, hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(Projectile_Patch.launcher(__instance),
                                                                                                      hitThing, __instance.intendedTarget.Thing, Projectile_Patch.equipmentDef(__instance), __instance.def, Projectile_Patch.targetCoverDef(__instance));

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            NotifyImpact(__instance, hitThing, map, position);
            if (hitThing != null)
            {
                DamageInfo dinfo = new DamageInfo(__instance.def.projectile.damageDef, __instance.DamageAmount, __instance.ArmorPenetration,
                                                  ExactRotation.eulerAngles.y, Projectile_Patch.launcher(__instance),
                                                  null, Projectile_Patch.equipmentDef(__instance), DamageInfo.SourceCategory.ThingOrUnknown, __instance.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= __instance.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }

                if (__instance.def.projectile.extraDamages != null)
                {
                    foreach (ExtraDamage extraDamage in __instance.def.projectile.extraDamages)
                    {
                        if (Rand.Chance(extraDamage.chance))
                        {
                            DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), ExactRotation.eulerAngles.y, Projectile_Patch.launcher(__instance),
                                                               null, Projectile_Patch.equipmentDef(__instance), DamageInfo.SourceCategory.ThingOrUnknown, __instance.intendedTarget.Thing);
                            hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                        }
                    }
                }
            }
            else
            {
                float StartingTicksToImpact = (Projectile_Patch.origin(__instance) - Projectile_Patch.destination(__instance)).magnitude / __instance.def.projectile.SpeedTilesPerTick;
                if (StartingTicksToImpact <= 0f)
                {
                    StartingTicksToImpact = 0.001f;
                }
                float   DistanceCoveredFraction = Mathf.Clamp01(1f - (float)(Projectile_Patch.ticksToImpact(__instance)) / StartingTicksToImpact);
                Vector3 b             = (Projectile_Patch.destination(__instance) - Projectile_Patch.origin(__instance)).Yto0() * DistanceCoveredFraction;
                Vector3 ExactPosition = Projectile_Patch.origin(__instance).Yto0() + b + Vector3.up * __instance.def.Altitude;

                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(__instance.Position, map));
                if (__instance.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(ExactPosition, map, Mathf.Sqrt(__instance.DamageAmount) * 1f, 4f);
                }
                else
                {
                    MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt);
                }
            }
            return(false);
        }
Exemple #2
0
        public static bool Impact(Spark __instance, Thing hitThing)
        {
            Map map = __instance.Map;

            Projectile_Patch.Base_Impact(__instance, hitThing);
            FireUtility.TryStartFireIn(__instance.Position, map, 0.1f);
            return(false);
        }
        public static bool Impact(Projectile_Explosive __instance, Thing hitThing)
        {
            if (__instance.def.projectile.explosionDelay == 0)
            {
                Explode(__instance);
                return(false);
            }

            Projectile_Patch.landed(__instance) = true;
            ticksToDetonation(__instance)       = __instance.def.projectile.explosionDelay;
            GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(__instance, __instance.def.projectile.damageDef, Projectile_Patch.launcher(__instance).Faction);
            return(false);
        }
 public static void InitializeAllThreadStatics()
 {
     AttackTargetFinder_Patch.InitializeThreadStatics();
     AttackTargetsCache_Patch.InitializeThreadStatics();
     BeautyUtility_Patch.InitializeThreadStatics();
     CellFinder_Patch.InitializeThreadStatics();
     CompCauseGameCondition_Patch.InitializeThreadStatics();
     DamageWorker_Patch.InitializeThreadStatics();
     DijkstraInt.InitializeThreadStatics();
     Fire_Patch.InitializeThreadStatics();
     FloatMenuMakerMap_Patch.InitializeThreadStatics();
     FoodUtility_Patch.InitializeThreadStatics();
     FloodFiller_Patch.InitializeThreadStatics();
     GenAdj_Patch.InitializeThreadStatics();
     GenAdjFast_Patch.InitializeThreadStatics();
     GenLeaving_Patch.InitializeThreadStatics();
     GenRadial_Patch.InitializeThreadStatics();
     GenTemperature_Patch.InitializeThreadStatics();
     GenText_Patch.InitializedThreadStatics();
     HaulAIUtility_Patch.InitializeThreadStatics();
     ImmunityHandler_Patch.InitializeThreadStatics();
     InfestationCellFinder_Patch.InitializeThreadStatics();
     MapTemperature_Patch.InitializeThreadStatics();
     PathFinder_Patch.InitializeThreadStatics();
     Pawn_InteractionsTracker_Transpile.InitializeThreadStatics();
     Pawn_MeleeVerbs_Patch.InitializeThreadStatics();
     Pawn_WorkSettings_Patch.InitializeThreadStatics();
     PawnDiedOrDownedThoughtsUtility_Patch.InitializeThreadStatics();
     PawnsFinder_Patch.InitializeThreadStatics();
     Rand_Patch.InitializeThreadStatics();
     RCellFinder_Patch.InitializeThreadStatics();
     Reachability_Patch.InitializeThreadStatics();
     ReachabilityCache_Patch.InitializeThreadStatics();
     RegionDirtyer_Patch.InitializeThreadStatics();
     RegionListersUpdater_Patch.InitializeThreadStatics();
     RegionTraverser_Transpile.InitializeThreadStatics(); //this
     Projectile_Patch.InitializeThreadStatics();
     ThinkNode_PrioritySorter_Patch.InitializeThreadStatics();
     ThoughtHandler_Patch.InitializeThreadStatics();
     Verb_Patch.InitializeThreadStatics();
     WealthWatcher_Patch.InitializeThreads();
     World_Patch.InitializeThreadStatics();
     JoyGiver_InteractBuilding_Patch.InitializeThreadStatics();
     JoyGiver_InteractBuildingSitAdjacent_Patch.InitializeThreadStatics();
     JoyGiver_TakeDrug_Patch.InitializeThreadStatics();
     WorkGiver_DoBill_RegionProcessor.InitializeThreadStatics();
     Pawn_RelationsTracker_Patch.InitializeThreadStatics();
     Battle_Patch.InitializeThreadStatics();
 }
Exemple #5
0
        public static bool Impact(WaterSplash __instance, Thing hitThing)
        {
            Projectile_Patch.Base_Impact(__instance, hitThing);
            List <Thing> list = new List <Thing>();

            foreach (Thing item in __instance.Map.thingGrid.ThingsAt(__instance.Position))
            {
                if (item.def == ThingDefOf.Fire)
                {
                    list.Add(item);
                }
            }

            foreach (Thing item2 in list)
            {
                item2.Destroy();
            }
            return(false);
        }
        public static bool Impact(Projectile_DoomsdayRocket __instance, Thing hitThing)
        {
            Map map = __instance.Map;

            Projectile_Patch.Base_Impact(__instance, hitThing);
            GenExplosion.DoExplosion(__instance.Position, map, __instance.def.projectile.explosionRadius, DamageDefOf.Bomb, Projectile_Patch.launcher(__instance), __instance.DamageAmount,
                                     __instance.ArmorPenetration, null, Projectile_Patch.equipmentDef(__instance), __instance.def, postExplosionSpawnThingDef: ThingDefOf.Filth_Fuel,
                                     intendedTarget: __instance.intendedTarget.Thing,
                                     postExplosionSpawnChance: 0.2f, postExplosionSpawnThingCount: 1, applyDamageToExplosionCellsNeighbors: false, preExplosionSpawnThingDef: null,
                                     preExplosionSpawnChance: 0f, preExplosionSpawnThingCount: 1, chanceToStartFire: 0.4f);
            CellRect cellRect = CellRect.CenteredOn(__instance.Position, 5);

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < 3; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                DoFireExplosion(__instance, randomCell, map, 3.9f);
            }
            return(false);
        }
 private static void DoFireExplosion(Projectile_DoomsdayRocket __instance, IntVec3 pos, Map map, float radius)
 {
     GenExplosion.DoExplosion(pos, map, radius, DamageDefOf.Flame, Projectile_Patch.launcher(__instance), __instance.DamageAmount, __instance.ArmorPenetration, null,
                              Projectile_Patch.equipmentDef(__instance), __instance.def, __instance.intendedTarget.Thing);
 }
        public static bool Explode(Projectile_Explosive __instance)
        {
            Map map = __instance.Map;

            __instance.Destroy();
            if (__instance.def.projectile.explosionEffect != null)
            {
                Effecter effecter = __instance.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(__instance.Position, map), new TargetInfo(__instance.Position, map));
                effecter.Cleanup();
            }

            GenExplosion.DoExplosion(__instance.Position, map, __instance.def.projectile.explosionRadius, __instance.def.projectile.damageDef, Projectile_Patch.launcher(__instance), __instance.DamageAmount,
                                     __instance.ArmorPenetration, __instance.def.projectile.soundExplode, Projectile_Patch.equipmentDef(__instance), __instance.def, __instance.intendedTarget.Thing, __instance.def.projectile.postExplosionSpawnThingDef,
                                     __instance.def.projectile.postExplosionSpawnChance, __instance.def.projectile.postExplosionSpawnThingCount, preExplosionSpawnThingDef: __instance.def.projectile.preExplosionSpawnThingDef,
                                     preExplosionSpawnChance: __instance.def.projectile.preExplosionSpawnChance, preExplosionSpawnThingCount: __instance.def.projectile.preExplosionSpawnThingCount,
                                     applyDamageToExplosionCellsNeighbors: __instance.def.projectile.applyDamageToExplosionCellsNeighbors, chanceToStartFire: __instance.def.projectile.explosionChanceToStartFire,
                                     damageFalloff: __instance.def.projectile.explosionDamageFalloff, direction: Projectile_Patch.origin(__instance).AngleToFlat(Projectile_Patch.destination(__instance)));
            return(false);
        }