PhotonCustomPropsUtils
Helps modders easily synchronize room/player properties across all connected clients through Photon's Custom Properties.
About this mod Author’s original text
Photon Custom Props Utils
Helps modders easily synchronize room/player properties across all connected clients.
Utilizes Photon RoomProperties and PlayerProperties to make it easier to synchronize properties for all players.
To Modders
The best way to reach me is through the Photon Custom Props Utils thread on the Peak modding discord server.
Peak Modding Discord Server
Guide
First add this mod dll as a project reference for your mod. Then you can add a dependency to the mod to ensure your mod runs after PhotonCustomPropsUtils.
[BepInDependency("com.snosz.photoncustompropsutils", BepInDependency.DependencyFlags.HardDependency)]
Or if you dont want to set a dependancy you can just check for IsReady and listen for OnReady.
if (PhotonCustomPropsUtilsPlugin.IsReady)
DoPhotonStuff();
else
PhotonCustomPropsUtilsPlugin.OnReady += DoPhotonStuff;
Then you can create your scoped CustomPropsManager by passing your plugin GUID like so:
manager = PhotonCustomPropsUtilsPlugin.GetManager("com.author.modname");
This ensures that any properties you listen to are specific to your mod which helps avoid naming conflicts where multiple mods might have similar property names.
To start listening for a property change you can use either RegisterRoomProperty, or RegisterPlayerProperty. You can also set the event type, depending on if its a player or room event you can use RoomEventType.All (for both OnJoinedRoom, and OnRoomPropertyChanged) or either one seperately if you want to handle that logic seperately.
PlayerEventType is similar and can be PlayerEventType.All, OnPlayerPropertyChanged, and OnJoinedRoom.
For easy usage you can specify the expected type to be received which means you dont have to worry about casting it yourself.
// This will be called for either OnJoinedRoom (which runs for the local player), or OnRoomPropertyChanged.
manager.RegisterRoomProperty("myValue", RoomEventType.All, value =>
{
storedValue = value; //This is where you handle what to do with the updated property
});
// This will be called for OnPlayerPropertyChanged.
manager.RegisterPlayerProperty("myValue", PlayerEventType.OnPlayerPropertyChanged, (targetPlayer, value) =>
{
storedValue = value; //This is where you handle what to do with the updated property
});
To set a new value for a property you can just call SetRoomProperty
manager.SetRoomProperty("myValue", newValue);
To listen for when the local player has joined a room:
manager.RegisterOnJoinedRoom(localPlayer =>
{
// Do thing
});
To get all player properties, or all players with a specific property:
var allPlayersProperties = manager.GetAllPlayerProperties("targetProperty");
Please note that this should not be used in excess such as setting a property every frame. It should be only done in response to client behaviour such as pushing a button.
For further reading about Photon custom properties, the official Photon docs have both information on how it can be used, and the allowed types that are supported.
Install & use Install: BepInEx plugin
- The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
- Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
- Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
- Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.
Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.
Install these first, or the mod will not work: