Clone this repo to your project.
Add RimTerritory.csproj as reference.
Before adding new features to your project, update repo(fetch and pull).
Example of usage(May be outdated):
Create/use Thing Class.
public class MyThing : Thing
{
public Territory Territory
{
get ;
protected set ;
}
public Territory . Locator < Pawn > ? PawnLocator ;
}
Add handlers.
protected void PawnEnter ( Pawn pawn )
{
// Pawn enter
}
protected void PawnExit ( Pawn pawn )
{
// Pawn exit
}
protected void PawnStay ( Pawn pawn )
{
// Pawn stay
}
Add initialization of territory.
public override void SpawnSetup ( Map map , bool respawningAfterLoad )
{
base . SpawnSetup ( map , respawningAfterLoad ) ;
// Initialization of territory
Territory ??= new Territory . Radial ( this , Radius ) ;
var events = Territory . PawnEvents ;
events . OnEnter += PawnEnter ;
events . OnExit += PawnExit ;
events . OnStay += PawnStay ;
PawnLocator = new ( Territory , ThingRequest . ForGroup ( ThingRequestGroup . Pawn ) )
{
Predicate = pawn => ! pawn . health . Dead
} ;
}
Add finalization of territory.
public override void DeSpawn ( DestroyMode mode = DestroyMode . Vanish )
{
base . DeSpawn ( mode ) ;
Territory = null ;
PawnLocator = null ;
}
Add ticking of locator.
public override void Tick ( )
{
base . Tick ( ) ;
PawnLocator ? . Tick ( ) ;
}
Add ExposeData.
public override void ExposeData ( )
{
base . ExposeData ( ) ;
Territory ? . ExposeData ( ) ;
}
Code is still in testing stage, consider report issues if you find any!