mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 11:39:45 +00:00
Compare commits
977
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7f3f9d5da | ||
|
|
5d54a0c2d3 | ||
|
|
cf1a75f5ea | ||
|
|
721bd20d2b | ||
|
|
0e3b6be5be | ||
|
|
06c746c632 | ||
|
|
95819cf83a | ||
|
|
d1d11e2bec | ||
|
|
b4ed14f7f2 | ||
|
|
951af42358 | ||
|
|
27e14488af | ||
|
|
9ab87955bb | ||
|
|
0141dfdea4 | ||
|
|
cd97fab3a2 | ||
|
|
3cd8db1f04 | ||
|
|
535967475d | ||
|
|
6fd5993959 | ||
|
|
b713599c13 | ||
|
|
f44ec15804 | ||
|
|
847a4dd287 | ||
|
|
83d55d409b | ||
|
|
7a00ea9174 | ||
|
|
22716b29ab | ||
|
|
43291bda50 | ||
|
|
d4a675f2a9 | ||
|
|
00c5c5c4ff | ||
|
|
abb6f3d161 | ||
|
|
eef098317e | ||
|
|
1c097b47df | ||
|
|
6fe2750545 | ||
|
|
a57f40fa79 | ||
|
|
54bfd3002b | ||
|
|
4c38189444 | ||
|
|
14ce020208 | ||
|
|
877fc15aec | ||
|
|
2160d1d823 | ||
|
|
4d187f3f79 | ||
|
|
4e37f8b3d4 | ||
|
|
015d175aa0 | ||
|
|
ca7da0c343 | ||
|
|
72fa908cb0 | ||
|
|
58067d9f21 | ||
|
|
b8b85e2bc3 | ||
|
|
043845ee11 | ||
|
|
df7c182abb | ||
|
|
2a4d16e65e | ||
|
|
9606871cbe | ||
|
|
ae45c506cb | ||
|
|
fd01273635 | ||
|
|
840761787f | ||
|
|
615d527c86 | ||
|
|
7628a41d86 | ||
|
|
121baeb178 | ||
|
|
0cf4954eaf | ||
|
|
8f403f5408 | ||
|
|
2f5c382ece | ||
|
|
1ab0c3f4a7 | ||
|
|
0230d98642 | ||
|
|
04b7a9905d | ||
|
|
317e0b6ea9 | ||
|
|
cbe44a40d0 | ||
|
|
d5c3905684 | ||
|
|
49d16b707c | ||
|
|
3eb5bfae01 | ||
|
|
b1293081fc | ||
|
|
83751a25a9 | ||
|
|
bd58fca7bd | ||
|
|
63d1003b2b | ||
|
|
0645c32cca | ||
|
|
8beabb20a2 | ||
|
|
3f28d70308 | ||
|
|
b919c55ef1 | ||
|
|
55a2161876 | ||
|
|
4ca2249fbd | ||
|
|
fc94c8e67e | ||
|
|
83e550c1f2 | ||
|
|
edee889ffe | ||
|
|
119d4c5152 | ||
|
|
c99f468abf | ||
|
|
adde6db1d0 | ||
|
|
0012fe8cd6 | ||
|
|
9148a1e8da | ||
|
|
8c5aee4beb | ||
|
|
30a39fa223 | ||
|
|
228ed9711a | ||
|
|
7c085b1072 | ||
|
|
8750e5c894 | ||
|
|
1b40b1c5e4 | ||
|
|
0a0ad74419 | ||
|
|
992bdbcbf8 | ||
|
|
f9721a8d69 | ||
|
|
e541840da9 | ||
|
|
eb18d82d8e | ||
|
|
7afd899e56 | ||
|
|
5cccc192b1 | ||
|
|
9d7e41a3c9 | ||
|
|
662b52f78d | ||
|
|
dac1d82d5c | ||
|
|
1b718092ee | ||
|
|
3eb0a4fdb3 | ||
|
|
850e82155c | ||
|
|
ff30d5fdd6 | ||
|
|
2eecba2e51 | ||
|
|
84321f290e | ||
|
|
d8d3cc202a | ||
|
|
e08e7e5f4b | ||
|
|
a5f0ed5975 | ||
|
|
d1f5e56cb9 | ||
|
|
127e3f600e | ||
|
|
47e02d3dcf | ||
|
|
f53e4fdc38 | ||
|
|
b1f0ec6da3 | ||
|
|
d0d5056e39 | ||
|
|
57e3f20cba | ||
|
|
7fdfd506e0 | ||
|
|
edf61e722f | ||
|
|
791daa08ad | ||
|
|
e4d2509895 | ||
|
|
62c8e27535 | ||
|
|
8852c014ab | ||
|
|
adb9a2823d | ||
|
|
ff658db6f1 | ||
|
|
750e00d06d | ||
|
|
3a5a397846 | ||
|
|
c846109d07 | ||
|
|
e3b0eb68c0 | ||
|
|
90921ff786 | ||
|
|
c1d0bb5d26 | ||
|
|
25a55b1b60 | ||
|
|
af2cc9a3c1 | ||
|
|
e9730f018d | ||
|
|
1d316bb02f | ||
|
|
c59ed8eaa6 | ||
|
|
2eac3d04f1 | ||
|
|
154b50fd76 | ||
|
|
390e4c1157 | ||
|
|
35b444854a | ||
|
|
8e5028c236 | ||
|
|
ad113a47ab | ||
|
|
59b8e92c48 | ||
|
|
d313089521 | ||
|
|
0852f769ae | ||
|
|
ae4b4d872b | ||
|
|
b33a66cbd9 | ||
|
|
ac87003d0a | ||
|
|
f7de7f127d | ||
|
|
d2fafc3650 | ||
|
|
0c0157fed2 | ||
|
|
e095e2da6a | ||
|
|
90bf402cbc | ||
|
|
50cb8ffc3d | ||
|
|
4f4b880ad4 | ||
|
|
b627006ba1 | ||
|
|
b0ceb129a4 | ||
|
|
bf7c800613 | ||
|
|
990bac4c06 | ||
|
|
08c6883a0d | ||
|
|
3066720e6e | ||
|
|
af363000c7 | ||
|
|
245f2e6919 | ||
|
|
fed3abafb2 | ||
|
|
925d47a275 | ||
|
|
45a3597ab2 | ||
|
|
faeb39d3de | ||
|
|
6b46cffe5e | ||
|
|
00a60bb7ad | ||
|
|
d89bce6956 | ||
|
|
7f92e94293 | ||
|
|
6199e55110 | ||
|
|
eac442443b | ||
|
|
6321753ec0 | ||
|
|
e66d45bd21 | ||
|
|
1e00181220 | ||
|
|
77c13bebdc | ||
|
|
fcd7856571 | ||
|
|
5680d27db1 | ||
|
|
00eaa2601c | ||
|
|
49d77fcf40 | ||
|
|
dcb4a3876f | ||
|
|
ba2deb66f1 | ||
|
|
bb5c212e97 | ||
|
|
f59e0af7e8 | ||
|
|
8f3a137877 | ||
|
|
44415019cc | ||
|
|
7125374cda | ||
|
|
cff46ebd19 | ||
|
|
9270de408d | ||
|
|
8940de76bb | ||
|
|
1813fe5a84 | ||
|
|
272b14f0e0 | ||
|
|
8b19271e34 | ||
|
|
c29e882d7e | ||
|
|
fdfb876b44 | ||
|
|
205eee96b2 | ||
|
|
8774c9da70 | ||
|
|
51c7e248f9 | ||
|
|
02f9c20804 | ||
|
|
6cc1d4b762 | ||
|
|
9dfad78df6 | ||
|
|
7f506000a4 | ||
|
|
795b6a81d7 | ||
|
|
bd8d7a3208 | ||
|
|
e8536e5d4b | ||
|
|
090db766b2 | ||
|
|
1f0027108e | ||
|
|
665724010d | ||
|
|
2d58c91289 | ||
|
|
b3ed6d67f9 | ||
|
|
64ef78e3a2 | ||
|
|
5e9e4012ef | ||
|
|
fe04a7033a | ||
|
|
ba0ee49255 | ||
|
|
97528b4380 | ||
|
|
50030c113b | ||
|
|
20e51cc993 | ||
|
|
64b5e01ba1 | ||
|
|
d4469153ab | ||
|
|
ab67c233d8 | ||
|
|
c72eacc7a2 | ||
|
|
13072d6834 | ||
|
|
c6342750ef | ||
|
|
5c2e95376d | ||
|
|
067859b9fd | ||
|
|
fe3bfcdbc4 | ||
|
|
5d01462a32 | ||
|
|
a9b6f40ed0 | ||
|
|
eae0024ec3 | ||
|
|
2907564d6a | ||
|
|
7ad003ed1e | ||
|
|
93eea6ea2f | ||
|
|
8e09b7fee0 | ||
|
|
1e4894538c | ||
|
|
303aedafc7 | ||
|
|
8ed4355504 | ||
|
|
76b02835a7 | ||
|
|
8d5bc710e7 | ||
|
|
798ce451d5 | ||
|
|
136bbde516 | ||
|
|
5252620108 | ||
|
|
c9b1c57774 | ||
|
|
d97df1a891 | ||
|
|
e93ef6fd1d | ||
|
|
3afe437101 | ||
|
|
62c01b2f72 | ||
|
|
089d2c1ea5 | ||
|
|
c65511d03e | ||
|
|
aee304fb96 | ||
|
|
11ba564eed | ||
|
|
259b9b7097 | ||
|
|
7e3a279b56 | ||
|
|
1fd2dd3539 | ||
|
|
3f60bcae2c | ||
|
|
fe1580bb7e | ||
|
|
8b23021b2a | ||
|
|
fdc715dac2 | ||
|
|
e1ca50be3e | ||
|
|
bf9b34e728 | ||
|
|
baf80618bb | ||
|
|
7d1976f772 | ||
|
|
4ce24c2a00 | ||
|
|
7fa75946fd | ||
|
|
43f92d4dc2 | ||
|
|
ee22b776eb | ||
|
|
f31349f6e8 | ||
|
|
448e2f9152 | ||
|
|
dde7e70406 | ||
|
|
713a7a2bcc | ||
|
|
056a9b6102 | ||
|
|
4b144a782d | ||
|
|
ae917a9c77 | ||
|
|
7a8d608b17 | ||
|
|
6503bbecb7 | ||
|
|
cb794c3fc2 | ||
|
|
88329bef79 | ||
|
|
eb7abecd75 | ||
|
|
fc9e9740be | ||
|
|
3c51c88963 | ||
|
|
e42f5e6029 | ||
|
|
61be7dda82 | ||
|
|
3220a4a820 | ||
|
|
8fd142a92e | ||
|
|
fcec6ad6e5 | ||
|
|
10a7ffe886 | ||
|
|
7e541733b7 | ||
|
|
99a275a97c | ||
|
|
67a5f0dd67 | ||
|
|
f13d46ec18 | ||
|
|
f9096b6160 | ||
|
|
8bf101534f | ||
|
|
479323acdd | ||
|
|
50c5899f4d | ||
|
|
fd719ae42f | ||
|
|
e050b043cb | ||
|
|
e78c456636 | ||
|
|
7e8d07672c | ||
|
|
77ae01c66a | ||
|
|
ce824f05fa | ||
|
|
b5fe3c7afd | ||
|
|
1750cd3db9 | ||
|
|
4dd2554b38 | ||
|
|
e5cfd8a2fc | ||
|
|
6d387cae96 | ||
|
|
59f3058685 | ||
|
|
9dfb40d7bf | ||
|
|
ffca13e6e6 | ||
|
|
c1d2868e77 | ||
|
|
18c52e0138 | ||
|
|
b64bf7c9de | ||
|
|
e98c16b9f5 | ||
|
|
e166efa666 | ||
|
|
8da80be027 | ||
|
|
af75cc3606 | ||
|
|
0f1962394a | ||
|
|
36991f34ee | ||
|
|
ae5f3783b4 | ||
|
|
12a1908c3e | ||
|
|
8246e05da6 | ||
|
|
c75e039141 | ||
|
|
ac66e0d62b | ||
|
|
c4cbf0b18d | ||
|
|
f3175990d3 | ||
|
|
790d868759 | ||
|
|
9f11874189 | ||
|
|
1b6a2c4eb3 | ||
|
|
81887c34d9 | ||
|
|
810fd54e10 | ||
|
|
5492c2b3cc | ||
|
|
f7a515882a | ||
|
|
89eb774501 | ||
|
|
5fd57633ff | ||
|
|
834d1d878e | ||
|
|
790b37e8d3 | ||
|
|
dfa8b29710 | ||
|
|
da7aab9aa2 | ||
|
|
2c0042e6a8 | ||
|
|
70f63f8b16 | ||
|
|
03a3733966 | ||
|
|
3d274c2f61 | ||
|
|
b94e20c6f7 | ||
|
|
5a0428c7c0 | ||
|
|
c41dd27f88 | ||
|
|
6872ca6866 | ||
|
|
4b7fa906b9 | ||
|
|
b7173d18ab | ||
|
|
ffc7a1a4fd | ||
|
|
a1611f5f7a | ||
|
|
1664aa1003 | ||
|
|
af3d99eafe | ||
|
|
94197e38dd | ||
|
|
97a0b2084a | ||
|
|
1d87790212 | ||
|
|
9d130a53de | ||
|
|
d8afc6887d | ||
|
|
c0a406610d | ||
|
|
d73c21936c | ||
|
|
449192f0ef | ||
|
|
f3614b9a5c | ||
|
|
a62c6d496c | ||
|
|
bebd648691 | ||
|
|
ecadfa86dd | ||
|
|
5ad53f695f | ||
|
|
31a9c0c98d | ||
|
|
ea389b986f | ||
|
|
ef85fab6a6 | ||
|
|
b2fdaaf89f | ||
|
|
e6043b6f5f | ||
|
|
ffe0db0e9e | ||
|
|
705ef64b4d | ||
|
|
ebdb4a09ca | ||
|
|
ac113b6a7f | ||
|
|
1f6962efe9 | ||
|
|
6b37b9c09c | ||
|
|
f515516937 | ||
|
|
8b2d24ccc1 | ||
|
|
57bab258e5 | ||
|
|
04d5e72caa | ||
|
|
b4e6e448f2 | ||
|
|
b19a0178ad | ||
|
|
8a71f13874 | ||
|
|
809e7a07ab | ||
|
|
47394c6afe | ||
|
|
a2a1e91439 | ||
|
|
2f5ca32475 | ||
|
|
5fb59408fa | ||
|
|
57c842ece6 | ||
|
|
63e552245d | ||
|
|
43d7f80660 | ||
|
|
45291b0e98 | ||
|
|
45972f71a9 | ||
|
|
a6f7171b71 | ||
|
|
e6d3819517 | ||
|
|
b97ada22bc | ||
|
|
5f67960b28 | ||
|
|
b4e30b2b68 | ||
|
|
2237d3a2df | ||
|
|
e708c23f81 | ||
|
|
3ca33b1d86 | ||
|
|
8967348cd3 | ||
|
|
305d2c3714 | ||
|
|
85a0275eea | ||
|
|
f006deab3f | ||
|
|
a274f23e65 | ||
|
|
f1a5aef581 | ||
|
|
ce15e93e59 | ||
|
|
08ca995eb1 | ||
|
|
453259df98 | ||
|
|
2ec3eec370 | ||
|
|
2ee8730ba4 | ||
|
|
c89e5938cc | ||
|
|
513be01c02 | ||
|
|
01fa1f0915 | ||
|
|
355eef509b | ||
|
|
763a493283 | ||
|
|
68e421bf91 | ||
|
|
c343ab5e9f | ||
|
|
9c1ef70ea7 | ||
|
|
c0c8fa08ff | ||
|
|
e7fba386aa | ||
|
|
72e5e0c137 | ||
|
|
4422072060 | ||
|
|
8145c8e599 | ||
|
|
afd6fbc3b6 | ||
|
|
74741b41a7 | ||
|
|
f98429b5f9 | ||
|
|
bf7edb30ab | ||
|
|
b4527014b7 | ||
|
|
277391ef1c | ||
|
|
dfe124d67a | ||
|
|
2b06633488 | ||
|
|
4784b1f0ad | ||
|
|
d9d0d6bc62 | ||
|
|
6b3038f397 | ||
|
|
4e1db039a0 | ||
|
|
62bee24789 | ||
|
|
2156c80467 | ||
|
|
0ff60071c2 | ||
|
|
de2f3f0d95 | ||
|
|
05f132c506 | ||
|
|
ab54c44434 | ||
|
|
bf652b68c3 | ||
|
|
00377c7926 | ||
|
|
55555604f3 | ||
|
|
de77a9fa92 | ||
|
|
eba2a037d3 | ||
|
|
bc7f772de9 | ||
|
|
f43191c4f2 | ||
|
|
cd818a18cf | ||
|
|
56d4e399d9 | ||
|
|
0d41ebbc13 | ||
|
|
9388ff487a | ||
|
|
720491e5cf | ||
|
|
9884df356e | ||
|
|
7ec4addacc | ||
|
|
bc9bc0ce24 | ||
|
|
aff1c311fa | ||
|
|
0d2a9d9700 | ||
|
|
669c541279 | ||
|
|
2e5f9639b3 | ||
|
|
e6d1f440c8 | ||
|
|
2ac8bdc240 | ||
|
|
d5d99001ea | ||
|
|
5628b79814 | ||
|
|
72a44f65f1 | ||
|
|
db6a336a63 | ||
|
|
90b23ec2ca | ||
|
|
20e927208c | ||
|
|
13ef3bdd49 | ||
|
|
b3ff6755bb | ||
|
|
67604600cd | ||
|
|
6e35de6185 | ||
|
|
a26ec51c7d | ||
|
|
3f6ae4cc41 | ||
|
|
15a2cdcd5b | ||
|
|
cf0bd6ec38 | ||
|
|
130236e899 | ||
|
|
3b7b247ac0 | ||
|
|
52de9a22de | ||
|
|
372a9e3aa9 | ||
|
|
10a9dcfa34 | ||
|
|
d46fdb0185 | ||
|
|
a361afbcbf | ||
|
|
24cdac0243 | ||
|
|
5fe75843ad | ||
|
|
a0436dcbba | ||
|
|
35be381a77 | ||
|
|
1298beb517 | ||
|
|
d41c19a176 | ||
|
|
476f4400ad | ||
|
|
2b46d90570 | ||
|
|
ae4aaf7af9 | ||
|
|
757b9436ca | ||
|
|
7ea10afffb | ||
|
|
0ab80c42f9 | ||
|
|
bc144568f4 | ||
|
|
07f402e659 | ||
|
|
1a6aed539a | ||
|
|
023cdaa470 | ||
|
|
98dd5ca056 | ||
|
|
1f3e21ce19 | ||
|
|
15e441dd71 | ||
|
|
8c67bbbd44 | ||
|
|
aa584a8f44 | ||
|
|
a8a584b61b | ||
|
|
acc4b1c8dd | ||
|
|
f9600bc906 | ||
|
|
f3da06870f | ||
|
|
9180dec9e1 | ||
|
|
ef6dedbd55 | ||
|
|
5d3c3ed319 | ||
|
|
5b22d667fd | ||
|
|
fb894c9f2c | ||
|
|
d0449f57b5 | ||
|
|
5ffd591258 | ||
|
|
cc0ac1b988 | ||
|
|
00b96f6e61 | ||
|
|
6cb7f9f145 | ||
|
|
b94472ee07 | ||
|
|
f8056c29da | ||
|
|
e7f9a3bb60 | ||
|
|
8d4f2baf1e | ||
|
|
11ba3dae64 | ||
|
|
86145f94f4 | ||
|
|
a9ded0b313 | ||
|
|
e0da386567 | ||
|
|
6f1da2de9f | ||
|
|
b85358e304 | ||
|
|
2c901bb9b9 | ||
|
|
68f40a96b7 | ||
|
|
a96ffc42f2 | ||
|
|
0907b14893 | ||
|
|
7a7204b0e0 | ||
|
|
e57e88c179 | ||
|
|
878eab25b8 | ||
|
|
e4f15f2ed9 | ||
|
|
bdc9fa28ac | ||
|
|
64604aff98 | ||
|
|
32a44d646d | ||
|
|
8f590b94a8 | ||
|
|
3ba71d8f19 | ||
|
|
96a47d480a | ||
|
|
bb72d885cf | ||
|
|
e242975d75 | ||
|
|
be6bc07a62 | ||
|
|
a6d55ec90f | ||
|
|
e5b6400eb8 | ||
|
|
0d1d1891a8 | ||
|
|
54d85a6996 | ||
|
|
531a799a24 | ||
|
|
3e6eb49d93 | ||
|
|
3fabe85a18 | ||
|
|
a3fc847d07 | ||
|
|
ddfad0752d | ||
|
|
f1846375ca | ||
|
|
fcb693e899 | ||
|
|
21bec074fa | ||
|
|
30516104aa | ||
|
|
e7508e299b | ||
|
|
b0cd1d30b3 | ||
|
|
9f3a40b48f | ||
|
|
31ffe6274c | ||
|
|
91c9a27df8 | ||
|
|
7484dd1a9f | ||
|
|
9c9964eecf | ||
|
|
78fad65b97 | ||
|
|
aef4d6daf1 | ||
|
|
87b94b1b6d | ||
|
|
cf92b97e8b | ||
|
|
bd0aa68cb8 | ||
|
|
f43a542134 | ||
|
|
efd176f7a4 | ||
|
|
b2fabdb139 | ||
|
|
a651099217 | ||
|
|
e2f39c29a8 | ||
|
|
140b697aaf | ||
|
|
a56b6d52ef | ||
|
|
3a36acd131 | ||
|
|
3adb7ef018 | ||
|
|
8c763e2a57 | ||
|
|
2df50112eb | ||
|
|
ce330325e4 | ||
|
|
516cc83170 | ||
|
|
89cd32d4a4 | ||
|
|
f0e37daf0e | ||
|
|
71e2f2e375 | ||
|
|
a5ddec48c8 | ||
|
|
9e6524817a | ||
|
|
5f4461f7e5 | ||
|
|
5e2ca191ba | ||
|
|
5af10b52a4 | ||
|
|
a0d3afc7c7 | ||
|
|
2e769d79f2 | ||
|
|
41305ad0e2 | ||
|
|
a8ac00d270 | ||
|
|
3cd7acbc70 | ||
|
|
ce583d11de | ||
|
|
31132e6e65 | ||
|
|
1a53e2b045 | ||
|
|
2418e17af6 | ||
|
|
6fb0afe14e | ||
|
|
32b368c1ef | ||
|
|
103c32f386 | ||
|
|
662b867dc5 | ||
|
|
adae0225e9 | ||
|
|
0d347b8b1b | ||
|
|
ab0063dd99 | ||
|
|
a35bf60870 | ||
|
|
692b9d7180 | ||
|
|
b99efaa420 | ||
|
|
2ecfa267d6 | ||
|
|
4fad586aa7 | ||
|
|
6d51e6806a | ||
|
|
b28a0a1253 | ||
|
|
51b54d4340 | ||
|
|
ea9bf162ea | ||
|
|
57105f487b | ||
|
|
c5e424e8ff | ||
|
|
d3b40aec5a | ||
|
|
521e5a12fd | ||
|
|
e6e4a86546 | ||
|
|
9afe821b0f | ||
|
|
a8d076656d | ||
|
|
be46ee7329 | ||
|
|
75a15dc090 | ||
|
|
cffb104392 | ||
|
|
bb0b678747 | ||
|
|
429b64fc03 | ||
|
|
bf5dadc6a0 | ||
|
|
b2137230da | ||
|
|
f48143610c | ||
|
|
9e8c05f21d | ||
|
|
2cfc5ac039 | ||
|
|
2f56c95b39 | ||
|
|
38f72c42a3 | ||
|
|
71b537dba9 | ||
|
|
e9beb3b423 | ||
|
|
5b608f5b3a | ||
|
|
23c0397afe | ||
|
|
2248726450 | ||
|
|
c60537cbd1 | ||
|
|
7917d4b5d9 | ||
|
|
bf795a2e36 | ||
|
|
144a95fa3b | ||
|
|
e25b78705b | ||
|
|
19ba9da2c3 | ||
|
|
ce9864ae8b | ||
|
|
8f76f21cb1 | ||
|
|
bc7b835dc8 | ||
|
|
f0b2f9ee2a | ||
|
|
25eafe664b | ||
|
|
db327604c5 | ||
|
|
1462061df9 | ||
|
|
fb40664bd0 | ||
|
|
3cba870980 | ||
|
|
ab2f03ee4d | ||
|
|
645d1dad1c | ||
|
|
a04e0d28db | ||
|
|
b04d9619b8 | ||
|
|
33fd657eb3 | ||
|
|
529fc89fc5 | ||
|
|
6ab283d39c | ||
|
|
08d8a48701 | ||
|
|
708534ed5c | ||
|
|
886ef0e31f | ||
|
|
0b9e54eb50 | ||
|
|
bad6648f44 | ||
|
|
86f970c989 | ||
|
|
7aafaf478c | ||
|
|
7890ec9456 | ||
|
|
8bb191270f | ||
|
|
451a626370 | ||
|
|
e02c06ca07 | ||
|
|
e43cd0ceff | ||
|
|
e680b5c872 | ||
|
|
b6f304fe1d | ||
|
|
e52f48c20d | ||
|
|
d97588b356 | ||
|
|
68304a5eb8 | ||
|
|
f2add2a65b | ||
|
|
bbff2dd2d9 | ||
|
|
664f8cb2e8 | ||
|
|
d9081ed17b | ||
|
|
6f248221d6 | ||
|
|
989b511276 | ||
|
|
b67fdf5ab1 | ||
|
|
26afd47d2a | ||
|
|
2e0ecd95a6 | ||
|
|
669d5765e6 | ||
|
|
309094bdf8 | ||
|
|
49d09bb44f | ||
|
|
f77b694e78 | ||
|
|
e3cf884975 | ||
|
|
3d91c8de25 | ||
|
|
3387564f2d | ||
|
|
9e2787b781 | ||
|
|
90ed9b2a98 | ||
|
|
530cb79981 | ||
|
|
6f4eff7b38 | ||
|
|
2159b6aa89 | ||
|
|
9ec270bd68 | ||
|
|
c9ff839f12 | ||
|
|
d1116b3fce | ||
|
|
65a81d0fb4 | ||
|
|
26b94b0127 | ||
|
|
6443b5932b | ||
|
|
a619a975d7 | ||
|
|
81834a7f1a | ||
|
|
3015c6dd6a | ||
|
|
0e2eeea069 | ||
|
|
7e4a71739c | ||
|
|
caa27642db | ||
|
|
4a8fb38380 | ||
|
|
66375e884f | ||
|
|
9ae9094a85 | ||
|
|
1c6fa9a84d | ||
|
|
0ebec6d0f1 | ||
|
|
0bed367eda | ||
|
|
176a1d5e5c | ||
|
|
fb19b4bc04 | ||
|
|
8fb8d18be9 | ||
|
|
b1846fae26 | ||
|
|
8b8f9ea5db | ||
|
|
bbec3c1958 | ||
|
|
758b1d3183 | ||
|
|
d8131d1f5d | ||
|
|
9ccf7104cb | ||
|
|
bc12c5a5f7 | ||
|
|
5dfbd5dc8f | ||
|
|
84c8f743f8 | ||
|
|
3905a3b394 | ||
|
|
fb5ff4b53e | ||
|
|
047312a197 | ||
|
|
8e0a8f0585 | ||
|
|
4849b52b47 | ||
|
|
9cc9a137cc | ||
|
|
055b097c21 | ||
|
|
87187fe205 | ||
|
|
975e8cb9b7 | ||
|
|
6775294a19 | ||
|
|
2af89a678f | ||
|
|
dda46e5903 | ||
|
|
ba92d9608c | ||
|
|
52ff4bfbfc | ||
|
|
b6dda5f970 | ||
|
|
9504862bea | ||
|
|
4b6ffc65df | ||
|
|
ccde63068b | ||
|
|
5e16429acf | ||
|
|
65cd177551 | ||
|
|
7801f81052 | ||
|
|
1e47500686 | ||
|
|
2d59b29c15 | ||
|
|
a62c75a13b | ||
|
|
c85cf7ef2f | ||
|
|
ead28339b0 | ||
|
|
0b1cf998f8 | ||
|
|
14a3669031 | ||
|
|
ae79cd87d9 | ||
|
|
fb99f02549 | ||
|
|
8382b9adf1 | ||
|
|
cb1a818377 | ||
|
|
e950278bf9 | ||
|
|
3de9482233 | ||
|
|
4508aaeb55 | ||
|
|
9177d5b456 | ||
|
|
284a0f58b1 | ||
|
|
47dfa63423 | ||
|
|
1b261d7287 | ||
|
|
ee15a1acbe | ||
|
|
113c716fd3 | ||
|
|
f7c34fb5cd | ||
|
|
37446964c5 | ||
|
|
0af392d60e | ||
|
|
e910805e50 | ||
|
|
2b1db0ee24 | ||
|
|
2bb1d41e65 | ||
|
|
7bf35fc8ae | ||
|
|
719ee0400d | ||
|
|
4db7605d27 | ||
|
|
c7d16f7fc9 | ||
|
|
8ed38c02ce | ||
|
|
328ee52549 | ||
|
|
e412e5ead5 | ||
|
|
59ab2736ab | ||
|
|
bb27f83e8b | ||
|
|
7fe2341be0 | ||
|
|
5bf39593c5 | ||
|
|
1e56c8860a | ||
|
|
7042c6e646 | ||
|
|
4fe301511d | ||
|
|
22718a708c | ||
|
|
fa8ea9dbab | ||
|
|
9c15ca4d06 | ||
|
|
a4b1868690 | ||
|
|
e569c27010 | ||
|
|
145ae304eb | ||
|
|
dcf557ca46 | ||
|
|
a65de5a938 | ||
|
|
8e2535ada2 | ||
|
|
ce81d8c1ff | ||
|
|
9485099ab9 | ||
|
|
35689487ae | ||
|
|
51fcc2c88f | ||
|
|
d5ac231811 | ||
|
|
3538bea933 | ||
|
|
1d34e82503 | ||
|
|
f5b4bdd1d4 | ||
|
|
cd6c4f5390 | ||
|
|
5cc29d903a | ||
|
|
c32eabcdff | ||
|
|
96f108ab92 | ||
|
|
204d1fe123 | ||
|
|
7b51d9b6e6 | ||
|
|
786450c7c1 | ||
|
|
82050b9d2b | ||
|
|
e2b8c0c0a9 | ||
|
|
69635e02f1 | ||
|
|
f39442785f | ||
|
|
409503a261 | ||
|
|
edca42247d | ||
|
|
ed7e9949f5 | ||
|
|
0fe6d98c67 | ||
|
|
9fb8a6bda4 | ||
|
|
3d2f53ce25 | ||
|
|
ed0c75acf8 | ||
|
|
246e40539c | ||
|
|
160d424707 | ||
|
|
14276b6c2b | ||
|
|
b909fb7447 | ||
|
|
8b9621dafa | ||
|
|
9de2ba8e41 | ||
|
|
23e11fef93 | ||
|
|
570bb388b6 | ||
|
|
5d05a07364 | ||
|
|
d3a815faa9 | ||
|
|
a23de7b51c | ||
|
|
13268ac70a | ||
|
|
870c913b5d | ||
|
|
c1d2455e4d | ||
|
|
29c2939871 | ||
|
|
2567722b52 | ||
|
|
04ee35d708 | ||
|
|
3ea46d5574 | ||
|
|
b6ba8f59bd | ||
|
|
f9f7898277 | ||
|
|
dbacd044eb | ||
|
|
707b5629b4 | ||
|
|
8884996c06 | ||
|
|
eac41a7c9e | ||
|
|
4c113e5fb8 | ||
|
|
bc756d5c1b | ||
|
|
bbe7cd5a91 | ||
|
|
538ad48d18 | ||
|
|
53baac167c | ||
|
|
167566dc9b | ||
|
|
2df1eaa7c0 | ||
|
|
dd7f643153 | ||
|
|
13dd0f4874 | ||
|
|
715d235bdc | ||
|
|
25590242bc | ||
|
|
49489ff0d1 | ||
|
|
aa2350bedf | ||
|
|
52daf69dfe | ||
|
|
95f78addee | ||
|
|
12d947748c | ||
|
|
be28948e7e | ||
|
|
d0161ba85c | ||
|
|
2411ac28a4 | ||
|
|
1bc0950acc | ||
|
|
3aecd5a91c | ||
|
|
836823c477 | ||
|
|
c24404620b | ||
|
|
7471a43d39 | ||
|
|
dd6d57343e | ||
|
|
fd75c99850 | ||
|
|
6e3de08043 | ||
|
|
1fa30485b0 | ||
|
|
faed84d0f6 | ||
|
|
2f7b0692f3 | ||
|
|
8123381e1e | ||
|
|
4d36c13c5b | ||
|
|
91b7901528 | ||
|
|
9a27a0c3d8 | ||
|
|
cda441ee56 | ||
|
|
6ee83f8c7d | ||
|
|
8712a2b4e7 | ||
|
|
30d2edfd9c | ||
|
|
76cb2a6a59 | ||
|
|
f20e7459a4 | ||
|
|
f462a116d7 | ||
|
|
6f771821c8 | ||
|
|
754b8ef684 | ||
|
|
d8eb671b49 | ||
|
|
24ebee2743 | ||
|
|
878cf15a20 | ||
|
|
2f7cf4d664 | ||
|
|
4fcfb2a9ee | ||
|
|
41bedd3e16 | ||
|
|
d27bf67f65 | ||
|
|
76ddfa4126 | ||
|
|
400ad535a4 | ||
|
|
eaf5890f67 | ||
|
|
b2651adcab | ||
|
|
c8c6ab1f61 | ||
|
|
7f65f2d5bb | ||
|
|
17da594207 | ||
|
|
fa8fdfc4f6 | ||
|
|
75dd5e8a35 | ||
|
|
a442f54b82 | ||
|
|
24dca63df1 | ||
|
|
08a4dc75f2 | ||
|
|
4e474dc5b2 | ||
|
|
3deffb701f | ||
|
|
f83dce99ef | ||
|
|
9c14db0321 | ||
|
|
f92d08b825 | ||
|
|
ae10917f2a | ||
|
|
51d08bb168 | ||
|
|
0e56a30c5c | ||
|
|
74055b8a17 | ||
|
|
812cef5f2b | ||
|
|
9665188a18 | ||
|
|
cb943c2173 | ||
|
|
dc483adc1c | ||
|
|
3d9bbc0833 | ||
|
|
b032e91e08 | ||
|
|
3cada4cb3d | ||
|
|
97ded2fc32 | ||
|
|
f207849e5e | ||
|
|
f8bb63483f | ||
|
|
a3dd4acf43 | ||
|
|
f17089f435 | ||
|
|
d1c469746e | ||
|
|
b053684235 | ||
|
|
0f26cadd9a | ||
|
|
a07c332dce | ||
|
|
74ab8c5581 | ||
|
|
aa72770bfc | ||
|
|
2b71438cd0 | ||
|
|
e22032e1fb | ||
|
|
bdb8852347 | ||
|
|
4775bbfeaa | ||
|
|
0aa164de99 | ||
|
|
5ec91813b7 | ||
|
|
e2cabc6782 | ||
|
|
126df24a23 | ||
|
|
8178967fd8 | ||
|
|
0e40526d26 | ||
|
|
7bb9733513 | ||
|
|
1c97a4d32a | ||
|
|
1f357b5e08 | ||
|
|
264defe8bf | ||
|
|
c318c447f7 | ||
|
|
06c59c5103 | ||
|
|
8fe58ca6ca | ||
|
|
1d92404b0e | ||
|
|
0429cd8005 | ||
|
|
dc5bb4177f | ||
|
|
5a95a6b352 | ||
|
|
7999506359 | ||
|
|
0b36939858 | ||
|
|
09ce9f7cfb | ||
|
|
aba4b30027 | ||
|
|
409113e37a | ||
|
|
a52f46972e | ||
|
|
9f975c8263 | ||
|
|
e083c0c420 | ||
|
|
592e636903 | ||
|
|
b139fbe51d | ||
|
|
ce87fc4705 | ||
|
|
f23d21d896 | ||
|
|
84651b90ea | ||
|
|
1428c629b8 | ||
|
|
feb73d6b07 | ||
|
|
54717c495f | ||
|
|
febfda7d6f | ||
|
|
913377e4df | ||
|
|
86893a1e9e |
No files matched your search
@@ -0,0 +1 @@
|
||||
[*.{cs,vb}]
|
||||
@@ -6,11 +6,11 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.nuget/packages
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
${{ runner.os }}-nuget-
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v3
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
@@ -29,23 +29,23 @@ jobs:
|
||||
with:
|
||||
verbosity: Diagnostic
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MiraAPI.dll
|
||||
path: MiraAPI/bin/Release/net6.0/MiraAPI.dll
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: AllOfUs.MiraAPI.nupkg
|
||||
path: MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg
|
||||
|
||||
- uses: softprops/action-gh-release@v1
|
||||
- uses: softprops/action-gh-release@v2
|
||||
if: github.ref_type == 'tag'
|
||||
with:
|
||||
draft: true
|
||||
files: MiraAPI/bin/Release/net6.0/MiraAPI.dll
|
||||
|
||||
- name: Push NuGet package
|
||||
if: github.repository == 'All-Of-Us-Mods/MiraAPI' && github.ref == 'refs/heads/master' && github.ref_type == 'tag'
|
||||
if: github.ref_type == 'tag'
|
||||
run: |
|
||||
dotnet nuget push {MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg} --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
|
||||
dotnet nuget push MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
|
||||
@@ -3,6 +3,7 @@
|
||||
.vs/
|
||||
obj/
|
||||
bin/
|
||||
.qodo/
|
||||
|
||||
*.user
|
||||
*.lock.json
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
<Project>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Reactor" Version="2.3.1" />
|
||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.697" Private="false" ExcludeAssets="runtime;native" />
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.8.13" PrivateAssets="all" />
|
||||
<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="2026.6.5" PrivateAssets="all" />
|
||||
|
||||
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
|
||||
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1" PrivateAssets="all" ExcludeAssets="runtime" />
|
||||
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
|
||||
<VersionPrefix>0.1.3</VersionPrefix>
|
||||
<VersionPrefix>0.4.3</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
|
||||
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
||||
@@ -33,8 +33,13 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
|
||||
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\stylecop.json" Link="stylecop.json" Visible="false" />
|
||||
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.7.0.110445">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\stylecop.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,29 +1,34 @@
|
||||
using MiraAPI.Example.Modifiers.Freezer;
|
||||
using MiraAPI.Example.Options.Roles;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Buttons.Freezer;
|
||||
|
||||
[RegisterButton]
|
||||
public class FreezeButton : CustomActionButton<PlayerControl>
|
||||
{
|
||||
public override string Name => "Freeze";
|
||||
public override float Cooldown => 5f;
|
||||
public override float EffectDuration => 0f;
|
||||
public override int MaxUses => 0;
|
||||
|
||||
public override float Cooldown => OptionGroupSingleton<FreezerRoleSettings>.Instance.FreezeDuration;
|
||||
public override bool PauseTimerInVent => true;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
public override MiraKeybind? Keybind => MiraGlobalKeybinds.PrimaryAbility;
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
Target?.RpcAddModifier<FreezeModifier>();
|
||||
}
|
||||
|
||||
public override PlayerControl GetTarget()
|
||||
public override PlayerControl? GetTarget()
|
||||
{
|
||||
return PlayerControl.LocalPlayer.Data.Role.FindClosestTarget();
|
||||
return PlayerControl.LocalPlayer.GetClosestPlayer(true, Distance);
|
||||
}
|
||||
|
||||
public override void SetOutline(bool active)
|
||||
@@ -31,14 +36,13 @@ public class FreezeButton : CustomActionButton<PlayerControl>
|
||||
Target?.cosmetics.SetOutline(active, new Il2CppSystem.Nullable<Color>(Palette.Blue));
|
||||
}
|
||||
|
||||
public override bool IsTargetValid(PlayerControl target)
|
||||
public override bool IsTargetValid(PlayerControl? target)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Enabled(RoleBehaviour role)
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return role is FreezerRole;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
using MiraAPI.Example;
|
||||
using MiraAPI.Example.Modifiers;
|
||||
using MiraAPI.Example.Modifiers;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
[RegisterButton]
|
||||
namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class MeetingButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Call Meeting";
|
||||
|
||||
public override float Cooldown => 15;
|
||||
|
||||
public override float EffectDuration => 0;
|
||||
|
||||
public override int MaxUses => 3;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
public override MiraKeybind? Keybind => MiraGlobalKeybinds.ModifierPrimaryAbility;
|
||||
|
||||
public override bool Enabled(RoleBehaviour role)
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return PlayerControl.LocalPlayer.HasModifier<CaptainModifier>();
|
||||
return PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.HasModifier<CaptainModifier>();
|
||||
}
|
||||
|
||||
protected override void OnClick()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using MiraAPI.Example.GameOver;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class NeutralKillerButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Win Game";
|
||||
public override float Cooldown => 0f;
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
public override MiraKeybind Keybind => ExampleKeybinds.NeutralWinKeybind;
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
CustomGameOver.Trigger<NeutralKillerGameOver>([PlayerControl.LocalPlayer.Data]);
|
||||
}
|
||||
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return role is NeutralKillerRole;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,34 @@
|
||||
using MiraAPI.Example.Options.Roles;
|
||||
using System.Collections;
|
||||
using MiraAPI.Example.Options.Roles;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Buttons.Teleporter;
|
||||
[RegisterButton]
|
||||
|
||||
public class TeleportButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Teleport";
|
||||
|
||||
public override float Cooldown => OptionGroupSingleton<TeleporterOptions>.Instance.TeleportCooldown;
|
||||
public override float Cooldown => OptionGroupSingleton<TeleporterOptions>.Instance.TeleportCooldown.Value;
|
||||
|
||||
public override float EffectDuration => OptionGroupSingleton<TeleporterOptions>.Instance.TeleportDuration;
|
||||
|
||||
public override int MaxUses => 0;
|
||||
public override int MaxUses => 2;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.TeleportButton;
|
||||
public override Color TextOutlineColor => new Color32(221, 176, 152, 255);
|
||||
public static bool IsZoom { get; private set; }
|
||||
public override MiraKeybind? Keybind => MiraGlobalKeybinds.PrimaryAbility;
|
||||
|
||||
public override bool Enabled(RoleBehaviour role)
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return role is TeleporterRole;
|
||||
}
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
Coroutines.Start(ZoomOutCoroutine());
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class ThinkButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Think";
|
||||
public override float Cooldown => 15f;
|
||||
public override float EffectDuration => 10f;
|
||||
public override int MaxUses => 1;
|
||||
public override ButtonUsesMode UsesMode => ButtonUsesMode.PerRound;
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
protected override void OnClick()
|
||||
{
|
||||
// This button does absolutely nothing besides changing its text
|
||||
Button!.OverrideText("Thinking...");
|
||||
}
|
||||
|
||||
public override void OnEffectEnd()
|
||||
{
|
||||
Button!.OverrideText("Think");
|
||||
}
|
||||
|
||||
public override bool IsEffectCancellable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return role != null && role.IsImpostor;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,9 @@ namespace MiraAPI.Example;
|
||||
public static class ExampleAssets
|
||||
{
|
||||
public static LoadableResourceAsset ExampleButton { get; } = new("MiraAPI.Example.Resources.ExampleButton.png");
|
||||
public static LoadableResourceAsset CallMeetingButton { get; } = new("MiraAPI.Example.Resources.CallMeeting.png");
|
||||
|
||||
// Credit to EpicHorrors for the teleport button asset.
|
||||
// Credit to EpicHorrors for the teleport button asset.
|
||||
public static LoadableResourceAsset TeleportButton { get; } = new("MiraAPI.Example.Resources.TeleportButton.png");
|
||||
public static LoadableResourceAsset Banner { get; } = new("MiraAPI.Example.Resources.FortniteBanner.jpeg");
|
||||
}
|
||||
}
|
||||
@@ -6,9 +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("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 Gold { get; } = new("Gold", new Color(1.0f, 0.84f, 0.0f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
using MiraAPI.Events.Vanilla.Map;
|
||||
using MiraAPI.Events.Vanilla.Meeting;
|
||||
using MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
using MiraAPI.Events.Vanilla.Player;
|
||||
using MiraAPI.Example.Buttons.Freezer;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
public static class ExampleEventHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// 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}");
|
||||
});
|
||||
|
||||
MiraEventManager.RegisterEventHandler<AfterMurderEvent>(@event =>
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.Source.Data.PlayerName} has killed {@event.Target.Data.PlayerName}");
|
||||
});
|
||||
|
||||
MiraEventManager.RegisterEventHandler<CompleteTaskEvent>(@event =>
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.Player.Data.PlayerName} completed {@event.Task.TaskType.ToString()}");
|
||||
});
|
||||
|
||||
// You can also unregister event handlers using the handle returned from RegisterEventHandler.
|
||||
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 _)
|
||||
{
|
||||
foreach (var plr in PlayerControl.AllPlayerControls.ToArray().Where(player => player.Data.Role is MayorRole))
|
||||
{
|
||||
plr.GetVoteData().IncreaseRemainingVotes(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Example of using the Voting API to make a role similar to the Prosecutor from Town of Us.
|
||||
[RegisterEvent(15)]
|
||||
public static void HandleVoteEvent(HandleVoteEvent @event)
|
||||
{
|
||||
if (@event.VoteData.Owner.Data.Role is not NeutralKillerRole) return;
|
||||
|
||||
@event.VoteData.SetRemainingVotes(0);
|
||||
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
@event.VoteData.VoteForPlayer(@event.TargetId);
|
||||
}
|
||||
|
||||
foreach (var plr in PlayerControl.AllPlayerControls.ToArray().Where(player => player != @event.VoteData.Owner))
|
||||
{
|
||||
plr.GetVoteData().Votes.Clear();
|
||||
plr.GetVoteData().VotesRemaining = 0;
|
||||
}
|
||||
|
||||
@event.Cancel();
|
||||
}
|
||||
|
||||
// Events can be registered using an attribute as well.
|
||||
[RegisterEvent]
|
||||
public static void UpdateSystemEventHandler(UpdateSystemEvent @event)
|
||||
{
|
||||
Logger<ExamplePlugin>.Error(@event.SystemType.ToString());
|
||||
}
|
||||
|
||||
// Example event handler
|
||||
[RegisterEvent(1)]
|
||||
public static void FreezeButtonClickHandler(MiraButtonClickEvent<FreezeButton> @event)
|
||||
{
|
||||
Logger<ExamplePlugin>.Warning("Freeze button clicked!");
|
||||
|
||||
if (PlayerControl.LocalPlayer.Data.PlayerName != "stupid") return;
|
||||
|
||||
@event.Cancel();
|
||||
@event.Button.SetTimer(15f);
|
||||
}
|
||||
|
||||
// Example event handler
|
||||
[RegisterEvent]
|
||||
public static void FreezeButtonCancelledHandler(MiraButtonCancelledEvent<FreezeButton> @event)
|
||||
{
|
||||
Logger<ExamplePlugin>.Warning("Freeze button cancelled!");
|
||||
@event.Button.OverrideName("Freeze Canceled");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using MiraAPI.Keybinds;
|
||||
using Rewired;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
[RegisterCustomKeybinds]
|
||||
public static class ExampleKeybinds
|
||||
{
|
||||
public static MiraKeybind NeutralWinKeybind { get; } = new("Neutral Win", KeyboardKeyCode.C, [ModifierKey.Shift]);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
public override string TabName => "Mira Example";
|
||||
protected override bool ShouldCreateLabels => false;
|
||||
|
||||
public override LocalSettingTabAppearance TabAppearance => new()
|
||||
{
|
||||
ToggleActiveColor = Color.blue,
|
||||
ToggleInactiveColor = Color.red,
|
||||
};
|
||||
|
||||
[LocalSettingsButton]
|
||||
public LocalSettingsButton ExampleButton { get; private set; } = new("Example Button", OnExampleButtonClick);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ExampleToggle { get; private set; } = config.Bind("General", "Example Bool", true);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ExampleToggle2 { get; private set; } = config.Bind("General", "Example Bool 2", false);
|
||||
|
||||
[LocalSliderSetting(suffixType: MiraNumberSuffixes.Percent, formatString: "0", roundValue: true)]
|
||||
public ConfigEntry<float> ExampleSlider { get; private set; } = config.Bind("General", "Slider", 50f);
|
||||
|
||||
[LocalNumberSetting]
|
||||
public ConfigEntry<float> ExampleNumber { get; private set; } = config.Bind("General", "Example Number", 4f);
|
||||
|
||||
[LocalNumberSetting(min: 0.1f, max: 2.5f, increment: 0.1f, formatString: "0.0", suffixType: MiraNumberSuffixes.Multiplier)]
|
||||
public ConfigEntry<float> ExampleFloatNumber { get; private set; } = config.Bind("General", "Example Multplier", 1f);
|
||||
|
||||
[LocalEnumSetting]
|
||||
public ConfigEntry<ExampleEnumSetting> ExampleEnum { get; private set; } = config.Bind("General", "Example Enum", ExampleEnumSetting.Fries);
|
||||
|
||||
private static void OnExampleButtonClick()
|
||||
{
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.Open();
|
||||
}
|
||||
}
|
||||
|
||||
public enum ExampleEnumSetting
|
||||
{
|
||||
Cheeseburger,
|
||||
Sandwich,
|
||||
Fries,
|
||||
ChickenNuggets,
|
||||
}
|
||||
@@ -3,9 +3,11 @@ using BepInEx.Configuration;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
@@ -18,10 +20,11 @@ public partial class ExamplePlugin : BasePlugin, IMiraPlugin
|
||||
{
|
||||
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()
|
||||
{
|
||||
ExampleEventHandlers.Initialize();
|
||||
Harmony.PatchAll();
|
||||
AddComponent<MiraDebugWindow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.GameOver;
|
||||
|
||||
public class NeutralKillerGameOver : CustomGameOver
|
||||
{
|
||||
public override bool VerifyCondition(PlayerControl playerControl, NetworkedPlayerInfo[] winners)
|
||||
{
|
||||
return winners is [{ Role: NeutralKillerRole }];
|
||||
}
|
||||
|
||||
public override void AfterEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
endGameManager.WinText.text = "Outcast Killer Wins!";
|
||||
endGameManager.WinText.color = Color.magenta;
|
||||
endGameManager.BackgroundBar.material.SetColor(ShaderID.Color, Color.magenta);
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,9 @@
|
||||
<ProjectReference Include="..\MiraAPI\MiraAPI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\ExampleButton.png" />
|
||||
<EmbeddedResource Include="Resources\FortniteBanner.jpeg" />
|
||||
<EmbeddedResource Include="Resources\TeleportButton.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\**\*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\AmongUs.props" />
|
||||
</Project>
|
||||
@@ -1,31 +1,27 @@
|
||||
using MiraAPI.Example.Modifiers;
|
||||
using MiraAPI.Utilities;
|
||||
using System;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.ImGui;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
public class MiraDebugWindow(IntPtr ptr) : MonoBehaviour(ptr)
|
||||
public class MiraDebugWindow(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
public readonly DragWindow DebuggingWindow = new(new Rect(10, 10, 0, 0), "MIRA API DEBUGGING", () =>
|
||||
{
|
||||
if (GUILayout.Button("Test modifier"))
|
||||
[HideFromIl2Cpp]
|
||||
public DragWindow DebuggingWindow { get; } = new(
|
||||
new Rect(10, 10, 0, 0),
|
||||
"MIRA API DEBUGGING",
|
||||
() =>
|
||||
{
|
||||
//PlayerControl.LocalPlayer.AddModifier<ModifierTimerExample>();
|
||||
}
|
||||
if (GUILayout.Button("Remove modifier"))
|
||||
{
|
||||
//PlayerControl.LocalPlayer.RemoveModifier<ModifierTimerExample>();
|
||||
}
|
||||
})
|
||||
})
|
||||
{
|
||||
Enabled = true
|
||||
Enabled = true,
|
||||
};
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
DebuggingWindow.OnGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,34 @@
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Example.Options.Modifiers;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Modifiers;
|
||||
|
||||
[RegisterModifier]
|
||||
public class CaptainModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "Captain";
|
||||
public override int GetAmountPerGame()
|
||||
public override LoadableAsset<Sprite>? ModifierIcon => ExampleAssets.CallMeetingButton;
|
||||
|
||||
public override void OnDeath(DeathReason reason)
|
||||
{
|
||||
return 1;
|
||||
Player.RemoveModifier(this);
|
||||
}
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return $"You can call a meeting from anywhere on the map.";
|
||||
}
|
||||
|
||||
public override int GetAssignmentChance()
|
||||
{
|
||||
return 100;
|
||||
return (int)OptionGroupSingleton<CaptainModifierSettings>.Instance.Chance;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetAmountPerGame()
|
||||
{
|
||||
return (int)OptionGroupSingleton<CaptainModifierSettings>.Instance.Amount;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using MiraAPI.Modifiers;
|
||||
using Il2CppSystem;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Modifiers.Freezer;
|
||||
|
||||
[RegisterModifier]
|
||||
public class FreezeModifier : TimedModifier
|
||||
{
|
||||
public override string ModifierName => "Freezed";
|
||||
@@ -20,6 +21,16 @@ public class FreezeModifier : TimedModifier
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdate()
|
||||
{
|
||||
base.FixedUpdate();
|
||||
|
||||
if (Player.AmOwner || PlayerControl.LocalPlayer.Data.Role is FreezerRole)
|
||||
{
|
||||
Player.cosmetics.SetOutline(true, new Nullable<Color>(Palette.LightBlue));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnTimerComplete()
|
||||
{
|
||||
if (Player.AmOwner)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using MiraAPI.Modifiers.Types;
|
||||
|
||||
namespace MiraAPI.Example.Modifiers;
|
||||
|
||||
public class HighPriorityModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "High Priority";
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return "You are high priority! Idrk what this means either tbh...";
|
||||
}
|
||||
|
||||
public override int GetAssignmentChance()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public override int GetAmountPerGame()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override int Priority()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
@@ -16,19 +16,16 @@ public class ExampleOptions : AbstractOptionGroup
|
||||
[ModdedToggleOption("Toggle Opt 2")]
|
||||
public bool ToggleOpt2 { get; set; } = true;
|
||||
|
||||
[ModdedNumberOption("Number Opt", min: 0, max: 10, suffixType: MiraNumberSuffixes.Percent)]
|
||||
[ModdedNumberOption("Number Opt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
|
||||
public float NumberOpt { get; set; } = 4f;
|
||||
|
||||
[ModdedStringOption("String Opt", ["Hello", "Hey", "Bye"])]
|
||||
public int StringOpt { get; set; } = 2;
|
||||
|
||||
[ModdedEnumOption("Best API", typeof(BestApiEnum), ["Mira API", "Mitochondria", "Reactor"])]
|
||||
public BestApiEnum EnumOpt { get; set; } = BestApiEnum.MiraAPI;
|
||||
[ModdedEnumOption("Best API", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
|
||||
public BestApi Opt { get; set; } = BestApi.MiraAPI;
|
||||
}
|
||||
|
||||
public enum BestApiEnum
|
||||
public enum BestApi
|
||||
{
|
||||
MiraAPI,
|
||||
Mitochondria,
|
||||
Reactor
|
||||
}
|
||||
Reactor,
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.Example.Options;
|
||||
|
||||
@@ -7,21 +8,28 @@ public class ExampleOptions2 : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "Example Options 2";
|
||||
|
||||
public override uint GroupPriority => 0; // This group will be displayed first. The default value is uint.MaxValue.
|
||||
|
||||
public override MenuCategory ParentMenu => MenuCategory.CustomTwo;
|
||||
|
||||
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 ModdedToggleOption ToggleOpt2 { get; } = new("Toggle Option 2", false)
|
||||
{
|
||||
Visible = () => OptionGroupSingleton<ExampleOptions2>.Instance.ToggleOpt1.Value
|
||||
Visible = () => OptionGroupSingleton<ExampleOptions2>.Instance.ToggleOpt1, // implicit cast from ModdedToggleOption to bool
|
||||
};
|
||||
|
||||
public ModdedStringOption StringOpt { get; } = new("String Opt", 0, ["Choice 1", "Choice 2", "Choice 3"]);
|
||||
|
||||
public ModdedEnumOption EnumOpt { get; } = new("Enum Opt", 0, typeof(TestingEnum));
|
||||
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("Enum Opt", 0)
|
||||
{
|
||||
ChangedEvent = x => Logger<ExamplePlugin>.Info($"changed Enum Opt to {x}"),
|
||||
};
|
||||
}
|
||||
|
||||
public enum TestingEnum
|
||||
public enum TestingData : ulong
|
||||
{
|
||||
Happy,
|
||||
Sad,
|
||||
Neutral
|
||||
}
|
||||
Neutral,
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using MiraAPI.Example.Modifiers;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
|
||||
namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class CaptainModifierSettings : AbstractOptionGroup<CaptainModifier>
|
||||
{
|
||||
public override string GroupName => "Captain Settings";
|
||||
|
||||
[ModdedNumberOption("Amount", 0, 5)]
|
||||
public float Amount { get; set; } = 1;
|
||||
|
||||
[ModdedNumberOption("Chance", 0, 100, 10)]
|
||||
public float Chance { get; set; } = 50;
|
||||
|
||||
[ModdedNumberOption("Uses", 1, 5)]
|
||||
public float NumUses { get; set; } = 3;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using MiraAPI.Example.Modifiers.Freezer;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
|
||||
namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class FreezeModifierSettings : AbstractOptionGroup<FreezeModifier>
|
||||
{
|
||||
public override string GroupName => "Freeze";
|
||||
|
||||
[ModdedToggleOption("Use Color")]
|
||||
public bool UseColor { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
|
||||
namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class GeneralModifierOptions : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "General";
|
||||
|
||||
public override uint GroupPriority => 0;
|
||||
|
||||
public override MenuCategory ParentMenu => MenuCategory.Modifiers;
|
||||
|
||||
[ModdedToggleOption("Some Boolean Option")]
|
||||
public bool SomeBooleanOption { get; set; } = true;
|
||||
|
||||
[ModdedNumberOption("Number Option", 0, 10, 1)]
|
||||
public float NumberOption { get; set; } = 5;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
using System;
|
||||
|
||||
namespace MiraAPI.Example.Options.Roles;
|
||||
|
||||
public class CustomRole2Settings : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "Custom Role";
|
||||
|
||||
public override Type AdvancedRole => typeof(FreezerRole);
|
||||
|
||||
[ModdedToggleOption("Teleportation ability")] public bool Teleport { get; set; } = true;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
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 OptionNotifConfiguration Configuration => new(
|
||||
Palette.Blue,
|
||||
TmpSpriteUtils.CreateSpriteAsset(
|
||||
MiraAssets.ImpostorFile.LoadAsset(),
|
||||
"ApiExample.Role.Impostor.FreezerRole"));
|
||||
public override string GroupName => "Custom Role";
|
||||
|
||||
[ModdedNumberOption("Freeze Duration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
|
||||
public float FreezeDuration { get; set; } = 5;
|
||||
|
||||
[ModdedNumberOption("Freeze Uses", 1, 5)]
|
||||
public float FreezeUses { get; set; } = 1;
|
||||
}
|
||||
@@ -1,23 +1,20 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Utilities;
|
||||
using System;
|
||||
|
||||
namespace MiraAPI.Example.Options.Roles;
|
||||
|
||||
public class TeleporterOptions : AbstractOptionGroup
|
||||
public class TeleporterOptions : AbstractRoleOptionGroup<TeleporterRole>
|
||||
{
|
||||
public override string GroupName => "Teleporter";
|
||||
|
||||
public override Type AdvancedRole => typeof(TeleporterRole);
|
||||
|
||||
[ModdedNumberOption("Teleport Cooldown", 5, 60, 2.5f, MiraNumberSuffixes.Seconds)]
|
||||
public float TeleportCooldown { get; set; } = 5;
|
||||
public ModdedNumberOption TeleportCooldown { get; set; } = new("Teleport Cooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
|
||||
|
||||
[ModdedNumberOption("Teleport Duration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
|
||||
public float TeleportDuration { get; set; } = 10;
|
||||
|
||||
[ModdedNumberOption("Zoom Distance", 4, 15)]
|
||||
public float ZoomDistance { get; set; } = 6;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,81 @@
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.Patches.Stubs;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
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 Color RoleColor => Palette.AcceptedGreen;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
|
||||
private bool _shouldHide;
|
||||
|
||||
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),
|
||||
};
|
||||
|
||||
public override void Initialize(PlayerControl player)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info("Initializing ChamelonRole for player: " + player.PlayerId);
|
||||
RoleBehaviourStubs.Initialize(this, player);
|
||||
_shouldHide = true;
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
{
|
||||
if (!Player || !_shouldHide)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player.MyPhysics.Velocity.magnitude > 0)
|
||||
{
|
||||
var rend = Player.cosmetics.currentBodySprite.BodySprite;
|
||||
var tmp = Player.cosmetics.nameText;
|
||||
tmp.color = Color.Lerp(tmp.color, new Color(tmp.color.r, tmp.color.g, tmp.color.b, 1), Time.deltaTime * 4f);
|
||||
rend.color = Color.Lerp(rend.color, new Color(1, 1, 1, 1), Time.deltaTime * 4f);
|
||||
|
||||
foreach (var cosmetic in Player.cosmetics.transform.GetComponentsInChildren<SpriteRenderer>())
|
||||
{
|
||||
cosmetic.color = Color.Lerp(cosmetic.color, new Color(1, 1, 1, 1), Time.deltaTime * 4f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deinitialize(PlayerControl targetPlayer)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info("Deinitializing ChamelonRole for player: " + targetPlayer.PlayerId);
|
||||
RoleBehaviourStubs.Deinitialize(this, targetPlayer);
|
||||
_shouldHide = false;
|
||||
foreach (var cosmetic in Player.cosmetics.transform.GetComponentsInChildren<SpriteRenderer>(true))
|
||||
{
|
||||
cosmetic.color = Color.white;
|
||||
}
|
||||
Player.cosmetics.currentBodySprite.BodySprite.color = Color.white;
|
||||
Player.cosmetics.nameText.color = Color.white;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Roles;
|
||||
|
||||
[RegisterCustomRole]
|
||||
public class FreezerRole : ImpostorRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Freezer";
|
||||
@@ -12,6 +11,12 @@ public class FreezerRole : ImpostorRole, ICustomRole
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public Color RoleColor => Palette.Blue;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
|
||||
public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
|
||||
public int MaxPlayers => 2;
|
||||
}
|
||||
|
||||
public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this)
|
||||
{
|
||||
Icon = MiraAssets.ImpostorFile,
|
||||
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.ImpostorFile.LoadAsset(), "ApiExample.Role.Impostor.FreezerRole"),
|
||||
OptionsScreenshot = ExampleAssets.Banner,
|
||||
MaxRoleCount = 2,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using MiraAPI.Roles;
|
||||
using UnityEngine;
|
||||
|
||||
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 Color RoleColor => new Color32(221, 176, 152, 255);
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
public CustomRoleConfiguration Configuration => new(this);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.Example.GameOver;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Roles;
|
||||
using UnityEngine;
|
||||
|
||||
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 Color RoleColor => Color.magenta;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Custom;
|
||||
|
||||
public CustomRoleConfiguration Configuration => new(this)
|
||||
{
|
||||
UseVanillaKillButton = true,
|
||||
CanGetKilled = true,
|
||||
CanUseVent = true,
|
||||
};
|
||||
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
||||
|
||||
[HideFromIl2Cpp]
|
||||
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
|
||||
Color.gray,
|
||||
"OUTCAST",
|
||||
"You are an Outcast. You do not have a team.");
|
||||
|
||||
public override void SpawnTaskHeader(PlayerControl playerControl)
|
||||
{
|
||||
// remove existing task header.
|
||||
}
|
||||
|
||||
public override bool DidWin(GameOverReason gameOverReason)
|
||||
{
|
||||
return gameOverReason == CustomGameOver.GameOverReason<NeutralKillerGameOver>();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Roles;
|
||||
|
||||
[RegisterCustomRole]
|
||||
public class TeleporterRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Teleporter";
|
||||
@@ -12,6 +10,17 @@ public class TeleporterRole : CrewmateRole, ICustomRole
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public Color RoleColor => new Color32(221, 176, 152, 255);
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
|
||||
|
||||
}
|
||||
public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this)
|
||||
{
|
||||
OptionsScreenshot = ExampleAssets.Banner,
|
||||
CanModifyChance = false,
|
||||
DefaultChance = 73,
|
||||
DefaultRoleCount = 4,
|
||||
};
|
||||
|
||||
public bool CanLocalPlayerSeeRole(PlayerControl player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,63 @@ using Reactor.Localization.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Colors;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a custom color with a main color and a shadow color.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the option.</param>
|
||||
/// <param name="mainColor">The main color.</param>
|
||||
/// <param name="shadowColor">The shadow color.</param>
|
||||
public sealed class CustomColor(StringNames name, Color32 mainColor, Color32 shadowColor)
|
||||
{
|
||||
public Color32 MainColor { get; } = mainColor;
|
||||
public Color32 ShadowColor { get; } = shadowColor;
|
||||
public StringNames Name { get; } = name;
|
||||
/// <summary>
|
||||
/// Gets or sets the main color.
|
||||
/// </summary>
|
||||
public Color32 MainColor { get; set; } = mainColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the shadow color.
|
||||
/// </summary>
|
||||
public Color32 ShadowColor { get; set; } = shadowColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the color.
|
||||
/// </summary>
|
||||
public StringNames Name { get; set; } = name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the color is lighter or darker. Can be used to help with colorblind stuff.
|
||||
/// </summary>
|
||||
public CustomColorBrightness ColorBrightness { get; set; } = CustomColorBrightness.Darker;
|
||||
|
||||
/// <inheritdoc />
|
||||
public CustomColor(StringNames name, Color32 mainColor) : this(name, mainColor, mainColor.GetShadowColor(60))
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CustomColor(string name, Color32 mainColor) : this(name, mainColor, mainColor.GetShadowColor(60))
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(CustomStringName.CreateAndRegister(name), mainColor, shadowColor)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can be used to help with colorblind stuff.
|
||||
/// </summary>
|
||||
public enum CustomColorBrightness
|
||||
{
|
||||
/// <summary>
|
||||
/// A lighter color.
|
||||
/// </summary>
|
||||
Lighter,
|
||||
|
||||
/// <summary>
|
||||
/// A darker color.
|
||||
/// </summary>
|
||||
Darker,
|
||||
}
|
||||
@@ -4,18 +4,29 @@ using HarmonyLib;
|
||||
|
||||
namespace MiraAPI.Colors;
|
||||
|
||||
internal static class PaletteManager
|
||||
/// <summary>
|
||||
/// Used to register and track <see cref="CustomColor"/>s.
|
||||
/// </summary>
|
||||
public static class PaletteManager
|
||||
{
|
||||
public static readonly List<CustomColor> CustomColors = [];
|
||||
|
||||
public static void RegisterAllColors()
|
||||
{
|
||||
var colors = CustomColors.Select(x => x.MainColor);
|
||||
var shadowColors = CustomColors.Select(x => x.ShadowColor);
|
||||
var stringNames = CustomColors.Select(x => x.Name);
|
||||
/// <summary>
|
||||
/// Gets all registered <see cref="CustomColor"/>s.
|
||||
/// </summary>
|
||||
public static CustomColor[] RegisteredColors => [.. CustomColors];
|
||||
|
||||
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors.ToArray());
|
||||
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors.ToArray());
|
||||
Palette.ColorNames = Palette.ColorNames.ToArray().AddRangeToArray(stringNames.ToArray());
|
||||
}
|
||||
}
|
||||
internal static readonly List<CustomColor> CustomColors = [];
|
||||
|
||||
internal static void RegisterAllColors()
|
||||
{
|
||||
var colors = CustomColors.Select(x => x.MainColor).ToArray();
|
||||
var shadowColors = CustomColors.Select(x => x.ShadowColor).ToArray();
|
||||
var stringNames = CustomColors.Select(x => x.Name).ToArray();
|
||||
|
||||
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors);
|
||||
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors);
|
||||
Palette.ColorNames = Palette.ColorNames.ToArray().AddRangeToArray(stringNames);
|
||||
|
||||
Palette.TextColors = Palette.TextColors.ToArray().AddRangeToArray(colors);
|
||||
Palette.TextOutlineColors = Palette.TextOutlineColors.ToArray().AddRangeToArray(shadowColors);
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,8 @@
|
||||
|
||||
namespace MiraAPI.Colors;
|
||||
|
||||
/// <summary>
|
||||
/// Used to mark a class for <see cref="CustomColor"/> registration.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RegisterCustomColorsAttribute : Attribute;
|
||||
public class RegisterCustomColorsAttribute : Attribute;
|
||||
@@ -0,0 +1,44 @@
|
||||
using MiraAPI.Hud;
|
||||
|
||||
namespace MiraAPI.Events.Mira;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
|
||||
public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActionButton
|
||||
{
|
||||
/// <summary>
|
||||
/// 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 <see cref="CustomActionButton"/> whose click was cancelled.</param>
|
||||
public MiraButtonCancelledEvent(T button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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 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 <see cref="CustomActionButton"/> whose click was cancelled.</param>
|
||||
public MiraButtonCancelledEvent(CustomActionButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using MiraAPI.Hud;
|
||||
|
||||
namespace MiraAPI.Events.Mira;
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
|
||||
public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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;
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// </summary>
|
||||
public sealed class MiraButtonClickEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 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 <see cref="CustomActionButton"/> that was clicked.</param>
|
||||
public MiraButtonClickEvent(CustomActionButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using MiraAPI.PluginLoading;
|
||||
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Abstract class for Mira Events that can be cancelled.
|
||||
/// </summary>
|
||||
[MiraIgnore]
|
||||
public abstract class MiraCancelableEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the event is cancelled.
|
||||
/// </summary>
|
||||
public bool IsCancelled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the event.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
IsCancelled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uncancels the event.
|
||||
/// </summary>
|
||||
public void UnCancel()
|
||||
{
|
||||
IsCancelled = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using MiraAPI.PluginLoading;
|
||||
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Abstract class for Mira Events.
|
||||
/// </summary>
|
||||
[MiraIgnore]
|
||||
public abstract class MiraEvent;
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Event handle to use when unregistering a <see cref="MiraEvent"/>.
|
||||
/// </summary>
|
||||
public class MiraEventHandle
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of event.
|
||||
/// </summary>
|
||||
public Type EventType { get; }
|
||||
|
||||
internal MiraEventWrapper EventWrapper { get; }
|
||||
|
||||
internal MiraEventHandle(Type type, MiraEventWrapper eventWrapper)
|
||||
{
|
||||
EventType = type;
|
||||
EventWrapper = eventWrapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Mira Event manager.
|
||||
/// </summary>
|
||||
public static class MiraEventManager
|
||||
{
|
||||
private static readonly Dictionary<Type, List<MiraEventWrapper>> EventWrappers = [];
|
||||
|
||||
/// <summary>
|
||||
/// Invoke a <see cref="MiraEvent"/>.
|
||||
/// </summary>
|
||||
/// <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 <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);
|
||||
if (handlers == null || handlers.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var handler in handlers)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Action<T>)handler.EventHandler).Invoke(eventInstance);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error($"Error invoking event handler for {typeof(T).Name}: {ex.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoke a <see cref="MiraEvent"/> and use a specific type to find the handlers.
|
||||
/// </summary>
|
||||
/// <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 <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
||||
public static bool InvokeEvent(MiraEvent eventInstance, Type type)
|
||||
{
|
||||
EventWrappers.TryGetValue(type, out var handlers);
|
||||
if (handlers == null || handlers.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var handler in handlers)
|
||||
{
|
||||
try
|
||||
{
|
||||
handler.EventHandler.DynamicInvoke(eventInstance);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error($"Error invoking event handler for {type.Name}: {ex.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a <see cref="MiraEvent"/> handler.
|
||||
/// </summary>
|
||||
/// <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>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)))
|
||||
{
|
||||
throw new InvalidOperationException($"Type must be a subclass of MiraEvent: {type.FullName}");
|
||||
}
|
||||
|
||||
EventWrappers.TryAdd(type, []);
|
||||
var handlers = EventWrappers[type];
|
||||
|
||||
var @delegate = Delegate.CreateDelegate(typeof(Action<>).MakeGenericType(type), methodInfo);
|
||||
var eventWrapper = new MiraEventWrapper(@delegate, priority);
|
||||
|
||||
var index = handlers.BinarySearch(eventWrapper, Comparer<MiraEventWrapper>.Create((a, b) => a.Priority.CompareTo(b.Priority)));
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = ~index;
|
||||
}
|
||||
|
||||
handlers.Insert(index, eventWrapper);
|
||||
return new MiraEventHandle(type, eventWrapper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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), []);
|
||||
|
||||
var handlers = EventWrappers[typeof(T)];
|
||||
var eventWrapper = new MiraEventWrapper(handler, priority);
|
||||
|
||||
var index = handlers.BinarySearch(eventWrapper, Comparer<MiraEventWrapper>.Create((a, b) => a.Priority.CompareTo(b.Priority)));
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = ~index;
|
||||
}
|
||||
|
||||
handlers.Insert(index, eventWrapper);
|
||||
return new MiraEventHandle(typeof(T), eventWrapper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregister a <see cref="MiraEvent"/> handler using the <see cref="MiraEventHandle"/>.
|
||||
/// </summary>
|
||||
/// <param name="eventHandle">A handle to the event.</param>
|
||||
/// <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))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!handlers.Remove(eventHandle.EventWrapper))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (handlers.Count == 0)
|
||||
{
|
||||
EventWrappers.Remove(eventHandle.EventType);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for <see cref="MiraEvent"/> handlers.
|
||||
/// </summary>
|
||||
public class MiraEventWrapper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the event handler delegate.
|
||||
/// </summary>
|
||||
public Delegate EventHandler { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority of the handler. Lower values are called first.
|
||||
/// </summary>
|
||||
public int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MiraEventWrapper"/> class.
|
||||
/// </summary>
|
||||
/// <param name="eventHandler">The action for the event handler.</param>
|
||||
/// <param name="priority">The priority of the handler.</param>
|
||||
public MiraEventWrapper(Delegate eventHandler, int priority)
|
||||
{
|
||||
EventHandler = eventHandler;
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Register a <see cref="MiraEvent"/> handler.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class RegisterEventAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the priority of the event. Lower values are called first.
|
||||
/// </summary>
|
||||
public int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RegisterEventAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="priority">The priority of the event. Lower values are called first.</param>
|
||||
public RegisterEventAttribute(int priority = 0)
|
||||
{
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked after a player is murdered. Only called after a successful murder. This event is not cancelable.
|
||||
/// </summary>
|
||||
public class AfterMurderEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that killed the <see cref="Target"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Source { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that was killed.
|
||||
/// </summary>
|
||||
public PlayerControl Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked before <see cref="GameManager.RpcEndGame"/> is called, allowing cancellation of the game end entirely.
|
||||
/// </summary>
|
||||
public class BeforeGameEndEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the reason for the game end.
|
||||
/// </summary>
|
||||
public GameOverReason Reason { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BeforeGameEndEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="reason">The reason for the game end.</param>
|
||||
public BeforeGameEndEvent(GameOverReason reason)
|
||||
{
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using MiraAPI.Networking;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked before a player is murdered. This event is cancelable.
|
||||
/// </summary>
|
||||
public sealed class BeforeMurderEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is killing the <see cref="Target"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Source { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
|
||||
/// </summary>
|
||||
public bool TriggeredByIntro { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BeforeRoundStartEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="triggeredByIntro">Whether the event was triggered by the intro or not.</param>
|
||||
public BeforeRoundStartEvent(bool triggeredByIntro)
|
||||
{
|
||||
TriggeredByIntro = triggeredByIntro;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the end game screen is shown. Non cancelable.
|
||||
/// </summary>
|
||||
public class GameEndEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 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 <see cref="global::EndGameManager"/> instance.</param>
|
||||
public GameEndEvent(EndGameManager manager)
|
||||
{
|
||||
EndGameManager = manager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the intro cutscene is shown. Non cancelable.
|
||||
/// </summary>
|
||||
public class IntroBeginEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IntroBeginEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="introCutscene">The intro cutscene.</param>
|
||||
public IntroBeginEvent(IntroCutscene introCutscene)
|
||||
{
|
||||
IntroCutscene = introCutscene;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the intro cutscene has finished playing.
|
||||
/// </summary>
|
||||
public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; } = introCutscene;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the player's role is shown on the intro cutscene. Non cancelable.
|
||||
/// </summary>
|
||||
public class IntroRoleRevealEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IntroRoleRevealEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="introCutscene">The intro cutscene.</param>
|
||||
public IntroRoleRevealEvent(IntroCutscene introCutscene)
|
||||
{
|
||||
IntroCutscene = introCutscene;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
|
||||
/// </summary>
|
||||
public bool TriggeredByIntro { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RoundStartEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="triggeredByIntro">Whether the event was triggered by the intro or not.</param>
|
||||
public RoundStartEvent(bool triggeredByIntro)
|
||||
{
|
||||
TriggeredByIntro = triggeredByIntro;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using AmongUs.GameOptions;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked after a player's role is set. This event is not cancelable.
|
||||
/// </summary>
|
||||
public class SetRoleEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> whose role was changed.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role that the player was set to.
|
||||
/// </summary>
|
||||
public RoleTypes Role { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetRoleEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The player.</param>
|
||||
/// <param name="role">The new role.</param>
|
||||
public SetRoleEvent(PlayerControl player, RoleTypes role)
|
||||
{
|
||||
Player = player;
|
||||
Role = role;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Map;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when a player closes the doors in a room.
|
||||
/// </summary>
|
||||
public class CloseDoorsEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the room that the doors were closed in.
|
||||
/// </summary>
|
||||
public SystemTypes Room { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CloseDoorsEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="room">The room that was closed.</param>
|
||||
public CloseDoorsEvent(SystemTypes room)
|
||||
{
|
||||
Room = room;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Map;
|
||||
|
||||
/// <summary>
|
||||
/// Sabotage from Vanilla Among Us.
|
||||
/// </summary>
|
||||
public class PlayerOpenSabotageEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 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 <see cref="global::MapBehaviour"/>.</param>
|
||||
public PlayerOpenSabotageEvent(MapBehaviour mapBehaviour)
|
||||
{
|
||||
MapBehaviour = mapBehaviour;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace MiraAPI.Events.Vanilla.Map;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="MiraCancelableEvent"/> that is invoked before a system is updated. Usually used for sabotage events.
|
||||
/// </summary>
|
||||
public class UpdateSystemEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of system that will be updated.
|
||||
/// </summary>
|
||||
public SystemTypes SystemType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is updating the system.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the byte amount the system is being updated by.
|
||||
/// </summary>
|
||||
public byte Amount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
SystemType = systemType;
|
||||
Player = player;
|
||||
Amount = amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MiraAPI.Events.Vanilla.Meeting;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a player is ejected. Non-cancelable.
|
||||
/// </summary>
|
||||
public class EjectionEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 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 <see cref="global::ExileController"/> instance.</param>
|
||||
public EjectionEvent(ExileController controller)
|
||||
{
|
||||
ExileController = controller;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MiraAPI.Events.Vanilla.Meeting;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the meeting has ended.
|
||||
/// </summary>
|
||||
public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace MiraAPI.Events.Vanilla.Meeting;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a body is reported.
|
||||
/// This is invoked in <see cref="PlayerControl.CmdReportDeadBody(NetworkedPlayerInfo)"/>.
|
||||
/// </summary>
|
||||
public class ReportBodyEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player that is reporting the body.
|
||||
/// </summary>
|
||||
public PlayerControl Reporter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player that is being reported. Will be <see langword="null"/> for emergency meeting.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo? Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DeadBody"/> that is being reported. Will be <see langword="null"/> for emergency meeting.
|
||||
/// </summary>
|
||||
public DeadBody? Body { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReportBodyEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="reporter">The player who reported the body.</param>
|
||||
/// <param name="target">The player being reported.</param>
|
||||
/// <param name="body">The <see cref="DeadBody"/> being reported.</param>
|
||||
public ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body)
|
||||
{
|
||||
Reporter = reporter;
|
||||
Target = target;
|
||||
Body = body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace MiraAPI.Events.Vanilla.Meeting;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a meeting is called. This event is not cancelable.
|
||||
/// This event is called after Mira resets votes, so if you plan on adding votes to a specific player, do it with this event.
|
||||
/// </summary>
|
||||
public class StartMeetingEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 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 <see cref="global::MeetingHud"/> instance.</param>
|
||||
public StartMeetingEvent(MeetingHud meetingHud)
|
||||
{
|
||||
MeetingHud = meetingHud;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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.
|
||||
/// </summary>
|
||||
public class AfterVoteEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player who voted.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AfterVoteEvent"/> class.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
VoteArea = playerVoteArea;
|
||||
Player = voter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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.
|
||||
/// </summary>
|
||||
public class BeforeVoteEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player who voted.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BeforeVoteEvent"/> class.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
VoteArea = playerVoteArea;
|
||||
Player = voter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if voting is complete. If canceled, the default end voting logic will be skipped.
|
||||
/// </summary>
|
||||
public class CheckForEndVotingEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether default voting logic determines that voting is complete.
|
||||
/// </summary>
|
||||
public bool IsVotingComplete { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the voting should be forced to end, regardless of the default logic.
|
||||
/// </summary>
|
||||
public bool ForceEndVoting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CheckForEndVotingEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="isVotingComplete"><see langword="true"/> if voting is complete, <see langword="false"/> otherwise.</param>
|
||||
public CheckForEndVotingEvent(bool isVotingComplete)
|
||||
{
|
||||
IsVotingComplete = isVotingComplete;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Voting;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked before the dummy selects their vote. If canceled, the dummy won't vote.
|
||||
/// </summary>
|
||||
public class DummyVoteEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the dummy that needs to vote.
|
||||
/// </summary>
|
||||
public DummyBehaviour Dummy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the dummy's <see cref="PlayerVoteData"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the dummy can vote to skip the meeting.
|
||||
/// </summary>
|
||||
public bool CanSkip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a predicate for validating whether the dummy can vote on a player.
|
||||
/// By default, excludes dead and disconnected players.
|
||||
/// </summary>
|
||||
public Predicate<PlayerControl> PlayerIsValid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DummyVoteEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="dummy">The voting dummy.</param>
|
||||
public DummyVoteEvent(DummyBehaviour dummy)
|
||||
{
|
||||
Dummy = dummy;
|
||||
VoteData = dummy.myPlayer.GetVoteData();
|
||||
CanSkip = true;
|
||||
PlayerIsValid = x => !x.Data.IsDead && !x.Data.Disconnected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using MiraAPI.Voting;
|
||||
|
||||
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 <see cref="PlayerVoteData.Votes"/> list after this event is invoked.
|
||||
/// </summary>
|
||||
public class HandleVoteEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player who voted.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player id of the target.
|
||||
/// </summary>
|
||||
public byte TargetId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to prevent the vote from commencing.
|
||||
/// </summary>
|
||||
public bool PreventVote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo TargetPlayerInfo { get; }
|
||||
|
||||
/// <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>
|
||||
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId)
|
||||
{
|
||||
VoteData = playerVoteData;
|
||||
Player = playerVoteData.Owner;
|
||||
TargetId = targetId;
|
||||
PreventVote = false;
|
||||
TargetPlayerInfo = GameData.Instance.GetPlayerById(targetId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using MiraAPI.Voting;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the player tries to select another player to vote.
|
||||
/// </summary>
|
||||
public class MeetingSelectEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player id of the target.
|
||||
/// </summary>
|
||||
public int TargetId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo TargetPlayerInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the player is allowed to select the target.
|
||||
/// </summary>
|
||||
public bool AllowSelect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MeetingSelectEvent"/> class.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public MeetingSelectEvent(PlayerVoteData playerVoteData, int targetId, bool allowSelect)
|
||||
{
|
||||
VoteData = playerVoteData;
|
||||
TargetId = targetId;
|
||||
TargetPlayerInfo = GameData.Instance.GetPlayerById((byte)targetId);
|
||||
AllowSelect = allowSelect;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using MiraAPI.Voting;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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 <see cref="CustomVote"/>s.</param>
|
||||
public PopulateResultsEvent(List<CustomVote> votes)
|
||||
{
|
||||
Votes = votes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Voting;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// Ran after calculating votes and before displaying the results. Only ran on the host.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="ProcessVotesEvent"/> class.
|
||||
/// </remarks>
|
||||
/// <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];
|
||||
|
||||
private NetworkedPlayerInfo? _exiledPlayer = exiledPlayer;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the exiled player has been modified by the event.
|
||||
/// </summary>
|
||||
public bool ExiledPlayerModified { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the votes have been modified by the event.
|
||||
/// </summary>
|
||||
public bool VotesModified => !Votes.SequenceEqual(_originalVotes);
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see langword="null"/> if no player is to be exiled.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo? ExiledPlayer
|
||||
{
|
||||
get => _exiledPlayer;
|
||||
set
|
||||
{
|
||||
_exiledPlayer = value;
|
||||
ExiledPlayerModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when the voting phase of a meeting is complete.
|
||||
/// </summary>
|
||||
/// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
|
||||
public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace MiraAPI.Events.Vanilla.Player;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a player completes a task within Hide and Seek. Non-cancelable.
|
||||
/// </summary>
|
||||
public class CompleteHnsTaskEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerControl"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerTask"/> that the player completed.
|
||||
/// </summary>
|
||||
public PlayerTask Task { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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)
|
||||
{
|
||||
HnsManager = hnsManager;
|
||||
Player = player;
|
||||
Task = task;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace MiraAPI.Events.Vanilla.Player;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a player completes a task. Non cancelable.
|
||||
/// </summary>
|
||||
public class CompleteTaskEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerControl"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerTask"/> that the player completed.
|
||||
/// </summary>
|
||||
public PlayerTask Task { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CompleteTaskEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The player who completed the task.</param>
|
||||
/// <param name="task">The task that the player completed.</param>
|
||||
public CompleteTaskEvent(PlayerControl player, PlayerTask task)
|
||||
{
|
||||
Player = player;
|
||||
Task = task;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace MiraAPI.Events.Vanilla.Player;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player dies. Non cancelable.
|
||||
/// </summary>
|
||||
public class PlayerDeathEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player who died.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reason the player died.
|
||||
/// </summary>
|
||||
public DeathReason DeathReason { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::DeadBody"/> associated with the player, if any.
|
||||
/// </summary>
|
||||
public DeadBody? DeadBody { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerDeathEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The player who died.</param>
|
||||
/// <param name="reason">The reason the player died.</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;
|
||||
DeathReason = reason;
|
||||
DeadBody = deadBody;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using InnerNet;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Player;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player joins the lobby. Non cancelable.
|
||||
/// </summary>
|
||||
public class PlayerJoinEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player who joined.
|
||||
/// </summary>
|
||||
public ClientData ClientData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerJoinEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">The data of the player who joined.</param>
|
||||
public PlayerJoinEvent(ClientData data)
|
||||
{
|
||||
ClientData = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using InnerNet;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Player;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player leaves the game. Non cancelable.
|
||||
/// </summary>
|
||||
public class PlayerLeaveEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player who left.
|
||||
/// </summary>
|
||||
public ClientData ClientData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reason why the player left.
|
||||
/// </summary>
|
||||
public DisconnectReasons Reason { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerLeaveEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">The data of the player who left.</param>
|
||||
/// <param name="reason">The reason why the player left.</param>
|
||||
public PlayerLeaveEvent(ClientData data, DisconnectReasons reason)
|
||||
{
|
||||
ClientData = data;
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace MiraAPI.Events.Vanilla.Usables;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player enters a vent. This event is cancelable.
|
||||
/// </summary>
|
||||
public class EnterVentEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is entering the <see cref="Vent"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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;
|
||||
Vent = vent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace MiraAPI.Events.Vanilla.Usables;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player exits a vent. This event is cancelable.
|
||||
/// </summary>
|
||||
public class ExitVentEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is exiting the <see cref="Vent"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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;
|
||||
Vent = vent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace MiraAPI.Events.Vanilla.Usables;
|
||||
|
||||
/// <summary>
|
||||
/// Event for if a <see cref="PlayerControl"/> can use an <see cref="IUsable"/> from Vanilla Among Us. Will always be ran locally.
|
||||
/// </summary>
|
||||
public class PlayerCanUseEvent : PlayerUseEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerCanUseEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="usable">The <see cref="IUsable"/>.</param>
|
||||
public PlayerCanUseEvent(IUsable usable) : base(usable)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace MiraAPI.Events.Vanilla.Usables;
|
||||
|
||||
/// <summary>
|
||||
/// Event for <see cref="PlayerControl"/> using a <see cref="IUsable"/> from Vanilla Among Us. Will always be ran locally.
|
||||
/// </summary>
|
||||
public class PlayerUseEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of <see cref="IUsable"/> that was used.
|
||||
/// </summary>
|
||||
public IUsable Usable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 <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 <see cref="IUsable"/>.</param>
|
||||
public PlayerUseEvent(IUsable usable)
|
||||
{
|
||||
Usable = usable;
|
||||
|
||||
IsPrimaryConsole = usable.TryCast<Console>() || usable.TryCast<SystemConsole>() || usable.TryCast<MapConsole>();
|
||||
IsVent = usable.TryCast<Vent>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
using MiraAPI.Networking;
|
||||
using Reactor.Networking.Rpc;
|
||||
|
||||
namespace MiraAPI.GameEnd;
|
||||
|
||||
/// <summary>
|
||||
/// Custom Game Over.
|
||||
/// </summary>
|
||||
public abstract class CustomGameOver
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current <see cref="CustomGameOver"/>.
|
||||
/// </summary>
|
||||
public static CustomGameOver? Instance { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Verifies if the condition for this <see cref="CustomGameOver"/> is met.
|
||||
/// </summary>
|
||||
/// <param name="playerControl">The <see cref="PlayerControl"/> that requested the Game Over.</param>
|
||||
/// <param name="winners">The collection of winners.</param>
|
||||
/// <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 <see cref="EndGameManager.SetEverythingUp"/>.
|
||||
/// </summary>
|
||||
/// <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 <see cref="EndGameManager.SetEverythingUp"/>.
|
||||
/// </summary>
|
||||
/// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
|
||||
public virtual void AfterEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see cref="global::GameOverReason"/> associated with the custom game over.</returns>
|
||||
public static GameOverReason GameOverReason<T>() where T : CustomGameOver
|
||||
{
|
||||
return (GameOverReason)GameOverManager.GetGameOverId<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a custom game over.
|
||||
/// </summary>
|
||||
/// <param name="winners">A collection of winners.</param>
|
||||
/// <typeparam name="T">Type of the custom game over.</typeparam>
|
||||
public static void Trigger<T>(IEnumerable<NetworkedPlayerInfo> winners) where T : CustomGameOver
|
||||
{
|
||||
var reason = GameOverManager.GetGameOverId<T>();
|
||||
var data = new GameOverData(reason, [.. winners]);
|
||||
|
||||
Rpc<CustomGameOverRpc>.Instance.Send(PlayerControl.LocalPlayer, data, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly convert a <see cref="CustomGameOver"/> to a <see cref="global::GameOverReason"/>.
|
||||
/// </summary>
|
||||
/// <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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MiraAPI.GameEnd;
|
||||
|
||||
/// <summary>
|
||||
/// Data for a game over.
|
||||
/// </summary>
|
||||
/// <param name="Reason">Reason for the game over.</param>
|
||||
/// <param name="Winners">A collection of winners.</param>
|
||||
public record struct GameOverData(int Reason, List<NetworkedPlayerInfo> Winners);
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MiraAPI.GameEnd;
|
||||
|
||||
/// <summary>
|
||||
/// Manage <see cref="CustomGameOver"/>s.
|
||||
/// </summary>
|
||||
public static class GameOverManager
|
||||
{
|
||||
private static readonly Dictionary<Type, int> GameOverIds = [];
|
||||
private static readonly Dictionary<int, Type> GameOverTypes = [];
|
||||
|
||||
private static int _nextId = Enum.GetNames<GameOverReason>().Length;
|
||||
|
||||
/// <summary>
|
||||
/// Register a <see cref="CustomGameOver"/>.
|
||||
/// </summary>
|
||||
/// <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))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gameOverType.IsAbstract)
|
||||
{
|
||||
Error("The type must not be abstract.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gameOverType.GetConstructor(Type.EmptyTypes) == null)
|
||||
{
|
||||
Error("The type must have a parameterless constructor.");
|
||||
return false;
|
||||
}
|
||||
|
||||
GameOverIds.Add(gameOverType, _nextId);
|
||||
GameOverTypes.Add(_nextId, gameOverType);
|
||||
_nextId++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of a <see cref="CustomGameOver"/>.
|
||||
/// </summary>
|
||||
/// <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))
|
||||
{
|
||||
customGameOver = Activator.CreateInstance(gameOverType) as CustomGameOver;
|
||||
return customGameOver != null;
|
||||
}
|
||||
|
||||
customGameOver = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the ID of a <see cref="CustomGameOver"/>.
|
||||
/// </summary>
|
||||
/// <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 <see cref="CustomGameOver"/>.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
if (GameOverIds.TryGetValue(gameOverType, out var id))
|
||||
return id;
|
||||
|
||||
throw new ArgumentException($"{gameOverType.FullName} is not a registered custom game over!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
[*.cs]
|
||||
dotnet_diagnostic.CS1591.severity = none
|
||||
@@ -0,0 +1,291 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.PluginLoading;
|
||||
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 the game mode description.
|
||||
/// </summary>
|
||||
public abstract string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game mode description.
|
||||
/// </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 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=#{this.Color.ToHtmlStringRGBA()}>{this.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;
|
||||
}
|
||||
@@ -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 => "Classic";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew.";
|
||||
|
||||
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MiraAPI.GameModes;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for custom gamemodes
|
||||
/// </summary>
|
||||
public abstract class CustomGameMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Game mode name
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Game mode description
|
||||
/// </summary>
|
||||
public abstract string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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 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>
|
||||
public virtual bool CanAccessRolesTab() => true;
|
||||
|
||||
/// <summary>
|
||||
/// Should Game Settings be available when this gamemode is selected?
|
||||
/// </summary>
|
||||
public virtual bool CanAccessSettingsTab() => true;
|
||||
|
||||
/// <summary>
|
||||
/// Custom winner selection
|
||||
/// </summary>
|
||||
/// <returns>List of winners</returns>
|
||||
public virtual List<NetworkedPlayerInfo> CalculateWinners() => null;
|
||||
|
||||
/// <summary>
|
||||
/// Show gamemode in Intro Cutscene
|
||||
/// </summary>
|
||||
public virtual bool ShowCustomRoleScreen() => false;
|
||||
|
||||
/// <summary>
|
||||
/// Can Admin be used in this gamemode
|
||||
/// </summary>
|
||||
/// <param name="console">Admin Console</param>
|
||||
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>
|
||||
public virtual bool CanReport(DeadBody body) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Can system consoles be used in this gamemode
|
||||
/// </summary>
|
||||
/// <param name="console">System Console</param>
|
||||
public virtual bool CanUseSystemConsole(SystemConsole console) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Can tasks be interacted with in this gamemode
|
||||
/// </summary>
|
||||
/// <param name="console">Task console</param>
|
||||
public virtual bool CanUseConsole(Console console) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Should the sabotage map be used when attempting to open sabotage overlay
|
||||
/// </summary>
|
||||
/// <param name="map">MapBehaviour object</param>
|
||||
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>
|
||||
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
|
||||
|
||||
}
|
||||
@@ -1,72 +1,122 @@
|
||||
#nullable enable
|
||||
using Reactor.Utilities;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.GameModes;
|
||||
|
||||
/// <summary>
|
||||
/// Manages custom gamemodes
|
||||
/// Manages custom 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()
|
||||
private static uint GetNextId() => ++LastId;
|
||||
|
||||
private static uint LastId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Register gamemode from type.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
return ActiveMode?.Id == 0;
|
||||
if (!typeof(AbstractGameMode).IsAssignableFrom(gameModeType))
|
||||
{
|
||||
Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
|
||||
return false;
|
||||
}
|
||||
|
||||
var instance = Activator.CreateInstance(gameModeType);
|
||||
|
||||
if (instance is not AbstractGameMode mode)
|
||||
{
|
||||
Error($"Failed to create instance of {gameModeType.Name}");
|
||||
return false;
|
||||
}
|
||||
|
||||
IdToModeMap.Add(GetNextId(), mode);
|
||||
pluginInfo.GameModes.Add(LastId, mode);
|
||||
mode.ID = LastId;
|
||||
GameModeOption.AddOption(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current gamemode
|
||||
/// Checks to see if the current game mode is an instance of the classic mode.
|
||||
/// </summary>
|
||||
public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode();
|
||||
/// <returns>True if the classic mode is the current one.</returns>
|
||||
public static bool IsClassic() => ActiveMode != null && ActiveMode.GetType().IsAssignableTo(typeof(ClassicMode));
|
||||
|
||||
/// <summary>
|
||||
/// Set current gamemode
|
||||
/// Checks to see if the current game mode is an instance of the HNS mode.
|
||||
/// </summary>
|
||||
/// <param name="id">gamemode ID</param>
|
||||
public static void SetGameMode(int id)
|
||||
{
|
||||
if (GameModes.TryGetValue(id, out var gameMode))
|
||||
{
|
||||
ActiveMode = gameMode;
|
||||
return;
|
||||
}
|
||||
|
||||
Logger<MiraApiPlugin>.Error($"No gamemode with id {id} found!");
|
||||
}
|
||||
/// <returns>True if the Hide & Seek mode is the current one.</returns>
|
||||
public static bool IsHideNSeek() => ActiveMode != null && ActiveMode.GetType().IsAssignableTo(typeof(HideAndSeekMode));
|
||||
|
||||
/// <summary>
|
||||
/// Register gamemode from type
|
||||
/// Checks if a provided GameMode is the current active one.
|
||||
/// </summary>
|
||||
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="CustomGameMode"/></param>
|
||||
internal static void RegisterGameMode(Type gameModeType)
|
||||
/// <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)
|
||||
{
|
||||
if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType))
|
||||
{
|
||||
Logger<MiraApiPlugin>.Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
|
||||
return;
|
||||
}
|
||||
|
||||
var modeObj = Activator.CreateInstance(gameModeType);
|
||||
|
||||
if (modeObj is not CustomGameMode gameMode)
|
||||
{
|
||||
Logger<MiraApiPlugin>.Error($"Failed to create instance of {gameModeType.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameModes.Any(x => x.Key == gameMode.Id))
|
||||
{
|
||||
Logger<MiraApiPlugin>.Error($"ID for gamemode {gameMode.Name} already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
GameModes.Add(gameMode.Id, 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;
|
||||
// TODO: Once Hide n Seek port is ready for release, we will remove this case.
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
var hnsMode = new HideAndSeekMode();
|
||||
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;
|
||||
}
|
||||
|
||||
ActiveMode = IdToModeMap[0];
|
||||
Logger<MiraApiPlugin>.Warning($"Unable to find game mode of id {id}!");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace MiraAPI.GameModes;
|
||||
|
||||
[RegisterGameMode]
|
||||
public class DefaultMode : CustomGameMode
|
||||
{
|
||||
public override string Name => "Default";
|
||||
public override string Description => "Default Among Us GameMode";
|
||||
public override int Id => 0;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
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.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 = CustomStringName.CreateAndRegister("Gamemode");
|
||||
internal static readonly StringNames CustomName = CustomStringName.CreateAndRegister("Custom");
|
||||
internal static readonly Dictionary<uint, StringNames> Values = new()
|
||||
{
|
||||
[0] = CustomStringName.CreateAndRegister("Classic"),
|
||||
};
|
||||
|
||||
internal static void AddOption(AbstractGameMode mode)
|
||||
{
|
||||
if (!Values.ContainsKey(mode.ID))
|
||||
Values.Add(mode.ID, CustomStringName.CreateAndRegister(mode.ColoredName));
|
||||
}
|
||||
/*[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;
|
||||
CustomGameModeManager.GetAndSetGameMode();
|
||||
HudPatches.SetGameModeText(CustomGameModeManager.GetMode(Values.ElementAt(_lastValue).Key).ColoredName);
|
||||
var gm = CustomGameModeManager.ActiveMode!;
|
||||
ModdedOptionsManager.AddSettingsChangeMessage(
|
||||
HudManager.Instance.Notifier,
|
||||
GamemodeName,
|
||||
gm.ColoredName,
|
||||
new Color(0.7333f, 0.7333f, 0.7333f, 1),
|
||||
gm.TmpIcon,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,531 @@
|
||||
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 => "Hide n Seek";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "You can run, but you can't hide!\nOutlive the timer or eliminate the crew.";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MiraAPI.GameModes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RegisterGameModeAttribute : Attribute
|
||||
{
|
||||
private static readonly HashSet<Assembly> RegisteredAssemblies = [];
|
||||
|
||||
internal static void Register(Assembly assembly)
|
||||
{
|
||||
if (!RegisteredAssemblies.Add(assembly))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
var attribute = type.GetCustomAttribute<RegisterGameModeAttribute>();
|
||||
if (attribute != null)
|
||||
{
|
||||
CustomGameModeManager.RegisterGameMode(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Roles;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.GameOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for option groups. An option group is a collection of options that are displayed together in the options menu.
|
||||
/// </summary>
|
||||
public abstract class AbstractOptionGroup
|
||||
{
|
||||
public List<IModdedOption> Options { get; } = [];
|
||||
internal List<IModdedOption> Options { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The name of the group. Visible in options menu.
|
||||
/// Gets a list of the options which are a part of this group.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<IModdedOption> Children => new(Options);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the group. Visible in options menu.
|
||||
/// </summary>
|
||||
public abstract string GroupName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A function that returns whether the group should be visible or not.
|
||||
/// Gets the Optionable type of the group.
|
||||
/// </summary>
|
||||
public virtual Type? OptionableType => null;
|
||||
|
||||
/// <summary>
|
||||
/// 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.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the function that determines whether the group should be visible or not.
|
||||
/// </summary>
|
||||
public virtual Func<bool> GroupVisible => () => true;
|
||||
|
||||
/// <summary>
|
||||
/// 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 => Color.clear;
|
||||
public virtual Color GroupColor => MiraApiPlugin.DefaultHeaderColor;
|
||||
|
||||
/// <summary>
|
||||
/// The role the group is associated with. This is used for the advanced role options menu.
|
||||
/// 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 <see langword="uint"/> value.
|
||||
/// </summary>
|
||||
public virtual Type AdvancedRole => null;
|
||||
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 CategoryHeaderMasked? Header { get; set; }
|
||||
|
||||
internal bool Ready { get; set; }
|
||||
}
|
||||
|
||||
/// <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 type of the optionable that this group contains.</typeparam>
|
||||
public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOptionable
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override Type OptionableType => typeof(T);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override MenuCategory ParentMenu
|
||||
{
|
||||
get
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (type == typeof(BaseModifier))
|
||||
{
|
||||
return MenuCategory.Modifiers;
|
||||
}
|
||||
else if (type == typeof(RoleBehaviour))
|
||||
{
|
||||
return MenuCategory.Roles;
|
||||
}
|
||||
return MenuCategory.Game;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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,
|
||||
|
||||
/// <summary>
|
||||
/// Determines the option group is in the second custom settings tab.
|
||||
/// </summary>
|
||||
CustomTwo,
|
||||
}
|
||||
@@ -1,27 +1,34 @@
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
public class ModdedEnumOptionAttribute(string title, Type enumType, string[] values = null, Type roleType = null)
|
||||
: ModdedOptionAttribute(title, roleType)
|
||||
/// <summary>
|
||||
/// Attribute for creating a <see cref="ModdedEnumOption"/>.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? values = null)
|
||||
: ModdedOptionAttribute(title)
|
||||
{
|
||||
internal override IModdedOption CreateOption(object value, PropertyInfo property)
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
var opt = new ModdedEnumOption(Title, (int)value, enumType, values, RoleType);
|
||||
var opt = new ModdedEnumOption(Title, (int)(value ?? 0), enumType, values);
|
||||
return opt;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetValue(object value)
|
||||
{
|
||||
var opt = HolderOption as ModdedEnumOption;
|
||||
opt.SetValue((int)value);
|
||||
opt?.SetValue((int)value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object GetValue()
|
||||
{
|
||||
var opt = HolderOption as ModdedEnumOption;
|
||||
return Enum.ToObject(enumType, opt.Value);
|
||||
return HolderOption is ModdedEnumOption opt
|
||||
? Enum.ToObject(enumType, opt.Value)
|
||||
: throw new InvalidOperationException($"HolderOption for option \"{Title}\" with EnumType ${enumType.FullName} is not a ModdedEnumOption");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,51 @@
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Utilities;
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for a <see cref="ModdedNumberOption"/>.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ModdedNumberOptionAttribute(
|
||||
string title,
|
||||
float min,
|
||||
float max,
|
||||
float increment = 1,
|
||||
MiraNumberSuffixes suffixType = MiraNumberSuffixes.None,
|
||||
bool zeroInfinity = false,
|
||||
Type roleType = null)
|
||||
: ModdedOptionAttribute(title, roleType)
|
||||
string? formatString = null,
|
||||
bool zeroInfinity = false)
|
||||
: ModdedOptionAttribute(title)
|
||||
{
|
||||
internal override IModdedOption CreateOption(object value, PropertyInfo property)
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
var toggleOpt = new ModdedNumberOption(Title, (float)value, min, max, increment, suffixType, zeroInfinity, RoleType);
|
||||
return toggleOpt;
|
||||
return new ModdedNumberOption(
|
||||
Title,
|
||||
(float)(value ?? min + increment),
|
||||
min,
|
||||
max,
|
||||
increment,
|
||||
suffixType,
|
||||
formatString,
|
||||
zeroInfinity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetValue(object value)
|
||||
{
|
||||
var toggleOpt = HolderOption as ModdedNumberOption;
|
||||
toggleOpt.SetValue((float)value);
|
||||
var opt = HolderOption as ModdedNumberOption;
|
||||
opt?.SetValue((float)value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object GetValue()
|
||||
{
|
||||
var toggleOpt = HolderOption as ModdedNumberOption;
|
||||
return toggleOpt.Value;
|
||||
if (HolderOption is ModdedNumberOption opt)
|
||||
{
|
||||
return opt.Value;
|
||||
}
|
||||
throw new InvalidOperationException($"HolderOption for option \"{Title}\" is not a ModdedNumberOption");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 334 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user