Compare commits

...
334 Commits
Author SHA1 Message Date
Atony ef19f5f7de Merge pull request #103 from All-Of-Us-Mods/dev
0.5.0
2026-09-03 20:34:33 -05:00
Atony e619acbc2a Merge branch 'master' into dev 2026-09-03 20:30:53 -05:00
Atony 9e21726ced Fix MultiTargetButton being renamed? 2026-09-03 20:29:05 -05:00
Atony 7d7d6469ce Bump version 2026-09-03 02:29:00 -05:00
Atony 087ea2a4bd Clear up il2cpp warnings 2026-09-03 02:28:27 -05:00
Atony 81c6bac979 Add UiButtonResetEvent for better ui button grid 2026-09-02 15:16:32 -05:00
Atony 85fb507a43 Adjust gamemode role checks for info guide 2026-09-02 02:34:01 -05:00
Atony 3e2c6df829 Fix skip button vote area order 2026-08-30 19:00:57 -05:00
Atony 6c7b362f95 Add toggles to disable abilities upon use / vote 2026-08-30 18:24:35 -05:00
Atony 027d4763f3 Expose vote methods for other mods 2026-08-30 17:49:20 -05:00
Atony d2f6ba9718 Fix god-awful spacing in the roles guide 2026-08-29 22:55:44 -05:00
Atony 28871d0a01 Refresh role info on the info guide immediately 2026-08-29 22:35:47 -05:00
Atony b62b8ae216 Add more helpers for getting role strings 2026-08-29 22:35:10 -05:00
Atony 4bdddc6f8a Fix IdPart shenanigans 2026-08-29 19:39:21 -05:00
Atony fa47d1dec4 Merge branch 'xml-translations' of https://github.com/All-Of-Us-Mods/MiraAPI into xml-translations 2026-08-29 18:15:43 -05:00
Atony 004f62eb77 Tweak system for registering changes 2026-08-29 18:15:30 -05:00
Turret 3f7e30a5c3 Translated using Weblate (Polish)
Currently translated at 71.0% (27 of 38 strings)

Translation: Mira API/Mira API
Translate-URL: https://weblate.duikbo.at/projects/mira-api/mira-api/pl/
2026-08-29 21:20:07 +00:00
Faulo Fault 1d18a2ac7b Translated using Weblate (Spanish (Latin America))
Currently translated at 100.0% (38 of 38 strings)

Translation: Mira API/Mira API
Translate-URL: https://weblate.duikbo.at/projects/mira-api/mira-api/es_419/
2026-08-29 21:20:07 +00:00
Shade the Minior Fan 663480c77f Translated using Weblate (Portuguese (Portugal))
Currently translated at 97.3% (37 of 38 strings)

Translation: Mira API/Mira API
Translate-URL: https://weblate.duikbo.at/projects/mira-api/mira-api/pt_PT/
2026-08-29 18:38:23 +00:00
Turret e95b52dbe8 Translated using Weblate (Polish)
Currently translated at 68.4% (26 of 38 strings)

Translation: Mira API/Mira API
Translate-URL: https://weblate.duikbo.at/projects/mira-api/mira-api/pl/
2026-08-29 18:38:23 +00:00
Faulo Fault 76105b3116 Translated using Weblate (Spanish (Latin America))
Currently translated at 76.3% (29 of 38 strings)

Translation: Mira API/Mira API
Translate-URL: https://weblate.duikbo.at/projects/mira-api/mira-api/es_419/
2026-08-29 18:38:23 +00:00
Anthony c82cc0e173 Translated using Weblate (Spanish)
Currently translated at 31.5% (12 of 38 strings)

Translation: Mira API/Mira API
Translate-URL: https://weblate.duikbo.at/projects/mira-api/mira-api/es/
2026-08-29 17:11:26 +00:00
Atony 2a432dd928 Add more localized strings 2026-08-28 00:37:14 -05:00
Atony 648e9ec185 Wrap up locale system 2026-08-27 23:51:25 -05:00
Atony 709b59300b Revert "Set role amount to 0 if chance is 0"
This reverts commit 794c762949.
2026-08-27 22:37:01 -05:00
Atony f064952aa6 Merge pull request #91 from HayashiUme/dev
Add XML Translation Api
2026-08-27 19:50:48 -05:00
Atony e532e558b6 Fix local tabs not being localized without hovering 2026-08-27 19:49:10 -05:00
Atony a3ed901a18 Translate local setting buttons 2026-08-27 19:36:33 -05:00
Atony 48aff163f9 Fix issues with local settings tab localization 2026-08-27 19:29:12 -05:00
Atony 28a77f96cb Fix capitalization of all xml strings 2026-08-27 18:21:14 -05:00
Atony 4206b74d12 Fix localization being applied 2026-08-26 00:24:02 -05:00
Atony 276ab0ac79 Fix overall localization 2026-08-25 19:02:55 -05:00
Atony 34148499b7 Fix up system registration for the most part 2026-08-25 18:26:54 -05:00
Atony 5b006ab7d3 Fix xml loading 2026-08-25 01:04:11 -05:00
Atony 47582897a8 Fix loading errors 2026-08-25 00:47:54 -05:00
Atony 80e1e6e454 Clear some warnings 2026-08-25 00:20:52 -05:00
Atony c449669cf2 Fix example plugin error 2026-08-25 00:15:39 -05:00
Atony 6da1048d09 Adjust system for Crowdin / Weblate support 2026-08-25 00:04:09 -05:00
Atony 6a7f58effa Add localization for gamemodes 2026-08-24 22:23:57 -05:00
Atony 39da0e7d08 Merge branch 'dev' into pr/91 2026-08-24 22:16:53 -05:00
Atony 5a23c38fba Merge pull request #102 from WanderingPix/meeting-abilities
Meeting abilities
2026-08-24 21:56:01 -05:00
Atony 0b1b223a6e Merge branch 'dev' into meeting-abilities 2026-08-24 21:48:54 -05:00
Atony a4a363b015 Merge branch 'dev-update' into meeting-abilities 2026-08-24 21:46:00 -05:00
Atony 794c762949 Set role amount to 0 if chance is 0 2026-08-24 16:18:39 -05:00
Atony e901abfc60 Merge branch 'dev' into dev-update 2026-08-24 15:49:12 -05:00
Atony 853a94681a Merge pull request #17 from All-Of-Us-Mods/game-modes
Game modes
2026-08-24 15:41:24 -05:00
wanderingpix d37222010d Document CenteredGridArrange 2026-08-22 13:37:02 +01:00
wanderingpix 1254de742a Fix text labels visible for disabled meeting abilties 2026-08-22 13:33:55 +01:00
wanderingpix 7bbbd7597d Refactor + untargeted meeting abilities 2026-08-22 13:32:14 +01:00
wanderingpix 4b7f17fa30 Fix skip button being broken 2026-08-21 19:30:24 +01:00
wanderingpix 06d62da24d Multi target meeting abilities 2026-08-21 17:00:24 +01:00
wanderingpix 0050c34225 Add singleton for accessing meeting buttons 2026-08-21 14:00:24 +01:00
wanderingpix 605c792e8f More documentation + Button outline color 2026-08-21 12:32:43 +01:00
wanderingpix 54d7c84e91 Edit example meeting ability 2026-08-21 11:52:48 +01:00
wanderingpix eb4bff1834 Document meeting abilities 2026-08-21 11:44:30 +01:00
wanderingpix e381de033e WIP Targeted meeting abilities API 2026-08-20 22:41:26 +01:00
Atony f230cff5e5 Add RoleMedDescription for the role guide 2026-08-19 23:28:00 -05:00
Atony 7c7d184d1f Wip faction display for roles
These need to be their own text object later.
2026-08-19 17:24:54 -05:00
Atony 6b923cfe01 Show nameplate on player list menu 2026-08-19 17:10:41 -05:00
Atony 247c765176 Fix bad ui because sloth sucx 2026-08-19 15:56:13 -05:00
Atony a3668b3150 Add proper support for modded roles in wiki 2026-08-19 13:52:33 -05:00
Atony aa4dd24ac3 Change options to V11 2026-08-19 13:31:36 -05:00
Atony cb0afe3095 Add ui resizing + wiki in the lobby 2026-08-19 13:29:03 -05:00
Atony 883222be82 Merge branch 'dev-update' into game-modes 2026-08-19 00:18:25 -05:00
Atony 6b774500dd Fix reimplemented Judge for good 2026-08-18 23:07:39 -05:00
Atony f96f75cea1 Fix issues with Judge and new meeting changes 2026-08-18 15:10:11 -05:00
linmeideli acfe345133 enhanced 2026-08-18 21:25:22 +08:00
Atony 75662a6c25 Improve vent checks 2026-08-17 17:47:33 -05:00
Atony 73e4506016 Fix role tab issue 2026-08-17 17:41:24 -05:00
Atony a491592669 Allow gamemodes to be hidden when registered 2026-08-16 23:01:58 -05:00
Atony 01fef0f747 Fix vanilla advanced role settings tab breaking 2026-08-16 22:36:57 -05:00
Atony e22f4daf3e Fix the first role option being duped in the menu 2026-08-16 22:00:24 -05:00
Atony b83cb5cc29 Force role menu to be refreshed on gamemode change 2026-08-16 21:56:48 -05:00
Atony fb164a54e3 Fix broken game options tab for mods 2026-08-16 20:05:30 -05:00
Atony b6475161f1 Merge branch 'dev' into game-modes 2026-08-16 17:03:11 -05:00
XtraCube c7f3f9d5da Merge remote-tracking branch 'origin/game-modes' into game-modes 2026-08-16 11:16:52 -04:00
XtraCube 5d54a0c2d3 cleanup this file 2026-08-16 11:16:37 -04:00
ang-xd cf1a75f5ea Fix gamemode options visibility 2026-08-16 11:16:37 -04:00
XtraCube 721bd20d2b improve lobby view pane gamemode handling 2026-08-16 11:08:08 -04:00
XtraCube 0e3b6be5be show different plugin gamemodes in lobby view pane 2026-08-16 10:46:19 -04:00
Atony 411340d9e9 Fix role screenshots for combined spritesheets 2026-08-15 16:27:49 -05:00
Atony 57d2a6a9b5 Expose button event types 2026-08-15 16:00:05 -05:00
Atony 6f61a75bb7 Add BundleSubAssetHolder for packed spritesheets 2026-08-15 13:18:05 -05:00
Atony 06c746c632 Add most music logic 2026-08-14 23:24:07 -05:00
Atony 95819cf83a Add (unsynced) in-game timebar + adjust ui pos 2026-08-14 22:29:40 -05:00
Atony d1d11e2bec Show gamemode change notification 2026-08-14 20:22:45 -05:00
Atony b4ed14f7f2 Remove Hide n Seek port on release builds for now 2026-08-14 19:52:51 -05:00
ang-xd 951af42358 Move icons to gamemode and add icons for vanilla modes 2026-08-14 16:39:16 -04:00
AS 27e14488af Merge branch 'dev' into game-modes 2026-08-14 07:11:38 -04:00
AzandHayashiUmi 182a53442e Update README_zh.md
Co-Authored-By: HayashiUmi <2558527373@qq.com>
2026-08-14 06:57:19 -04:00
ang-xd 9ab87955bb i forgor to mask mod icon 2026-08-14 03:19:06 -04:00
ang-xd 0141dfdea4 Update gamemodes info panel to show mod icon 2026-08-14 03:12:04 -04:00
Az 35e4c7cc9d move chinese readme to translated folder 2026-08-14 02:18:15 -04:00
AS b2a5b236c0 Merge pull request #79 from TAIKgroup/master
Translate the README.md of MiraAPI into Simplified Chinese
2026-08-14 02:14:46 -04:00
linmeideli 525f987926 this check does not work for Unity's fake null 2026-08-14 13:38:28 +08:00
linmeideli 0b81a8808a Add Translation API 2026-08-14 13:05:30 +08:00
Atony cd97fab3a2 Show gamemode description in options 2026-08-13 23:59:51 -05:00
Atony 3cd8db1f04 Show gamemode settings properly again 2026-08-13 23:00:09 -05:00
AS 535967475d Merge pull request #100 from All-Of-Us-Mods/shader-improvement
Pass shader caching through helper method
2026-08-13 23:43:50 -04:00
Az 6fd5993959 pass shader caching through helper method 2026-08-13 23:27:07 -04:00
Atony b713599c13 Fix option toggling for vanilla options 2026-08-13 20:51:29 -05:00
ang-xd f44ec15804 Patch console use 2026-08-13 16:19:23 -04:00
ang-xd 847a4dd287 Move initialize to begin 2026-08-13 14:37:52 -04:00
Atony 83d55d409b Change indirect and defense flags to get sets 2026-08-13 10:07:40 -05:00
Atony 7a00ea9174 Merge branch 'dev' into game-modes 2026-08-13 09:24:10 -05:00
Atony 22716b29ab Add Framed and Advanced Murder RPCs 2026-08-13 09:20:26 -05:00
ang-xd 43291bda50 Merge branch 'game-modes' of https://github.com/All-Of-Us-Mods/MiraAPI into game-modes 2026-08-13 00:43:23 -04:00
ang-xd d4a675f2a9 Hide roles tab if no roles in mod 2026-08-13 00:43:15 -04:00
Atony 00c5c5c4ff Merge branch 'dev' into game-modes 2026-08-12 23:23:14 -05:00
Atony abb6f3d161 Add better murder event data 2026-08-12 23:22:55 -05:00
Atony eef098317e Add hide and seek end logic and cooldown checks 2026-08-12 23:20:19 -05:00
Atony 1c097b47df Add end game patches for all gamemodes 2026-08-12 23:18:17 -05:00
Atony 6fe2750545 Make kill timer use whatever the gamemode sets 2026-08-12 23:18:00 -05:00
Atony a57f40fa79 Apply role menu toggle 2026-08-12 23:17:29 -05:00
Atony 54bfd3002b Add role settings toggle and imp cooldown for mode 2026-08-12 22:53:30 -05:00
Atony 4c38189444 Fix initialize patch for gamemodes 2026-08-12 22:25:56 -05:00
Atony 14ce020208 Hide modifier spawning on non-dev builds 2026-08-12 21:14:50 -05:00
Atony 877fc15aec Merge branch 'dev' into game-modes 2026-08-09 22:26:50 -05:00
Atony 2160d1d823 Allow HandleVoteEvent's PreventVote to be set 2026-08-09 22:26:31 -05:00
amber 4d187f3f79 more null checks, yay! 2026-08-09 09:49:25 -04:00
amber 4e37f8b3d4 fix scrollbar 2026-08-09 09:31:59 -04:00
amber 015d175aa0 check if header is not null 2026-08-09 09:11:05 -04:00
Amber ca7da0c343 update gamelibs 2026-08-09 08:43:56 -04:00
Atony 72fa908cb0 Move patches to account for gamemodes 2026-08-08 20:34:10 -05:00
Atony 58067d9f21 Merge branch 'dev' into game-modes 2026-08-08 20:26:39 -05:00
Atony b8b85e2bc3 Merge pull request #99 from yanpla/fix/role-assignment
Fix role assignment
2026-08-08 20:13:02 -05:00
Atony 043845ee11 Fix crashing on Epic and MS Store 2026-08-08 19:57:47 -05:00
yanpla df7c182abb use .select() in loop 2026-08-09 01:52:33 +02:00
yanpla 2a4d16e65e simplify and fix role assignment patch 2026-08-09 01:50:29 +02:00
Nix-main 9606871cbe sync gamemode on join 2026-08-07 23:22:49 -04:00
Atony ae45c506cb Temporary fix for scroller being too small 2026-08-07 18:32:55 -05:00
Atony fd01273635 Merge branch 'dev' into game-modes 2026-08-07 15:08:23 -05:00
Atony 840761787f Merge pull request #97 from All-Of-Us-Mods/dev
MiraAPI 0.4.3
2026-08-06 18:29:35 -05:00
Atony 615d527c86 Merge branch 'master' into dev 2026-08-06 18:25:58 -05:00
Atony 7628a41d86 Adjust tab count + text 2026-08-06 17:50:25 -05:00
amber 121baeb178 Remove IsHideAndSeek 2026-08-06 17:37:55 -04:00
Atony 0cf4954eaf Add in Hide and Seek role logic 2026-08-05 22:36:34 -05:00
Atony 8f403f5408 Add modifier classic check 2026-08-05 22:05:27 -05:00
Atony 2f5c382ece Remove hns IsNormal patch 2026-08-05 22:00:20 -05:00
Nix-main 1ab0c3f4a7 Fix IsInstance for associated mode 2026-08-05 22:55:01 -04:00
Nix-main 0230d98642 make IsClassic and IsHideNSeek use assignable 2026-08-05 22:53:17 -04:00
Nix-main 04b7a9905d make gamemode use assignable from / instance 2026-08-05 22:00:09 -04:00
Nix-main 317e0b6ea9 Fix gamemodes not being properly added to the option 2026-08-05 21:26:09 -04:00
Nix-main cbe44a40d0 Fix button issue and emove options reload logic for now 2026-08-06 01:10:21 -04:00
Nix-main d5c3905684 fix reloading not occuring until next opening of the menu 2026-08-06 00:34:30 -04:00
Nix-main 49d16b707c use ValueChanged patch for logic 2026-08-06 00:31:04 -04:00
Nix-main 3eb5bfae01 Merge remote-tracking branch 'origin/game-modes' into game-modes
# Conflicts:
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
2026-08-06 00:23:51 -04:00
Nix-main b1293081fc Merge remote-tracking branch 'origin/dev' into game-modes
# Conflicts:
#	MiraAPI/Patches/Options/GameSettingMenuPatches.cs
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
2026-08-05 22:04:06 -04:00
Atony 83751a25a9 add back some fixes 2026-08-05 18:58:25 -05:00
Atony bd58fca7bd Merge branch 'dev' into game-modes 2026-08-05 18:50:22 -05:00
XtraCube 63d1003b2b fix role scroll issues 2026-08-05 15:08:58 -04:00
Atony 0645c32cca Add tmp sprite todo comment 2026-08-05 13:39:43 -05:00
Atony 8beabb20a2 Bump version 2026-08-05 12:19:10 -05:00
Atony 3f28d70308 Fix errors every time role options are opened 2026-08-05 12:18:36 -05:00
Atony b919c55ef1 Fix advanced role settings being unscrollable 2026-08-05 11:55:30 -05:00
XtraCube 55a2161876 get rid of field warning 2026-08-04 00:04:13 -04:00
XtraCube 4ca2249fbd options patches overhaul 2026-08-04 00:01:21 -04:00
Atony fc94c8e67e Bump version 2026-08-02 20:13:16 -05:00
Atony 83e550c1f2 Merge pull request #96 from All-Of-Us-Mods/dev
MiraAPI 0.4.2
2026-08-02 20:11:59 -05:00
Atony edee889ffe Fix hidden local tabs breaking the menu 2026-07-30 23:15:24 -05:00
amber 119d4c5152 use methodrpc 2026-07-30 01:58:04 -04:00
Nix-main c99f468abf sync gamemode option 2026-07-30 00:39:02 -04:00
Nix-main adde6db1d0 Merge remote-tracking branch 'origin/dev' into game-modes
# Conflicts:
#	MiraAPI/GameModes/AbstractGameMode.cs
#	MiraAPI/GameModes/CustomGameModeManager.cs
#	MiraAPI/GameOptions/AbstractOptionGroup.cs
#	MiraAPI/GameOptions/ModdedOptionsManager.cs
#	MiraAPI/Modifiers/Types/TimedModifier.cs
#	MiraAPI/Patches/Menu/NameplatesTabPatches.cs
#	MiraAPI/Patches/Menu/SkinsTabPatches.cs
#	MiraAPI/Patches/Menu/VisorsTabPatches.cs
#	MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
#	MiraAPI/Patches/Options/GameSettingMenuPatches.cs
#	MiraAPI/Patches/Options/LobbyViewPanePatches.cs
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
#	MiraAPI/PluginLoading/IMiraPlugin.cs
#	MiraAPI/PluginLoading/MiraPluginInfo.cs
#	MiraAPI/PluginLoading/MiraPluginManager.cs
#	MiraAPI/Utilities/Extensions.cs
2026-07-29 19:50:41 -04:00
Nix-main 0012fe8cd6 Make ActiveMode setter private 2026-07-29 18:14:27 -04:00
Nix-main 9148a1e8da Sync gamemode option surely 2026-07-29 18:13:14 -04:00
Atony 8c5aee4beb Fix vanilla roles tab being broken 2026-07-26 11:56:21 -05:00
Atony 30a39fa223 Add DisplayOnOptionsMenu for mira api mods 2026-07-26 11:12:28 -05:00
Atony 228ed9711a Add mod name abbreviation 2026-07-26 11:05:13 -05:00
Atony 7c085b1072 Add modifier post assignment-check 2026-07-25 18:03:29 -05:00
Atony 8750e5c894 Reorder modifier validity checks 2026-07-25 17:20:14 -05:00
XtraCube 1b40b1c5e4 attempt to improve gc behavior 2026-07-20 20:23:38 -04:00
XtraCube 0a0ad74419 improve GC collection 2026-07-20 20:02:29 -04:00
XtraCube 992bdbcbf8 cleanup usings 2026-07-20 19:10:06 -04:00
XtraCube f9721a8d69 improve stability and FPS on 17.4+ 2026-07-20 19:06:52 -04:00
XtraCube e541840da9 improve lag issues in settings menu on 17.4 2026-07-20 16:35:52 -04:00
Atony eb18d82d8e Allow overriding configuration on modded option 2026-07-17 21:34:10 -05:00
Atony 7afd899e56 Improve example options 2026-07-17 15:47:53 -05:00
Atony 5cccc192b1 Add support for better option notfs 2026-07-17 15:07:40 -05:00
Atony 9d7e41a3c9 Fix duplicated Populate Results Event 2026-07-09 23:03:02 -05:00
Atony 662b52f78d Allow populated votes to be modified 2026-07-09 22:57:59 -05:00
Atony dac1d82d5c Reduce heavy garbage collection temporarily 2026-07-09 22:57:31 -05:00
Atony 1b718092ee Move GC clearing out of coroutines 2026-07-08 18:13:34 -05:00
Atony 3eb0a4fdb3 Fix some instant crashing
Happens very quickly on practice mode when spam switching tasks
2026-07-08 17:31:20 -05:00
Atony 850e82155c Improve tmp offsets 2026-07-01 23:39:57 -05:00
Atony ff30d5fdd6 Add tmp sprite scaling support 2026-07-01 20:30:44 -05:00
Atony 2eecba2e51 Add TMP icon support for roles 2026-07-01 19:57:29 -05:00
Atony 84321f290e Fix game option checks 2026-06-30 16:25:53 -05:00
Atony d8d3cc202a Merge pull request #94 from All-Of-Us-Mods/dev
MiraAPI v0.4.1
2026-06-29 09:22:38 -05:00
Atony e08e7e5f4b Merge branch 'master' into dev 2026-06-29 09:22:03 -05:00
Atony a5f0ed5975 Bump version 2026-06-29 09:13:24 -05:00
Atony d1f5e56cb9 Merge pull request #93 from TheDavSmasher/documentation-improvement
Documentation improvement
2026-06-29 09:12:15 -05:00
Atony 127e3f600e Fix misc warnings 2026-06-29 09:05:35 -05:00
Atony 47e02d3dcf Add documentation for menu categories 2026-06-29 08:47:21 -05:00
Atony f53e4fdc38 Add more option documentation 2026-06-29 08:44:56 -05:00
Atony b1f0ec6da3 Fix settings button breaking 2026-06-28 21:15:30 -05:00
Atony d0d5056e39 Fix hat tab being severely broken on v17.4 2026-06-28 20:30:28 -05:00
Atony 57e3f20cba Improve role option garbage collection further 2026-06-27 21:00:57 -05:00
David Higueros 7fdfd506e0 Added missing method cref 2026-06-23 21:18:05 -06:00
David Higueros edf61e722f Updated added method 2026-06-23 21:17:43 -06:00
David Higueros 791daa08ad Merge branch 'dev' into documentation-improvement 2026-06-23 21:08:22 -06:00
David Higueros e4d2509895 Added href tags for links 2026-06-23 21:01:45 -06:00
David Higueros 62c8e27535 Fixed annotations with double > annotations 2026-06-23 20:55:47 -06:00
David Higueros 8852c014ab Replaced true, false, and null with langword annotations 2026-06-23 20:54:23 -06:00
David Higueros adb9a2823d Updated docstrings to reference classes, fields, and methods directly 2026-06-23 20:43:32 -06:00
Atony ff658db6f1 Remove destroyable singletons 2026-06-20 15:08:22 -05:00
Atony 750e00d06d Run GC when destroying multiple objects 2026-06-20 14:53:45 -05:00
Atony 3a5a397846 Only run gc when using v17.4 2026-06-20 14:28:08 -05:00
David Higueros c846109d07 Changed to use obsolete annotation 2026-06-19 17:07:31 -06:00
Atony e3b0eb68c0 Temporary measures for clearing up memory leaks 2026-06-12 18:03:13 -05:00
amber 90921ff786 Remove UseVanillaVentButton as it's unnecessary 2026-06-11 22:37:10 -04:00
amber c1d0bb5d26 Seperate vanilla vent data receiving from the actual button 2026-06-11 22:34:27 -04:00
amber 25a55b1b60 ColoredName property rather than a method 2026-05-31 11:33:14 -04:00
amber af2cc9a3c1 Renames DefaultMode to ClassicMode among other util changes. 2026-05-31 11:27:46 -04:00
Atony e9730f018d Check valid gamemode roles to spawn 2026-05-31 10:08:41 -05:00
Atony 1d316bb02f Merge branch 'dev' into game-modes 2026-05-31 09:17:43 -05:00
Atony c59ed8eaa6 Fix screenshake within options menu 2026-05-31 09:17:26 -05:00
Atony 2eac3d04f1 Add more configuration for hns tasks 2026-05-31 09:16:48 -05:00
Atony 154b50fd76 Mods can now choose to appear in the settings menu 2026-05-31 08:54:27 -05:00
Atony 390e4c1157 Fix toggle title 2026-05-13 12:26:24 -05:00
Atony 35b444854a Fix showing/hiding groups 2026-05-13 12:23:51 -05:00
Atony 8e5028c236 Fix scroller issues 2026-05-13 12:07:15 -05:00
Atony ad113a47ab Hide and add gamemode options 2026-05-13 10:15:03 -05:00
Atony 59b8e92c48 WIP option toggling 2026-05-13 08:32:26 -05:00
Atony d313089521 Register MiraAPI within itself 2026-05-13 08:32:11 -05:00
Atony 0852f769ae Fix game mode option appearing in mod tabs 2026-05-12 22:18:48 -05:00
Atony ae4b4d872b Add crewmate kill tracker 2026-05-12 22:09:38 -05:00
Atony b33a66cbd9 Fix OnPlayerDeath for HnS 2026-05-12 21:48:14 -05:00
Atony ac87003d0a Fix color not applying on game mode name 2026-05-12 21:46:01 -05:00
Atony f7de7f127d Merge branch 'dev' into game-modes 2026-05-12 21:24:52 -05:00
Atony d2fafc3650 Fix errors in How to Play menu 2026-05-04 09:55:37 -05:00
Atony 0c0157fed2 Add soft-support for Corsac Cosmetics 2026-05-04 07:43:53 -05:00
Atony e095e2da6a Merge branch 'dev' into game-modes 2026-05-03 22:32:51 -05:00
Atony 90bf402cbc Fix UI resizing with the top right buttons 2026-05-03 11:57:04 -05:00
Atony 50cb8ffc3d Add body type patch for Hide n Seek 2026-05-01 20:52:54 -05:00
Atony 4f4b880ad4 Reimplement Hide n Seek intro (no music) 2026-05-01 20:34:45 -05:00
amber b627006ba1 Move gamemode option to the top, fix registration. 2026-05-01 12:44:54 -04:00
Atony b0ceb129a4 Re-add Hns options as modded options
The options don't appear yet though, this needs to be fixed!
2026-04-30 12:37:54 -05:00
Atony bf7c800613 Add basic Hide n Seek gamemode 2026-04-30 11:58:02 -05:00
Atony 990bac4c06 Merge branch 'dev' into game-modes 2026-04-30 10:09:46 -05:00
amber 08c6883a0d Remove more StringNames duplication 2026-04-26 23:19:01 -04:00
Nix-main 3066720e6e Rename Default -> Classic 2026-04-26 23:09:00 -04:00
Nix-main af363000c7 Fix bugs and add HuD 2026-04-26 23:06:38 -04:00
Atony 245f2e6919 Merge pull request #83 from All-Of-Us-Mods/dev
## What's Changed
- Guardian Angel protection is checked properly.
- The Options Menu no longer throws errors on Android
- Framerate slider applies properly on PC again
- StateMachineWrapper now allows overriding existing states and returns for Coroutines.
2026-04-18 08:41:18 -05:00
Atony fed3abafb2 Bump version 2026-04-18 08:31:59 -05:00
Atony 925d47a275 Fix framerate slider 2026-04-18 08:29:11 -05:00
Atony 45a3597ab2 Update dependencies 2026-04-04 20:50:27 -05:00
Chipseq faeb39d3de use AccessTools to allow any method to be an event handler 2026-04-04 22:05:41 +02:00
Atony 6b46cffe5e Add isKilling check for basic kills 2026-04-03 20:31:27 -05:00
Atony 00a60bb7ad Add methods for StateMachineWrapper 2026-04-03 09:46:44 -05:00
Atony d89bce6956 Merge branch 'master' into dev 2026-04-01 21:33:21 -05:00
Atony 7f92e94293 Fix options menu error on mobile 2026-04-01 21:30:28 -05:00
Atony 6199e55110 Add Guardian Angel protection checks 2026-04-01 21:30:19 -05:00
Pietro420 eac442443b Random Snapshot for kill anim 2026-03-29 22:34:43 -03:00
Pietro420 6321753ec0 Don't use nullable for kill anim 2026-03-29 22:26:07 -03:00
XtraCube e66d45bd21 revert ID change for now 2026-03-23 19:33:16 -04:00
XtraCube 1e00181220 Change plugin identifier for Mira API 2026-03-23 12:07:08 -04:00
Amber 77c13bebdc fix goofy 'works on my machine' 2026-03-22 03:30:33 -04:00
Atony fcd7856571 Merge pull request #82 from All-Of-Us-Mods/dev
MiraAPI 0.3.9
2026-03-21 16:25:04 -05:00
Atony 5680d27db1 Merge branch 'master' into dev 2026-03-21 16:22:27 -05:00
amber 00eaa2601c Make Gamemode text bigger 2026-03-11 21:55:40 -04:00
Atony 49d77fcf40 Fix issues with PlayerControl.Die race condition 2026-03-11 15:40:50 -05:00
Atony dcb4a3876f Fix neutral color in view pane 2026-03-11 00:23:32 -05:00
amber ba2deb66f1 Remove from HNS, fix spacing. 2026-03-10 20:24:39 -04:00
amber bb5c212e97 Summary tag for the only public part of the option 2026-03-10 19:57:11 -04:00
amber f59e0af7e8 make patch methods private 2026-03-10 19:54:10 -04:00
amber 8f3a137877 Merge remote-tracking branch 'origin/game-modes' into game-modes 2026-03-10 19:49:56 -04:00
amber 44415019cc Full gamemode option in vanilla Game Options menu. 2026-03-10 19:49:44 -04:00
Atony 7125374cda Merge branch 'runtime-options' into game-modes 2026-03-10 18:47:48 -05:00
Atony cff46ebd19 Merge branch 'dev' into runtime-options 2026-03-10 18:47:28 -05:00
Atony 9270de408d Verify that target isn't already dead or dc'd 2026-03-10 18:04:22 -05:00
Atony 8940de76bb Add one last murder check 2026-03-10 00:18:55 -05:00
Atony 1813fe5a84 Adjust functions 2026-03-09 09:43:00 -05:00
Atony 272b14f0e0 Change murders to check with the host beforehand 2026-03-09 09:35:36 -05:00
amber 8b19271e34 Merge branch 'runtime-options' into game-modes 2026-03-08 17:57:00 -04:00
amber c29e882d7e Fix error from float data in ModdedStringOption.cs 2026-03-08 13:24:24 -04:00
Atony fdfb876b44 Fix plugin loading 2026-03-07 22:36:39 -06:00
Atony 205eee96b2 Merge branch 'dev' into game-modes 2026-03-07 22:21:08 -06:00
amber 8774c9da70 Fix tony's -1 index 2026-03-07 21:48:28 -05:00
Atony 51c7e248f9 Update Directory.Build.props 2026-03-07 15:24:28 -06:00
Atony 02f9c20804 Add wip string option 2026-03-07 15:23:26 -06:00
XtraCube 6cc1d4b762 updated readme 2026-02-27 12:11:41 -05:00
Atony 9dfad78df6 Merge pull request #81 from All-Of-Us-Mods/dev
MiraAPI 0.3.8
2026-02-11 11:50:15 -06:00
Atony 7f506000a4 Check for vanilla kills 2026-02-11 11:40:55 -06:00
Atony 795b6a81d7 Merge branch 'dev' of https://github.com/All-Of-Us-Mods/MiraAPI into dev 2026-02-10 14:00:51 -06:00
Atony bd8d7a3208 Add lobby checks for kills 2026-02-10 14:00:47 -06:00
Atony e8536e5d4b Merge pull request #80 from All-Of-Us-Mods/dev
## What's New
- Individual game options can be reset if they are a part of a preset.
- A new meeting-specific murder rpc is now available for use, checking for kills happening within and outside of a meeting.
- ## What's Changed
- Framerate Slider has been renamed to be more accurate
- Memory usage per frame has been improved
2026-02-08 16:30:05 -06:00
Atony 090db766b2 Bump version from 0.3.6 to 0.3.7 2026-02-08 16:25:37 -06:00
Atony 1f0027108e Automatically change reactor dev build indicator 2026-02-01 13:22:57 -06:00
Atony 665724010d Fix how to play errors without custom roles 2026-01-26 13:02:39 -06:00
wangzeyu b100f92525 Update README_zh.md 2026-01-24 06:34:59 +08:00
wangzeyu 202b098857 Create README_zh.md 2026-01-24 06:33:49 +08:00
wangzeyu fedba71889 Update README.md 2026-01-23 05:22:50 +08:00
Atony 2d58c91289 Replace alt murder rpc 2026-01-21 04:47:27 -06:00
XtraCube b3ed6d67f9 Reduce memory allocations in HudManagerPatches.cs 2026-01-20 16:35:44 -05:00
Atony 64ef78e3a2 Fix wordwrap on local setting 2026-01-20 10:21:37 -06:00
Atony 5e9e4012ef Update CustomMurderRpc.cs 2026-01-19 21:38:45 -06:00
Atony fe04a7033a Change kill button to use alt murder rpc 2026-01-19 21:15:52 -06:00
Atony ba0ee49255 Add reset button for game options 2026-01-19 20:10:21 -06:00
Atony 97528b4380 Add alternative Murder RPC for meeting checks 2026-01-19 19:31:31 -06:00
Atony 50030c113b Merge pull request #78 from All-Of-Us-Mods/dev
## What's New
- Screen shake no longer interferes with scrolling in the host options menu
## What's Changed
- Sabotage flashes no longer break on Starlight
- Using the button scale setting no longer breaks the UI.
- If a role fails to register to a marshalling error (nullables) the game will no longer crash.
2026-01-04 12:41:46 -06:00
Atony 20e51cc993 Bump version 2026-01-04 12:38:43 -06:00
Atony 64b5e01ba1 Improve scrolling in roles menu itself 2026-01-03 19:06:51 -06:00
Atony d4469153ab Improve scrolling in roles menu 2026-01-03 19:00:46 -06:00
Atony ab67c233d8 Add FPS slider (default to 120 fps) 2026-01-03 18:55:12 -06:00
Atony c72eacc7a2 Fix options scroll with screen shake 2026-01-03 18:54:57 -06:00
Atony 13072d6834 Fix dualshock light errors on Starlight 2026-01-02 22:57:58 -06:00
Atony c6342750ef Add checks to prevent errors on Starlight 2026-01-02 15:17:31 -06:00
XtraCube 5c2e95376d add exception handling around role registration 2025-12-31 22:38:01 -05:00
Atony 067859b9fd Fix scale factor not setting properly when changed 2025-12-31 18:36:19 -06:00
Atony fe3bfcdbc4 Merge pull request #77 from All-Of-Us-Mods/dev
- Added Vanilla Button Click Event (and respective Cancel Event)
- Added accessibility settings for sabotage flashes and blares
- Added an in-game slider for resizing ability buttons
2025-12-28 18:00:57 -06:00
Atony 5d01462a32 Adjust local setting groups 2025-12-28 17:55:33 -06:00
Atony a9b6f40ed0 Add Button Scale Slider 2025-12-28 17:51:39 -06:00
Atony eae0024ec3 Add Accessibility settings for sabotages 2025-12-22 21:41:36 -06:00
Atony 2907564d6a Add Vanilla Button Click Event (& Cancel Event) 2025-12-16 22:14:50 -06:00
XtraCube 7890ec9456 WIP update gamemodes 2025-03-04 19:21:57 -05:00
XtraCube 8bb191270f Merge branch 'dev' into game-modes
# Conflicts:
#	MiraAPI.Example/Modifiers/CaptainModifier.cs
#	MiraAPI/GameModes/CustomGameModeManager.cs
#	MiraAPI/GameOptions/AbstractOptionGroup.cs
#	MiraAPI/GameOptions/Attributes/ModdedEnumOptionAttribute.cs
#	MiraAPI/GameOptions/Attributes/ModdedNumberOptionAttribute.cs
#	MiraAPI/GameOptions/Attributes/ModdedToggleOptionAttribute.cs
#	MiraAPI/GameOptions/IModdedOption.cs
#	MiraAPI/GameOptions/ModdedOptionsManager.cs
#	MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs
#	MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs
#	MiraAPI/GameOptions/OptionTypes/ModdedOption.cs
#	MiraAPI/GameOptions/OptionTypes/ModdedToggleOption.cs
#	MiraAPI/Hud/CustomActionButton.cs
#	MiraAPI/MiraApiPlugin.cs
#	MiraAPI/Modifiers/BaseModifier.cs
#	MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
#	MiraAPI/Patches/Options/LobbyViewPanePatches.cs
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
#	MiraAPI/PluginLoading/MiraPluginManager.cs
#	MiraAPI/Roles/ICustomRole.cs
2025-03-04 19:02:38 -05:00
XtraCube 65cd177551 fix more scrolling issues 2025-02-18 11:15:00 -05:00
XtraCube 7801f81052 Merge branch 'dev' into game-modes
# Conflicts:
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
2025-02-18 11:07:04 -05:00
XtraCube 2d59b29c15 cleanup 2025-02-18 10:19:55 -05:00
XtraCube a62c75a13b that was stupid 2025-02-18 10:19:22 -05:00
XtraCube c85cf7ef2f finish merge 2025-02-18 10:15:39 -05:00
XtraCube ead28339b0 Merge branch 'dev' into game-modes
# Conflicts:
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
#	MiraAPI/Roles/CustomRoleConfiguration.cs
#	MiraAPI/Roles/ICustomRole.cs
2025-02-18 10:11:53 -05:00
XtraCube 9177d5b456 fix merge stuff 2025-02-17 10:14:38 -05:00
XtraCube 284a0f58b1 oops 2025-02-17 10:14:26 -05:00
XtraCube 47dfa63423 improve CustomRoleConfiguration.cs 2025-02-17 10:13:32 -05:00
XtraCube 1b261d7287 Merge remote-tracking branch 'origin/dev' into game-modes
# Conflicts:
#	MiraAPI/Hud/CustomActionButton.cs
#	MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
#	MiraAPI/PluginLoading/MiraPluginManager.cs
#	MiraAPI/Roles/ICustomRole.cs
2025-02-17 09:59:42 -05:00
XtraCube fa8ea9dbab final fix to logic 2025-02-03 22:44:35 -05:00
XtraCube 9c15ca4d06 update to optimization 2025-02-03 22:43:25 -05:00
XtraCube a4b1868690 Merge branch 'optimization' into game-modes
# Conflicts:
#	MiraAPI/GameModes/DefaultMode.cs
#	MiraAPI/GameModes/RegisterGameModeAttribute.cs
#	MiraAPI/PluginLoading/MiraPluginManager.cs
2025-02-03 22:03:48 -05:00
AlchlcDvl 409503a261 read me change to reflect now mode filtering 2024-12-23 20:57:53 -05:00
AlchlcDvl edca42247d finish full implementation of game modes i hope 2024-12-23 20:52:18 -05:00
AlchlcDvl b6ba8f59bd better approach 2024-12-07 11:21:07 -05:00
AlchlcDvl f9f7898277 set option title 2024-12-07 11:18:58 -05:00
AlchlcDvl dbacd044eb game mode stuff, missing implementation of 4 methods coming soon™️ 2024-12-07 10:46:26 -05:00
319 changed files with 11972 additions and 3253 deletions

