You are viewing a potentially older version of this package. View all versions.
HatterTeam-ScopePartitioningLibrary-1.0.0 icon

ScopePartitioningLibrary

A library for mod developers: splits R.E.P.O.'s player lookups into scopes (enemies, hazards, truck, UI...) so mods can add proxy players that only some of the game sees. Changes nothing on its own.

Date uploaded 18 hours ago
Version 1.0.0
Download link HatterTeam-ScopePartitioningLibrary-1.0.0.zip
Downloads 104
Dependency string HatterTeam-ScopePartitioningLibrary-1.0.0

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2305 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2305

README

Latest changes 1.0.0

  • First release: splits the game's player lookups into scopes, with a startup report and config overrides.
  • Proxy players: mods can add players that only the chosen scopes see, with health events, an optional physics body, and multiplayer sync.

Scope Partitioning Library

TLDR

If you want to develop mods that mimics players, this library helps to separate the different scopes which interact with players. For example, in the mod HatterMiscellaneousPack, there's an item Decoy Bear which pulls enemies attention by mimicking a player body in the bear, but the same body doesn't interact with other scopes such as the truck healing at the end of a level.

Docs: https://github.com/kt-kianheng/repo_mods/tree/main/ScopePartitioningLibrary/docs

WARNING FOR DEVELOPERS

This library is vibe-coded, I've done a bit of testing with the library itself and with HatterMiscellaneousPack, but I havn't actually to hand-write the code using the library, so the API docs MIGHT be a bit problematic to read. I highly recommend just feeding LLM Guide.md to AI and let it do the work instead.

A library for mod developers. On its own it changes nothing in the game; install it only if a mod asks for it.

R.E.P.O. keeps one list of players, and every part of the game reads it: enemies, traps, the truck, extraction, spectating, voice chat... This library splits those lookups into scopes (Enemies, Hazards, Valuables, NPCs, Items, LevelFlow, CameraAndUI, VoiceAndEyes, Network, Mods). Mods can then add proxy players that only some scopes see: for example a decoy only enemies notice, which the truck, extraction and spectating ignore.

  • Real players behave the same way as before, all scopes are left in place.
  • With no proxies, every part of the game gets the game's own player list back, unchanged.
  • It finds the game's player lookups by reading the game's code at startup, so updates that add new ones are picked up (unknown ones are left alone).

For players

Nothing to set up. The config (BepInEx/config/ScopePartitioningLibrary.cfg) has an on/off switch, scope overrides and log switches. At startup one line in BepInEx/LogOutput.log sums up what was found; turn on [Report] LogFullReport for the full list of player lookups and their scopes.

For mod developers

The full API reference is in API.md, included in this package (next to the DLL, with ScopePartitioningLibrary.xml for your editor's tooltips). LLM_GUIDE.md, also included, is the same API written to be handed straight to an AI coding assistant (complete signatures, the rules that make proxies work, templates). Short version:

[BepInDependency(ScopePartitioningLibrary.Plugin.Guid)]

// the players enemies can see (real players + proxies visible to enemies)
List<PlayerAvatar> seen = ScopedPlayers.Get(PlayerScope.Enemies);

// run code as if it were enemy code
using (ScopedPlayers.Enter(PlayerScope.Enemies)) { var all = SemiFunc.PlayerGetList(); }

// a decoy only enemies see, on every player's game (host)
var decoy = ProxyPlayer.CreateNetworked(new ProxySettings { Name = "Decoy", Anchor = transform, MaxHealth = 200 }, photonView);
decoy.Hurt += (p, hit) => { /* your health logic */ };

Modders can test with [Debug] TestProxyKey in the config: it places a stand-in only enemies can see.

Feedback

If you have any issues or feedback, contact me at the GitHub page: https://github.com/kt-kianheng/repo_mods

CHANGELOG

Changelog

1.0.0

  • First release (in development). Scans the game's player lookups at startup, puts each in a scope (Enemies, Hazards, Valuables, NPCs, Items, LevelFlow, CameraAndUI, VoiceAndEyes, Network, Mods, or None), and patches them so a scope can see proxy players; with no proxies every lookup gets the game's own list. Startup report, config overrides, public API (PlayerScope, ScopedPlayers, ScopeReport, PlayerLookup).
  • Proxy players (ProxyPlayer, ProxySettings, ProxyDamage): hollow players visible only in chosen scopes, standing on a mod's object; hits and heals arrive as events on the host; optional physics body used as the tumble body; CreateNetworked builds them on every game (late joiners included); safe removal (dead first, destroyed after a delay); network calls on proxies dropped; [Debug] TestProxyKey test proxy.
  • Proxies can be seen and hit: their hit colliders (ProxySettings.HitColliders, default: the body's) count as a player's body for enemy sight, enemy attacks and SemiFunc's sight checks; SemiFunc.PlayerEyesOverride is skipped on proxies (it froze the Animal); the test key turns the item you look at into a proxy body.
  • Proxies are added to every enemy's per-player tables (Enemy.PlayerAdded, as for a joining player), so enemy sight no longer stops for good after seeing one; EnemyOnScreen (needs a real camera) left out of the Enemies scope; the log says when an enemy first sees a proxy.
  • Proxies without a body get a switched-off stand-in body, so grabbing enemies (Hidden, Oogly, Gambler/Spinny...) no longer throw errors on them.
  • Test capsule moved to the Player layer (enemy wall checks treat Default as a wall); docs say to keep proxy hit colliders off Default.
  • Proxies carry a player trigger (like a player's PlayerTrigger), so enemies whose attack starts from a trigger (the Head's bite, the Snatcher's tongue) can attack them.
  • The eye point game code reads is always the proxy's own (a mod's VisionPoint is copied into it), so it never dangles when the mod's object is destroyed (it broke an enemy's player-distance check); the log says when a proxy is first recognised through its colliders and how long it lived.
  • A proxy body's root object (where its rigidbody is) counts as part of the proxy: Unity reports a ray hit on an item's collider as a hit on the item's rigidbody object, so enemy sight never recognised proxy bodies; test proxy probe (Probe: log lines) shows what each nearby enemy's sight ray hits.
  • Quieter log for release: the full lookup table is off by default ([Report] LogFullReport), routine proxy lines only with [Debug] VerboseLog.
  • Added LLM_GUIDE.md: the API in one file for AI coding assistants.