Files
RickGrymes f84841be45 Merge modules into core and add robotics
Consolidates Enlist, Laser, and PresettablePocketMap code into FCP_Core and removes their separate projects/assemblies. Adds a full robotics feature set (robot control terminal, modes, hacking, docking/upgrading, loadouts, quest integration, derelict/wild robot behavior, and supporting defs/jobs), plus biome-restricted raid support and dedicated trader-character spawning updates. Also expands game content with new weapon/melee sound defs and assets, many new site map icons, a new Fusion Core item, lunchbox loot table additions, and several compatibility/bug fixes for updated RimWorld APIs and edge cases.
2026-07-15 23:24:32 -05:00

55 lines
1.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
namespace FCP.Core.Robotics
{
public class GenStep_DerelictRobot : GenStep
{
public float chancePerMap = 0.06f;
public List<CharacterDef> characters = new List<CharacterDef>();
public override int SeedPart => 1927481157;
public override void Generate(Map map, GenStepParams parms)
{
if (characters.NullOrEmpty() || !Rand.Chance(chancePerMap))
{
return;
}
UniqueCharactersTracker tracker = UniqueCharactersTracker.Instance;
if (tracker == null)
{
return;
}
List<CharacterDef> candidates = characters.Where(c => !tracker.CharacterPawnExists(c)).ToList();
if (candidates.Count == 0)
{
return;
}
Pawn pawn = tracker.GetOrGenPawn(candidates.RandomElement());
if (pawn == null)
{
return;
}
if (!CellFinder.TryFindRandomCellNear(map.Center, map, 50, c => c.Standable(map) && !c.Fogged(map), out IntVec3 cell))
{
cell = CellFinder.RandomCell(map);
}
GenSpawn.Spawn(pawn, cell, map);
CompRefuelable fuel = pawn.GetComp<CompRefuelable>();
if (fuel != null && fuel.Fuel > 0f)
{
fuel.ConsumeFuel(fuel.Fuel);
}
}
}
}