No files matched your search

+3 -3
View File
@@ -1,8 +1,8 @@
<Project>
<ItemGroup>
<PackageReference Include="Reactor" Version="2.3.1" />
<PackageReference Include="Reactor" Version="2.5.0-ci.371" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2025.10.14" PrivateAssets="all" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2026.8.18" PrivateAssets="all" />
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
@@ -11,4 +11,4 @@
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
</Target>
</Project>
</Project>
+2 -2
View File
@@ -8,7 +8,7 @@
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<VersionPrefix>0.3.4</VersionPrefix>
<VersionPrefix>0.5.0</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
<Authors>All Of Us, XtraCube, Angxl</Authors>
@@ -42,4 +42,4 @@
<PropertyGroup>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project>
</Project>
@@ -13,7 +13,7 @@ namespace MiraAPI.Example.Buttons.Freezer;
public class FreezeButton : CustomActionButton<PlayerControl>
{
public override string Name => "Freeze";
public override string Name => "button.freeze";
public override float Cooldown => OptionGroupSingleton<FreezerRoleSettings>.Instance.FreezeDuration;
public override bool PauseTimerInVent => true;
+1 -1
View File
@@ -9,7 +9,7 @@ namespace MiraAPI.Example.Buttons;
public class MeetingButton : CustomActionButton
{
public override string Name => "Call Meeting";
public override string Name => "button.callMeeting";
public override float Cooldown => 15;
@@ -10,7 +10,7 @@ namespace MiraAPI.Example.Buttons;
public class NeutralKillerButton : CustomActionButton
{
public override string Name => "Win Game";
public override string Name => "button.winGame";
public override float Cooldown => 0f;
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
public override MiraKeybind Keybind => ExampleKeybinds.NeutralWinKeybind;
@@ -12,7 +12,7 @@ namespace MiraAPI.Example.Buttons.Teleporter;
public class TeleportButton : CustomActionButton
{
public override string Name => "Teleport";
public override string Name => "button.teleport";
public override float Cooldown => OptionGroupSingleton<TeleporterOptions>.Instance.TeleportCooldown.Value;
+4 -4
View File
@@ -1,4 +1,5 @@
using MiraAPI.Hud;
using MiraAPI.Translation;
using MiraAPI.Utilities.Assets;
using UnityEngine;
@@ -6,7 +7,7 @@ namespace MiraAPI.Example.Buttons;
public class ThinkButton : CustomActionButton
{
public override string Name => "Think";
public override string Name => "button.think";
public override float Cooldown => 15f;
public override float EffectDuration => 10f;
public override int MaxUses => 1;
@@ -14,13 +15,12 @@ public class ThinkButton : CustomActionButton
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
protected override void OnClick()
{
// This button does absolutely nothing besides changing its text
Button!.OverrideText("Thinking...");
Button!.OverrideText("button.think.thinking".Translate());
}
public override void OnEffectEnd()
{
Button!.OverrideText("Think");
Button!.OverrideText("button.think".Translate());
}
public override bool IsEffectCancellable()
+1
View File
@@ -9,5 +9,6 @@ public static class ExampleAssets
// Credit to EpicHorrors for the teleport button asset.
public static LoadableResourceAsset TeleportButton { get; } = new("MiraAPI.Example.Resources.TeleportButton.png");
public static LoadableResourceAsset SharpshootButton { get; } = new("MiraAPI.Example.Resources.SharpshootButton.png");
public static LoadableResourceAsset Banner { get; } = new("MiraAPI.Example.Resources.FortniteBanner.jpeg");
}
+3 -3
View File
@@ -6,12 +6,12 @@ namespace MiraAPI.Example;
[RegisterCustomColors]
public static class ExampleColors
{
public static CustomColor Cerulean { get; } = new("Cerulean", new Color(0.0f, 0.48f, 0.65f))
public static CustomColor Cerulean { get; } = new("color.cerulean", new Color(0.0f, 0.48f, 0.65f))
{
ColorBrightness = CustomColorBrightness.Lighter,
};
public static CustomColor Rose { get; } = new("Rose", new Color(0.98f, 0.26f, 0.62f));
public static CustomColor Rose { get; } = new("color.rose", new Color(0.98f, 0.26f, 0.62f));
public static CustomColor Gold { get; } = new("Gold", new Color(1.0f, 0.84f, 0.0f));
public static CustomColor Gold { get; } = new("color.gold", new Color(1.0f, 0.84f, 0.0f));
}
+18 -2
View File
@@ -1,4 +1,5 @@
using System.Linq;
using System.Globalization;
using System.Linq;
using MiraAPI.Events;
using MiraAPI.Events.Mira;
using MiraAPI.Events.Vanilla.Gameplay;
@@ -17,7 +18,7 @@ public static class ExampleEventHandlers
{
public static void Initialize()
{
// You can register event handlers with the MiraEventManager class.
// You can register event handlers with the MiraEventManager class
var handle = MiraEventManager.RegisterEventHandler<BeforeMurderEvent>(@event =>
{
Logger<ExamplePlugin>.Info($"{@event.Source.Data.PlayerName} is about to kill {@event.Target.Data.PlayerName}");
@@ -37,6 +38,21 @@ public static class ExampleEventHandlers
MiraEventManager.UnregisterEventHandler(handle);
}
// If you want to check vanilla buttons, use something like this!
[RegisterEvent]
public static void VanillaButtonClickHandler(VanillaButtonClickEvent @event)
{
Logger<ExamplePlugin>.Info($"{@event.Button.buttonLabelText.text} is being used!");
if (@event.PlayerTarget != null)
{
Logger<ExamplePlugin>.Info($"{@event.PlayerTarget.Data.PlayerName} is being targeted!");
}
else if (@event.VentTarget != null)
{
Logger<ExamplePlugin>.Info($"Vent with id {@event.VentTarget.Id.ToString(CultureInfo.InvariantCulture)} is being targeted!");
}
}
// If you want to add extra votes to a player, do something like this.
[RegisterEvent]
public static void StartMeetingEvent(StartMeetingEvent _)
+2 -2
View File
@@ -8,7 +8,7 @@ namespace MiraAPI.Example;
public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
{
public override string TabName => "Mira Example";
public override string TabName => "settings.miraExample";
protected override bool ShouldCreateLabels => false;
public override LocalSettingTabAppearance TabAppearance => new()
@@ -18,7 +18,7 @@ public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
};
[LocalSettingsButton]
public LocalSettingsButton ExampleButton { get; private set; } = new("Example Button", OnExampleButtonClick);
public LocalSettingsButton ExampleButton { get; private set; } = new("settings.miraExample.button.exampleButton", OnExampleButtonClick);
[LocalToggleSetting]
public ConfigEntry<bool> ExampleToggle { get; private set; } = config.Bind("General", "Example Bool", true);
+7 -2
View File
@@ -1,9 +1,9 @@
using System.Linq;
using BepInEx;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using MiraAPI.PluginLoading;
using MiraAPI.Translation;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Attributes;
@@ -17,8 +17,13 @@ namespace MiraAPI.Example;
[ReactorModFlags(ModFlags.RequireOnAllClients)]
public partial class ExamplePlugin : BasePlugin, IMiraPlugin
{
public ExamplePlugin()
{
MiraLocaleManager.Register("mira.example");
}
public Harmony Harmony { get; } = new(Id);
public string OptionsTitleText => "Mira API\nExample Mod";
public string CustomOptionMenuNameTwo => "angxl's Options";
public ConfigFile GetConfigFile() => Config;
public override void Load()
{
+13
View File
@@ -0,0 +1,13 @@
using MiraAPI.GameModes;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.Example.GameModes;
public class ExampleMode : AbstractGameMode
{
public override string Name => "Example Mode";
public override string Description => "An example gamemode.";
public override LoadableAsset<Sprite>? Icon => ExampleAssets.ExampleButton;
public override Color Color => Color.red;
}
@@ -1,5 +1,6 @@
using MiraAPI.Example.Roles;
using MiraAPI.GameEnd;
using MiraAPI.Translation;
using MiraAPI.Utilities;
using UnityEngine;
@@ -14,7 +15,7 @@ public class NeutralKillerGameOver : CustomGameOver
public override void AfterEndGameSetup(EndGameManager endGameManager)
{
endGameManager.WinText.text = "Outcast Killer Wins!";
endGameManager.WinText.text = "gameover.outcastKiller.win".Translate();
endGameManager.WinText.color = Color.magenta;
endGameManager.BackgroundBar.material.SetColor(ShaderID.Color, Color.magenta);
}
@@ -0,0 +1,29 @@
using MiraAPI.Example.Roles;
using MiraAPI.MeetingAbilities;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.Example.MeetingAbilities;
public class EndMeetingButton : MeetingActionButton
{
public override string Name => "End Meeting";
public override float Cooldown => 15;
public override float InitialCooldown => 30;
public override int MaxUses => 3;
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
public override bool Enabled(RoleBehaviour? role)
{
return PlayerControl.LocalPlayer != null && role is MayorRole;
}
protected override void OnClick()
{
MeetingHud.Instance.RpcClose();
}
}
@@ -0,0 +1,37 @@
using MiraAPI.MeetingAbilities;
using MiraAPI.Networking;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.Example.MeetingAbilities;
public class ShootButton : TargetedMeetingButton
{
public override string Name => "Shoot";
public override int MaxUses => 3;
public override float InitialCooldown => 5;
public override float Cooldown => 3;
public override LoadableAsset<Sprite> Sprite => ExampleAssets.SharpshootButton;
public override Color OutlineColor => Color.red;
public override bool Enabled(RoleBehaviour r)
{
return r.IsImpostor;
}
protected override void OnClick(PlayerVoteArea playerVoteArea)
{
playerVoteArea.SetDisabled();
var player = playerVoteArea.GetPlayer();
if (player != null)
{
PlayerControl.LocalPlayer.RpcCustomMurder(player);
}
}
}
@@ -0,0 +1,54 @@
using MiraAPI.MeetingAbilities;
using MiraAPI.Networking;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.Example.MeetingAbilities;
public class ShotgunButton : MultiTargetMeetingButton
{
public override string Name => "Shotgun";
public override int MaxUses => 3;
public override float InitialCooldown => 5;
public override float Cooldown => 3;
public override LoadableAsset<Sprite> Sprite => ExampleAssets.SharpshootButton;
public override Color OutlineColor => Color.red;
public override bool Enabled(RoleBehaviour r)
{
return r.IsImpostor;
}
protected override void OnClick(PlayerVoteArea playerVoteArea)
{
// Emptu because it only triggers the actual kills once all meeting abilities have been used.
}
public override LoadableAsset<Sprite> SpriteActive => ExampleAssets.CallMeetingButton;
public override int TargetsCount => 4;
protected override void OnSelect(PlayerVoteArea playerVoteArea, bool toggle)
{
HudManager.Instance.PlayerCam.ShakeScreen(0.5f, 2);
}
public override void OnFinish()
{
foreach (var playerVoteArea in Targets.Keys)
{
playerVoteArea.SetDisabled();
var player = playerVoteArea.GetPlayer();
if (player != null)
{
PlayerControl.LocalPlayer.RpcCustomMurder(player);
}
}
}
}
+1
View File
@@ -3,6 +3,7 @@
<Version>1.0.0</Version>
<Description>Example mod for Mira API</Description>
<Authors>Angxl, XtraCube</Authors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
+3 -2
View File
@@ -2,6 +2,7 @@
using MiraAPI.GameOptions;
using MiraAPI.Modifiers;
using MiraAPI.Modifiers.Types;
using MiraAPI.Translation;
using MiraAPI.Utilities.Assets;
using UnityEngine;
@@ -9,7 +10,7 @@ namespace MiraAPI.Example.Modifiers;
public class CaptainModifier : GameModifier
{
public override string ModifierName => "Captain";
public override string ModifierName => MiraLocaleManager.Get("modifier.captain");
public override LoadableAsset<Sprite>? ModifierIcon => ExampleAssets.CallMeetingButton;
public override void OnDeath(DeathReason reason)
@@ -19,7 +20,7 @@ public class CaptainModifier : GameModifier
public override string GetDescription()
{
return $"You can call a meeting from anywhere on the map.";
return MiraLocaleManager.Get("modifier.captain.TabDescription");
}
public override int GetAssignmentChance()
@@ -1,13 +1,14 @@
using Il2CppSystem;
using MiraAPI.Example.Roles;
using MiraAPI.Modifiers.Types;
using MiraAPI.Translation;
using UnityEngine;
namespace MiraAPI.Example.Modifiers.Freezer;
public class FreezeModifier : TimedModifier
{
public override string ModifierName => "Freezed";
public override string ModifierName => MiraLocaleManager.Get("modifier.freezed");
public override bool HideOnUi => false;
public override float Duration => 15f;
public override bool AutoStart => true;
@@ -1,14 +1,15 @@
using MiraAPI.Modifiers.Types;
using MiraAPI.Translation;
namespace MiraAPI.Example.Modifiers;
public class HighPriorityModifier : GameModifier
{
public override string ModifierName => "High Priority";
public override string ModifierName => MiraLocaleManager.Get("modifier.highPriority");
public override string GetDescription()
{
return "You are high priority! Idrk what this means either tbh...";
return MiraLocaleManager.Get("modifier.highPriority.TabDescription");
}
public override int GetAssignmentChance()
+5 -5
View File
@@ -7,19 +7,19 @@ namespace MiraAPI.Example.Options;
public class ExampleOptions : AbstractOptionGroup
{
public override string GroupName => "Example Options 1";
public override string GroupName => "options.exampleOptions1";
public override Color GroupColor => Color.green;
[ModdedToggleOption("Toggle Opt 1")]
[ModdedToggleOption("options.exampleOptions1.toggleOpt1")]
public bool ToggleOpt { get; set; } = false;
[ModdedToggleOption("Toggle Opt 2")]
[ModdedToggleOption("options.exampleOptions1.toggleOpt1")]
public bool ToggleOpt2 { get; set; } = true;
[ModdedNumberOption("Number Opt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
[ModdedNumberOption("options.exampleOptions1.numberOpt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
public float NumberOpt { get; set; } = 4f;
[ModdedEnumOption("Best API", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
[ModdedEnumOption("options.exampleOptions1.bestApi", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
public BestApi Opt { get; set; } = BestApi.MiraAPI;
}
+8 -6
View File
@@ -6,20 +6,22 @@ namespace MiraAPI.Example.Options;
public class ExampleOptions2 : AbstractOptionGroup
{
public override string GroupName => "Example Options 2";
public override string GroupName => "options.exampleOptions2";
public override uint GroupPriority => 0; // This group will be displayed first. The default value is uint.MaxValue.
public ModdedPlayerOption PlayerOption2 { get; } = new("YOU MUST CHOSE A PLAYER", false);
public ModdedPlayerOption PlayerOption { get; } = new("Eh whatever");
public ModdedToggleOption ToggleOpt1 { get; } = new("Toggle Option 1", false);
public override MenuCategory ParentMenu => MenuCategory.CustomTwo;
public ModdedToggleOption ToggleOpt2 { get; } = new("Toggle Option 2", false)
public ModdedPlayerOption PlayerOption2 { get; } = new("options.exampleOptions2.youMustChoseAPlayer", false);
public ModdedPlayerOption PlayerOption { get; } = new("options.exampleOptions2.ehWhatever");
public ModdedToggleOption ToggleOpt1 { get; } = new("options.exampleOptions2.toggleOption1", false);
public ModdedToggleOption ToggleOpt2 { get; } = new("options.exampleOptions2.toggleOption2", false)
{
Visible = () => OptionGroupSingleton<ExampleOptions2>.Instance.ToggleOpt1, // implicit cast from ModdedToggleOption to bool
};
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("Enum Opt", 0)
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("options.exampleOptions2.enumOpt", 0)
{
ChangedEvent = x => Logger<ExamplePlugin>.Info($"changed Enum Opt to {x}"),
};
@@ -6,14 +6,14 @@ namespace MiraAPI.Example.Options.Modifiers;
public class CaptainModifierSettings : AbstractOptionGroup<CaptainModifier>
{
public override string GroupName => "Captain Settings";
public override string GroupName => "options.captainSettings";
[ModdedNumberOption("Amount", 0, 5)]
[ModdedNumberOption("options.captainSettings.amount", 0, 5)]
public float Amount { get; set; } = 1;
[ModdedNumberOption("Chance", 0, 100, 10)]
[ModdedNumberOption("options.captainSettings.chance", 0, 100, 10)]
public float Chance { get; set; } = 50;
[ModdedNumberOption("Uses", 1, 5)]
[ModdedNumberOption("options.captainSettings.uses", 1, 5)]
public float NumUses { get; set; } = 3;
}
@@ -6,8 +6,8 @@ namespace MiraAPI.Example.Options.Modifiers;
public class FreezeModifierSettings : AbstractOptionGroup<FreezeModifier>
{
public override string GroupName => "Freeze";
public override string GroupName => "options.freezeModifierSettings";
[ModdedToggleOption("Use Color")]
[ModdedToggleOption("options.freezeModifierSettings.useColor")]
public bool UseColor { get; set; } = true;
}
@@ -5,15 +5,15 @@ namespace MiraAPI.Example.Options.Modifiers;
public class GeneralModifierOptions : AbstractOptionGroup
{
public override string GroupName => "General";
public override string GroupName => "options.generalModifier";
public override uint GroupPriority => 0;
public override bool ShowInModifiersMenu => true;
public override MenuCategory ParentMenu => MenuCategory.Modifiers;
[ModdedToggleOption("Some Boolean Option")]
[ModdedToggleOption("options.generalModifier.someBooleanOption")]
public bool SomeBooleanOption { get; set; } = true;
[ModdedNumberOption("Number Option", 0, 10, 1)]
[ModdedNumberOption("options.generalModifier.numberOption", 0, 10, 1)]
public float NumberOption { get; set; } = 5;
}
@@ -2,16 +2,22 @@
using MiraAPI.GameOptions;
using MiraAPI.GameOptions.Attributes;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
namespace MiraAPI.Example.Options.Roles;
public class FreezerRoleSettings : AbstractOptionGroup<FreezerRole>
{
public override string GroupName => "Custom Role";
public override OptionNotifConfiguration Configuration => new(
Palette.Blue,
TmpSpriteUtils.CreateSpriteAsset(
MiraAssets.ImpostorFile.LoadAsset(),
"ApiExample.Role.Impostor.FreezerRole"));
public override string GroupName => "ApiExample.Role.Freezer";
[ModdedNumberOption("Freeze Duration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
[ModdedNumberOption("ApiExample.Role.Freezer.Settings.FreezeDuration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
public float FreezeDuration { get; set; } = 5;
[ModdedNumberOption("Freeze Uses", 1, 5)]
[ModdedNumberOption("ApiExample.Role.Freezer.Settings.FreezeUses", 1, 5)]
public float FreezeUses { get; set; } = 1;
}
@@ -6,15 +6,15 @@ using MiraAPI.Utilities;
namespace MiraAPI.Example.Options.Roles;
public class TeleporterOptions : AbstractOptionGroup<TeleporterRole>
public class TeleporterOptions : AbstractRoleOptionGroup<TeleporterRole>
{
public override string GroupName => "Teleporter";
public override string GroupName => "ApiExample.Role.Teleporter";
public ModdedNumberOption TeleportCooldown { get; set; } = new("Teleport Cooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
public ModdedNumberOption TeleportCooldown { get; set; } = new("ApiExample.Role.Teleporter.Settings.TeleportCooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
[ModdedNumberOption("Teleport Duration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
[ModdedNumberOption("ApiExample.Role.Teleporter.Settings.TeleportDuration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
public float TeleportDuration { get; set; } = 10;
[ModdedNumberOption("Zoom Distance", 4, 15)]
[ModdedNumberOption("ApiExample.Role.Teleporter.Settings.ZoomDistance", 4, 15)]
public float ZoomDistance { get; set; } = 6;
}
@@ -0,0 +1,83 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="ApiExample.Role.Crewmate.Teleporter">Teleporter</string>
<string name="ApiExample.Role.Crewmate.Teleporter.IntroBlurb">Zoom out and teleport across the map!</string>
<string name="ApiExample.Role.Crewmate.Teleporter.MedDescription">Zoom out and teleport across the map!</string>
<string name="ApiExample.Role.Crewmate.Teleporter.TabDescription">Zoom out and teleport across the map!</string>
<string name="ApiExample.Role.Crewmate.Teleporter.WikiDescription">The Teleporter is a Crewmate role that can move around the map using their dope-ass ability.</string>
<string name="ApiExample.Role.Impostor.Freezer">Freezer</string>
<string name="ApiExample.Role.Impostor.Freezer.IntroBlurb">Get iced, nerd.</string>
<string name="ApiExample.Role.Impostor.Freezer.MedDescription">Freeze others for a duration of time.</string>
<string name="ApiExample.Role.Impostor.Freezer.TabDescription">Freeze another player for a duration of time.</string>
<string name="ApiExample.Role.Impostor.Freezer.WikiDescription">The Freezer is an Impostor role that can freeze players. Or something along those lines.</string>
<string name="ApiExample.Role.Crewmate.Mayor">Mayor</string>
<string name="ApiExample.Role.Crewmate.Mayor.IntroBlurb">Democracy is the best policy.</string>
<string name="ApiExample.Role.Crewmate.Mayor.MedDescription">Vote out the Impostors with more votes.
Your votes have double the power.</string>
<string name="ApiExample.Role.Crewmate.Mayor.TabDescription">You get one extra vote in the meeting!</string>
<string name="ApiExample.Role.Crewmate.Mayor.WikiDescription">The Mayor is a Crewmate role that gets two votes in the meeting, instead of the singular vote other Crewmates get.</string>
<string name="ApiExample.Role.Crewmate.Chamelon">Chamelon</string>
<string name="ApiExample.Role.Crewmate.Chamelon.IntroBlurb">Become one with the environment.</string>
<string name="ApiExample.Role.Crewmate.Chamelon.MedDescription">Fade out of everyone's vision by not moving.</string>
<string name="ApiExample.Role.Crewmate.Chamelon.TabDescription">Stay invisible while not moving.</string>
<string name="ApiExample.Role.Crewmate.Chamelon.WikiDescription">The Chamelon is a Crewmate role that slowly becomes invisible while standing still.</string>
<string name="ApiExample.Role.Outcast.OutcastKiller">Outcast Killer</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.IntroBlurb">Kill everyone else.</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.MedDescription">Be the last outcast standing.
Eliminate every other faction.</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.TabDescription">Outcast who can kill.</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.WikiDescription">The Outcast Killer is an Outcast role that can kill, like some sort of neutral killer...</string>
<string name="outcast">Outcast</string>
<string name="outcast.group">Outcast Roles</string>
<string name="outcast.roleTitle">OUTCAST</string>
<string name="outcast.teamIntroDescription">You are an Outcast. You do not have a team.</string>
<string name="button.think">Think</string>
<string name="button.think.thinking">Thinking...</string>
<string name="button.freeze">Freeze</string>
<string name="button.teleport">Teleport</string>
<string name="button.callMeeting">Call Meeting</string>
<string name="button.winGame">Win Game</string>
<string name="modifier.captain">Captain</string>
<string name="modifier.captain.TabDescription">You can call a meeting from anywhere on the map.</string>
<string name="modifier.freezed">Freezed</string>
<string name="modifier.highPriority">High Priority</string>
<string name="modifier.highPriority.TabDescription">You are high priority! Idrk what this means either tbh...</string>
<string name="options.exampleOptions1">Example Options 1</string>
<string name="options.exampleOptions1.toggleOpt1">Toggle Opt 1</string>
<string name="options.exampleOptions1.toggleOpt2">Toggle Opt 2</string>
<string name="options.exampleOptions1.numberOpt">Number Opt</string>
<string name="options.exampleOptions1.bestApi">Best API</string>
<string name="options.exampleOptions2">Example Options 2</string>
<string name="options.exampleOptions2.youMustChoseAPlayer">YOU MUST CHOSE A PLAYER</string>
<string name="options.exampleOptions2.ehWhatever">Eh whatever</string>
<string name="options.exampleOptions2.toggleOption1">Toggle Option 1</string>
<string name="options.exampleOptions2.toggleOption2">Toggle Option 2</string>
<string name="options.exampleOptions2.enumOpt">Enum Opt</string>
<string name="options.captainSettings">Captain Settings</string>
<string name="options.captainSettings.amount">Amount</string>
<string name="options.captainSettings.chance">Chance</string>
<string name="options.captainSettings.uses">Uses</string>
<string name="options.freezeModifierSettings">Freeze</string>
<string name="options.freezeModifierSettings.useColor">Use Color</string>
<string name="options.generalModifier">General</string>
<string name="options.generalModifier.someBooleanOption">Some Boolean Option</string>
<string name="options.generalModifier.numberOption">Number Option</string>
<string name="options.freezerRoleSettings">Custom Role</string>
<string name="ApiExample.Role.Freezer.Settings.FreezeDuration">Freeze Duration</string>
<string name="ApiExample.Role.Freezer.Settings.FreezeUses">Freeze Uses</string>
<string name="ApiExample.Role.Teleporter.Settings.TeleportCooldown">Teleport Cooldown</string>
<string name="ApiExample.Role.Teleporter.Settings.TeleportDuration">Teleport Duration</string>
<string name="ApiExample.Role.Teleporter.Settings.ZoomDistance">Zoom Distance</string>
<string name="settings.miraExample">Mira Example</string>
<string name="settings.miraExample.exampleBool">Example Bool</string>
<string name="settings.miraExample.exampleBool2">Example Bool 2</string>
<string name="settings.miraExample.slider">Slider</string>
<string name="settings.miraExample.exampleNumber">Example Number</string>
<string name="settings.miraExample.exampleMultiplier">Example Multplier</string>
<string name="settings.miraExample.exampleEnum">Example Enum</string>
<string name="settings.miraExample.button.exampleButton">Example Button</string>
<string name="gameover.outcastKiller.win">Outcast Killer Wins!</string>
<string name="color.cerulean">Cerulean</string>
<string name="color.rose">Rose</string>
<string name="color.gold">Gold</string>
</resources>
@@ -0,0 +1,66 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="ApiExample.Role.Teleporter">传送者</string>
<string name="ApiExample.Role.Teleporter.IntroBlurb">缩小视野并在地图上传送!</string>
<string name="ApiExample.Role.Teleporter.MedDescription">缩小视野并在地图上传送!</string>
<string name="ApiExample.Role.Teleporter.TabDescription">缩小视野并在地图上传送!</string>
<string name="ApiExample.Role.Freezer">冰冻者</string>
<string name="ApiExample.Role.Freezer.TabDescription">将其他玩家冰冻一段时间。</string>
<string name="ApiExample.Role.Crewmate.Mayor">市长</string>
<string name="ApiExample.Role.Crewmate.Mayor.TabDescription">你拥有额外投票权!</string>
<string name="ApiExample.Role.Crewmate.Chamelon">变色龙</string>
<string name="ApiExample.Role.Crewmate.Chamelon.TabDescription">静止不动时保持隐身。</string>
<string name="ApiExample.Role.Outcast.OutcastKiller">流放杀手</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.TabDescription">可以击杀的流放者。</string>
<string name="outcast">流放者</string>
<string name="outcast.roleTitle">流放者</string>
<string name="outcast.teamIntroDescription">你是流放者,你没有队伍。</string>
<string name="button.think">思考</string>
<string name="button.think.thinking">思考中...</string>
<string name="button.freeze">冰冻</string>
<string name="button.teleport">传送</string>
<string name="button.callMeeting">召集会议</string>
<string name="button.winGame">赢得游戏</string>
<string name="modifier.captain">队长</string>
<string name="modifier.captain.TabDescription">你可以在地图上任意位置召集会议。</string>
<string name="modifier.freezed">已被冰冻</string>
<string name="modifier.highPriority">高优先级</string>
<string name="modifier.highPriority.TabDescription">你是高优先级!老实说我也不太清楚这是什么意思……</string>
<string name="options.exampleOptions1">示例选项组 1</string>
<string name="options.exampleOptions1.toggleOpt1">开关选项 1</string>
<string name="options.exampleOptions1.toggleOpt2">开关选项 2</string>
<string name="options.exampleOptions1.numberOpt">数字选项</string>
<string name="options.exampleOptions1.bestApi">谁是最好的API</string>
<string name="options.exampleOptions2">示例选项组 2</string>
<string name="options.exampleOptions2.youMustChoseAPlayer">你必须选择一个玩家</string>
<string name="options.exampleOptions2.ehWhatever">咕咕嘎嘎</string>
<string name="options.exampleOptions2.toggleOption1">开关选项 1</string>
<string name="options.exampleOptions2.toggleOption2">开关选项 2</string>
<string name="options.exampleOptions2.enumOpt">枚举选项</string>
<string name="options.captainSettings">队长设置</string>
<string name="options.captainSettings.amount">数量</string>
<string name="options.captainSettings.chance">概率</string>
<string name="options.captainSettings.uses">使用次数</string>
<string name="options.freezeModifierSettings">冰冻</string>
<string name="options.freezeModifierSettings.useColor">使用颜色</string>
<string name="options.generalModifier">通用</string>
<string name="options.generalModifier.someBooleanOption">某个布尔选项</string>
<string name="options.generalModifier.numberOption">数字选项</string>
<string name="ApiExample.Role.Freezer.Settings.FreezeDuration">冰冻时长</string>
<string name="ApiExample.Role.Freezer.Settings.FreezeUses">冰冻次数</string>
<string name="ApiExample.Role.Teleporter.Settings.TeleportCooldown">传送冷却</string>
<string name="ApiExample.Role.Teleporter.Settings.TeleportDuration">传送持续时间</string>
<string name="ApiExample.Role.Teleporter.Settings.ZoomDistance">缩放距离</string>
<string name="settings.miraExample">Mira 示例插件</string>
<string name="settings.miraExample.exampleBool">示例布尔</string>
<string name="settings.miraExample.exampleBool2">示例布尔 2</string>
<string name="settings.miraExample.slider">滑块</string>
<string name="settings.miraExample.exampleNumber">示例数字</string>
<string name="settings.miraExample.exampleMultiplier">示例倍数</string>
<string name="settings.miraExample.exampleEnum">示例枚举</string>
<string name="settings.miraExample.button.exampleButton">示例按钮</string>
<string name="gameover.outcastKiller.win">流放杀手获胜!</string>
<string name="color.cerulean">天蓝</string>
<string name="color.rose">玫瑰红</string>
<string name="color.gold">金色</string>
</resources>
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

+16 -5
View File
@@ -1,6 +1,7 @@
using AmongUs.GameOptions;
using MiraAPI.Patches.Stubs;
using MiraAPI.Roles;
using MiraAPI.Utilities.Assets;
using Reactor.Utilities;
using TMPro;
using UnityEngine;
@@ -9,9 +10,8 @@ namespace MiraAPI.Example.Roles;
public class ChameloenRole : CrewmateRole, ICustomRole
{
public string RoleName => "Chamelon";
public string RoleLongDescription => "Stay invisible while not moving.";
public string RoleDescription => RoleLongDescription;
public string IdPart => "Chamelon";
public string IdPrefix => "ApiExample.Role.Crewmate";
public Color RoleColor => Palette.AcceptedGreen;
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
@@ -20,6 +20,10 @@ public class ChameloenRole : CrewmateRole, ICustomRole
public CustomRoleConfiguration Configuration => new(this)
{
OptionsScreenshot = ExampleAssets.Banner,
Icon = MiraAssets.CrewmateFile,
IconTmp = TmpSpriteUtils.CreateSpriteAsset(
MiraAssets.CrewmateFile.LoadAsset(),
"ApiExample.Role.Impostor.ChameleonRole"),
IntroSound = CustomRoleUtils.GetIntroSound(RoleTypes.Shapeshifter),
};
@@ -53,12 +57,18 @@ public class ChameloenRole : CrewmateRole, ICustomRole
{
SpriteRenderer rend = Player.cosmetics.currentBodySprite.BodySprite;
TextMeshPro tmp = Player.cosmetics.nameText;
tmp.color = Color.Lerp(tmp.color, new Color(tmp.color.r, tmp.color.g, tmp.color.b, Player.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
tmp.color = Color.Lerp(
tmp.color,
new Color(tmp.color.r, tmp.color.g, tmp.color.b, Player.AmOwner ? 0.3f : 0),
Time.deltaTime * 4f);
rend.color = Color.Lerp(rend.color, new Color(1, 1, 1, Player.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
foreach (var cosmetic in Player.cosmetics.transform.GetComponentsInChildren<SpriteRenderer>())
{
cosmetic.color = Color.Lerp(cosmetic.color, new Color(1, 1, 1, Player.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
cosmetic.color = Color.Lerp(
cosmetic.color,
new Color(1, 1, 1, Player.AmOwner ? 0.3f : 0),
Time.deltaTime * 4f);
}
}
}
@@ -72,6 +82,7 @@ public class ChameloenRole : CrewmateRole, ICustomRole
{
cosmetic.color = Color.white;
}
Player.cosmetics.currentBodySprite.BodySprite.color = Color.white;
Player.cosmetics.nameText.color = Color.white;
}
+5 -3
View File
@@ -1,18 +1,20 @@
using MiraAPI.Roles;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.Example.Roles;
public class FreezerRole : ImpostorRole, ICustomRole
{
public string RoleName => "Freezer";
public string RoleLongDescription => "Freeze another player for a duration of time.";
public string RoleDescription => RoleLongDescription;
public string IdPart => "Freezer";
public string IdPrefix => "ApiExample.Role.Impostor";
public Color RoleColor => Palette.Blue;
public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this)
{
Icon = MiraAssets.ImpostorFile,
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.ImpostorFile.LoadAsset(), "ApiExample.Role.Impostor.Freezer"),
OptionsScreenshot = ExampleAssets.Banner,
MaxRoleCount = 2,
};
+2 -3
View File
@@ -5,9 +5,8 @@ namespace MiraAPI.Example.Roles;
public class MayorRole : CrewmateRole, ICustomRole
{
public string RoleName => "Mayor";
public string RoleLongDescription => "You get extra votes!";
public string RoleDescription => RoleLongDescription;
public string IdPart => "Mayor";
public string IdPrefix => "ApiExample.Role.Crewmate";
public Color RoleColor => new Color32(221, 176, 152, 255);
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
public CustomRoleConfiguration Configuration => new(this);
+5 -6
View File
@@ -8,9 +8,8 @@ namespace MiraAPI.Example.Roles;
public class NeutralKillerRole : ImpostorRole, ICustomRole
{
public string RoleName => "Outcast Killer";
public string RoleDescription => "Outcast who can kill.";
public string RoleLongDescription => RoleDescription;
public string IdPart => "OutcastKiller";
public string IdPrefix => "ApiExample.Role.Outcast";
public Color RoleColor => Color.magenta;
public ModdedRoleTeams Team => ModdedRoleTeams.Custom;
@@ -21,13 +20,13 @@ public class NeutralKillerRole : ImpostorRole, ICustomRole
CanUseVent = true,
};
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
public RoleOptionsGroup RoleOptionsGroup { get; } = new("outcast.group", Color.gray);
[HideFromIl2Cpp]
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
Color.gray,
"OUTCAST",
"You are an Outcast. You do not have a team.");
"outcast.roleTitle",
"outcast.teamIntroDescription");
public override void SpawnTaskHeader(PlayerControl playerControl)
{
+2 -3
View File
@@ -5,9 +5,8 @@ namespace MiraAPI.Example.Roles;
public class TeleporterRole : CrewmateRole, ICustomRole
{
public string RoleName => "Teleporter";
public string RoleLongDescription => "Zoom out and teleport across the map!";
public string RoleDescription => RoleLongDescription;
public string IdPart => "Teleporter";
public string IdPrefix => "ApiExample.Role.Crewmate";
public Color RoleColor => new Color32(221, 176, 152, 255);
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
+3 -3
View File
@@ -1,5 +1,5 @@
using MiraAPI.Utilities;
using Reactor.Localization.Utilities;
using MiraAPI.Translation;
using MiraAPI.Utilities;
using UnityEngine;
namespace MiraAPI.Colors;
@@ -43,7 +43,7 @@ public sealed class CustomColor(StringNames name, Color32 mainColor, Color32 sha
}
/// <inheritdoc />
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(CustomStringName.CreateAndRegister(name), mainColor, shadowColor)
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(MiraLocaleManager.GetOrCreateLocaleString(name), mainColor, shadowColor)
{
}
}
+4 -3
View File
@@ -5,12 +5,12 @@ using HarmonyLib;
namespace MiraAPI.Colors;
/// <summary>
/// Used to register and track custom colors.
/// Used to register and track <see cref="CustomColor"/>s.
/// </summary>
public static class PaletteManager
{
/// <summary>
/// Gets all registered custom colors.
/// Gets all registered <see cref="CustomColor"/>s.
/// </summary>
public static CustomColor[] RegisteredColors => [.. CustomColors];
@@ -20,7 +20,8 @@ public static class PaletteManager
{
var colors = CustomColors.Select(x => x.MainColor).ToArray();
var shadowColors = CustomColors.Select(x => x.ShadowColor).ToArray();
var stringNames = CustomColors.Select(x => x.Name).ToArray();
var stringNames = CustomColors.Select(x =>
x.Name).ToArray();
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors);
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors);
@@ -3,7 +3,7 @@
namespace MiraAPI.Colors;
/// <summary>
/// Used to mark a class for custom colors registration.
/// Used to mark a class for <see cref="CustomColor"/> registration.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomColorsAttribute : Attribute;
@@ -3,20 +3,20 @@
namespace MiraAPI.Events.Mira;
/// <summary>
/// Invoked when a Mira Button click is cancelled. Do not use for vanilla buttons.
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <typeparam name="T">The Mira Button type.</typeparam>
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActionButton
{
/// <summary>
/// Gets Mira Button whose click was cancelled.
/// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
/// </summary>
public T Button { get; }
/// <summary>
/// Initializes a new instance of the <see cref="MiraButtonCancelledEvent{T}"/> class.
/// </summary>
/// <param name="button">The Mira Button whose click was cancelled.</param>
/// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
public MiraButtonCancelledEvent(T button)
{
Button = button;
@@ -24,19 +24,19 @@ public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActi
}
/// <summary>
/// Invoked when a Mira Button click is cancelled. Do not use for vanilla buttons.
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
public sealed class MiraButtonCancelledEvent : MiraEvent
{
/// <summary>
/// Gets Mira Button whose click was cancelled.
/// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
/// </summary>
public CustomActionButton Button { get; }
/// <summary>
/// Initializes a new instance of the <see cref="MiraButtonCancelledEvent"/> class.
/// </summary>
/// <param name="button">The Mira Button whose click was cancelled.</param>
/// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
public MiraButtonCancelledEvent(CustomActionButton button)
{
Button = button;
+11 -11
View File
@@ -3,26 +3,26 @@
namespace MiraAPI.Events.Mira;
/// <summary>
/// Button click event for Mira Buttons only. Do not use for vanilla buttons.
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <typeparam name="T">The Mira Button type.</typeparam>
public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
public class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
{
/// <summary>
/// Gets Mira Button that was clicked.
/// Gets the <see cref="CustomActionButton"/> that was clicked.
/// </summary>
public T Button { get; }
/// <summary>
/// Gets the generic click event that is invoked before this button-specific event.
/// Gets the generic <see cref="MiraButtonClickEvent"/> that is invoked before this button-specific event.
/// </summary>
public MiraButtonClickEvent GenericClickEvent { get; }
/// <summary>
/// Initializes a new instance of the <see cref="MiraButtonClickEvent{T}"/> class.
/// </summary>
/// <param name="button">The Mira Button that was clicked.</param>
/// <param name="genericClickEvent">The generic click event invoked before button-specific events.</param>
/// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
/// <param name="genericClickEvent">The generic <see cref="MiraButtonClickEvent"/> invoked before button-specific events.</param>
public MiraButtonClickEvent(T button, MiraButtonClickEvent genericClickEvent)
{
GenericClickEvent = genericClickEvent;
@@ -31,19 +31,19 @@ public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : Cust
}
/// <summary>
/// Button click event for Mira Buttons only. Do not use for vanilla buttons.
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
public sealed class MiraButtonClickEvent : MiraCancelableEvent
public class MiraButtonClickEvent : MiraCancelableEvent
{
/// <summary>
/// Gets Mira Button that was clicked.
/// Gets the <see cref="CustomActionButton"/> that was clicked.
/// </summary>
public CustomActionButton Button { get; }
/// <summary>
/// Initializes a new instance of the <see cref="MiraButtonClickEvent"/> class.
/// </summary>
/// <param name="button">The Mira Button that was clicked.</param>
/// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
public MiraButtonClickEvent(CustomActionButton button)
{
Button = button;
@@ -0,0 +1,30 @@
using UnityEngine;
namespace MiraAPI.Events.Mira;
/// <summary>
/// Event fired by Mira API to adjust the UI buttons at the top right of the screen.
/// </summary>
public class UiButtonPostResetEvent : MiraEvent
{
/// <summary>
/// Gets the <see cref="GameObject"/> parent for the very top UI row.
/// </summary>
public GameObject MainTopUiRow { get; }
/// <summary>
/// Gets the <see cref="GameObject"/> parent for the second top UI row.
/// </summary>
public GameObject SecondTopUiRow { get; }
/// <summary>
/// Initializes a new instance of the <see cref="UiButtonPostResetEvent"/> class.
/// </summary>
/// <param name="topUiRow">The <see cref="GameObject"/> for the top UI row.</param>
/// <param name="secondUiRow">The <see cref="GameObject"/> for the second UI row.</param>
public UiButtonPostResetEvent(GameObject topUiRow, GameObject secondUiRow)
{
MainTopUiRow = topUiRow;
SecondTopUiRow = secondUiRow;
}
}
+15
View File
@@ -0,0 +1,15 @@
namespace MiraAPI.Events.Mira;
/// <summary>
/// Event fired by Mira API prior to adjusting the UI buttons at the top right of the screen.
/// </summary>
public class UiButtonResetEvent : MiraEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="UiButtonResetEvent"/> class.
/// </summary>
public UiButtonResetEvent()
{
// nothing!
}
}
+4 -1
View File
@@ -1,8 +1,11 @@
namespace MiraAPI.Events;
using MiraAPI.PluginLoading;
namespace MiraAPI.Events;
/// <summary>
/// Abstract class for Mira Events that can be cancelled.
/// </summary>
[MiraIgnore]
public abstract class MiraCancelableEvent : MiraEvent
{
/// <summary>
+4 -1
View File
@@ -1,6 +1,9 @@
namespace MiraAPI.Events;
using MiraAPI.PluginLoading;
namespace MiraAPI.Events;
/// <summary>
/// Abstract class for Mira Events.
/// </summary>
[MiraIgnore]
public abstract class MiraEvent;
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Events;
/// <summary>
/// Event handle to use when unregistering an event.
/// Event handle to use when unregistering a <see cref="MiraEvent"/>.
/// </summary>
public class MiraEventHandle
{
+15 -16
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Reactor.Utilities;
namespace MiraAPI.Events;
@@ -13,11 +12,11 @@ public static class MiraEventManager
private static readonly Dictionary<Type, List<MiraEventWrapper>> EventWrappers = [];
/// <summary>
/// Invoke an event.
/// Invoke a <see cref="MiraEvent"/>.
/// </summary>
/// <param name="eventInstance">The event instance.</param>
/// <param name="eventInstance">The <typeparamref name="T"/> instance.</param>
/// <typeparam name="T">Type of Event.</typeparam>
/// <returns>If there was an event handler invoked for this event, return true. Otherwise, return false.</returns>
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
public static bool InvokeEvent<T>(T eventInstance) where T : MiraEvent
{
EventWrappers.TryGetValue(typeof(T), out var handlers);
@@ -42,11 +41,11 @@ public static class MiraEventManager
}
/// <summary>
/// Invoke an event and use a specific type to find the handlers.
/// Invoke a <see cref="MiraEvent"/> and use a specific type to find the handlers.
/// </summary>
/// <param name="eventInstance">The event instance.</param>
/// <param name="eventInstance">The <see cref="MiraEvent"/> instance.</param>
/// <param name="type">The type to use for handler lookup.</param>
/// <returns>If there was an event handler invoked for this event, return true. Otherwise, return false.</returns>
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
public static bool InvokeEvent(MiraEvent eventInstance, Type type)
{
EventWrappers.TryGetValue(type, out var handlers);
@@ -71,12 +70,12 @@ public static class MiraEventManager
}
/// <summary>
/// Register an event.
/// Register a <see cref="MiraEvent"/> handler.
/// </summary>
/// <param name="type">The type of event.</param>
/// <param name="methodInfo">The MethodInfo of the event handler.</param>
/// <param name="type">The type of <see cref="MiraEvent"/> event.</param>
/// <param name="methodInfo">The <see cref="MethodInfo"/> of the event handler.</param>
/// <param name="priority">The priority of the event handler. Lower values are called first.</param>
/// <returns>An event handle to use when unregistering the event.</returns>
/// <returns>A <see cref="MiraEventHandle"/> to use when unregistering the event.</returns>
public static MiraEventHandle RegisterEventHandler(Type type, MethodInfo methodInfo, int priority = 0)
{
if (!type.IsSubclassOf(typeof(MiraEvent)))
@@ -102,12 +101,12 @@ public static class MiraEventManager
}
/// <summary>
/// Register an event.
/// Register a <typeparamref name="T"/> handler.
/// </summary>
/// <param name="handler">The callback method/handler for the event.</param>
/// <param name="priority">The priority of the event handler. Lower values are called first.</param>
/// <typeparam name="T">Type of event.</typeparam>
/// <returns>An event handle to use when unregistering the event.</returns>
/// <typeparam name="T">Type of <see cref="MiraEvent"/> event.</typeparam>
/// <returns>A <see cref="MiraEventHandle"/> to use when unregistering the event.</returns>
public static MiraEventHandle RegisterEventHandler<T>(Action<T> handler, int priority = 0) where T : MiraEvent
{
EventWrappers.TryAdd(typeof(T), []);
@@ -127,10 +126,10 @@ public static class MiraEventManager
}
/// <summary>
/// Unregister an event using the event handle.
/// Unregister a <see cref="MiraEvent"/> handler using the <see cref="MiraEventHandle"/>.
/// </summary>
/// <param name="eventHandle">A handle to the event.</param>
/// <returns>True if the event was unregistered successfully, false otherwise.</returns>
/// <returns><see langword="true"/> if the event was unregistered successfully, <see langword="false"/> otherwise.</returns>
public static bool UnregisterEventHandler(MiraEventHandle eventHandle)
{
if (!EventWrappers.TryGetValue(eventHandle.EventType, out var handlers))
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Events;
/// <summary>
/// Wrapper for event handlers.
/// Wrapper for <see cref="MiraEvent"/> handlers.
/// </summary>
public class MiraEventWrapper
{
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Events;
/// <summary>
/// Register an event.
/// Register a <see cref="MiraEvent"/> handler.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class RegisterEventAttribute : Attribute
@@ -6,30 +6,86 @@
public class AfterMurderEvent : MiraEvent
{
/// <summary>
/// Gets the player that killed the target.
/// Gets the <see cref="PlayerControl"/> that killed the <see cref="Target"/>.
/// </summary>
public PlayerControl Source { get; }
/// <summary>
/// Gets the player that was killed.
/// Gets the <see cref="PlayerControl"/> that was killed.
/// </summary>
public PlayerControl Target { get; }
/// <summary>
/// Gets the player's body, if it exists.
/// Gets the <see cref="PlayerControl"/> that was framed, if any.
/// </summary>
public PlayerControl? Framed { get; }
/// <summary>
/// Gets a value indicating whether the murder was done indirectly.
/// This is commonly used to prevent the <see cref="Source"/> <see cref="PlayerControl"/> from being killed.
/// </summary>
public bool IsIndirectAttack { get; }
/// <summary>
/// Gets a value indicating whether the murder was able to bypass protective roles or general defense, such as <see cref="GuardianAngelRole"/>.
/// </summary>
public bool IgnoreDefense { get; }
/// <summary>
/// Gets the <see cref="Target"/>'s <see cref="DeadBody"/>, if it exists.
/// </summary>
public DeadBody? DeadBody { get; }
/// <summary>
/// Initializes a new instance of the <see cref="AfterMurderEvent"/> class.
/// </summary>
/// <param name="source">The killer.</param>
/// <param name="target">The killed player.</param>
/// <param name="deadBody">The player's vody, if it exists.</param>
/// <param name="source">The <see cref="PlayerControl"/> that killed the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that was killed.</param>
/// <param name="deadBody">The <paramref name="target"/>'s <see cref="DeadBody"/>, if it exists.</param>
/// <param name="isIndirect">Whether the murder was caused indirectly.</param>
/// <param name="ignoreDefense">Whether the murder ignored protection.</param>
public AfterMurderEvent(PlayerControl source, PlayerControl target, DeadBody? deadBody, bool isIndirect, bool ignoreDefense = false)
{
Source = source;
Target = target;
Framed = null;
DeadBody = deadBody;
IsIndirectAttack = isIndirect;
IgnoreDefense = ignoreDefense;
}
/// <summary>
/// Initializes a new instance of the <see cref="AfterMurderEvent"/> class.
/// </summary>
/// <param name="source">The <see cref="PlayerControl"/> that killed the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that was killed.</param>
/// <param name="framed">The <see cref="PlayerControl"/> that was framed.</param>
/// <param name="deadBody">The <paramref name="target"/>'s <see cref="DeadBody"/>, if it exists.</param>
/// <param name="isIndirect">Whether the murder was caused indirectly.</param>
/// <param name="ignoreDefense">Whether the murder ignored protection.</param>
public AfterMurderEvent(PlayerControl source, PlayerControl target, PlayerControl framed, DeadBody? deadBody, bool isIndirect = true, bool ignoreDefense = false)
{
Source = source;
Target = target;
Framed = framed;
DeadBody = deadBody;
IsIndirectAttack = isIndirect;
IgnoreDefense = ignoreDefense;
}
/// <summary>
/// Initializes a new instance of the <see cref="AfterMurderEvent"/> class.
/// </summary>
/// <param name="source">The <see cref="PlayerControl"/> that killed the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that was killed.</param>
/// <param name="deadBody">The <paramref name="target"/>'s <see cref="DeadBody"/>, if it exists.</param>
public AfterMurderEvent(PlayerControl source, PlayerControl target, DeadBody? deadBody)
{
Source = source;
Target = target;
Framed = null;
DeadBody = deadBody;
IsIndirectAttack = false;
IgnoreDefense = false;
}
}
@@ -1,7 +1,7 @@
namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary>
/// Invoked before RpcEndGame is called, allowing cancellation of the game end entirely.
/// Invoked before <see cref="GameManager.RpcEndGame"/> is called, allowing cancellation of the game end entirely.
/// </summary>
public class BeforeGameEndEvent : MiraCancelableEvent
{
@@ -1,4 +1,6 @@
namespace MiraAPI.Events.Vanilla.Gameplay;
using MiraAPI.Networking;
namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary>
/// Event that is invoked before a player is murdered. This event is cancelable.
@@ -6,23 +8,101 @@
public sealed class BeforeMurderEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the player that is killing the target.
/// Gets the <see cref="PlayerControl"/> that is killing the <see cref="Target"/>.
/// </summary>
public PlayerControl Source { get; }
/// <summary>
/// Gets the player that is being killed.
/// Gets the <see cref="PlayerControl"/> that is being killed.
/// </summary>
public PlayerControl Target { get; }
/// <summary>
/// Gets the <see cref="PlayerControl"/> that is being framed, if any.
/// </summary>
public PlayerControl? Framed { get; }
/// <summary>
/// Gets or sets a value indicating whether the murder is done indirectly.
/// This is commonly used to prevent the <see cref="Source"/> <see cref="PlayerControl"/> from being killed.
/// </summary>
public bool IsIndirectAttack { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the murder should bypass protective roles or general defense, such as <see cref="GuardianAngelRole"/>.
/// </summary>
public bool IgnoreDefense { get; set; }
/// <summary>
/// Gets whether the murder was meant to be done in a meeting, via an enum.
/// </summary>
public MeetingCheck InMeeting { get; }
/// <summary>
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
/// </summary>
/// <param name="source">The player that is killing the target.</param>
/// <param name="target">The player that is being killed.</param>
/// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
/// <param name="isIndirect">Whether the murder is caused indirectly.</param>
/// <param name="ignoreDefense">Whether the murder should ignore protection.</param>
/// <param name="inMeeting">Whether the murder is intended to be triggered in a meeting.</param>
public BeforeMurderEvent(PlayerControl source, PlayerControl target, bool isIndirect, bool ignoreDefense = false, MeetingCheck inMeeting = MeetingCheck.Ignore)
{
Source = source;
Target = target;
Framed = null;
IsIndirectAttack = isIndirect;
IgnoreDefense = ignoreDefense;
InMeeting = inMeeting;
}
/// <summary>
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
/// </summary>
/// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
/// <param name="framed">The <see cref="PlayerControl"/> that is being framed.</param>
/// <param name="isIndirect">Whether the murder is caused indirectly.</param>
/// <param name="ignoreDefense">Whether the murder should ignore protection.</param>
/// <param name="inMeeting">Whether the murder is intended to be triggered in a meeting.</param>
public BeforeMurderEvent(PlayerControl source, PlayerControl target, PlayerControl framed, bool isIndirect = true, bool ignoreDefense = false, MeetingCheck inMeeting = MeetingCheck.Ignore)
{
Source = source;
Target = target;
Framed = framed;
IsIndirectAttack = isIndirect;
IgnoreDefense = ignoreDefense;
InMeeting = inMeeting;
}
/// <summary>
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
/// </summary>
/// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
/// <param name="inMeeting">Whether the murder is intended to be triggered in a meeting.</param>
public BeforeMurderEvent(PlayerControl source, PlayerControl target, MeetingCheck inMeeting)
{
Source = source;
Target = target;
Framed = null;
IsIndirectAttack = false;
IgnoreDefense = false;
InMeeting = inMeeting;
}
/// <summary>
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
/// </summary>
/// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
/// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
public BeforeMurderEvent(PlayerControl source, PlayerControl target)
{
Source = source;
Target = target;
Framed = null;
IsIndirectAttack = false;
IgnoreDefense = false;
InMeeting = MeetingCheck.Ignore;
}
}
@@ -1,12 +1,13 @@
namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary>
/// Event invoked on IntroCutscene.OnDestroy and ExileController.WrapUp to determine if it should run the round event or not.
/// Event invoked on <see cref="IntroCutscene.OnDestroy"/> and <see cref="ExileController.WrapUp"/>
/// to determine if it should run the <see cref="RoundStartEvent"/> event or not.
/// </summary>
public class BeforeRoundStartEvent : MiraCancelableEvent
{
/// <summary>
/// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController.
/// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
/// </summary>
public bool TriggeredByIntro { get; }
@@ -6,14 +6,14 @@
public class GameEndEvent : MiraEvent
{
/// <summary>
/// Gets the instance of the EndGameManager.
/// Gets the <see cref="global::EndGameManager"/> instance.
/// </summary>
public EndGameManager EndGameManager { get; }
/// <summary>
/// Initializes a new instance of the <see cref="GameEndEvent"/> class.
/// </summary>
/// <param name="manager">The instance of the EndGameManager.</param>
/// <param name="manager">The <see cref="global::EndGameManager"/> instance.</param>
public GameEndEvent(EndGameManager manager)
{
EndGameManager = manager;
@@ -6,7 +6,7 @@
public class IntroBeginEvent : MiraEvent
{
/// <summary>
/// Gets the instance of the IntroCutscene.
/// Gets the <see cref="global::IntroCutscene"/> instance.
/// </summary>
public IntroCutscene IntroCutscene { get; }
@@ -6,7 +6,7 @@
public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent
{
/// <summary>
/// Gets the instance of the IntroCutscene.
/// Gets the <see cref="global::IntroCutscene"/> instance.
/// </summary>
public IntroCutscene IntroCutscene { get; } = introCutscene;
}
@@ -6,7 +6,7 @@
public class IntroRoleRevealEvent : MiraEvent
{
/// <summary>
/// Gets the instance of the IntroCutscene.
/// Gets the <see cref="global::IntroCutscene"/> instance.
/// </summary>
public IntroCutscene IntroCutscene { get; }
@@ -1,12 +1,13 @@
namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary>
/// Start Round event, invoked on IntroCutscene.OnDestroy and ExileController.WrapUp if the event isn't cancelled.
/// Start Round event, invoked on <see cref="IntroCutscene.OnDestroy"/> and <see cref="ExileController.WrapUp"/>
/// if the <see cref="BeforeRoundStartEvent"/> isn't cancelled.
/// </summary>
public class RoundStartEvent : MiraEvent
{
/// <summary>
/// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController.
/// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
/// </summary>
public bool TriggeredByIntro { get; }
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Gameplay;
public class SetRoleEvent : MiraEvent
{
/// <summary>
/// Gets the player whos role was changed.
/// Gets the <see cref="PlayerControl"/> whose role was changed.
/// </summary>
public PlayerControl Player { get; }
@@ -0,0 +1,44 @@
using MiraAPI.Hud;
namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary>
/// Invoked when a Vanilla <see cref="AbilityButton"/> click is cancelled. Do not use for <see cref="CustomActionButton"/>.
/// </summary>
/// <typeparam name="T">The vanilla <see cref="AbilityButton"/> type.</typeparam>
public sealed class VanillaButtonCancelledEvent<T> : MiraEvent where T : AbilityButton
{
/// <summary>
/// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
/// </summary>
public T Button { get; }
/// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent{T}"/> class.
/// </summary>
/// <param name="button">The vanilla <see cref="AbilityButton"/> whose click was cancelled.</param>
public VanillaButtonCancelledEvent(T button)
{
Button = button;
}
}
/// <summary>
/// Invoked when a Vanilla <see cref="AbilityButton"/> click is cancelled. Do not use for <see cref="CustomActionButton"/>s.
/// </summary>
public sealed class VanillaButtonCancelledEvent : MiraEvent
{
/// <summary>
/// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
/// </summary>
public AbilityButton Button { get; }
/// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent"/> class.
/// </summary>
/// <param name="button">The vanilla <see cref="AbilityButton"/> whose click was cancelled.</param>
public VanillaButtonCancelledEvent(AbilityButton button)
{
Button = button;
}
}
@@ -0,0 +1,65 @@
using MiraAPI.Hud;
namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary>
/// Button click event for Vanilla <see cref="AbilityButton"/>s only. Do not use for <see cref="CustomActionButton"/>s.
/// </summary>
/// <typeparam name="T">The vanilla <see cref="AbilityButton"/> type.</typeparam>
public sealed class VanillaButtonClickEvent<T> : MiraCancelableEvent where T : AbilityButton
{
/// <summary>
/// Gets the vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary>
public T Button { get; }
/// <summary>
/// Gets the generic <see cref="VanillaButtonClickEvent"/> that is invoked before this button-specific event.
/// </summary>
public VanillaButtonClickEvent GenericClickEvent { get; }
/// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent{T}"/> class.
/// </summary>
/// <param name="button">The vanilla <see cref="AbilityButton"/> that was clicked.</param>
/// <param name="genericClickEvent">The generic <see cref="VanillaButtonClickEvent"/> invoked before button-specific events.</param>
public VanillaButtonClickEvent(T button, VanillaButtonClickEvent genericClickEvent)
{
GenericClickEvent = genericClickEvent;
Button = button;
}
}
/// <summary>
/// Button click event for Vanilla <see cref="AbilityButton"/> only. Do not use for <see cref="CustomActionButton"/>s.
/// </summary>
public sealed class VanillaButtonClickEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the Vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary>
public AbilityButton Button { get; }
/// <summary>
/// Gets the target <see cref="PlayerControl"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary>
public PlayerControl? PlayerTarget { get; }
/// <summary>
/// Gets the target <see cref="Vent"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary>
public Vent? VentTarget { get; }
/// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent"/> class.
/// </summary>
/// <param name="button">The Vanilla <see cref="AbilityButton"/> that was clicked.</param>
/// <param name="playerTarget">The <see cref="PlayerControl"/> target, if any.</param>
/// <param name="ventTarget">The <see cref="Vent"/> target, if any.</param>
public VanillaButtonClickEvent(AbilityButton button, PlayerControl? playerTarget = null, Vent? ventTarget = null)
{
Button = button;
PlayerTarget = playerTarget;
VentTarget = ventTarget;
}
}
@@ -6,14 +6,14 @@
public class PlayerOpenSabotageEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the MapBehaviour.
/// Gets the <see cref="global::MapBehaviour"/>.
/// </summary>
public MapBehaviour MapBehaviour { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PlayerOpenSabotageEvent"/> class.
/// </summary>
/// <param name="mapBehaviour">The MapBehaviour.</param>
/// <param name="mapBehaviour">The <see cref="global::MapBehaviour"/>.</param>
public PlayerOpenSabotageEvent(MapBehaviour mapBehaviour)
{
MapBehaviour = mapBehaviour;
@@ -1,7 +1,7 @@
namespace MiraAPI.Events.Vanilla.Map;
/// <summary>
/// Cancelable event that is invoked before a system is updated. Usually used for sabotage events.
/// <see cref="MiraCancelableEvent"/> that is invoked before a system is updated. Usually used for sabotage events.
/// </summary>
public class UpdateSystemEvent : MiraCancelableEvent
{
@@ -11,7 +11,7 @@ public class UpdateSystemEvent : MiraCancelableEvent
public SystemTypes SystemType { get; }
/// <summary>
/// Gets the player that is updating the system.
/// Gets the <see cref="PlayerControl"/> that is updating the system.
/// </summary>
public PlayerControl Player { get; }
@@ -21,10 +21,10 @@ public class UpdateSystemEvent : MiraCancelableEvent
public byte Amount { get; }
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class.
/// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class.
/// </summary>
/// <param name="systemType">The SystemType being updated.</param>
/// <param name="player">The player that is updating the system.</param>
/// <param name="systemType">The <see cref="SystemTypes"/> being updated.</param>
/// <param name="player">The <see cref="PlayerControl"/> that is updating the system.</param>
/// <param name="amount">Amount to update System to.</param>
public UpdateSystemEvent(SystemTypes systemType, PlayerControl player, byte amount)
{
@@ -6,14 +6,14 @@
public class EjectionEvent : MiraEvent
{
/// <summary>
/// Gets the instance of the ExileController.
/// Gets the <see cref="global::ExileController"/> instance.
/// </summary>
public ExileController ExileController { get; }
/// <summary>
/// Initializes a new instance of the <see cref="EjectionEvent"/> class.
/// </summary>
/// <param name="controller">The exile controller.</param>
/// <param name="controller">The <see cref="global::ExileController"/> instance.</param>
public EjectionEvent(ExileController controller)
{
ExileController = controller;
@@ -6,7 +6,7 @@
public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent
{
/// <summary>
/// Gets the MeetingHud instance.
/// Gets the <see cref="global::MeetingHud"/> instance.
/// </summary>
public MeetingHud MeetingHud { get; } = meetingHud;
}
@@ -2,7 +2,7 @@
/// <summary>
/// The event that is invoked when a body is reported.
/// This is invoked in CmdReportBody.
/// This is invoked in <see cref="PlayerControl.CmdReportDeadBody(NetworkedPlayerInfo)"/>.
/// </summary>
public class ReportBodyEvent : MiraCancelableEvent
{
@@ -12,12 +12,12 @@ public class ReportBodyEvent : MiraCancelableEvent
public PlayerControl Reporter { get; }
/// <summary>
/// Gets the player that is being reported. Will be null for emergency meeting.
/// Gets the player that is being reported. Will be <see langword="null"/> for emergency meeting.
/// </summary>
public NetworkedPlayerInfo? Target { get; }
/// <summary>
/// Gets the body that is being reported. Will be null for emergency meeting.
/// Gets the <see cref="DeadBody"/> that is being reported. Will be <see langword="null"/> for emergency meeting.
/// </summary>
public DeadBody? Body { get; }
@@ -26,7 +26,7 @@ public class ReportBodyEvent : MiraCancelableEvent
/// </summary>
/// <param name="reporter">The player who reported the body.</param>
/// <param name="target">The player being reported.</param>
/// <param name="body">The body being reported.</param>
/// <param name="body">The <see cref="DeadBody"/> being reported.</param>
public ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body)
{
Reporter = reporter;
@@ -7,14 +7,14 @@
public class StartMeetingEvent : MiraEvent
{
/// <summary>
/// Gets the MeetingHud instance.
/// Gets the <see cref="global::MeetingHud"/> instance.
/// </summary>
public MeetingHud MeetingHud { get; }
/// <summary>
/// Initializes a new instance of the <see cref="StartMeetingEvent"/> class.
/// </summary>
/// <param name="meetingHud">The MeetingHud instance.</param>
/// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
public StartMeetingEvent(MeetingHud meetingHud)
{
MeetingHud = meetingHud;
@@ -1,6 +1,4 @@
using MiraAPI.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary>
/// Event that is invoked after the local player successfully votes a player or skips. This event is not cancelable.
@@ -8,7 +6,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
public class AfterVoteEvent : MiraEvent
{
/// <summary>
/// Gets the instance of the voter's vote data.
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
/// </summary>
public PlayerVoteArea VoteArea { get; }
@@ -20,7 +18,7 @@ public class AfterVoteEvent : MiraEvent
/// <summary>
/// Initializes a new instance of the <see cref="AfterVoteEvent"/> class.
/// </summary>
/// <param name="playerVoteArea">The player vote area that was voted on.</param>
/// <param name="playerVoteArea">The <see cref="PlayerVoteArea"/> that was voted on.</param>
/// <param name="voter">The player who voted.</param>
public AfterVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
{
@@ -1,6 +1,4 @@
using MiraAPI.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary>
/// Event that is invoked before the local player confirms a vote on a player or when skipping. This event is cancelable.
@@ -8,7 +6,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
public class BeforeVoteEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the instance of the voter's vote data.
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
/// </summary>
public PlayerVoteArea VoteArea { get; }
@@ -20,7 +18,7 @@ public class BeforeVoteEvent : MiraCancelableEvent
/// <summary>
/// Initializes a new instance of the <see cref="BeforeVoteEvent"/> class.
/// </summary>
/// <param name="playerVoteArea">The player vote area that was voted on.</param>
/// <param name="playerVoteArea">The <see cref="PlayerVoteArea"/> that was voted on.</param>
/// <param name="voter">The player who voted.</param>
public BeforeVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
{
@@ -18,7 +18,7 @@ public class CheckForEndVotingEvent : MiraCancelableEvent
/// <summary>
/// Initializes a new instance of the <see cref="CheckForEndVotingEvent"/> class.
/// </summary>
/// <param name="isVotingComplete">>True if voting is complete, false otherwise.</param>
/// <param name="isVotingComplete"><see langword="true"/> if voting is complete, <see langword="false"/> otherwise.</param>
public CheckForEndVotingEvent(bool isVotingComplete)
{
IsVotingComplete = isVotingComplete;
@@ -15,7 +15,7 @@ public class DummyVoteEvent : MiraCancelableEvent
public DummyBehaviour Dummy { get; }
/// <summary>
/// Gets the instance of the dummy's vote data.
/// Gets the instance of the dummy's <see cref="PlayerVoteData"/>.
/// </summary>
public PlayerVoteData VoteData { get; }
@@ -5,12 +5,12 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary>
/// The event that is invoked when Mira handles a vote. This is invoked before Mira's behaviour, so be cautious.
/// If you intend on adding custom vote behaviour, cancel the event and do so.
/// If you are NOT canceling the event, keep in mind that Mira automatically removes a vote and adds the suspect to the VotedPlayers list after this event is invoked.
/// If you are NOT canceling the event, keep in mind that Mira automatically removes a vote and adds the suspect to the <see cref="PlayerVoteData.Votes"/> list after this event is invoked.
/// </summary>
public class HandleVoteEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the instance of the voter's vote data.
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
/// </summary>
public PlayerVoteData VoteData { get; }
@@ -25,19 +25,24 @@ public class HandleVoteEvent : MiraCancelableEvent
public byte TargetId { get; }
/// <summary>
/// Gets a value indicating whether to prevent the vote from commencing.
/// Gets or sets a value indicating whether to prevent the vote from commencing.
/// </summary>
public bool PreventVote { get; }
public bool PreventVote { get; set; }
/// <summary>
/// Gets the player info of the target.
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
/// </summary>
public NetworkedPlayerInfo TargetPlayerInfo { get; }
/// <summary>
/// Gets or sets a value indicating whether the vote event is an Overrule caused by a Judge.
/// </summary>
public bool IsOverruling { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="HandleVoteEvent"/> class.
/// </summary>
/// <param name="playerVoteData">The voter's data.</param>
/// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
/// <param name="targetId">The target's playerId.</param>
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId)
{
@@ -47,4 +52,20 @@ public class HandleVoteEvent : MiraCancelableEvent
PreventVote = false;
TargetPlayerInfo = GameData.Instance.GetPlayerById(targetId);
}
/// <summary>
/// Initializes a new instance of the <see cref="HandleVoteEvent"/> class.
/// </summary>
/// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
/// <param name="targetId">The target's playerId.</param>
/// <param name="isOverruling">Whether the vote is actually for a Judge.</param>
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool isOverruling)
{
VoteData = playerVoteData;
Player = playerVoteData.Owner;
TargetId = targetId;
PreventVote = false;
IsOverruling = isOverruling;
TargetPlayerInfo = GameData.Instance.GetPlayerById(targetId);
}
}
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
public class MeetingSelectEvent : MiraEvent
{
/// <summary>
/// Gets the instance of the voter's vote data.
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
/// </summary>
public PlayerVoteData VoteData { get; }
@@ -18,7 +18,7 @@ public class MeetingSelectEvent : MiraEvent
public int TargetId { get; }
/// <summary>
/// Gets the player info of the target.
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
/// </summary>
public NetworkedPlayerInfo TargetPlayerInfo { get; }
@@ -30,9 +30,9 @@ public class MeetingSelectEvent : MiraEvent
/// <summary>
/// Initializes a new instance of the <see cref="MeetingSelectEvent"/> class.
/// </summary>
/// <param name="playerVoteData">The voter's data.</param>
/// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
/// <param name="targetId">The target's playerId.</param>
/// <param name="allowSelect">>Whether the player is allowed to select the target.</param>
/// <param name="allowSelect">Whether the player is allowed to select the target.</param>
public MeetingSelectEvent(PlayerVoteData playerVoteData, int targetId, bool allowSelect)
{
VoteData = playerVoteData;
@@ -4,20 +4,20 @@ using MiraAPI.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary>
/// Called in VotingUtils.HandlePopulateResults.
/// Called in <see cref="VotingUtils.HandlePopulateResults"/>.
/// Cancelling is NOT advised but if you do plan on cancelling, please ensure you account for displaying ALL player's votes.
/// </summary>
public class PopulateResultsEvent : MiraCancelableEvent
{
/// <summary>
/// Gets a list of networked votes.
/// Gets a list of networked <see cref="CustomVote"/>s.
/// </summary>
public List<CustomVote> Votes { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PopulateResultsEvent"/> class.
/// </summary>
/// <param name="votes">The list of votes.</param>
/// <param name="votes">The list of <see cref="CustomVote"/>s.</param>
public PopulateResultsEvent(List<CustomVote> votes)
{
Votes = votes;
@@ -10,8 +10,8 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <remarks>
/// Initializes a new instance of the <see cref="ProcessVotesEvent"/> class.
/// </remarks>
/// <param name="votes">>The list of votes that are being processed.</param>
/// <param name="exiledPlayer">The player to be exiled. Will be null if no player is to be exiled.</param>
/// <param name="votes">The list of <see cref="CustomVote"/>s that are being processed.</param>
/// <param name="exiledPlayer">The player to be exiled. Will be <see langword="null"/> if no player is to be exiled.</param>
public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exiledPlayer = null) : MiraEvent
{
private readonly List<CustomVote> _originalVotes = [.. votes];
@@ -29,12 +29,22 @@ public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exil
public bool VotesModified => !Votes.SequenceEqual(_originalVotes);
/// <summary>
/// Gets the list of votes that are being processed.
/// Gets the list of <see cref="CustomVote"/>s that are being processed.
/// </summary>
public List<CustomVote> Votes { get; } = votes;
/// <summary>
/// Gets or sets the player to be exiled. Will be null if no player is to be exiled.
/// Gets or sets a value indicating whether an overruling was done. Normally set by judge but can be overwritten.
/// </summary>
public bool OverruledVote { get; set; }
/// <summary>
/// Gets or sets a value specifically to determine which Judge (if any) caused the overruling. Normally set by judge but can be overwritten.
/// </summary>
public ushort OverruledNonce { get; set; }
/// <summary>
/// Gets or sets the player to be exiled. Will be <see langword="null"/> if no player is to be exiled.
/// </summary>
public NetworkedPlayerInfo? ExiledPlayer
{
@@ -3,11 +3,11 @@
/// <summary>
/// The event that is invoked when the voting phase of a meeting is complete.
/// </summary>
/// <param name="meetingHud">The MeetingHud instance.</param>
/// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent
{
/// <summary>
/// Gets the MeetingHud instance.
/// Gets the <see cref="global::MeetingHud"/> instance.
/// </summary>
public MeetingHud MeetingHud { get; } = meetingHud;
}
@@ -16,14 +16,14 @@ public class CompleteHnsTaskEvent : MiraEvent
public PlayerTask Task { get; }
/// <summary>
/// Gets the instance of the <see cref="HnsManager"/> attached to the game.
/// Gets the instance of the <see cref="HideAndSeekManager"/> attached to the game.
/// </summary>
public HideAndSeekManager HnsManager { get; }
/// <summary>
/// Initializes a new instance of the <see cref="CompleteHnsTaskEvent"/> class.
/// </summary>
/// <param name="hnsManager">The Hide and Seek Manager currently active.</param>
/// <param name="hnsManager">The <see cref="HideAndSeekManager"/> currently active.</param>
/// <param name="player">The player who completed the task.</param>
/// <param name="task">The task that the player completed.</param>
public CompleteHnsTaskEvent(HideAndSeekManager hnsManager, PlayerControl player, PlayerTask task)
@@ -16,7 +16,7 @@ public class PlayerDeathEvent : MiraEvent
public DeathReason DeathReason { get; }
/// <summary>
/// Gets the dead body associated with the player, if any.
/// Gets the <see cref="global::DeadBody"/> associated with the player, if any.
/// </summary>
public DeadBody? DeadBody { get; }
@@ -25,7 +25,7 @@ public class PlayerDeathEvent : MiraEvent
/// </summary>
/// <param name="player">The player who died.</param>
/// <param name="reason">The reason the player died.</param>
/// <param name="deadBody">The player's body, if it exists.</param>
/// <param name="deadBody">The player's <see cref="global::DeadBody"/>, if it exists.</param>
public PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody? deadBody)
{
Player = player;
@@ -6,20 +6,20 @@
public class EnterVentEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the player that is entering the vent.
/// Gets the <see cref="PlayerControl"/> that is entering the <see cref="Vent"/>.
/// </summary>
public PlayerControl Player { get; }
/// <summary>
/// Gets the vent that the player is entering.
/// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is entering.
/// </summary>
public Vent? Vent { get; }
/// <summary>
/// Initializes a new instance of the <see cref="EnterVentEvent"/> class.
/// </summary>
/// <param name="player">The player that is entering the vent.</param>
/// <param name="vent">The vent being entered.</param>
/// <param name="player">The <see cref="PlayerControl"/> that is entering the <paramref name="vent"/>.</param>
/// <param name="vent">The <see cref="global::Vent"/> being entered.</param>
public EnterVentEvent(PlayerControl player, Vent? vent)
{
Player = player;
@@ -6,20 +6,20 @@
public class ExitVentEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the player that is exiting the vent.
/// Gets the <see cref="PlayerControl"/> that is exiting the <see cref="Vent"/>.
/// </summary>
public PlayerControl Player { get; }
/// <summary>
/// Gets the vent that the player is exiting.
/// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is exiting.
/// </summary>
public Vent? Vent { get; }
/// <summary>
/// Initializes a new instance of the <see cref="ExitVentEvent"/> class.
/// </summary>
/// <param name="player">The player who is exiting the vent.</param>
/// <param name="vent">The vent being exited from.</param>
/// <param name="player">The <see cref="PlayerControl"/> who is exiting the <paramref name="vent"/>.</param>
/// <param name="vent">The <see cref="global::Vent"/> being exited from.</param>
public ExitVentEvent(PlayerControl player, Vent? vent)
{
Player = player;
@@ -8,7 +8,7 @@ public class PlayerCanUseEvent : PlayerUseEvent
/// <summary>
/// Initializes a new instance of the <see cref="PlayerCanUseEvent"/> class.
/// </summary>
/// <param name="usable">The IUsable.</param>
/// <param name="usable">The <see cref="IUsable"/>.</param>
public PlayerCanUseEvent(IUsable usable) : base(usable)
{
}
@@ -11,19 +11,19 @@ public class PlayerUseEvent : MiraCancelableEvent
public IUsable Usable { get; }
/// <summary>
/// Gets a value indicating whether the IUsable is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>.
/// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>.
/// </summary>
public bool IsPrimaryConsole { get; }
/// <summary>
/// Gets a value indicating whether the IUsable is a <see cref="Vent"/>.
/// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Vent"/>.
/// </summary>
public bool IsVent { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PlayerUseEvent"/> class.
/// </summary>
/// <param name="usable">The IUsable.</param>
/// <param name="usable">The <see cref="IUsable"/>.</param>
public PlayerUseEvent(IUsable usable)
{
Usable = usable;
+14 -14
View File
@@ -10,44 +10,44 @@ namespace MiraAPI.GameEnd;
public abstract class CustomGameOver
{
/// <summary>
/// Gets the current CustomGameOver.
/// Gets the current <see cref="CustomGameOver"/>.
/// </summary>
public static CustomGameOver? Instance { get; internal set; }
/// <summary>
/// Verifies if the condition for this CustomGameOver is met.
/// Verifies if the condition for this <see cref="CustomGameOver"/> is met.
/// </summary>
/// <param name="playerControl">The PlayerControl that requested the Game Over.</param>
/// <param name="playerControl">The <see cref="PlayerControl"/> that requested the Game Over.</param>
/// <param name="winners">The collection of winners.</param>
/// <returns>True if the condition is met, otherwise false.</returns>
/// <returns><see langword="true"/> if the condition is met, otherwise <see langword="false"/>.</returns>
public virtual bool VerifyCondition(PlayerControl playerControl, NetworkedPlayerInfo[] winners)
{
return true;
}
/// <summary>
/// Runs before the base game calls EndGameManager.SetEverythingUp.
/// Runs before the base game calls <see cref="EndGameManager.SetEverythingUp"/>.
/// </summary>
/// <param name="endGameManager">The EndGameManager instance.</param>
/// <returns>Return True to use the run the original method, return False to skip it.</returns>
/// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
/// <returns>Return <see langword="true"/> to use the run the original method, return <see langword="false"/> to skip it.</returns>
public virtual bool BeforeEndGameSetup(EndGameManager endGameManager)
{
return true;
}
/// <summary>
/// Runs after the base game calls EndGameManager.SetEverythingUp.
/// Runs after the base game calls <see cref="EndGameManager.SetEverythingUp"/>.
/// </summary>
/// <param name="endGameManager">The EndGameManager instance.</param>
/// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
public virtual void AfterEndGameSetup(EndGameManager endGameManager)
{
}
/// <summary>
/// Get the GameOverReason associated with this CustomGameOver.
/// Get the <see cref="global::GameOverReason"/> associated with this <see cref ="CustomGameOver"/>.
/// </summary>
/// <typeparam name="T">Type of the custom game over.</typeparam>
/// <returns>The GameOverReason associated with the custom game over.</returns>
/// <returns>The <see cref="global::GameOverReason"/> associated with the custom game over.</returns>
public static GameOverReason GameOverReason<T>() where T : CustomGameOver
{
return (GameOverReason)GameOverManager.GetGameOverId<T>();
@@ -67,10 +67,10 @@ public abstract class CustomGameOver
}
/// <summary>
/// Implicitly convert a CustomGameOver to a GameOverReason.
/// Implicitly convert a <see cref="CustomGameOver"/> to a <see cref="global::GameOverReason"/>.
/// </summary>
/// <param name="gameOver">The CustomGameOver instance.</param>
/// <returns>The GameOverReason associated with the CustomGameOver.</returns>
/// <param name="gameOver">The <see cref="CustomGameOver"/> instance.</param>
/// <returns>The <see cref="global::GameOverReason"/> associated with the CustomGameOver.</returns>
public static implicit operator GameOverReason(CustomGameOver gameOver)
{
return (GameOverReason)GameOverManager.GetGameOverId(gameOver.GetType());
+15 -16
View File
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Reactor.Utilities;
namespace MiraAPI.GameEnd;
/// <summary>
/// Manage custom game overs.
/// Manage <see cref="CustomGameOver"/>s.
/// </summary>
public static class GameOverManager
{
@@ -16,11 +15,11 @@ public static class GameOverManager
private static int _nextId = Enum.GetNames<GameOverReason>().Length;
/// <summary>
/// Register a custom game over.
/// Register a <see cref="CustomGameOver"/>.
/// </summary>
/// <param name="gameOverType">Type of the custom game over.</param>
/// <exception cref="ArgumentException">Thrown when the type is not a subclass of CustomGameOver, is abstract, or does not have a parameterless constructor.</exception>
/// <returns>>True if the game over was registered successfully, false otherwise.</returns>
/// <param name="gameOverType">Type of the <see cref="CustomGameOver"/>.</param>
/// <exception cref="ArgumentException">Thrown when the type is not a subclass of <see cref="CustomGameOver"/>, is abstract, or does not have a parameterless constructor.</exception>
/// <returns><see langword="true"/> if the game over was registered successfully, <see langword="false"/> otherwise.</returns>
public static bool RegisterGameOver(Type gameOverType)
{
if (!typeof(CustomGameOver).IsAssignableFrom(gameOverType))
@@ -47,11 +46,11 @@ public static class GameOverManager
}
/// <summary>
/// Create an instance of a custom game over.
/// Create an instance of a <see cref="CustomGameOver"/>.
/// </summary>
/// <param name="id">ID of the custom game over.</param>
/// <param name="customGameOver">The created instance of the custom game over.</param>
/// <returns>An instance of the custom game over.</returns>
/// <param name="id">ID of the <see cref="CustomGameOver"/>.</param>
/// <param name="customGameOver">The created instance of the <see cref="CustomGameOver"/>.</param>
/// <returns>An instance of the <see cref="CustomGameOver"/>.</returns>
public static bool TryGetGameOver(int id, [NotNullWhen(true)] out CustomGameOver? customGameOver)
{
if (GameOverTypes.TryGetValue(id, out var gameOverType))
@@ -65,20 +64,20 @@ public static class GameOverManager
}
/// <summary>
/// Get the ID of a custom game over.
/// Get the ID of a <see cref="CustomGameOver"/>.
/// </summary>
/// <typeparam name="T">Type of the custom game over.</typeparam>
/// <returns>The ID of the custom game over.</returns>
/// <typeparam name="T">Type of the <see cref="CustomGameOver"/>.</typeparam>
/// <returns>The ID of the <see cref="CustomGameOver"/>.</returns>
public static int GetGameOverId<T>() where T : CustomGameOver
{
return GetGameOverId(typeof(T));
}
/// <summary>
/// Get the ID of a custom game over.
/// Get the ID of a <see cref="CustomGameOver"/>.
/// </summary>
/// <param name="gameOverType">Type of the custom game over.</param>
/// <returns>The ID of the custom game over.</returns>
/// <param name="gameOverType">Type of the <see cref="CustomGameOver"/>.</param>
/// <returns>The ID of the <see cref="CustomGameOver"/>.</returns>
/// <exception cref="ArgumentException">Thrown when the type is not registered.</exception>
public static int GetGameOverId(Type gameOverType)
{
+297
View File
@@ -0,0 +1,297 @@
using System.Collections;
using System.Collections.Generic;
using AmongUs.GameOptions;
using MiraAPI.GameOptions;
using MiraAPI.PluginLoading;
using MiraAPI.Translation;
using MiraAPI.Utilities.Assets;
using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;
namespace MiraAPI.GameModes;
/// <summary>
/// Base class for custom gamemodes.
/// </summary>
[MiraIgnore]
public abstract class AbstractGameMode : IOptionable
{
/// <summary>
/// Gets the game mode name.
/// </summary>
public abstract string Name { get; }
/// <summary>
/// Gets a value indicating whether the mode is visible in the menu. Only checked at startup.
/// </summary>
public virtual bool HideMode => false;
/// <summary>
/// Gets the game mode description.
/// </summary>
public abstract string Description { get; }
/// <summary>
/// Gets the game mode color to display on the lobby pane.
/// </summary>
public virtual Color Color { get; } = Color.white;
/// <summary>
/// Gets the icon of the gamemode. Will be shown in options menu underneath the gamemode option.
/// </summary>
public virtual LoadableAsset<Sprite>? Icon => null;
/// <summary>
/// Gets or sets the icon of the gamemode for use on the options pop-up.
/// </summary>
public TMP_SpriteAsset TmpIcon { get; set; } = null!;
/// <summary>
/// Gets the colored game mode name, using the color and name properties.
/// </summary>
public string ColoredName => $"<color=#{Color.ToHtmlStringRGBA()}>{MiraLocaleManager.Get(Name)}</color>";
/// <summary>
/// Gets the game mode id.
/// </summary>
public uint ID { get; internal set; }
/// <summary>
/// Gets a value indicating whether a specific body type is used by the game mode.
/// </summary>
public virtual bool GameModeBodyTypeOverride => false;
/// <summary>
/// Gets a value indicating whether the gamemode removes the normal game settings.
/// </summary>
public virtual bool ShowNormalGameSettings => true;
/// <summary>
/// Gets a value indicating whether the gamemode removes the normal role settings.
/// </summary>
public virtual bool ShowNormalRoleSettings => true;
/// <summary>
/// Gets a value indicating the default kill cooldown for impostors in this mode.
/// </summary>
public virtual float DefaultImpostorKillCooldown => GameOptionsManager.Instance.CurrentGameOptions.GetFloat(FloatOptionNames.KillCooldown);
/// <summary>
/// Called on GameManager.GetBodyType().
/// </summary>
/// <param name="player">Player to get body type from.</param>
/// <returns>Resulting body type.</returns>
public virtual PlayerBodyTypes GetBodyType(PlayerControl player)
{
if (AprilFoolsMode.ShouldHorseAround())
{
return PlayerBodyTypes.Horse;
}
if (AprilFoolsMode.ShouldLongAround())
{
return PlayerBodyTypes.Long;
}
return PlayerBodyTypes.Normal;
}
/// <summary>
/// Gets a value indicating whether a custom intro sequence is implemented by the game mode.
/// </summary>
public virtual bool ShowGameModeIntroCutscene => false;
/// <summary>
/// Called when Intro Cutscene is destroyed.
/// </summary>
public virtual void Initialize()
{
}
/// <summary>
/// Called on HudManager.Start().
/// </summary>
/// <param name="instance">Instance of HudManager.</param>
public virtual void HudStart(HudManager instance)
{
}
/// <summary>
/// Called every frame on HudManager.Update().
/// </summary>
/// <param name="instance">Instance of HudManager.</param>
public virtual void HudUpdate(HudManager instance)
{
}
/// <summary>
/// Called when a player is killed.
/// </summary>
/// <param name="player">PlayerControl that was killed.</param>
/// <param name="assignGhostRole">Determines whether to assign a ghost role on the player.</param>
public virtual void OnPlayerDeath(PlayerControl player, bool assignGhostRole)
{
GameManager.Instance.LogicRoleSelection.OnPlayerDeath(player, assignGhostRole);
}
/// <summary>
/// Calculate Game End logic.
/// </summary>
/// <param name="runOriginal">Should original game end logic be used.</param>
/// <param name="instance">Instance of LogicGameFlowNormal.</param>
public virtual void CheckGameEnd(out bool runOriginal, LogicGameFlowNormal instance)
{
runOriginal = true;
}
/// <summary>
/// Custom role assignment.
/// </summary>
/// <param name="runOriginal">Should original role assignment be used.</param>
/// <param name="instance">Instance of LogicRoleSelection.</param>
public virtual void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance)
{
runOriginal = true;
}
/// <summary>
/// Custom role assignment to run after all roles are handed out.
/// </summary>
/// <param name="instance">Instance of LogicRoleSelection.</param>
public virtual void PostAssignRoles(LogicRoleSelectionNormal instance)
{
}
/// <summary>
/// Custom murder logic.
/// </summary>
/// <param name="runOriginal">Should the original murder logic be used.</param>
/// <param name="result">Result of custom murder logic.</param>
/// <param name="target">Target player for murder.</param>
public virtual void CanKill(out bool runOriginal, out bool result, PlayerControl target)
{
result = false;
runOriginal = true;
}
/// <summary>
/// Custom winner selection.
/// </summary>
/// <returns>List of winners or null.</returns>
public virtual List<NetworkedPlayerInfo>? CalculateWinners() => null;
/// <summary>
/// The IEnumerator that plays the intro cutscene for this gamemode.
/// </summary>
/// <param name="__instance">An instance of IntroCutscene.</param>
/// <returns>An IEnumerator to run the intro cutscene instead of the base game one.</returns>
public virtual IEnumerator IntroCutscene(IntroCutscene __instance)
{
yield return new WaitForEndOfFrame();
}
/// <summary>
/// Can Admin be used in this gamemode.
/// </summary>
/// <param name="console">Admin Console.</param>
/// <returns>True if Admin console is enabled.</returns>
public virtual bool CanUseMapConsole(MapConsole console) => true;
/// <summary>
/// Can a body be reported in this gamemode.
/// </summary>
/// <param name="body">Target body for reporting.</param>
/// <returns>True if dead bodies can be reported.</returns>
public virtual bool CanReport(DeadBody body) => true;
/// <summary>
/// Can system consoles be used in this gamemode.
/// </summary>
/// <param name="console">System Console.</param>
/// <returns>True if system consoles are enabled in this mode.</returns>
public virtual bool CanUseSystemConsole(SystemConsole console) => true;
/// <summary>
/// Can tasks be interacted with in this gamemode.
/// </summary>
/// <param name="console">Task console.</param>
/// <returns>True if tasks are enabled in this mode.</returns>
public virtual bool CanUseTasks(Console console) => true;
/// <summary>
/// Should the sabotage map be used when attempting to open sabotage overlay.
/// </summary>
/// <param name="map">MapBehaviour object.</param>
/// <returns>True if the sabotage map should be shown.</returns>
public virtual bool ShouldShowSabotageMap(MapBehaviour map) => true;
/// <summary>
/// Gets the <see cref="MapOptions"/> to display on the map.
/// </summary>
/// <returns>The <see cref="MapOptions"/> for the gamemode.</returns>
public virtual MapOptions GetMapOptions()
{
return new MapOptions
{
Mode = PlayerControl.LocalPlayer.Data.Role.IsImpostor && !MeetingHud.Instance
? MapOptions.Modes.Sabotage
: MapOptions.Modes.Normal,
};
}
/// <summary>
/// Can a player vent in this gamemode.
/// </summary>
/// <param name="vent">Target vent.</param>
/// <param name="playerInfo">Player attempting to vent.</param>
/// <returns>True if venting is enabled in this mode.</returns>
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
/// <summary>
/// Does the task bar appear in the gamemode.
/// </summary>
/// <returns>True if the task bar is enabled in this mode.</returns>
public virtual bool ShowTaskBar => true;
public virtual void UpdateTaskPanel(TaskPanelBehaviour instance)
{
instance.background.transform.localScale = (instance.taskText.textBounds.size.x > 0f)
? new Vector3(instance.taskText.textBounds.size.x + 0.2f, instance.taskText.textBounds.size.y + 0.2f, 1f)
: Vector3.zero;
Vector3 vector = instance.background.sprite.bounds.extents;
vector.y = -vector.y;
vector = vector.Mul(instance.background.transform.localScale);
instance.background.transform.localPosition = vector;
Vector3 vector2 = instance.tab.sprite.bounds.extents;
vector2 = vector2.Mul(instance.tab.transform.localScale);
vector2.y = -vector2.y;
vector2.x += vector.x * 2f;
instance.tab.transform.localPosition = vector2;
if (GameManager.Instance == null)
{
return;
}
var yPos = 0.6f;
var xPos = -instance.background.sprite.bounds.size.x * instance.background.transform.localScale.x;
instance.closedPosition = new Vector3(xPos, yPos, instance.closedPosition.z);
instance.openPosition = new Vector3(instance.openPosition.x, yPos, instance.openPosition.z);
if (instance.open)
{
instance.timer = Mathf.Min(1f, instance.timer + Time.deltaTime / instance.animationTimeSeconds);
}
else
{
instance.timer = Mathf.Max(0f, instance.timer - Time.deltaTime / instance.animationTimeSeconds);
}
Vector3 relativePos = new(
Mathf.SmoothStep(instance.closedPosition.x, instance.openPosition.x, instance.timer),
yPos,
instance.openPosition.z);
instance.transform.localPosition =
AspectPosition.ComputePosition(AspectPosition.EdgeAlignments.LeftTop, relativePos);
}
/// <inheritdoc/>
public override string ToString() => Name;
}
+20
View File
@@ -0,0 +1,20 @@
using MiraAPI.PluginLoading;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.GameModes;
/// <summary>
/// The classic game mode.
/// </summary>
[MiraIgnore]
public class ClassicMode : AbstractGameMode
{
/// <inheritdoc/>
public override string Name => "MiraApi.Gamemode.Classic";
/// <inheritdoc/>
public override string Description => "MiraApi.Gamemode.Classic.Description";
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
}
-154
View File
@@ -1,154 +0,0 @@
using System.Collections.Generic;
namespace MiraAPI.GameModes;
/// <summary>
/// Base class for custom gamemodes.
/// </summary>
public abstract class CustomGameMode
{
/// <summary>
/// Gets the game mode name.
/// </summary>
public abstract string Name { get; }
/// <summary>
/// Gets the game mode description.
/// </summary>
public abstract string Description { get; }
/// <summary>
/// Gets the game mode ID.
/// </summary>
public abstract int Id { get; }
/// <summary>
/// Called when Intro Cutscene is destroyed.
/// </summary>
public virtual void Initialize()
{
}
/// <summary>
/// Called on HudManager.Start().
/// </summary>
/// <param name="instance">Instance of HudManager.</param>
public virtual void HudStart(HudManager instance)
{
}
/// <summary>
/// Called every frame on HudManager.Update().
/// </summary>
/// <param name="instance">Instance of HudManager.</param>
public virtual void HudUpdate(HudManager instance)
{
}
/// <summary>
/// Called when a player is killed.
/// </summary>
/// <param name="player">PlayerControl that was killed.</param>
public virtual void OnDeath(PlayerControl player)
{
}
/// <summary>
/// Calculate Game End logic.
/// </summary>
/// <param name="runOriginal">Should original game end logic be used.</param>
/// <param name="instance">Instance of LogicGameFlowNormal.</param>
public virtual void CheckGameEnd(out bool runOriginal, LogicGameFlowNormal instance)
{
runOriginal = true;
}
/// <summary>
/// Custom role assignment.
/// </summary>
/// <param name="runOriginal">Should original role assignment be used.</param>
/// <param name="instance">Instance of LogicRoleSelection.</param>
public virtual void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance)
{
runOriginal = true;
}
/// <summary>
/// Custom murder logic.
/// </summary>
/// <param name="runOriginal">Should the original murder logic be used.</param>
/// <param name="result">Result of custom murder logic.</param>
/// <param name="target">Target player for murder.</param>
public virtual void CanKill(out bool runOriginal, out bool result, PlayerControl target)
{
result = false;
runOriginal = true;
}
/// <summary>
/// Should Roles Settings be available when this gamemode is selected.
/// </summary>
/// <returns>True if Role Settings are enabled in this game mode.</returns>
public virtual bool AreRoleSettingsEnabled() => true;
/// <summary>
/// Should Game Settings be available when this gamemode is selected.
/// </summary>
/// <returns>True if Game Settings are enabled in this mode.</returns>
public virtual bool AreGameSettingsEnabled() => true;
/// <summary>
/// Custom winner selection.
/// </summary>
/// <returns>List of winners or null.</returns>
public virtual List<NetworkedPlayerInfo>? CalculateWinners() => null;
/// <summary>
/// Show gamemode in Intro Cutscene.
/// </summary>
/// <returns>True if the game mode should be shown in the intro cutscene.</returns>
public virtual bool ShowGameModeIntroCutscene() => false;
/// <summary>
/// Can Admin be used in this gamemode.
/// </summary>
/// <param name="console">Admin Console.</param>
/// <returns>True if Admin console is enabled.</returns>
public virtual bool CanUseMapConsole(MapConsole console) => true;
/// <summary>
/// Can a body be reported in this gamemode.
/// </summary>
/// <param name="body">Target body for reporting.</param>
/// <returns>True if dead bodies can be reported.</returns>
public virtual bool CanReport(DeadBody body) => true;
/// <summary>
/// Can system consoles be used in this gamemode.
/// </summary>
/// <param name="console">System Console.</param>
/// <returns>True if system consoles are enabled in this mode.</returns>
public virtual bool CanUseSystemConsole(SystemConsole console) => true;
/// <summary>
/// Can tasks be interacted with in this gamemode.
/// </summary>
/// <param name="console">Task console.</param>
/// <returns>True if tasks are enabled in this mode.</returns>
public virtual bool CanUseTasks(Console console) => true;
/// <summary>
/// Should the sabotage map be used when attempting to open sabotage overlay.
/// </summary>
/// <param name="map">MapBehaviour object.</param>
/// <returns>True if the sabotage map should be shown.</returns>
public virtual bool ShouldShowSabotageMap(MapBehaviour map) => true;
/// <summary>
/// Can a player vent in this gamemode.
/// </summary>
/// <param name="vent">Target vent.</param>
/// <param name="playerInfo">Player attempting to vent.</param>
/// <returns>True if venting is enabled in this mode.</returns>
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
}
+90 -37
View File
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MiraAPI.Translation;
using MiraAPI.PluginLoading;
using Reactor.Utilities;
namespace MiraAPI.GameModes;
@@ -10,62 +12,113 @@ namespace MiraAPI.GameModes;
/// </summary>
public static class CustomGameModeManager
{
/// <summary>
/// List of registered gamemodes.
/// </summary>
internal static readonly Dictionary<int, CustomGameMode> GameModes = [];
internal static readonly Dictionary<uint, AbstractGameMode> IdToModeMap = [];
public static bool IsDefault()
{
return ActiveMode?.Id == 0;
}
private static uint GetNextId() => ++LastId;
/// <summary>
/// Gets the current gamemode.
/// </summary>
public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode();
/// <summary>
/// Set current gamemode.
/// </summary>
/// <param name="id">gamemode ID.</param>
public static void SetGameMode(int id)
{
if (GameModes.TryGetValue(id, out var gameMode))
{
ActiveMode = gameMode;
return;
}
Error($"No gamemode with id {id} found!");
}
private static uint LastId { get; set; }
/// <summary>
/// Register gamemode from type.
/// </summary>
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="CustomGameMode"/>.</param>
internal static void RegisterGameMode(Type gameModeType)
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="AbstractGameMode"/>.</param>
/// <param name="pluginInfo">The custom plugin info of the mod.</param>
/// <returns>Whether the gamemode was successfully registered.</returns>
internal static bool RegisterGameMode(Type gameModeType, MiraPluginInfo pluginInfo)
{
if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType))
if (!typeof(AbstractGameMode).IsAssignableFrom(gameModeType))
{
Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
return;
return false;
}
var modeObj = Activator.CreateInstance(gameModeType);
var instance = Activator.CreateInstance(gameModeType);
if (modeObj is not CustomGameMode gameMode)
if (instance is not AbstractGameMode mode)
{
Error($"Failed to create instance of {gameModeType.Name}");
return;
return false;
}
if (GameModes.Any(x => x.Key == gameMode.Id))
if (!mode.HideMode)
{
Error($"ID for gamemode {gameMode.Name} already exists!");
IdToModeMap.Add(GetNextId(), mode);
pluginInfo.GameModes.Add(LastId, mode);
mode.ID = LastId;
GameModeOption.AddOption(mode);
}
return true;
}
/// <summary>
/// Checks to see if the current game mode is an instance of the classic mode.
/// </summary>
/// <returns>True if the classic mode is the current one.</returns>
public static bool IsClassic() => ActiveMode != null && ActiveMode.GetType().IsAssignableTo(typeof(ClassicMode));
/// <summary>
/// Checks to see if the current game mode is an instance of the HNS mode.
/// </summary>
/// <returns>True if the Hide n Seek mode is the current one.</returns>
public static bool IsHideNSeek() => ActiveMode != null && ActiveMode.GetType().IsAssignableTo(typeof(HideAndSeekMode));
/// <summary>
/// Checks if a provided GameMode is the current active one.
/// </summary>
/// <typeparam name="T">The AbstractGameMode subclass being checked.</typeparam>
/// <returns>Whether the provided mode is the current active one.</returns>
public static bool IsActiveGameMode<T>() where T : AbstractGameMode => ActiveMode is T;
/// <summary>
/// Gets the current gamemode.
/// </summary>
public static AbstractGameMode? ActiveMode { get; private set; }
/// <summary>
/// Gets a gamemode from an ID.
/// </summary>
/// <param name="id">The ID of the gamemode to fetch.</param>
/// <returns>The gamemode matching that ID.</returns>
public static AbstractGameMode GetMode(uint id) => IdToModeMap[id];
/// <summary>
/// Finds the parent mod of a custom gamemode.
/// </summary>
/// <param name="gameMode">The <see cref="AbstractGameMode"/> object.</param>
/// <returns>A <see cref="MiraPluginInfo"/> object representing the parent mod of the gamemode.</returns>
public static MiraPluginInfo? FindParentMod(AbstractGameMode gameMode)
{
return MiraPluginManager.Instance.RegisteredPlugins.FirstOrDefault(plugin => plugin.GameModes.ContainsValue(gameMode));
}
internal static void RegisterDefaultMode()
{
var defaultMode = new ClassicMode();
IdToModeMap.Add(0, defaultMode);
// no need to add to game mode option as it already contains it
// because we cannot have the option be created with no values
defaultMode.ID = 0;
var hnsMode = new HideAndSeekMode();
if (!hnsMode.HideMode)
{
IdToModeMap.Add(1, hnsMode);
hnsMode.ID = 1;
GameModeOption.AddOption(hnsMode);
LastId++;
}
}
internal static void GetAndSetGameMode()
{
var id = (uint)GameModeOption.Value;
if (IdToModeMap.TryGetValue(id, out var mode))
{
ActiveMode = mode;
return;
}
GameModes.Add(gameMode.Id, gameMode);
ActiveMode = IdToModeMap[0];
Logger<MiraApiPlugin>.Warning($"Unable to find game mode of id {id}!");
}
}
-8
View File
@@ -1,8 +0,0 @@
namespace MiraAPI.GameModes;
public class DefaultMode : CustomGameMode
{
public override string Name => "Default";
public override string Description => "Default Among Us GameMode";
public override int Id => 0;
}
+161
View File
@@ -0,0 +1,161 @@
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MiraAPI.GameOptions;
using MiraAPI.Networking;
using MiraAPI.Patches.GameModes;
using MiraAPI.Patches.Options;
using MiraAPI.Translation;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
using Reactor.Localization.Utilities;
using Reactor.Networking.Attributes;
using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.ProBuilder;
using Object = UnityEngine.Object;
namespace MiraAPI.GameModes;
/// <summary>
/// The game mode option.
/// </summary>
[HarmonyPatch]
public static class GameModeOption
{
/// <summary>
/// Gets the current index of the Game Mode Option
/// For the value as an <see cref="AbstractGameMode"/>, see <see cref="CustomGameModeManager.ActiveMode"/>.
/// </summary>
public static int Value
{
get =>
OptionBehaviour != null
? OptionBehaviour.GetInt()
: _lastValue;
private set
{
_lastValue = value;
if (OptionBehaviour == null)
return;
OptionBehaviour.Value = value;
OptionBehaviour.UpdateValue();
_lastValue = value;
}
}
internal static StringOption OptionBehaviour { get; set; } = null!;
internal static int _lastValue;
internal static readonly StringNames GamemodeName = MiraLocaleManager.GetOrCreateLocaleString("Gamemode");
internal static readonly StringNames CustomName = MiraLocaleManager.GetOrCreateLocaleString("Custom");
internal static readonly Dictionary<uint, StringNames> Values = new()
{
[0] = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode.Classic"),
};
internal static void AddOption(AbstractGameMode mode)
{
if (!Values.ContainsKey(mode.ID))
Values.Add(mode.ID, MiraLocaleManager.GetOrCreateLocaleString(mode.Name));
}
/*[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.CreateSettings))]
[HarmonyPostfix]
private static void CreateSettingsPatch(GameOptionsMenu __instance)
{
if (MenuState.Instance.CurrentModIdx != 0 || GameManager.Instance.IsHideAndSeek() || CustomGameModeManager.ActiveMode == null)
{
return;
}
var num = 0.713f;
foreach (var category in __instance.settingsContainer.GetComponentsInChildren<CategoryHeaderMasked>())
{
if (category)
category.gameObject.transform.localPosition -= new Vector3(0, 1.3f, 0);
}
CategoryHeaderMasked categoryHeaderMasked = Object.Instantiate(__instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, __instance.settingsContainer);
categoryHeaderMasked.SetHeader(CustomName, 20);
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f);
OptionBehaviour = Object.Instantiate(
__instance.stringOptionOrigin,
Vector3.zero,
Quaternion.identity,
__instance.settingsContainer);
num -= 0.63f;
OptionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f);
OptionBehaviour.SetClickMask(__instance.ButtonClickMask);
StringGameSetting setting = ScriptableObject.CreateInstance<StringGameSetting>();
setting.Type = OptionTypes.MultipleChoice;
setting.Title = GamemodeName;
setting.Index = _lastValue;
setting.Values = new Il2CppStructArray<StringNames>([Values[0]]);
OptionBehaviour.SetUpFromData(setting, 20);
Set(_lastValue);
OptionBehaviour.TitleText.fontSize = 3;
foreach (var optionBehaviour in __instance.Children.ToArray().Skip(1))
{
optionBehaviour.gameObject.transform.localPosition -= new Vector3(0, 1.3f, 0);
}
__instance.Children.Add(OptionBehaviour);
for (var i = 1; i < Values.Count; i++)
OptionBehaviour.Values = (Il2CppStructArray<StringNames>)OptionBehaviour.Values.Add(Values.ElementAt(i).Value);
__instance.scrollBar.SetYBoundsMax(__instance.scrollBar.GetYBounds().max + 1);
}*/
internal static void Set(int val)
{
Value = val;
var previousMode = CustomGameModeManager.ActiveMode;
CustomGameModeManager.GetAndSetGameMode();
HudPatches.SetGameModeText(CustomGameModeManager.GetMode(Values.ElementAt(_lastValue).Key).ColoredName);
var gm = CustomGameModeManager.ActiveMode!;
if (gm != previousMode)
{
ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
GamemodeName,
gm.ColoredName,
new Color(0.7333f, 0.7333f, 0.7333f, 1),
gm.TmpIcon,
true);
if (MenuState.Instance)
{
// should force reset roles for gamemodes properly
foreach (var roleMenu in MenuState.Instance.QueuedRoleMenuRefresh)
{
MenuState.Instance.QueuedRoleMenuRefresh[roleMenu.Key] = true;
}
}
}
// could make Values a dict of AbstractGameMode too
}
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.ValueChanged))]
[HarmonyPrefix]
private static bool ValueChanged(GameOptionsMenu __instance, OptionBehaviour option)
{
if (OptionBehaviour.Equals(option))
{
Info($"Game mode changed to {option.GetInt()}");
RpcSyncGamemode(PlayerControl.LocalPlayer, option.GetInt());
if (GameSettingMenu.Instance && CustomGameModeManager.ActiveMode != null)
{
GameOptionsMenuPatch.ToggleGamemodeOptions(CustomGameModeManager.ActiveMode, __instance);
GameSettingMenu.Instance.RoleSettingsButton.gameObject.SetActive(CustomGameModeManager.ActiveMode.ShowNormalRoleSettings);
}
return false;
}
return true;
}
[MethodRpc((uint) MiraRpc.SyncGamemodeOption)]
internal static void RpcSyncGamemode(PlayerControl host, int data)
{
Set(data);
}
}
+534
View File
@@ -0,0 +1,534 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using AmongUs.Data;
using AmongUs.GameOptions;
using HarmonyLib;
using InnerNet;
using MiraAPI.GameOptions;
using MiraAPI.HnsReimplemented;
using MiraAPI.HnsReimplemented.Options;
using MiraAPI.PluginLoading;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
using PowerTools;
using UnityEngine;
namespace MiraAPI.GameModes;
/// <summary>
/// The vanilla Hide and Seek game mode, ported to Mira.
/// </summary>
[MiraIgnore]
public class HideAndSeekMode : AbstractGameMode
{
/// <inheritdoc/>
public override string Name => "MiraApi.Gamemode.HideAndSeek";
/// <inheritdoc/>
public override string Description => "MiraApi.Gamemode.HideAndSeek.Description";
// TODO: Once the Hide n Seek port is ready for release, we will remove this.
public override bool HideMode => !MiraApiPlugin.IsDevBuild;
public override Color Color { get; } = new Color32(255, 88, 90, 255);
public override LoadableAsset<Sprite>? Icon => MiraAssets.HnSGamemodeIcon;
public override bool CanReport(DeadBody body) => false;
public override bool ShouldShowSabotageMap(MapBehaviour map) => false;
public override bool ShowGameModeIntroCutscene => true;
public override bool GameModeBodyTypeOverride => true;
public override bool ShowNormalGameSettings => false;
public override bool ShowNormalRoleSettings => false;
public override float DefaultImpostorKillCooldown => 1f;
public override bool ShowTaskBar => false;
public static int ImpostorPlayerID()
{
return OptionGroupSingleton<HnsImpostorOptions>.Instance.SelectedSeeker.Value;
}
public static bool HasImpostorPlayerID()
{
return ImpostorPlayerID() > -1;
}
public static bool ValidateImpostorPlayerID(List<NetworkedPlayerInfo> players)
{
return HasImpostorPlayerID() && players.Find((NetworkedPlayerInfo p) => (int)p.PlayerId == ImpostorPlayerID()) != null;
}
public override void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance)
{
runOriginal = false;
Il2CppSystem.Collections.Generic.List<ClientData> list = new();
AmongUsClient.Instance.GetAllClients(list);
List<NetworkedPlayerInfo> list2 = list.ToArray()
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
!c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data)
.ToList();
foreach (NetworkedPlayerInfo networkedPlayerInfo in GameData.Instance.AllPlayers)
{
if (networkedPlayerInfo.Object != null && networkedPlayerInfo.Object.isDummy)
{
list2.Add(networkedPlayerInfo);
}
}
IGameOptions currentGameOptions = GameOptionsManager.Instance.CurrentGameOptions;
int adjustedNumImpostors = GameOptionsManager.Instance.CurrentGameOptions.GetAdjustedNumImpostors(list2.Count);
AssignRolesForTeam(list2, currentGameOptions, RoleTeamTypes.Impostor, Math.Max(adjustedNumImpostors, 1), RoleTypes.Impostor);
AssignRolesForTeam(list2, currentGameOptions, RoleTeamTypes.Crewmate, int.MaxValue, RoleTypes.Engineer);
}
public static void AssignRolesForTeam(
List<NetworkedPlayerInfo> players,
IGameOptions opts,
RoleTeamTypes team,
int teamMax,
RoleTypes defaultRole)
{
Error($"Hide And Seek Mode - AssignRolesForTeam: Team: {team}, Max: {teamMax}, Players: {players.Count}, DefaultRole: {defaultRole}");
int num = 0;
IRoleOptionsCollection roleOptions = opts.RoleOptions;
var source = RoleManager.Instance.AllRoles.ToArray()
.Where(role => role.TeamType == team && !RoleManager.IsGhostRole(role.Role) &&
CustomRoleUtils.CanSpawnOnCurrentMode(role));
var assignmentData = source.Where(x => !x.IsDead).Select(role =>
new RoleManager.RoleAssignmentData(
role,
roleOptions.GetNumPerGame(role.Role),
roleOptions.GetChancePerGame(role.Role))).ToList();
var source2 = CustomRoleUtils.GetPossibleRoles(assignmentData, x => x.Chance == 100);
var guaranteedRoles = source.Where(x => source2.Contains(((ushort)x.Role, 100)));
List<RoleTypes> list = new List<RoleTypes>();
if (team == RoleTeamTypes.Crewmate)
{
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
{
while (true)
{
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
int count = roleAssignmentData2.Count;
roleAssignmentData2.Count = count - 1;
if (count <= 0)
{
break;
}
list.Add(roleAssignmentData.Role.Role);
}
}
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
AssignRolesFromList(players, teamMax, list, ref num);
var list2 = source.Where(x => !x.IsDead).Select(role =>
new RoleManager.RoleAssignmentData(
role,
roleOptions.GetNumPerGame(role.Role),
roleOptions.GetChancePerGame(role.Role))).ToList();
list.Clear();
foreach (RoleManager.RoleAssignmentData roleAssignmentData3 in list2)
{
for (int i = 0; i < roleAssignmentData3.Count; i++)
{
if (HashRandom.Next(101) < roleAssignmentData3.Chance)
{
list.Add(roleAssignmentData3.Role.Role);
}
}
}
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Potential Assignment");
AssignRolesFromList(players, teamMax, list, ref num);
var basicRole = RoleTypes.Engineer;
while (list.Count < players.Count && list.Count + num < teamMax)
{
list.Add(basicRole);
}
AssignRolesFromList(players, teamMax, list, ref num);
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Fallback Assignment");
}
else if (team == RoleTeamTypes.Impostor)
{
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
var newImpostors = new List<NetworkedPlayerInfo>();
// Specified Seeker
if (HasImpostorPlayerID() &&
ValidateImpostorPlayerID(players) &&
!AmongUsClient.Instance.IsGamePublic)
{
NetworkedPlayerInfo networkedPlayerInfo = players.ToArray()
.First(p => p.PlayerId == ImpostorPlayerID());
players.Remove(networkedPlayerInfo);
newImpostors.Add(networkedPlayerInfo);
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
}
// Random Seeker
else
{
int num2 = 0;
while (num2 < teamMax && players.Count > 0)
{
PseudoRandomList<NetworkedPlayerInfo> pseudoRandomList = new PseudoRandomList<NetworkedPlayerInfo>(AmongUsClient.Instance.GameId);
players.Do(x => pseudoRandomList.Add(x));
for (int i = 0; i < GameData.RoundsPlayedInSession; i++)
{
pseudoRandomList.PickRandom();
}
NetworkedPlayerInfo networkedPlayerInfo = pseudoRandomList.PickRandom();
players.Remove(networkedPlayerInfo);
newImpostors.Add(networkedPlayerInfo);
num2++;
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
}
}
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
{
while (true)
{
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
int count = roleAssignmentData2.Count;
roleAssignmentData2.Count = count - 1;
if (count <= 0)
{
break;
}
list.Add(roleAssignmentData.Role.Role);
}
}
AssignRolesFromList(newImpostors, teamMax, list, ref num);
var list2 = source.Where(x => !x.IsDead).Select(role =>
new RoleManager.RoleAssignmentData(
role,
roleOptions.GetNumPerGame(role.Role),
roleOptions.GetChancePerGame(role.Role))).ToList();
list.Clear();
foreach (RoleManager.RoleAssignmentData roleAssignmentData3 in list2)
{
for (int i = 0; i < roleAssignmentData3.Count; i++)
{
if (HashRandom.Next(101) < roleAssignmentData3.Chance)
{
list.Add(roleAssignmentData3.Role.Role);
}
}
}
AssignRolesFromList(newImpostors, teamMax, list, ref num);
var basicRole = RoleTypes.Impostor;
while (list.Count < newImpostors.Count && list.Count + num < teamMax)
{
list.Add(basicRole);
}
AssignRolesFromList(newImpostors, teamMax, list, ref num);
}
}
public static void AssignRolesFromList(List<NetworkedPlayerInfo> players, int teamMax, List<RoleTypes> roleList, ref int rolesAssigned)
{
while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
{
int index = HashRandom.FastNext(roleList.Count);
RoleTypes roleType = roleList[index];
roleList.RemoveAt(index);
int index2 = HashRandom.FastNext(players.Count);
players[index2].Object.RpcSetRole(roleType, false);
players.RemoveAt(index2);
rolesAssigned++;
}
}
public override IEnumerator IntroCutscene(IntroCutscene __instance)
{
SoundManager.Instance.PlaySound(__instance.IntroStinger, false, 1f, null);
Logger.GlobalInstance.Info("IntroCutscene :: CoBegin() :: Game Mode: Hide and Seek (MiraAPI)", null);
__instance.LogPlayerRoleData();
__instance.HideAndSeekPanels.SetActive(true);
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor)
{
__instance.CrewmateRules.SetActive(false);
__instance.ImpostorRules.SetActive(true);
}
else
{
__instance.CrewmateRules.SetActive(true);
__instance.ImpostorRules.SetActive(false);
}
__instance.ImpostorName.gameObject.SetActive(true);
__instance.ImpostorTitle.gameObject.SetActive(true);
__instance.BackgroundBar.enabled = false;
__instance.TeamTitle.gameObject.SetActive(false);
var impostor = PlayerControl.AllPlayerControls.ToArray().FirstOrDefault(x => x.Data.Role.IsImpostor);
if (impostor == null)
{
Logger.GlobalInstance.Error("IntroCutscene :: CoBegin() :: impostor is NULL", null);
}
GameManager.Instance.SetSpecialCosmetics(impostor);
if (impostor != null)
{
__instance.ImpostorName.text = impostor.Data.PlayerName;
}
else
{
__instance.ImpostorName.text = "???";
}
yield return new WaitForSecondsRealtime(0.1f);
if (impostor != null)
{
__instance.ImpostorTitle.text = impostor.Data.Role.GetRoleName();
}
PoolablePlayer playerSlot = null;
if (impostor != null)
{
playerSlot = __instance.CreatePlayer(1, 1, impostor.Data, false);
playerSlot.SetBodyType(PlayerBodyTypes.Normal);
playerSlot.SetFlipX(false);
playerSlot.transform.localPosition = __instance.impostorPos;
playerSlot.transform.localScale = Vector3.one * __instance.impostorScale;
}
yield return ShipStatus.Instance.CosmeticsCache.PopulateFromPlayers();
yield return new WaitForSecondsRealtime(6f);
if (playerSlot != null)
{
playerSlot.gameObject.SetActive(false);
}
__instance.HideAndSeekPanels.SetActive(false);
__instance.CrewmateRules.SetActive(false);
__instance.ImpostorRules.SetActive(false);
HnsMusicHandler.Instance.StartMusicWithIntro();
var hideTimer = 10f;
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor)
{
__instance.HideAndSeekTimerText.gameObject.SetActive(true);
PoolablePlayer poolablePlayer;
AnimationClip anim;
if (AprilFoolsMode.ShouldHorseAround())
{
poolablePlayer = __instance.HorseWrangleVisualSuit;
poolablePlayer.gameObject.SetActive(true);
poolablePlayer.SetBodyType(PlayerBodyTypes.Seeker);
anim = __instance.HnSSeekerSpawnHorseAnim;
__instance.HorseWrangleVisualPlayer.SetBodyType(PlayerBodyTypes.Normal);
__instance.HorseWrangleVisualPlayer.UpdateFromPlayerData(
PlayerControl.LocalPlayer.Data,
PlayerControl.LocalPlayer.CurrentOutfitType,
PlayerMaterial.MaskType.None,
false,
null,
false);
}
else if (AprilFoolsMode.ShouldLongAround())
{
poolablePlayer = __instance.HideAndSeekPlayerVisual;
poolablePlayer.gameObject.SetActive(true);
poolablePlayer.SetBodyType(PlayerBodyTypes.LongSeeker);
anim = __instance.HnSSeekerSpawnLongAnim;
}
else
{
poolablePlayer = __instance.HideAndSeekPlayerVisual;
poolablePlayer.gameObject.SetActive(true);
poolablePlayer.SetBodyType(PlayerBodyTypes.Seeker);
anim = __instance.HnSSeekerSpawnAnim;
}
poolablePlayer.SetBodyCosmeticsVisible(false);
poolablePlayer.UpdateFromPlayerData(
PlayerControl.LocalPlayer.Data,
PlayerControl.LocalPlayer.CurrentOutfitType,
PlayerMaterial.MaskType.None,
false,
null,
false);
SpriteAnim component = poolablePlayer.GetComponent<SpriteAnim>();
poolablePlayer.gameObject.SetActive(true);
poolablePlayer.ToggleName(false);
component.Play(anim, 1f);
while (hideTimer > 0f)
{
__instance.HideAndSeekTimerText.text = Mathf.RoundToInt(hideTimer).ToString();
hideTimer -= Time.deltaTime;
yield return null;
}
}
else
{
HideAndSeekHudHelper.Instance.HideCountdown = hideTimer;
if (AprilFoolsMode.ShouldHorseAround())
{
if (impostor != null)
{
impostor.AnimateCustom(__instance.HnSSeekerSpawnHorseInGameAnim);
}
}
else if (AprilFoolsMode.ShouldLongAround())
{
if (impostor != null)
{
impostor.AnimateCustom(__instance.HnSSeekerSpawnLongInGameAnim);
}
}
else if (impostor != null)
{
impostor.AnimateCustom(__instance.HnSSeekerSpawnAnim);
impostor.cosmetics.SetBodyCosmeticsVisible(false);
}
}
ShipStatus.Instance.StartSFX();
HnsMusicHandler.Instance.OnGameStart();
HnsDangerMeter.Instance.OnGameStart();
UnityEngine.Object.Destroy(__instance.gameObject);
}
public override void Initialize()
{
deadPlayerCount = 0;
ShipStatus.Instance.BreakEmergencyButton();
PlayerControl.LocalPlayer.SetKillTimer(0.01f);
if (HudManager.InstanceExists)
{
HudManager.Instance.gameObject.AddComponent<HnsMusicHandler>();
HudManager.Instance.gameObject.AddComponent<HideAndSeekHudHelper>();
HudManager.Instance.gameObject.AddComponent<HnsDangerMeter>();
}
}
public override MapOptions GetMapOptions()
{
MapOptions mapOptions = new MapOptions
{
Mode = MapOptions.Modes.Normal,
};
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor && HideAndSeekHudHelper.Instance.SeekerAdminMapEnabled(PlayerControl.LocalPlayer))
{
mapOptions.Mode = MapOptions.Modes.CountOverlay;
mapOptions.AllowMovementWhileMapOpen = true;
mapOptions.IncludeDeadBodies = false;
mapOptions.ShowLivePlayerPosition = false;
}
return mapOptions;
}
public override void CheckGameEnd(out bool runOriginal, LogicGameFlowNormal instance)
{
runOriginal = false;
if (Helpers.GetAlivePlayers().Count(x => x.Data.Role.IsImpostor) == 0)
{
instance.Manager.RpcEndGame(GameOverReason.ImpostorDisconnect, !DataManager.Player.Ads.HasPurchasedAdRemoval);
}
if (Helpers.GetAlivePlayers().Count(x => !x.Data.Role.IsImpostor) != 0)
{
if (HideAndSeekHudHelper.Instance.AllTimersExpired())
{
instance.Manager.RpcEndGame(GameOverReason.HideAndSeek_CrewmatesByTimer, !DataManager.Player.Ads.HasPurchasedAdRemoval);
}
return;
}
instance.Manager.RpcEndGame(GameOverReason.HideAndSeek_ImpostorsByKills, !DataManager.Player.Ads.HasPurchasedAdRemoval);
}
public override PlayerBodyTypes GetBodyType(PlayerControl player)
{
if (player == null || player.Data == null || player.Data.Role == null)
{
if (AprilFoolsMode.ShouldHorseAround())
{
return PlayerBodyTypes.Horse;
}
if (AprilFoolsMode.ShouldLongAround())
{
return PlayerBodyTypes.Long;
}
return PlayerBodyTypes.Normal;
}
else if (AprilFoolsMode.ShouldHorseAround())
{
if (player.Data.Role.IsImpostor)
{
return PlayerBodyTypes.Normal;
}
return PlayerBodyTypes.Horse;
}
else if (AprilFoolsMode.ShouldLongAround())
{
if (player.Data.Role.IsImpostor)
{
return PlayerBodyTypes.LongSeeker;
}
return PlayerBodyTypes.Long;
}
else
{
if (player.Data.Role.IsImpostor)
{
return PlayerBodyTypes.Seeker;
}
return PlayerBodyTypes.Normal;
}
}
public override void UpdateTaskPanel(TaskPanelBehaviour instance)
{
instance.background.transform.localScale = (instance.taskText.textBounds.size.x > 0f)
? new Vector3(instance.taskText.textBounds.size.x + 0.2f, instance.taskText.textBounds.size.y + 0.2f, 1f)
: Vector3.zero;
Vector3 vector = instance.background.sprite.bounds.extents;
vector.y = -vector.y;
vector = vector.Mul(instance.background.transform.localScale);
instance.background.transform.localPosition = vector;
Vector3 vector2 = instance.tab.sprite.bounds.extents;
vector2 = vector2.Mul(instance.tab.transform.localScale);
vector2.y = -vector2.y;
vector2.x += vector.x * 2f;
instance.tab.transform.localPosition = vector2;
if (GameManager.Instance == null)
{
return;
}
var yPos = 1.6f;
var xPos = -instance.background.sprite.bounds.size.x * instance.background.transform.localScale.x;
instance.closedPosition = new Vector3(xPos, yPos, instance.closedPosition.z);
instance.openPosition = new Vector3(instance.openPosition.x, yPos, instance.openPosition.z);
if (instance.open)
{
instance.timer = Mathf.Min(1f, instance.timer + Time.deltaTime / instance.animationTimeSeconds);
}
else
{
instance.timer = Mathf.Max(0f, instance.timer - Time.deltaTime / instance.animationTimeSeconds);
}
Vector3 relativePos = new(
Mathf.SmoothStep(instance.closedPosition.x, instance.openPosition.x, instance.timer),
yPos,
instance.openPosition.z);
instance.transform.localPosition =
AspectPosition.ComputePosition(AspectPosition.EdgeAlignments.LeftTop, relativePos);
}
private int deadPlayerCount;
public override void OnPlayerDeath(PlayerControl player, bool assignGhostRole)
{
base.OnPlayerDeath(player, assignGhostRole);
HudManager.Instance.NotifyOfDeath();
var popup = GameManagerCreator.Instance.HideAndSeekManagerPrefab.DeathPopupPrefab;
deadPlayerCount++;
var item = UnityEngine.Object.Instantiate(popup, HudManager.Instance.transform.parent);
item.Show(player, deadPlayerCount);
}
}
+72 -8
View File
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using MiraAPI.Modifiers;
using MiraAPI.Roles;
using UnityEngine;
namespace MiraAPI.GameOptions;
@@ -29,15 +31,18 @@ public abstract class AbstractOptionGroup
public virtual Type? OptionableType => null;
/// <summary>
/// Gets a value indicating whether the group should be shown in the modifiers menu. This is deprecated, please use ParentMenu!
/// Gets a value indicating whether the group should be shown in the modifiers menu.
/// </summary>
// TODO: make this not a boolean
#pragma warning disable S1133
[Obsolete("Use ParentMenu instead.")]
#pragma warning restore S1133
public virtual bool ShowInModifiersMenu => false;
/// <summary>
/// Gets a value indicating which menu the group is in.
/// </summary>
public virtual MenuCategory ParentMenu => MenuCategory.Roles;
public virtual MenuCategory ParentMenu => MenuCategory.Game;
/// <summary>
/// Gets the function that determines whether the group should be visible or not.
@@ -45,19 +50,26 @@ public abstract class AbstractOptionGroup
public virtual Func<bool> GroupVisible => () => true;
/// <summary>
/// Gets the group color. This is used to color the group in the options menu.
/// Gets the group <see cref="Color"/>. This is used to color the group in the options menu.
/// </summary>
public virtual Color GroupColor => MiraApiPlugin.DefaultHeaderColor;
/// <summary>
/// Gets the group priority. This is used to determine the order in which groups are displayed in the options menu.
/// Zero is the highest priority, and the default value is the max uint value.
/// Zero is the highest priority, and the default value is the max <see langword="uint"/> value.
/// </summary>
public virtual uint GroupPriority => uint.MaxValue;
/// <summary>
/// Gets the default notification settings for the group.
/// </summary>
public virtual OptionNotifConfiguration Configuration => new(new Color(0.7333f, 0.7333f, 0.7333f, 1));
internal bool AllOptionsHidden { get; set; }
internal CategoryHeaderMasked? Header { get; set; }
internal bool Ready { get; set; }
}
/// <summary>
@@ -69,9 +81,7 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
/// <inheritdoc />
public override Type OptionableType => typeof(T);
/// <summary>
/// Gets a value indicating which menu the group is in.
/// </summary>
/// <inheritdoc />
public override MenuCategory ParentMenu
{
get
@@ -90,11 +100,65 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
}
}
/// <summary>
/// Base class for option groups. An option group is a collection of options that are displayed together in the options menu.
/// </summary>
/// <typeparam name="T">The custom role that the group is for.</typeparam>
public abstract class AbstractRoleOptionGroup<T>() : AbstractOptionGroup<T> where T : ICustomRole
{
/// <inheritdoc />
public override Type OptionableType => typeof(T);
/// <inheritdoc />
public override MenuCategory ParentMenu => MenuCategory.Roles;
/// <inheritdoc />
public override OptionNotifConfiguration Configuration
{
get
{
var role = CustomRoleManager.CustomMiraRoles.FirstOrDefault(x => x.GetType() == OptionableType);
if (role == null)
{
return new(new Color(0.7333f, 0.7333f, 0.7333f, 1));
}
return new(role.RoleColor, role.Configuration.IconTmp);
}
}
}
/// <summary>
/// Menu categories for option groups.
/// </summary>
public enum MenuCategory
{
/// <summary>
/// Placeholder for indexing purposes. Options don't exist in the presset tab.
/// </summary>
Preset,
/// <summary>
/// Determines the option group is in the game settings tab.
/// </summary>
Game,
/// <summary>
/// Determines the option group is in the role settings tab.
/// </summary>
Roles,
/// <summary>
/// Determines the option group is in the modifier settings tab.
/// </summary>
Modifiers,
/// <summary>
/// Determines the option group is in the first custom settings tab.
/// </summary>
CustomOne,
CustomTwo
/// <summary>
/// Determines the option group is in the second custom settings tab.
/// </summary>
CustomTwo,
}
@@ -1,11 +1,12 @@
using System;
using System.Reflection;
using MiraAPI.GameOptions.OptionTypes;
using MiraAPI.Translation;
namespace MiraAPI.GameOptions.Attributes;
/// <summary>
/// Attribute for creating an enum option.
/// Attribute for creating a <see cref="ModdedEnumOption"/>.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? values = null)
@@ -13,7 +14,7 @@ public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? va
{
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
{
var opt = new ModdedEnumOption(Title, (int)(value ?? 0), enumType, values);
var opt = new ModdedEnumOption(Title.Translate(), (int)(value ?? 0), enumType, values);
return opt;
}
@@ -1,12 +1,13 @@
using System;
using System.Reflection;
using MiraAPI.GameOptions.OptionTypes;
using MiraAPI.Translation;
using MiraAPI.Utilities;
namespace MiraAPI.GameOptions.Attributes;
/// <summary>
/// A number option attribute for the modded options system.
/// Attribute for a <see cref="ModdedNumberOption"/>.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ModdedNumberOptionAttribute(
@@ -22,7 +23,7 @@ public class ModdedNumberOptionAttribute(
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
{
return new ModdedNumberOption(
Title,
Title.Translate(),
(float)(value ?? min + increment),
min,
max,
@@ -4,12 +4,13 @@ using System.Reflection;
namespace MiraAPI.GameOptions.Attributes;
/// <summary>
/// Represents an attribute that is used to define a modded option.
/// Represents an attribute that is used to define an <see cref="IModdedOption"/>.
/// </summary>
/// <param name="title">The option title.</param>
/// <param name="roleType">Optional parameter to specify a role Type.</param>
/// <param name="modeType">Optional parameter to specify a game mode Type.</param>
[AttributeUsage(AttributeTargets.Property)]
public abstract class ModdedOptionAttribute(string title, Type? roleType = null) : Attribute
public abstract class ModdedOptionAttribute(string title, Type? roleType = null, Type? modeType = null) : Attribute
{
internal IModdedOption? HolderOption { get; set; }
@@ -23,16 +24,21 @@ public abstract class ModdedOptionAttribute(string title, Type? roleType = null)
/// </summary>
protected Type? RoleType { get; private set; } = roleType;
/// <summary>
/// Gets the game mode type of the option.
/// </summary>
protected Type? ModeType { get; private set; } = modeType;
/// <summary>
/// Sets the value of the option.
/// </summary>
/// <param name="value">The new value as an object.</param>
/// <param name="value">The new value as an <see langword="object"/>.</param>
public abstract void SetValue(object value);
/// <summary>
/// Gets the value of the option.
/// </summary>
/// <returns>The value of the option as an object.</returns>
/// <returns>The value of the option as an <see langword="object"/>.</returns>
public abstract object GetValue();
internal abstract IModdedOption? CreateOption(object? value, PropertyInfo property);
@@ -1,11 +1,12 @@
using System;
using System.Reflection;
using MiraAPI.GameOptions.OptionTypes;
using MiraAPI.Translation;
namespace MiraAPI.GameOptions.Attributes;
/// <summary>
/// Attribute for a toggle option.
/// Attribute for a <see cref="ModdedToggleOption"/>.
/// </summary>
/// <param name="title">The option title.</param>
[AttributeUsage(AttributeTargets.Property)]
@@ -13,7 +14,7 @@ public class ModdedToggleOptionAttribute(string title) : ModdedOptionAttribute(t
{
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
{
var toggleOpt = new ModdedToggleOption(Title, (bool)(value ?? false));
var toggleOpt = new ModdedToggleOption(Title.Translate(), (bool)(value ?? false));
return toggleOpt;
}
+29 -19
View File
@@ -22,22 +22,32 @@ public interface IModdedOption
string Title { get; set; }
/// <summary>
/// Gets the StringName for the option, used for localization.
/// Gets or sets the parent <see cref="AbstractOptionGroup"/> of the option.
/// </summary>
AbstractOptionGroup ParentGroup { get; set; }
/// <summary>
/// Gets the notification settings for the option.
/// </summary>
OptionNotifConfiguration Configuration { get; }
/// <summary>
/// Gets the <see cref="StringNames"/> for the option, used for localization.
/// </summary>
StringNames StringName { get; }
/// <summary>
/// Gets or sets the MiraPlugin that created this option.
/// Gets or sets the <see cref="IMiraPlugin"/> that created this option.
/// </summary>
IMiraPlugin? ParentMod { get; set; }
/// <summary>
/// Gets the game setting data for the option.
/// Gets the <see cref="BaseGameSetting"/> for the option.
/// </summary>
BaseGameSetting Data { get; }
/// <summary>
/// Gets the OptionBehaviour object of the option.
/// Gets the <see cref="global::OptionBehaviour"/> object of the option.
/// </summary>
OptionBehaviour? OptionBehaviour { get; }
@@ -52,55 +62,55 @@ public interface IModdedOption
bool IncludeInPreset { get; set; }
/// <summary>
/// Gets or sets the ConfigDefinition for the option, used for BepInEx configuration.
/// Gets or sets the <see cref="BepInEx.Configuration.ConfigDefinition"/> for the option, used for BepInEx configuration.
/// </summary>
ConfigDefinition? ConfigDefinition { get; set; }
/// <summary>
/// Creates the option behaviour for the modded option.
/// </summary>
/// <param name="toggleOpt">The ToggleOption template.</param>
/// <param name="numberOpt">The NumberOption template.</param>
/// <param name="stringOpt">The StringOption template.</param>
/// <param name="playerOpt">The PlayerOption template.</param>
/// <param name="container">>The Transform container for the option.</param>
/// <returns>>The created OptionBehaviour object.</returns>
/// <param name="toggleOpt">The <see cref="ToggleOption"/> template.</param>
/// <param name="numberOpt">The <see cref="NumberOption"/> template.</param>
/// <param name="stringOpt">The <see cref="StringOption"/> template.</param>
/// <param name="playerOpt">The <see cref="PlayerOption"/> template.</param>
/// <param name="container">The <see cref="Transform"/> container for the option.</param>
/// <returns>The created <see cref="global::OptionBehaviour"/> object.</returns>
OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container);
/// <summary>
/// Gets the value as a float.
/// Gets the value as a <see langword="float"/>.
/// </summary>
/// <returns>>The value of the option as a float.</returns>
/// <returns>The value of the option as a <see langword="float"/>.</returns>
float GetFloatData();
/// <summary>
/// Gets the NetData for the option, used for network synchronization.
/// Gets the <see cref="NetData"/> for the option, used for network synchronization.
/// </summary>
/// <returns>>Returns the NetData object for the option.</returns>
/// <returns>Returns the <see cref="NetData"/> object for the option.</returns>
NetData GetNetData();
/// <summary>
/// Handles incoming network data for the option.
/// </summary>
/// <param name="data">>The byte array representing the network data.</param>
/// <param name="data">The byte array representing the network data.</param>
void HandleNetData(byte[] data);
/// <summary>
/// Saves the option to a preset configuration file.
/// </summary>
/// <param name="presetConfig">The ConfigFile representing the preset configuration.</param>
/// <param name="presetConfig">The <see cref="ConfigFile"/> representing the preset configuration.</param>
/// <param name="saveDefault">Indicates whether to save the default value instead of the current value.</param>
void SaveToPreset(ConfigFile presetConfig, bool saveDefault = false);
/// <summary>
/// Binds the option to a configuration file.
/// </summary>
/// <param name="config">The ConfigFile to bind the option to.</param>
/// <param name="config">The <see cref="ConfigFile"/> to bind the option to.</param>
void Bind(ConfigFile config);
/// <summary>
/// Loads the option from a preset configuration file, applying the values to the option's configuration.
/// </summary>
/// <param name="presetConfig">The ConfigFile representing the preset configuration.</param>
/// <param name="presetConfig">The <see cref="ConfigFile"/> representing the preset configuration.</param>
void LoadFromPreset(ConfigFile presetConfig);
}
@@ -13,7 +13,7 @@ namespace MiraAPI.GameOptions;
public class MiraNumberOptionComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
{
/// <summary>
/// Gets or sets the modded option associated with the object.
/// Gets or sets the <see cref="ModdedNumberOption"/> associated with the object.
/// </summary>
[HideFromIl2Cpp]
public ModdedNumberOption NumberOption { get; set; }
+73 -2
View File
@@ -5,6 +5,8 @@ using System.Linq;
using System.Reflection;
using BepInEx.Configuration;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using MiraAPI.GameModes;
using MiraAPI.GameOptions.Attributes;
using MiraAPI.GameOptions.OptionTypes;
using MiraAPI.Networking;
@@ -12,11 +14,13 @@ using MiraAPI.PluginLoading;
using MiraAPI.Utilities;
using Reactor.Networking.Rpc;
using Reactor.Utilities;
using TMPro;
using UnityEngine;
namespace MiraAPI.GameOptions;
/// <summary>
/// Handles modded options.
/// Handles <see cref="IModdedOption"/>s.
/// </summary>
public static class ModdedOptionsManager
{
@@ -24,12 +28,67 @@ public static class ModdedOptionsManager
private static readonly Dictionary<Type, AbstractOptionGroup> TypeToGroup = [];
internal static readonly Dictionary<OptionBehaviour, ModdedPlayerOption> CreatedPlayerOptions = [];
internal static readonly Dictionary<OptionBehaviour, ModdedStringOption> CreatedStringOptions = [];
internal static readonly Dictionary<Type, List<AbstractOptionGroup>> GameModeOptionGroups = [];
internal static readonly Dictionary<uint, IModdedOption> ModdedOptions = [];
internal static readonly List<AbstractOptionGroup> Groups = [];
internal static uint NextId => _nextId++;
private static uint _nextId = 1;
public static void AddSettingsChangeMessage(NotificationPopper notif, StringNames key, string value, Color textColor, TMP_SpriteAsset? sprite, bool playSound = true)
{
string item;
var text = textColor.ToTextColor();
if (sprite != null)
{
item = TranslationController.Instance.GetString(
StringNames.LobbyChangeSettingNotification,
string.Concat(
"<sprite name=\"",
sprite.name,
"\"><font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">",
text,
TranslationController.Instance.GetString(key),
"</color></font>"),
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + value + "</font>"
);
}
else
{
item = TranslationController.Instance.GetString(
StringNames.LobbyChangeSettingNotification,
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" +
text +
TranslationController.Instance.GetString(key) + "</color></font>",
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + value + "</font>");
}
notif.SettingsChangeMessageLogic(key, item, playSound);
}
internal static bool RegisterGroup(Type type)
{
if (Activator.CreateInstance(type) is not AbstractOptionGroup group)
{
return false;
}
if (TypeToGroup.ContainsKey(type))
{
Logger<MiraApiPlugin>.Error($"Group {type.Name} already exists.");
return false;
}
Groups.Add(group);
TypeToGroup.Add(type, group);
typeof(OptionGroupSingleton<>).MakeGenericType(type)
.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)!
.SetValue(null, group);
return true;
}
internal static bool RegisterGroup(Type type, MiraPluginInfo pluginInfo)
{
if (Activator.CreateInstance(type) is not AbstractOptionGroup group)
@@ -45,6 +104,17 @@ public static class ModdedOptionsManager
Groups.Add(group);
TypeToGroup.Add(type, group);
if (group.OptionableType?.IsAssignableTo(typeof(AbstractGameMode)) == true)
{
if (GameModeOptionGroups.TryGetValue(group.OptionableType, out var oldList))
{
oldList.Add(group);
}
else
{
GameModeOptionGroups.Add(group.OptionableType, new List<AbstractOptionGroup>() { group });
}
}
pluginInfo.InternalOptionGroups.Add(group);
typeof(OptionGroupSingleton<>).MakeGenericType(type)
@@ -123,6 +193,7 @@ public static class ModdedOptionsManager
option.ConfigDefinition = new ConfigDefinition(groupName, propertyName);
option.ParentGroup = group;
option.ParentMod = pluginInfo.MiraPlugin;
pluginInfo.InternalOptions.Add(option);
ModdedOptions.Add(option.Id, option);
@@ -192,7 +263,7 @@ public static class ModdedOptionsManager
/// </summary>
/// <param name="__originalMethod">The original getter method.</param>
/// <param name="__result">The result of the property getter.</param>
/// <returns>False so the original getter gets skipped.</returns>
/// <returns><see langword="false"/> so the original getter gets skipped.</returns>
#pragma warning disable CA1707
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony naming convention")]
public static bool PropertyGetterPatch(MethodBase __originalMethod, ref object __result)
@@ -1,8 +1,10 @@
using System.Linq;
using MiraAPI.PluginLoading;
namespace MiraAPI.GameOptions;
#pragma warning disable CA1852
[MiraIgnore]
internal class ModifierOptionGroup : AbstractOptionGroup
#pragma warning restore CA1852
{
Loaded 100 of 319 files, more files were not shown because too many files have changed in this diff. Show more