How yanpla/yanplaroles works
Project Nature and Main Purpose
• This is a game-modification (mod) project. Its core objective is to inject new gameplay elements into Among Us by defining new roles (like Janitor, Miner, Sheriff, etc.), special abilities (modifiers such as Captain and Guesser), and custom game behaviors via patches.
Analyzing the File Structure
• “Buttons” Directory – Contains role-specific interaction components (like RememberButton, Ignition logic, cleaning, etc.). This implies there is a UI or input layer that triggers role-specific actions.
• “Modifiers” Directory – Provides implementations for role modifiers (e.g., Captain, ExecutionerTarget, Guesser) that alter or extend gameplay.
• “Options” Directory – Contains classes to manage game options and modifier/role configuration. This suggests a configuration or settings layer.
• “Patches” Directory – Includes a variety of patch classes (e.g., CheckEndCriteriaPatch, EndGamePatch, VentPatches, etc.). These classes are likely method detours or runtime modifications that “hook” into the game logic.
• “Roles” Directory – Organizes the different role implementations into subdirectories (Crewmate, Impostor, Neutral). This clearly represents the core game mechanics extensions.
• Other files like Assets.cs, CustomRpc.cs, and yanplaRolesPlugin.cs indicate the entry point and integration with the game’s runtime environment.
• The solution (*.sln) and project (*.csproj) files reveal that this is a C# project developed with Visual Studio, typical for Unity mod development.
Identifying Main Components
a. Core Game Plugin:
– yanplaRolesPlugin.cs: Acts as the plugin entry point integrated via BepInEx.
– Custom RPC and game event hooks that manage mod-specific messaging and interactions.
b. Role Logic Components:
– “Roles” directory: Different directories for Crewmate, Impostor, and Neutral roles with their individual logic (for Sheriff, Snitch, Jester, etc.).
– “Modifiers” directory: Implements modifiers that tweak the behavior of roles.
c. UI / Interaction Layers:
– “Buttons” directory: Contains scripts mapping custom UI buttons and actions (e.g., cleaning, vent placing) to role abilities.
– “Options” directory: Manages configurable settings related to roles and modifiers.
d. Patches / Game Hooks:
– “Patches” directory: Contains classes that override or extend core game behavior (hooking into game start, ending criteria, and visible roles features).
e. External Dependencies:
– Libraries such as BepInEx, MiraAPI, Reactor, and dependencies referenced in the README.
f. Custom Game Data and Utilities:
– Files like Resources, Utils.cs, and the custom game over reasons file which support runtime decision making and state management.
Relationships and Interactions
• The Entry Point (yanplaRolesPlugin.cs) is loaded by BepInEx and initializes the mod.
• Once loaded, the Plugin registers all patches (in the Patches directory), which modify the behavior of the Among Us game at runtime.
• Role-specific logic (found in the Roles directory) is activated when game events occur, sometimes routed through custom UI buttons (in Buttons) that offer new interactions.
• Options and Modifiers allow for runtime configuration, influencing how roles respond to game events.
• External libraries are used throughout—ensuring that dependencies are annotated within the design (e.g., BepInEx for plugin management, MiraAPI for mod functions).
Architectural Patterns
• Plugin Architecture: Clear injection point using BepInEx.
• Aspect-oriented modifications: Patches act as aspects by interjecting behavior into the core game loops.
• Modular Design: Separation by concerns (Buttons for UI interactions, Roles for game logic, Patches for hooking into game execution, Options for configuration).