Skip to content

feat(api): implement Pawn Social subsystem and REST endpoints#74

Open
IlyaChichkov wants to merge 3 commits intodevelopfrom
feat/add-social-endpoints
Open

feat(api): implement Pawn Social subsystem and REST endpoints#74
IlyaChichkov wants to merge 3 commits intodevelopfrom
feat/add-social-endpoints

Conversation

@IlyaChichkov
Copy link
Copy Markdown
Owner

This PR introduces the PawnSocialController and its backing service, exposing RimWorld's social and relationship systems to the REST API. It allows clients to query real-time interaction readiness, extract deep historical interaction logs, view opinion breakdowns, and actively manipulate relationships or force interactions.

New Endpoints

Queries (GET)

/api/v1/game/defs/interactions: Lists all valid InteractionDef types.

/api/v1/pawns/interactions: Returns a pawn's current readiness to interact (cooldown ticks and status).

/api/v1/pawns/interactions/log: Retrieves the parsed historical interaction log (who, what, and translated grammar text).

/api/v1/pawns/relations: Returns all established familial/social bonds, explicitly bypassing cache limits to include dynamic "Friend/Rival" thresholds and modded Familiars.

/api/v1/pawns/opinions: Retrieves a map-wide numerical opinion matrix for the pawn, including a specific breakdown of social memories (e.g., "Chitchat +5", "Insulted -15").

Actions (POST/DELETE)

/api/v1/pawns/interactions/force: Forces a specific social interaction between two pawns via the game's native AI router.

/api/v1/pawns/relations/add: Instantly creates a direct social relation bond.

/api/v1/pawns/relations/remove: Severs a specific social relation bond.

Copy link
Copy Markdown
Contributor

@jkbennitt jkbennitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Comprehensive social API — interactions, relations, opinions, force/add/remove. Follows the established controller pattern (direct service calls, main-thread execution via the request queue pipeline). One compilation blocker.

1. Compilation error in GetPawnOpinionsst vs t (blocker)

Line 297: foreach (var st in socialThoughts) but line 299 uses if (t is Thought_SituationalSocial ss ...). Loop variable is st, body references t. This won't compile. Likely needs st throughout (or rename the loop variable to t).

Minor / Suggestions

  • Hardcoded 120-tick cooldown (line 276): Magic number — worth a comment documenting the source in RimWorld's interaction system.
  • Reflection fragility: PlayLogEntry_Interaction fields (initiator, recipient, intDef) accessed via reflection. If field names change across RimWorld versions, entries silently return null. A one-time log warning when field resolution fails would help.
  • No pagination on interaction log: GetPawnInteractionLog iterates all PlayLog.AllEntries. On long colonies this could be hundreds of entries. A ?limit=N query param (defaulting to e.g. 50) would be useful.
  • DELETE with JSON body: RemoveRelation uses DELETE with a request body. Some proxies/clients strip bodies from DELETE requests. Query params would be more portable.

What's good

  • Comprehensive scope — 8 endpoints covering the full social subsystem
  • Reflection fields cached outside loops in interaction log parsing
  • entry.Concerns(pawn) fast-path filter before heavier reflection work
  • Graceful empty-list handling when PlayLog is null
  • Bruno collection covers all endpoints
  • Follows established DDD controller pattern

@IlyaChichkov IlyaChichkov force-pushed the feat/add-tutorial-endpoints branch from 8ad2cc7 to 6a9bf92 Compare April 14, 2026 19:36
@IlyaChichkov IlyaChichkov force-pushed the feat/add-social-endpoints branch from 2d371f8 to bfc9ec5 Compare April 14, 2026 19:53
@IlyaChichkov IlyaChichkov changed the base branch from feat/add-tutorial-endpoints to develop April 14, 2026 19:54
Adds `PawnSocialController` to expose REST endpoints for RimWorld's pawn social systems. Supported capabilities include:
- Fetching available interaction defs, pawn interaction status, and recent interaction logs.
- Retrieving established pawn relations and detailed opinion breakdowns.
- Forcing specific social interactions between pawns.
- Dynamically adding or removing direct social relations.
 Add API macro macroses for PawnSocialController in English and Russian. Include endpoints for interactions, relations, and opinions. Update pawn documentation index.
@IlyaChichkov IlyaChichkov force-pushed the feat/add-social-endpoints branch from bfc9ec5 to 443ca66 Compare April 14, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants