mirror of
https://github.com/FalloutCollaborationProject/FCP-Tools.git
synced 2026-07-27 16:59:37 -07:00
Introduced several new mod source projects including BM_HeavyWeapon, BM_WeaponSummon, CompGiveThought, FragProjectile, Fusrodah, GauntletSpawners, Hediff_PawnConverter, Stims, WeaponRequirement, taranchuk_homingprojectiles, taranchuk_lasers, and tent. Each project includes initial implementation files, project and solution files, and relevant code for RimWorld modding features such as custom verbs, abilities, job drivers, and Harmony patches.
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Verse;
|
|
|
|
namespace GauntletSpawners
|
|
{
|
|
public static class UtilityCore
|
|
{
|
|
public static List<Pawn> GetNearbyPawnInLineOfSight(this IntVec3 center, Map map, float radius, bool needLoS)
|
|
{
|
|
IReadOnlyList<Pawn> list = map.mapPawns.AllPawnsSpawned;
|
|
List<Pawn> result = new List<Pawn>();
|
|
float squaredDistance = radius * radius;
|
|
for (int i = list.Count - 1; i >= 0; i--)
|
|
{
|
|
Pawn pawn = list[i];
|
|
if (pawn.Dead) continue;
|
|
if (needLoS && !GenSight.LineOfSightToThing(center, pawn, map)) continue;
|
|
float distance = squaredDistance + 1f;
|
|
if (pawn.Spawned)
|
|
{
|
|
distance = pawn.Position.DistanceToSquared(center);
|
|
}
|
|
else if (pawn.Corpse != null)
|
|
{
|
|
distance = pawn.Corpse.Position.DistanceToSquared(center);
|
|
}
|
|
|
|
if (distance > squaredDistance)
|
|
{
|
|
continue;
|
|
}
|
|
result.Add(pawn);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static IEnumerable<Pawn> NearbyPawnInLineOfSight(this IntVec3 center, Map map, float radius, bool needLoS)
|
|
{
|
|
IReadOnlyList<Pawn> list = map.mapPawns.AllPawnsSpawned;
|
|
List<Pawn> result = new List<Pawn>();
|
|
float squaredDistance = radius * radius;
|
|
for (int i = list.Count - 1; i >= 0; i--)
|
|
{
|
|
Pawn pawn = list[i];
|
|
if (pawn.Dead) continue;
|
|
if (needLoS && !GenSight.LineOfSightToThing(center, pawn, map)) continue;
|
|
float distance = squaredDistance + 1f;
|
|
if (pawn.Spawned)
|
|
{
|
|
distance = pawn.Position.DistanceToSquared(center);
|
|
}
|
|
else if (pawn.Corpse != null)
|
|
{
|
|
distance = pawn.Corpse.Position.DistanceToSquared(center);
|
|
}
|
|
|
|
if (distance > squaredDistance)
|
|
{
|
|
continue;
|
|
}
|
|
yield return pawn;
|
|
}
|
|
}
|
|
}
|
|
}
|