From a940e5fab56dfb478a39dbd35b5a8a0595d4f289 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 14:49:46 +0200 Subject: [PATCH 001/199] Change File name to MainLoader --- .vs/Synapse/v16/.suo | Bin 0 -> 13312 bytes .vs/VSWorkspaceState.json | 6 ++ .vs/slnx.sqlite | Bin 0 -> 90112 bytes Synapse/{Class1.cs => MainLoader.cs} | 2 +- Synapse/Synapse.csproj | 90 +++++++++++++-------------- 5 files changed, 51 insertions(+), 47 deletions(-) create mode 100644 .vs/Synapse/v16/.suo create mode 100644 .vs/VSWorkspaceState.json create mode 100644 .vs/slnx.sqlite rename Synapse/{Class1.cs => MainLoader.cs} (56%) diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..ca791cc6576cb9c5179767d86045d3777fb56b91 GIT binary patch literal 13312 zcmeHO&2Jk;6rZ#dQoai%{h&Z7rL<5dv15|dv?U)d5GiRwoum;&NcK8OO`O+R0Y*L(A3 z-kUcc{^{zD-@f{8@9)9|C&X59V`aOz+lX&Lc#HmiSctn2X55XHl@&&B1tPc!w~+)+ zivoVjqFtO6OL&*WMRsLiXcODYeZH+mslWHWlN#>*rR6^4`w-)YFb;|Z@wONS^*Mx2 ziVG?s;Ij=Q(iC@)VgtzJkT26G-J-~YgOZp9rXY(naJEK;2gH_^dg=F|&aa(%$Hcp! zk{3C&pEz$&P9mlhfIjt*dPzQNWS7Y=;& z5qn-t3S0U@N$CltA)(dK(SZL$x$Bxzpp=(BP!6Fb^aG!B;9?%JB}rMO=n~cMBcM-P zPJe`ws!m<|D}iW^9m1H%!228pwUR@dJ|87vizzvRR6eige$c00P(OmwKZ?Bc*9b#s zeHye#EeFcyS8<{8c|GBOR@q&zd}h2U|3S#RAQsU7X-Htf@IK8F-r;>{e+!anBZ9X7 z1oBe12@|sQ3t|MVw;}bEI17GC2ys-h7yN<#H`kqd{_)SPQjg1gAD4Uqd=J{-7{0*SCE1oshpTKr&sK0dcB{Xfmo3E|@8k(V>#8}Tj)8_G`7AX5q zO;ju40j!FPu#X&n9EprIp~o5jdYx#dd4=g)a?MIefhsMJ1-&N~Qa+713rH*cI(Q>r zw2gMzN~p4Y_JKbA4!!=YqC8VWbJ;(7Jk>QI{#zk;HyT-R#4;G!4t6rZG1IW$%ix{hU z>`>|5q7IA`TeRBUcK(xV!-v1Uo{ao?>N*>s<)PnRjrukB@mt?qxpeJ~)}6cF{3Da` z%6F&6Qy09D^9s}MbpKzEk&XDK{?mVJ6q+qh-@O_7v|}t^siWAB&%n?u|A7g4WUTP* zks&~|UQ3u+n~5{)2^wZUegv#N8*rUtV^*iP-Husd8R0DA3Rv3@Bg9!@3NywG<~^=W z^2j{{-yr40MnxPu05Q=cpMCHExzH@T%Yt2@wNSk(#Al)6 zE+@KS)q14dz6cd(>YQ=`(kntAlxD84mDPQyHIwVddA=~5jj&JBq*L;> zF8IXeFH-*U51C~czV*Os0Hd%vd1-aH8lca>H9@hw124pJ+%4m-6?d+yf&19p`<5b; zClL(i`XQ#l&eTLA8tY4RCEklhd$O_E(O6`*yEhw&N3Com-PPM0na!lFv=z7dEGzy# z*Mg){4@_U>?nvWsK)6p}Y|)OD4y7N(3WrZW;Am(Dz8{}n>HJ~-FRORY2aW9iHA8!| z?D|Wv#Ti24_q>!5PC`%s0=$+z@Nv z{EK^&+%F{f(I0{r!1Y`KD}Yzw6%?dba7vyq>2tUfpwGK&`p&AXw8n#TCg*xWQ2Kf= zl4~RSV;XS&Uv<``<7>S&{ZX8DPGZJ)--Bs4ZX)>Ab+7^Y{ismWUw!_|^$Sm9wS@hs z3vgb4`(H$r+_xvV=?|ixc_O?3DHr6PuKyj7L!htkAk&7cTK%8hNFH&rxasrG1J9nh zzu|rBqEbKPU-$iQ-l^c+N?41&x`C9H`c{h{otZ~ zrA;m!3r!ES9RrO41NjpQ6lkvf3wkNgb8kfh^i&kR6={J2L2~HK?#}+0U5bj_s!;kR z^n<(e-prfNy!Uo~P^xW}bW@Y=b$bV@DP4;#!~`MsBT0(IVhQqnfqb*qIr4_yV=sZd zIpTLBwz6EABmzSEYby47`s=yR=N4vfCtuFInEpbHPi@6NoA_#?I`RGywV>#15SXTB z4!=JyX71#K;g)XfX^(4%2fN))LA$3Lx~X@Kmi^Y)U)MWYaj#X35=zTeC0|#hV!5Dv zAnhEhj%F$;k=JH9EZ>xtc7n||v%~W#F(VT*Z$_J0Ru8mjjXo zYH=f9y(`^T?n?PaeY035)ov)|I!ApFv$6W5-2JtCB-XZ#@GPM+xe<|D_>o@di{FV zHJIbdRMrQb&f(TT?dbP(Z7-^V;CL{-+r&#eUaZHgG~aG({l31dcW4(~th^ZKgCRMu z%YJ|~P-=&LQ#)`G^0z2T$~wrUt!PgdLawN}`4JIZ*$xnPv>#UtzS#T>6gd@tO3GyAlWv?A_#(~3A=i@%-? zMjT&E+Gi2R7x`o67!l_TXq3$%&k01F)$VwQc{P7wVeRh}^Y?%?Owe^+b|V!3(Lr86 zd_b}!%T%lh7I}63Kub>;?1pVv z(izr9xwzGEpFB*)Rr0wPD|0$Vo-yo>Z8Dcg+|q5W*C&A%%KT4a(_$u@6`sCp`5~*! zu0D7*6ZFAgq0a+Zfq#&W;d!=axCYzZ@zU&-v00Y2>vr`x%5=zXh+;;`u_5Cfxm8hn znqjtR+UCoqBgc=I^4H)SN?wdk7^0re%j9upnZPShUmmVaiJ1>c<~#H}ifME((11>8*sFq-8Hj`)KiY zP6h*nFZP89Uv#oiv2FIe{1`Klkz?THIxCOS`4oMfU`p_68NS%3Y?{(qF+2?{seN;E zx3BdcX=GaDWnO2tC>50Te4|vC+Jl}Iu_jB?B*?pQF|)cT4BxcEq^6msZtPnz?aa6B zJBgq_h2<U3;#eoX}G*m3UqT+X?3YM!>Ob_Qe|Iqz(cwc2aR6!|$h|5Ysg zxAbq*zfM0RZ}9>F5C8!X009sH0T2KI5C8!X0D#Wz&m25(Wa++%zf`t&L4ra= z+aQNgspQY!N+e?PYXxn0uwPeu`%c& zn5!2j60zJhxu>b7wzt`9JlLaeu3TTawz_il%GE2<>N_{yxqf4H^@5OyUCh+T3Cw}& z?8>gLTwA$L*Z&jgKgZJlBtP&10T2KI5C8!X009sH0T2KI5C8!XID-VvO~i9E{3l#y zh4`Z2>@G|uNv|f;&tmC6rGJ(FUHV!2?`N=^Fc}0u00ck)1V8`;KmY_l00ck)1kM0~ zH{-H!#K#aOY55VK4oIAjUlu|i4T!%H&k6ho111*Y7iR(=0-)#rLi(>U@`V=&fB*=9 z00@8p2!H?xfB*=900@AzAI|?}zCZW* z+`{bbTX!mqO zH}$U3vfmo}>v~5k?zM_hLTS0GVXz*-252hJk2pCQNgApZcOo?j~|5j{^OmuxN}h{e4o;agX3DpjdcEpFticct6PT`AwFZx+j>+6|>#CsvW~ zMya&y)KcknAL)Bq&#%p7Y!NyLRb^eNDrH%zNjpqKF-+Y&Y%aMsNEKO6g^XLHQlKCR z2033)0!0O-qVDTS`o)<@z=A#h~tY%`z+%4B7e*rBjTI^jj}o9If00? z+8ysOujVf-to@y0{vNP~3A)b9ZiM1LI>_sX4@j0|nTj>RBCoC=Xnj*Xc+iw+@~9U# zNG2uuih5#hM$BB!3Qy9OC$eT~eJ%Qf-LMTyI>Xv17q=SjlZVN;NIl zUYfl!Hp{Yh-L4)-nGV?vQOqbgHe|dbw<>B+Gt3rE+kDw{|ZA{;e=*0O+|FkI7 zETs}{@YEQCJy!4;hR>N)HKu7jeRSoo%yzXClU0gu$<*a)^y)i7!|bH%EVOW(k0=p z6o8?JE4AkM!`G_%8-f|yxc6rN~SosMnJuZch%JI-C7 z%Q<&W&C|Bk&VY;~=biRL(pvw=UdGbpxtFv5n%$gU6+fQ(eWDcqCAoR(ujdPIi05;; z=@)k%>Dothu3k~i`_>as*ZTam!+E=?+>!V)N$sbScZ&5}ByQwJwN~6#!ZP`qGgYJU zRU=Cbxh{qCft0UFYid6*2QTg|OQQmq%FDLj+amT8oT|_?5hynAOY7CmjZmvzM_jK+4aYIR^ zE1pcTTqdi~_sP05M1o4L*T}NolO~;s7^V08_Ryrmu#=RNO0v|}-EU2axUP)&8@D#+tQ#V!O>X|Ql) z9g&Y|S{+TaUL6c`GyClE>(&JJ7nitaG*$8x=+*gPjtmz1Qf08{SH=8W`d&ibJfu}wbw7YTCPRda$Deo~beja~Ims5Fi`#Kf z&$j>VLL^`poe(x9H@%EV9{l8G literal 0 HcmV?d00001 diff --git a/Synapse/Class1.cs b/Synapse/MainLoader.cs similarity index 56% rename from Synapse/Class1.cs rename to Synapse/MainLoader.cs index c140395..bbcface 100644 --- a/Synapse/Class1.cs +++ b/Synapse/MainLoader.cs @@ -1,6 +1,6 @@ namespace Synapse { - public class Class1 + public class MainLoader { } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 414a5f0..85cfeb2 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -1,54 +1,52 @@  - - - Debug - AnyCPU - {93AB5927-1313-45A0-A27E-6AA8CA7C7BE1} - Library - Properties - Synapse - Synapse - v4.7.2 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - + \ No newline at end of file From 5905cf61a601d24e0408cfadfad2bfacb2bd2ead Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 15:39:52 +0200 Subject: [PATCH 002/199] Create Directory --- .vs/Synapse/v16/.suo | Bin 13312 -> 34304 bytes Synapse/MainLoader.cs | 26 ++++++++++++++++++++- Synapse/PluginManager.cs | 49 +++++++++++++++++++++++++++++++++++++++ Synapse/Synapse.csproj | 10 ++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 Synapse/PluginManager.cs diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index ca791cc6576cb9c5179767d86045d3777fb56b91..267684df1a777d0cc722eaf849277c0f0e135661 100644 GIT binary patch literal 34304 zcmeHPOKcm*8D82+>!eAV#Ho{}X`{G~<2*=H6h%sM9^y-mQ^{6L*>Ms!2}M#e9f}f2 z`BmFR5d`R^K#RUm^iZVj#b{9!EznyJMNdU9>7_-HQvwv|t%o*;07avI-wa1PyV_mu zQfr%xImEw@+1dGL{`qI-e=Yy=?mh4S^fwQFVA#^L#!lnojoXY*Y55Uc?@;%58^$fT zX5Pme8yn2t3Bctr4G;y68>{%O8zV-+XyV*5E^;V+r#;54n`8cPm$&AB`{aL*rvDZh zLAh^yK^C3|##Q5taRk_xa8)oa$Ok@;d%%%8x&6GhfY01NH$P1?&er1~>qC z9Pk9-Nx)NpD8Nr!bo|3>cM60#|2tC}BjlX!-nCIWhWXFAH+=)=e*^eKoc|G>y3Ref z=01(v5a+*Tu30fT-6yRmRD}Yx4CBRn!uK`{Mya6Z!76BE2YL9;AUVR4eruH1DLrYmm zJgcaE1ubde>{sqVb3}Rw@<#+$TnpGJnd^OA#$)d7Obfu<2Hsi7I&DZoMdP%P!PY?$ zN=9v2%=Jk5hkQkz^oxH9Wx2jFQSPIZ*MjU-h8#A7b~JF`Hk4#oLrd1dAFC+Al02HN zn(9IRMKhLK0T?CDCU=9h#NSViu6v|tsO>cCeQ*iEeJZLWbkBJ2z2o!|Z+L)mdI z_()#zCuzgA)hki{y&VO10Q}<5pzPI7rB*8E1?B6If}6N%b;@|1M$muip_Cu};@9ba z5)@tlbyqR!i#T2Y2NLr+(7b}HZfS34{JB2*#m`#VW~L+H{30}ui;!#+*u|3A(Izpf z86ySWEa1r9%suT#|2dSz&E#Ivd{V_F$BW5}|4x85q(vSxgW8Z&ilHX%36BE&;@9b4 z6qM&ompm@#*%I!SF)LaEvwY%&ojSn|vH$E1fWLsU=Q;#9hEYF*Rec$_>~s92kRY7# zs$7hJgnQZuz;FNaD68n71K)84Y-87`gWBh}v;u`a64yWC-H9@O@$2+Iftg0Fw`^2_ zy=q(aoK_rbW7vP<<(_^m@OQHZkpGF7I^wm!&lTw$<|JiHrv&~BEdT5De;%V=6|`?+ z9cW-QX2gu(Xtcl;-I7{=*mtIG<@sF4&;Bi9rY++~j4z29SHUjKJ+OPi`YY%zvHQbM zxty{hlO2B+ZK$CQZ(>bc1#PUmt$as69svCxK?Zddzy0TmN?DG{j-UL-b$@MhMe?Qs z_)pj^C=2_=Pn}80A5QqClu<=1szN^TYEKINr=InA0Q}@-g`d3O1a|qKWhmqE+^_OK z`=$4Ve5T*4Yo-5j9cEq@=bWubyMb&)lwQlenex(29Qn{XUCzcYV_y-V&Obl8(042>Czo z`b*wYHR<}s9C(3RklYDk*bBG|G{q?J%=O5g66pV9$lML^+keU`2Rapb;m>twu?iX- z?(pXtwC}RemgKtpEby}~+8g}hr|iYGjL9#4r6X`8*0i0m7yT~+ybAvutOq9`J=%F~ zMAJk?LtPG>e-Gms*K5E1pGH}Q-@gA)|K%FM_E7%rrUR+@Pdkub{KWl7ZrDif_%C9V zsgX5gL6;-b7E=GlVC<%at5Lg$$szq9e^0`wtSj+e0+An^#ca|?BWl$sie$@7<nUdO{_A=5R;!E# zKkj=oXoJ4*sM^VYs_%aB(_W+2UoZS8MbFoTjdXFd?|h>Q%A6Lv&@}oV6hCRNQg*(z(EP-{;;>{A~X>fAQK6cDE}3iT`O|_IJ1ce*aYEucscu zwKHa!OFHmbOqOCL~A&cl0F z>a73N5jY1{&=Sr`&d?Ghg&dw2!JoXoh&;JU*Sg-vFw5ImePsm59e;?6=n!fL*AHt< z$e8SnO3#Ike^uBROPf8F9)%d_M7v)NbGePNJcA?0S0#=LHEnZ+zKq?f2?~!0ik~pP z1Ll1pTg+kXa^5A2x!kO(S3h$lS^@q(I;K3~9(ZleUE?^zb028gH(%&}d3H?59^7#k1wZK#M_j+@p$m8X75z<0+Br3b z6_qrg6fJ2?o~AEPN=o+Ds@+Qz&<>Pr4x%3FQOlU8V zr_olf+e~5k|I{8RYxO=Z<1u9rrV#vp5&GVO=%2d$;pKnv>HibH7wX`Cx^xPxzjL_`kTLD*A`u{}bcR zv1dZnU6W3KwSREeb=oI;l}lq=_MHs&B-(Yk@6+GQnQrc3`NHfG?slY2u-%_4xQyAT z8Y3N9`8;Z;rbrpozW+rb(=f_}TIU+99P~AFmtM!6l*n{xU>SQR>B86$(u#@gWGqj( z?OX#@xI@ztQ8&JZwpU?!Q8J?3z1{Y7YoA_6Pqx%19sg+!e+cn^ zf$6X7AKmbCJ@!iUKhyTbHN|iLgW%`<{3OT!g%SUAD`+1i{_Sa$9|bTu>;Km_{)Zk0 zC4X4$Prb$eF!qH$WxxE#_#GjLlH~bBZY-anYq*>&ojp{&T zuNZ0!)y!;To;LcBa_7Kpy04Cud#A6)mM!GhH;g*2W7bj*F^n5KZ>eiF(3T~%&0Kxe zeSfx2wz=PEw^cgA;EE*2S=|LaM>Zwcpl{0Z$_~=eqWEbd)fvJbYcy>P--a_<*7}Hd z(}3=Bo>!bMDnMc+r}ZcEy^h4co%H^{Ha6xk>l$L#QDWhqNtt+UGd7Gdp*ux{6)ktx zM85}RZzi)X^=aH>4;B}uMiUcL@u^Frqp4~lF`0wdF!agp=qfc>fh3Lg#Slc`-owLfzn%%?Qx!!UMkW&SPbi~_E@{|-S>_> z{_79((SIKOkR4F=Aa!=@lt~GvD@7%BcB`fLeELoO@jr1Kf|P3*m+%iEV~DcJ;@`I> zp$VtOw_0P+0>^NbL~aJ-8^w{&3b;z)Is=(1hhrMYG~O+s{1xcXRje!4c_+WRm9vhN zJR~^8T1Hs}Wh^_(?h-M8VYclMS{rt6`E3#Z--mHkHNzfJAHz;dj|l&L=rpbxppK#g zsn2f%!t7y8^Zy2I3%$4*w3E^bBh7PYJ0qJp67+_dmVJB8`YOseVEQk17(b8Xu~K5K zoE*z!$0rl%=;+w!STs4FiAOVubRn9`WF~T%bS|AOj9$51yx1(SwQHr$IaX<}wN}qu zu1=M3UT&3FR_e7@tyyYU*4m9yyHi@7*BWP+>&=yNv%Fku;oZxZFJ)4>bTXNlh{g-a zOf)%@OGPIpQkiHxl}t>G#mAGWbn?nO*Rzo;<$ANRTCN6aA=X>*hghJgQJ)?NqVDv! zRW6n*6+a+s=Z76k6qFdaVoMaSZe%+3F86`n(?0BS)_(wO8;qi+ z#4`%%fJd)Hk}Pgh`>@M^W=uR=z;B_X82fg}c%%#yOxCn}8~$GZ_G`bo`qq1|?7Hv% zSO2lN=tZl3d=_RrHph|nCmF4L3U-TzkT2Djb#76vSr8_e7SS!{pHW5pTKyuVTz-j1 z?Z1Y$s0eC)X z_~?mquZE1l86T@0p!Qs~&r*q9WBC7fO2AIN?hlEVs%;QS8O1HV(WPQ}UCeDaj*K{l>H1QD9NO!+ zDemqy{*67|;n3afD@VQ7{Axco<5A<3;I2W$$?hdxySFh z&3%9GhZn!6B*|cB%Fok)?zUsy!cRR@j|G!BRrHi|ESdBBN`99$$fJsOitCv!*NoqD zdE_hGDSj_V{2%m$VDWpl_`gAq-*bvuGxN-mlvf-QUYR9s_V_eZx)dF4buD_ala z_uOL(hw*z}v4q3;y=xt0IE>%3gt`yo_w=|_e}R7?2b0~`**u2vdwT3}$rAM!GRf)W Zm;(&s_pE|T=WZCkH`wuej)NK?^Z%%LY|8)u delta 1303 zcmcIk%}*0i5Z||KKPX#Sq(BQzfNCO9l&uOysIm=3YeBXKqa+vu@iUDFj5d5o!p6u+ z53;|D2T$n1c!E@;@kAnbqX*Ca2YR3hnkde+UF^w|Om;dmzc)Mc+j;NRdMsPFR!3yv zLc83$=X>*=v9qx+qDGP=OT)Z8FA^xY7hOFBtYEHcSXIcANw-Pxsdc}9fC4uuO9O;b zA8sO#msuJse3g9YzF;U+27gn6i+r|0vflifVv6O-j4h8ij6Oe|br>0SMMgSJP(%NK7*uEe%pAztv-}aH^ zxs@wC(Yd6f$ID3^$H?!kh#8AhZ2JOGYBaoSN-a;musf4T*2iIKgMOjWaxE!S;i0?x zD9|PR)Y2;VZN4A>sGNT>z6mqJmRuSZU85a^KQRpyL&T6j6#y$T9Z+!*e z?x$d!8v4`Nkabsr!k3uJ4r3#c#B?_P*S0=HD%45amuoZC0OdKm&Hb?1X2CKQ%(gGU zxU6_Mfh50uUWk>Y-5F|eps!&>ETJJ08L;br3dS`g9PgN)X@8CXr>Nb z-UGu-BR%r~s@a3nkv_r{tY;KaizTyPmF`N{r6bY|*=anRyNDavE3n26;#H=xcAUP7 zCn!mR9)XXUC=QLQF5a#x8bue@CoC8lLwl1M-|l*Q^V`)}XfZy$bs#^LeJ+U0xm`G6 z!P4nk{m;k4RXiT}5xZ{>DKzA{-eHw*oAXal+vThis method is called by the Scp Server in the assembly-csharp + public static void LoaderExecutionCode() + { + if (!Directory.Exists(PluginManager.ConfigDirectory)) + Directory.CreateDirectory(PluginManager.ConfigDirectory); + + if (!File.Exists(PluginManager.ConfigPath)) + File.Create(PluginManager.ConfigPath).Close(); + + if (!Directory.Exists(PluginManager.MainPluginDirectoty)) + Directory.CreateDirectory(PluginManager.MainPluginDirectoty); + + if (!Directory.Exists(PluginManager.ServerPluginDirectory)) + Directory.CreateDirectory(PluginManager.ServerPluginDirectory); + + if (!Directory.Exists(PluginManager.DependenciesDirectory)) + Directory.CreateDirectory(PluginManager.DependenciesDirectory); + + CustomNetworkManager.Modded = true; + Timing.RunCoroutine(PluginManager.LoadPlugins()); + } } } \ No newline at end of file diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs new file mode 100644 index 0000000..71f6300 --- /dev/null +++ b/Synapse/PluginManager.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using MEC; +using System.IO; +using System.Reflection; + +namespace Synapse +{ + public class PluginManager + { + public static List LoadedDependencies { get; } = new List(); + public static string SynapseDirectoty { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); + public static string MainPluginDirectoty { get; } = Path.Combine(SynapseDirectoty, "Plugins"); + public static string ServerPluginDirectory { get; } = Path.Combine(MainPluginDirectoty,$"Server{ServerStatic.ServerPort} Plugins"); + public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectoty,"dependencies"); + public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectoty, "ServerConfigs"); + public static string ConfigPath { get; } = ConfigDirectory + $"Server{ServerStatic.ServerPort}-config.yml"; + + public static IEnumerator LoadPlugins() + { + yield return Timing.WaitForSeconds(0.5f); + + + } + + private static void LoadDependencies() + { + string[] depends = Directory.GetFiles(DependenciesDirectory); + + foreach (string dll in depends) + { + if (!dll.EndsWith(".dll")) continue; + + if (IsLoaded(dll)) + return; + } + } + + private static bool IsLoaded(string path) + { + foreach (Assembly assembly in LoadedDependencies) + { + if (assembly.Location == path) + return true; + } + return false; + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 85cfeb2..49e0715 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -32,12 +32,22 @@ 4 + + ..\..\Exiled Verweise\Assembly-CSharp-firstpass.dll + + + ..\..\Exiled Verweise\publicized_assemblies\Assembly-CSharp_publicized.dll + + + ..\..\Exiled Verweise\UnityEngine.CoreModule.dll + + From af0c44b90e7856505ce0d2ecc374100b2d462e89 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 15:52:44 +0200 Subject: [PATCH 003/199] Bug Fix --- .vs/Synapse/v16/.suo | Bin 34304 -> 33792 bytes Synapse/PluginManager.cs | 10 ++++++---- Synapse/Synapse.csproj | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index 267684df1a777d0cc722eaf849277c0f0e135661..95a75e03c8ec062942473acfc3215a34e890ec18 100644 GIT binary patch delta 1259 zcma)5%}*0S6z@!T+ilr}0!8_h(ttoLO$ikUln?2WG(g-H4B(Rl0EMmb;B4N`%fg6wYel|t>39Qk2u$)8DB8S6Kj8=wrXln&HFG0J2=0__>J3xOa_RJK%5mDdW z9qorH*O#MMhFcQ}UkqPof)Jrzu-ttl3Rk2D65n^3ySAm!^S1(7_HIzvs0o23ZwXbl zJ)(w_2H3Cdm7O@EX#7a`jGu5y{Fxb9A8+fwQbRnnFB?xHFdd5LFNf+EL55 z3GtSj5NLS;>v{JeuCy^TKS89tj8%Re)@cNc0$t8W$3>fySp^zZ93nzK8w^IFcFb_0 zE_3!cn`bvE!ox_2aPCi0t4M=*v#F3AM9Ssj`mHU-@jMYQcGQ zPx~3bP;`N_n$95VIEfx9#YO)gr7m4hZ_c`XvV{jcZ1^Ns;2@Lp=r(N7kjSe>V*7O+ zgtWrL@Lize0Wik|mL1u1!epc?6;frcDX*eaDvh+-oa9r~3L(L{^~Pam zK$W@twP@*cGoyWxEC(eDl4?Sa=1X<^VKv!_9UtxXhQLe;OzmFrfEtWJyVe7b!eN-~ z_ok)=Sl1FDYZCaUL(r+KFh3oGRo(C1A((?V7gW%E_^EfHTaY+EZRmB~jt^;4>H=$;Jo%W2hRIMwGJ=q~`9hj?s^lb&ahE$GT;O9TScu ve)vjYCtS|Z!;w~Cvs%_FxELIXa zV$9PPN-0#(?g8Hf$%7AqXmk7ElLX^~pb!;*fW8ZYj9?Iq=VYB`A^~xR!`%CwbI-l! zJKvr1U!r_b+%5>7fRsq+&iu}Iht;$=!gaohF$T|PI-yV0gBKbZh#}C9){3?gc-nB@ zf!2(+1ucQL8SOpBsIvBw>k(sR%!cWjr?8mn2e;OSMbQslZGmTDpYb<5iW~6ENb`O0 zueLH@|3DaFTu)oTlSCJI^071!pab}zZsQ~i%jS^D>TxInK5)ZJ=4vF>;I9C;!O?UC z){1JdO=cp}y)G<*XcUpoAnHYyU@==ZIi;g&*V0DOlj>J)Q;8dOL66t$$SwpTLC}pk zvIT)10Z@4{TU5DeL2i&Euf>tHLp%@#ZmSIk%Bt83 z_==!zDKB{?q|1dq6w;-xuerF~tnPOI8Ish!;K9H(k!YfxYVqmR9h^{K4@uI}Cv7bm z)N4N$ys#sa2!w*5yR&4FTKp(J32z#TMz8{KsmCb{THoUVM7JWkzQ5U3*5@-h&d1=N z%<$GJc8-m+Gwd{*K$~Tg>?d}L{m6d9car@|KDc_M6_OL-*eSL_G)(t*t4H6w4pq|k zWiM_>a`Vp%Uiz6qoc|BFv33>N^BEwE!g9Y|GCAFX^`gvulwHm?ImxOfxYpfWRSU^>En!m!M3dvnwJ!3xy#oIdMrE)@ zh4;@2*guqmg?tI3g|xB;@6~~DqTo1bu7B8|3>?|@kwaQ?IoyYIg zCoWj93(#KNjyp-PoIK=P`I1UFpbC@iz7EV|K#(y4F zEhn#QUoM5zhEiY|6weuav19Nelh{}=>e$518a%|cRdbvkBtTQfFLxUK>PRs3e73r? IbH9f^0GK=mQvd(} diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 71f6300..bbcc084 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -8,19 +8,21 @@ namespace Synapse { public class PluginManager { - public static List LoadedDependencies { get; } = new List(); + //Variablen + private static List LoadedDependencies = new List(); public static string SynapseDirectoty { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); public static string MainPluginDirectoty { get; } = Path.Combine(SynapseDirectoty, "Plugins"); - public static string ServerPluginDirectory { get; } = Path.Combine(MainPluginDirectoty,$"Server{ServerStatic.ServerPort} Plugins"); + public static string ServerPluginDirectory { get; } = Path.Combine(MainPluginDirectoty,$"Server{ServerConsole.Port} Plugins"); public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectoty,"dependencies"); public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectoty, "ServerConfigs"); - public static string ConfigPath { get; } = ConfigDirectory + $"Server{ServerStatic.ServerPort}-config.yml"; + public static string ConfigPath { get; } = Path.Combine(ConfigDirectory + $"Server{ServerConsole.Port}-config.yml"); + //Methoden public static IEnumerator LoadPlugins() { yield return Timing.WaitForSeconds(0.5f); - + LoadDependencies(); } private static void LoadDependencies() diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 49e0715..9d4b5d6 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -32,12 +32,12 @@ 4 + + ..\..\Exiled Verweise\Assembly-CSharp.dll + ..\..\Exiled Verweise\Assembly-CSharp-firstpass.dll - - ..\..\Exiled Verweise\publicized_assemblies\Assembly-CSharp_publicized.dll - From 09d7e326b87a505395524bc5468d1c2d6d7e88fb Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 16:55:30 +0200 Subject: [PATCH 004/199] PluginManager shoul load actually plugins now --- .vs/Synapse/v16/.suo | Bin 33792 -> 40960 bytes Synapse/Log.cs | 30 +++++++++++++++ Synapse/Plugin.cs | 18 +++++++++ Synapse/PluginManager.cs | 80 ++++++++++++++++++++++++++++++++++++++- Synapse/Synapse.csproj | 8 ++-- 5 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 Synapse/Log.cs create mode 100644 Synapse/Plugin.cs diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index 95a75e03c8ec062942473acfc3215a34e890ec18..4f3aa109fee4b7f6880ca8ccd25062782e8f8072 100644 GIT binary patch delta 1827 zcmb7_ZA@EL7{~9qy=`wxFBI2~A}=ir#K0&+U1rFf1quu)w5%HpTs9D}QY){w8+16k zM3=>p82fxO(GS+RuVU|_i-`uKi6kS-Fur_s$v*26OTvh8{!g*CWYf5l{Bq9ooO924 z&hvlnz46Opd{tcWiOfk=qSIuJUw`ZPp`VzGqK2FFO;t0g#^r?MJ7^aKp%gq0?&q~K z*cG4>*nkuKiTQH$`{|<8VB%IItX3M8{k3fvwF58c0G*%<90lFr1<*sEN;i3yeLOJ3VK}{vV#XMY(WcSaD8pd_3NV5Kz#}a}ZvchB0(d|N zsa3v0>w9JTLEg`N2(3xqi@81=eIsH1!^Pv{3$yX^F^`w`94aqy$$`He$H1&dYGjKLoPt}TvF}J32VEO$#w0n32U5n(Wdnc)~Q8{uZStLD3a)C-Kiso zKhvijw=7&8uF5}Krc2*s9$IYi%O!d4M2AFME$bFNe06z#N|yyP_b$$Nda5ODq5LvS zxYlGYcXo3v?Xs}M5tTfPlBn+0VwIN|@**cX3{+U1s_|eg0}|N2wjFky2>1TFR?~L- z?(ZKa)gNzsi7~BLm#6l<&Gd@vvpYlDJ2j0=T(N0i)m~@KW;_>w!cizc35DIl7&PTO zcD4Ds`Bi<;Je2d(Y~4`8vL^F{XM?1)#jh}K{il|cR{Rf&sHuekmdO%-8*^J0VJ&|l z@oQ{kZH$!A)nk<@_p^-k)4T5JhBK(jsPGbQGKm{Z3Nc|q7)R7WVG*|)#q2yh zy|~Lb%{JF+>rLP5Qjd9c4=WHzEjC-8!P&eLc}qCjA6f?adQ-Y|r$#)dAZ3e>WkmkJ z%J(ouaNwjTKrROrnNSQ>aDHLeVn?HZs((9TpJu4GiYjfnWe%_3R|U_ z{?lxPmiqh3W*(@$6SxbnzoXh#zsyJsmecAv8&w8v;Rf~|tqeqTk?9b(=*-~9^vS>q%gyUafAZ;^U0@1CqM^wt zYziqhT Ltk*m*#>Kw?y>2!? delta 1357 zcma)5&u<$=6!sghm$kjyIF4zY#&uIGw4o#-DQ+Etakh<1OXK=SgM?%d5|HvUIpHOy z7K%X;szll<`w68Y;$r>*=yHyXia1rMNEIgzrFU+&6sjoUjf;&fabToRGw;3c&AgfK zO|>qn*Ti=jfs8t0jJ*C;{&M0s8gaQ?ReT~Uw2Y?6;*OZ27h$;{uii(~{p!>Za}F^M zGxod2lWY$&qKpvZ2xE`q5q#=P(BAijd9u|dZ~o!K*W^(FSmGCX07~w4TMJD*!F-M3 zW%wBeLvDY7XO+>%ko)O8$8kpcQj^vxws2n?r@f8BzU|v}b`PoqG4?Ya+=yXP_|O>3 z;Z9^0pBrbDrzE=*csgg0n>~UdPeS47s8c$TCuOvU_YCu7RkFf=dE@I;3yIsO(}bVI zBuf43xbF`k;8PIx1@OSHXtGpUB;vkXxT|SiX-G`tSO1`%;_xgZ&9DbUt^1tkH6s2I zrIlw6W@u4z`#)g+hm0jgYnP3}yd9o1Tpo4=812GP3iEyWSsUSdx_nQmS0~sQT0?ne z-XQs!gWZvOQNhlk`BtjQ>+*0$ml7WDA;p-)0jWuUcfgD(PC0Uo?9`k=QZ3mbom0)5 z98KLNq@!!vSXabpM0Kj2Rc*aQ@4?a++Tzf=XzDqAfVn+YmW;e2rD*fiJR5Nj9vLqi zBs;HL%Wq2uh~9zKm+KLfuAtesO3%XztWpBaKu!usr(q>l{j#6rtMPF5&y#8g`9d+a zWb1S;R0_VLNmkoIFQFM+rE{8@+Y-( zX$IENf+nA|?E;JFlxH&Z|MejQR%D<2unsS1$GZ0N_}I|!*O7`U@1wh%tEopsURcqN z7HCB8DN@h&qr+TLoSicPp`4pr$m6rwBrX)EAy&eu7efs5pE-ouN8_j#6-Qa#_97ii zV(;UN_#roKmldq7T)@uN03zj4d((s|UF9UI<&f_W;^X8{aa0WSJ(pOVh)=z}IPvCW zA~A6V_3{)_Mb#@=*+tik%f4Q(-5>-jCvi*!k**{i^JZ00-1%|iPeIctY$fOf@>>;L z`darK8q#Z`OtL)*IW3vweA21#Mmge*;HbI&L`6UO%a|5@p|i L(VG~lZMy#k4B^C| diff --git a/Synapse/Log.cs b/Synapse/Log.cs new file mode 100644 index 0000000..20fb01d --- /dev/null +++ b/Synapse/Log.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse +{ + public static class Log + { + public static void Info(string message) + { + Assembly assembly = Assembly.GetCallingAssembly(); + ServerConsole.AddLog($"[INFO] [{assembly.GetName()}] {message}"); + } + + public static void Warn(string message) + { + Assembly assembly = Assembly.GetCallingAssembly(); + ServerConsole.AddLog($"[WARN] [{assembly.GetName()}] {message}",ConsoleColor.Yellow); + } + + public static void Error(string message) + { + Assembly assembly = Assembly.GetCallingAssembly(); + ServerConsole.AddLog($"[ERROR] [{assembly.GetName()}] {message}",ConsoleColor.Red); + } + } +} diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs new file mode 100644 index 0000000..933d989 --- /dev/null +++ b/Synapse/Plugin.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse +{ + public abstract class Plugin + { + public static YamlConfig Config; + public abstract string getName { get; } + + /// The Method ist always activated when the Server starts + /// You can use it to hook Events + public abstract void OnEnable(); + } +} diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index bbcc084..d324540 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -3,6 +3,7 @@ using MEC; using System.IO; using System.Reflection; +using System.Linq; namespace Synapse { @@ -10,12 +11,13 @@ public class PluginManager { //Variablen private static List LoadedDependencies = new List(); + public static readonly List _plugins = new List(); public static string SynapseDirectoty { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); public static string MainPluginDirectoty { get; } = Path.Combine(SynapseDirectoty, "Plugins"); public static string ServerPluginDirectory { get; } = Path.Combine(MainPluginDirectoty,$"Server{ServerConsole.Port} Plugins"); public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectoty,"dependencies"); public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectoty, "ServerConfigs"); - public static string ConfigPath { get; } = Path.Combine(ConfigDirectory + $"Server{ServerConsole.Port}-config.yml"); + public static string ConfigPath { get; } = Path.Combine(ConfigDirectory,$"Server{ServerConsole.Port}-config.yml"); //Methoden public static IEnumerator LoadPlugins() @@ -23,10 +25,22 @@ public static IEnumerator LoadPlugins() yield return Timing.WaitForSeconds(0.5f); LoadDependencies(); + + List plugins = Directory.GetFiles(ServerPluginDirectory).Where(plugin => plugin.EndsWith(".dll")).ToList(); + + foreach (string plugin in plugins) + { + if (plugin.EndsWith("Synapse.dll")) continue; + + LoadPlugin(plugin); + } + + OnEnable(); } private static void LoadDependencies() { + Log.Info("Dependencies werden geladen"); string[] depends = Directory.GetFiles(DependenciesDirectory); foreach (string dll in depends) @@ -35,6 +49,9 @@ private static void LoadDependencies() if (IsLoaded(dll)) return; + + Assembly assembly = Assembly.LoadFrom(dll); + LoadedDependencies.Add(assembly); } } @@ -47,5 +64,66 @@ private static bool IsLoaded(string path) } return false; } + + private static void LoadPlugin(string pluginpath) + { + Log.Info($"Loading {pluginpath}"); + try + { + byte[] file = ReadFile(pluginpath); + Assembly assembly = Assembly.Load(file); + + foreach (Type type in assembly.GetTypes()) + { + if (type.IsAbstract) + { + continue; + } + + if (type.FullName == null) continue; + + if (!typeof(Plugin).IsAssignableFrom(type)) continue; + + object plugin = Activator.CreateInstance(type); + + if (!(plugin is Plugin p)) continue; + + _plugins.Add(p); + Log.Info($"Succesfully loaded {p.getName}"); + } + } + catch (Exception e) + { + Log.Error($"Error while initializing {pluginpath}: {e}"); + } + } + + private static void OnEnable() + { + foreach (Plugin plugin in _plugins) + { + try + { + plugin.OnEnable(); + } + catch (Exception e) + { + Log.Error($"Plugin {plugin.getName} threw an exception while enabling {e}"); + } + } + } + + public static byte[] ReadFile(string path) + { + FileStream fileStream = File.Open(path, FileMode.Open); + byte[] result; + using (MemoryStream memoryStream = new MemoryStream()) + { + fileStream.CopyTo(memoryStream); + result = memoryStream.ToArray(); + } + fileStream.Close(); + return result; + } } } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 9d4b5d6..06ab342 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -32,12 +32,12 @@ 4 - - ..\..\Exiled Verweise\Assembly-CSharp.dll - ..\..\Exiled Verweise\Assembly-CSharp-firstpass.dll + + ..\..\Exiled Verweise\Assembly-CSharp_publicized.SynapseMod.dll + @@ -47,6 +47,8 @@ + + From 520c47745d6ed156bb4307627348981ef902f443 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 17:27:13 +0200 Subject: [PATCH 005/199] Api first class --- .vs/Synapse/v16/.suo | Bin 40960 -> 29696 bytes Synapse/Api/Map.cs | 10 ++++++++++ Synapse/Log.cs | 12 +++++++++--- Synapse/PluginManager.cs | 4 ++-- Synapse/Synapse.csproj | 4 ++++ 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 Synapse/Api/Map.cs diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index 4f3aa109fee4b7f6880ca8ccd25062782e8f8072..8355a5106df8412189e2186c94130eea4b3bba7a 100644 GIT binary patch delta 4228 zcmcIndr;HK9pBB1kc5B`FF}O_$SG>TMBWM#1U>bThg_!?saL@G8Xyq}NW>#PuJ-DI zny(7J>g(P!ZAIJ8bXq%HwKulC8PAz|{pbGBX|L0nPCHId<|;GQe!h7yxkqob^)~a# z?tXXoySv~0?&rI|;DjRhS9!Qxogjozj92LuRI9NW8!CUE@M6h_av`MdxfDXO7FNbJBPBx=mE%cbO34kh(N^nt`5l9r^(9MY-O+$V=xwPvZof5GbcXv_sz&M7Ne z-hlie>a2GjkPXZR768uzbAY+P8XylShqk4%3jb-OQrj#%_Ib$b0M^T?9%U*wI})uZ zv;Yr}G#(0RI*jfG?!WQYWC`U%oZXGIaT&q<}J@`2mV=DQGHTR)qmYoC<@G|gS-~hm@VtgOvgVFkMG(Uv=aI_pkPQcM<{W$Vb zU<^0`oTOX&w7jz@odeDT7l4bvYryNk8^D{uTR?c$@x~1@WayP=$Zx2p8l_X7rb$B` zU7J%$dy~35UqDA2TM6mw+(L9QXJtrdn8BwOvkB)~-j|lojcZh@J32FF==g4B=w@DD ziEcH(OTcoV8sJ_lkgo)u16D<4EN7>z1=a%Woa~ehKqIgYXad61Ht2)SzG#K7(oSFi z2mrf)V?b;MtLDjO(}ScnNm7X-I~JA`zOWa2jZ*r_pIom}KumW= zvdO8?8BU?X0!|@IjX{k(1&EE4738-J$#R;s)Eij%Onf6)AiYVO7bnv2dZB+RX|61y z^U56d0L=(`42OkuAvu$lDK#qg<=86JM^L#&a`bt+o>fCBqvdqHav3R7|0&ndWa^My zP5!ilq2gY-g#0N(vXmxM>gl?|DND#dqe;sQ6I*a%F)CU>@Yzv{PRlUxHRPr7H72KS zEGcGJ&WpLLy&O#y0N?*u>*tT0Qq*(Eq1S4;1D`9%rh#77m(w5grlH3{T<^g`wpU69m@R?&m{aC40GOuW-v#B#vN}-zx(gCn;W_r!{P|1xPXu zz5?OP5n&+<4NTTdU9n;6S5XW%;@r44nLv}a zgH=yrd@qc?33uI#L+OGEIW42A*#-JRl)@e+#Fa+{X$nfsET&aTht!cjvtE^q=9p*G z{mdZ3px;_Y)z%_uqVeXLWX!&7XMT_X-#7d975hf37QR>UTl?|@?`%Al*4_Sz^M-vn zy`ODK`l;@hbCgu6gy=- z-x<_7(cNC6)V@o!w||*lhAk11?-(nRD#}u%(FMCBv{Oa<`&Us-c427Lq`S)o_R8Rn+kvXTeEhRd zMfi2NBVeUqz(|93qip7p8O(88qGL8Z_>FaR%5v*s!~2#qiBtE(V-#X5cchQz%`zX} z^zO|+e)#si-OATDrYBF{#$wosLq^+E328OqkX9KBX$WBmX+@EcRswe}>1`>%j8TSx z6`yXvU{e3TqXggSrx_(~(v2m%{`VN6=NKUq$)C}rWk2QR@jlgT#Qzd5q=WpneIT0$ zwgX>VU~sn~@*pS}I2gshlMoo{saolxUTb}1-~B53SJe%KLPOTwd!L-Y(0lv$SHb!5 z0b%MVQ`;@y*uM53^!IF%D`-znr4(1*&8bw;_;5NocbQD03||fi3xx4bp z#I8QYOxNzgrh%?jUyp}h;LO=-afa@m>PTqyZENXl_0iejLfSXr{>6(KiEP_x$D%aK3f18o0JG4&Aq`!9 z={@p>F5&y&bMqoj_U|e9qFk$4+v)@LEoKrmRAHf!`T`dV5~2bc-@8tifaP(_s+ped zO2*zl$JNMgbn5<#<;aBOi-8R*fO!!mTJAc<|eDi)mo15ZEe AxBvhE literal 40960 zcmeHQU2GiH6&@#q1_~4igp{9R(vSqoZr1DduI=#S{c|w2iOD)4z!tLJT{}+JUf1jV z5eHSMRbMJq>VK=M0{VhlRc$3otE!bypQ`qOzED*>frQjIgbJz-o2hXbMRX#;WKkWs~F(dag^#vG0d#yK{n=d|6}vfSo(H+kyDul?a0 z6N!IzbtB)<9WwJcFjkEd#t5)a;Vf&Ml{Y+oZ-+$c?Dq0l1(_heA}RdDJ8x7#!Gci+ zhg>KK@|3%dVvRxQ@~O&W>9~^w1zo@D+^AD>(`0@3piIaG|4V* zAIJB{^^Dta{GWQ*<;XtXEZvH-J`cDZpyy>%-vuC@w*V+7EbmSn9{}tGd=anI-!@F-ve@EG9B053dfm6o-BzMcKQ z-lf5*#_5CCe*fN6=>P0{Z`75A>VIq5|6c(9_3r-}4xC8q(f^+ZUe*7VylufX>H*65 zR-9i0xE}Bsz-Ix>_crC(fPTOLU=Xk$K)w4A;9M(?m*{7so) z`%@O!hi(F}{W*?Mw{r}jEU5NZ;{kO8^}QMg*!{Z!_W-==e~uN@|CFgl?XT0z_Sb)_ zbG`kk?|EJ6f1XqStGssoPgzmze-P*6^}L60%mF3jN1*q&s1MP?cQ=V0j)M5fSYFa}La;PNqCaeYElxz|{gcJPbN2_+3NmO3SniN)}-sRFQ)@ z`E61)2>isWY#v#v`#0M~<;b91)^xUB@{_(0V*ZF@09G(Dot7!E}e4m8`67y;Byoj@AX(#Ysi%e>aY?hz*&j3g>(+DI# zhn{>6nk|Y^EQS$n0Iixd;*iZOzB!sXr`^C$eayNuIp;L*oW?2Ji-{bcg#1n8!+Jl7 zUckP09KRaLn|#Xr2LG3Fd&SRjnPUZ$9e)ZmltIHu@T4mGg5KNYGy3;l)SqL>%>b|X z$x-TZCOdx0JllQVwb#jK`3?Syc?-uvulQ**DgDz3ztl1%P*D>4$&H>k>c36U;T?a> zg5O#H9EJo?CNe@MI8v=lVbq_h>rPreXS);sJ^>K3zfcjrj{OpfziTaOqr;mU~ zx4i0}pZc?Zo`z0lpJ|jJe=XJjQM7tV@O}>CKn1NaEP4c6W5I(4Zk7M!MI*Qp?0;47 z6dIQPANAYG|D)Ug%uD;9w$vd&4ln^|#r{|L^`mb8tLv2WcBK@0ei5TB^)&CSd>bl#JbMc;fhQ|7zerQ@`2b+$=7=L{GU+E7}_J>{Hsk+l2Wv7kQ z(EisG$6uCpD}X%E?>U{*C!y>=EB*=8`xJWp;<7({LCnn5=(w^(+W+jUoR53OPdQR0 z>GO>-$O30U(h>~A7Niw8Ct86=jt}+}U4{PJj6#O$1-ao**LhI|4-VAja~|H8f|xDI zvFYJDe)=1{)}Lc9=c`O!@vAukTVh_*%bfr1MLG0yc*Wm^ybAvqw8vps4|ZAW)@Gu} z?wHvBw&3m_fLHuO$gA*keADfJ&VQ)`NDu9=W^*9b|8MevpSb^0pMN^zKZjQ4jI4s( z&I$NMy;*lA=bYvpUHQB}?%|9e2Y9JX2OG4V`VIR}`K~Ds)>WTV~xbLgepx<*kCvK(xINPS@i8D@O zA?8E4M!BP>FhjG?}PX@oATb>ohnW&{FLcWUi;+4j>9L$-v8^a)Vm*i`0^`@Z~gtxIREA^p8fu|h2n=1 zod53HKkXhYzIF6YoRbpv1JZBSVSWfdJ*QUbPmK*v(0>qyU6VymH}%XJp=(dV!y)wm z<&j$WA!@|a7ZB%-s?f9$0$CO{Lsf;Lu!6*8C%0k10;f1P+_EmJSRp{9@Erca# zt2uDETX6ia@f!&5W2sykZI^b>nM5bOu-&KfOzQy#^EF| zWkpWTFM1$z92@r6&!RYs;!33MC%br&GZERIvp6nVM2=Ay4{>BaUAW zAzypjU-94Mq+L?O7*WXs(l2>TndV$xT1s|mmGvSrXkQ%J_Msfkqo&bMr4L8;+rfJ6 z52Qv%XaSBRAN}sMw`EUYi}Nn2;5>BNcAcf`PucAi_9j&Z<$?EEx|-9H8Y`wd(AsMs z|Cly#aX#8LA_zy=E+F$f+a@B>LXXh~rO521!mAuGX3jufUrGP4ouST40orUI3GZOm=jHBPLtapUptMFIRe$U{6U4`wU9wDim6- z_WFll32|)-eHHVV8#6-5_{<`HNjpxrA*R7I@`Wo(I3hEV&L?nOOFEweb*DrNa(+8w zJde7Sz(1>y!wx5MX7{}V(yzu2r0jr!X(5usJ@N3us<@PwdLG-r?b*CPawKm}T7&q%`}zmY887Gfzd0uk)_-x7+JNi7eEXkc&>Cv~ z8^r&m_fh)f7-5oYp=j^gW3rtb|MwIB_8R~482|UZ{(|v;<^OSufBA|3s~8B1Zkjmv zrMHvGEB;Q7|FiCUP#3TB{~_d6^|$N)ApXDM;{PI+xZ6kj>+yeY@mIAoms!y9YsX3 z;wdJaLL0U>rp=fX-!(V~Z#>u0aSdBpi*L$!HCHY2s(U+dg@6u>!gKVM6o*klN#Npa zm$725a^Sje=DT}2pY(q;UjOP|#=V}((AUtqm&g52{BhfA=`eooR_DH!%lC(GsO|U~ zuV-8WBp$Oz83Ze#-ATqE6$Gr6lo4Of-lj4K?t z{()2f{IdRbxI?ZLeUji{Z(#f>xCIjx?#JZi!A(G&Z~<+S#P zel@GTqE-iW>D9*hMz6VjHPFhMs~nALeheJgIDOLEqNe4eUvE^)*4GJjiY3Z@mh{?& zvCA4Q)kd}M49k>}c|R5{vRi7STd(pwm(JpCt-%OB=LdR|slI_|BGl8{(;JHQB_p9^ zG?5L(lga*cGLcTCvOO1;a_8m>^R;rmehe3D^9$7zOQk_>Nhh$eM4tOiitii|zXfP+ zn_8_X;@iY8TWaMRi}L!sLc3b}8(V=#pi^iInik*~q*h+#UNU@hFD}0Ou~L@rRON+* zSA-#fNr-*fMT$5`UKk6vDq@7ZM&D(iAs|g#Qbgiauw686>u9|IE z6SG{MPo1LI`Oce@m#8!JxD$nT{Y-l*@Gv-gRRRwKR~$C>C0WPD#{EC=Ff@M$r+prV zjqt_}*M7NsBmBGvgu*QLC-vDRu5FxIQsB8z+GQig#a7PW1J8w;WwCEEu}>buapUw! z>zqCCT=0FpE7fzMM^PxvUgzpw^Z6;0d6}-%`9JGU?GpHZ)_ac52w&j;@$V-K{6Eck z=IsBmucWf>?d4@Yx*A`nou0GshQ>O;e`lwQGtF5+*H54$*UuMgr%SF>QCAJ)2OUM- z4EFfq{txss{;Z=Y<312`*zKD8op4`A-4ogwJ)s7=DjmqV(-@m5b!smSa_*&$YFkps zbuZjCmMdjs3}t=$E%!>TfR-uHW_sV%Z^P(B>Lkr<-%g@#rF8@XMRJO#S$XgDe3!-7 zrONbvqfNrAftYy7<3v%r$Lqoe%Da^1e)dEeWf!%k)J z-9gU1m=rCHRh@!{R&SkhPsq*UU#7U;%bGAJywTH;Q% zY0y3`sNE|5`PI4P{f4=Ki2ozV_m8hKe%h63&ypl8O`2XP%+Ah~7s_+_T5-Ns$=B)& znACB;a%y^J4rDAXolnNoiC8SzABtpS$xv)K9S`;Q$CIH*JQnTmjr7IhiP(i7uO)Sr z>a-8ie!iBZNyg0<<_gp01s_Ddw3bB97G~xu)k4V^g&5YvKaoNhjhUg&mc}hcYF}<* zuqWEjHGDli@lrH85Dk@W#>r%%SSZGd{l#MJLZ-88bj`Txk&(<`e%#W9bLsKis9Jlt zd|dql4;0GLL?J#I0mEW_A@uV8&_KL273wP&rg{fr<#KO)ARLKA621LP6bC)+FuH7U z1ioY)1!Ou{M_fHBR7%JrZ@uSM7MF?`2mU{Oom}Amb-&gPd68uod^EEE6V@J7lr9RBU}RipUwTa!ds`jPVPP` z^RCLTj+ADen>ns@|DWmYHhE&6DZZ&A`DaaB=^yyt8v7;#|C^gHuoeHCDTDkUANt=m z8G#!~IS19T4Q`|j!PL#G@Fs1DirpxEL}Sa|%7jP%N4uVDgQrQ4LEev!D*oQC^S!Cp zkHH5!s(i39k9=?ap*C>bRE~zhzt*I!Ml*-Os1=Df*E1b`ljFeZ)2%H7=MECXFbQC{{x^pTm}FD diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs new file mode 100644 index 0000000..75febdb --- /dev/null +++ b/Synapse/Api/Map.cs @@ -0,0 +1,10 @@ +using System.Linq; +using UnityEngine; + +namespace Synapse.Api +{ + public static class Map + { + + } +} diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 20fb01d..78c2698 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -9,22 +9,28 @@ namespace Synapse { public static class Log { + /// Send a Information in the Console + /// The Information public static void Info(string message) { Assembly assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[INFO] [{assembly.GetName()}] {message}"); + ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}"); } + /// Sends a Warn in the Console + /// Warnmessage public static void Warn(string message) { Assembly assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[WARN] [{assembly.GetName()}] {message}",ConsoleColor.Yellow); + ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); } + /// Sends a Error in the Console + /// Error Message public static void Error(string message) { Assembly assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[ERROR] [{assembly.GetName()}] {message}",ConsoleColor.Red); + ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); } } } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index d324540..3290532 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -26,13 +26,13 @@ public static IEnumerator LoadPlugins() LoadDependencies(); - List plugins = Directory.GetFiles(ServerPluginDirectory).Where(plugin => plugin.EndsWith(".dll")).ToList(); + string[] plugins = Directory.GetFiles(ServerPluginDirectory); foreach (string plugin in plugins) { if (plugin.EndsWith("Synapse.dll")) continue; - LoadPlugin(plugin); + if (plugin.EndsWith(".dll")) LoadPlugin(plugin); } OnEnable(); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 06ab342..a8a8e4b 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -42,11 +42,15 @@ + + ..\..\Synaps Verweise\UnityEngine.dll + ..\..\Exiled Verweise\UnityEngine.CoreModule.dll + From d2c9aa57603e7f08835bb12dec0d1399ab9accf8 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 17:53:57 +0200 Subject: [PATCH 006/199] a few Api Methods --- .vs/Synapse/v16/.suo | Bin 29696 -> 28160 bytes Synapse/Api/Map.cs | 93 ++++++++++++++++++++++++++++++++++++++++- Synapse/Plugin.cs | 8 +--- Synapse/Synapse.csproj | 8 +++- 4 files changed, 99 insertions(+), 10 deletions(-) diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index 8355a5106df8412189e2186c94130eea4b3bba7a..9c6894f2cb129a2fb58c712d99422d0c09518a2f 100644 GIT binary patch delta 2101 zcmb`IZA_C_6vvtd&Ab1p!wSk#>z0jC1hWw!4k=F2s#RL$#n^5$ zaoJeJ{%1xqb!L89mMj_c!;+ae63yZg6HS)AX4zZzVKMu#WU@@Mtvly|Zr$d`-Q?Hj z+;i`__uPB`_cs26h<_<&on=zG7$iv{TPFTUrBdt`sMMI}hcAePd`Mrvd^y6@bA|j8V#3UVICM-k=VI|fQoPGnbj;J6?iS-1JTgTbsvQk>YDY}R)gqz?Q z%jsLcvOW{7FH~^n?#&=Cu$CI6YIT9HKX8HBE!3e|U@B`Wdy-5`7M63Y!p4IcHRRyQ z(`6HT&kdLQcV#qimfWFw^~?EGk-d?4h^Qep6P3gU;$gx^cvc28Rc@t9GqH`}Y8X!)-L>@-lh&zLn6qMBaY=Yvj8?TqG_fFXjcsx#8-BE+Qrn)y2dKEa_6Z z9%^*(QBa|v+`ocW18O640C#}r15a) zigfDiJw@F+iS4Ul?1QPiLg`+0prw39jH{D;W2{&(-4h~$rJ|Tlw9W<3d=6-%H@%%{&&Kb9IB)<<8S_I9nN)g#`=FXHgO8onLE!%^q}MM^FgE(`5(vSr+_d<@rht}BslS?Ce9r9?iWRo!~^ zKC!~mn5U5^UIk=YQb z4B)!#($0`G2A87<1^w5G&%Cw!eBrU+&(52+PTLLt^RISn{-E_keAgew8hafU?Om9$ zyWy>~Kwsk2__z1lh6cDdHG zooMUAtyT{-B`sKN)8z7-#6{rcw)#Z739q!3W3f)7@R;4BQZr)5-2ZgEf6STBcR`(% zW*HiP(j*<0_DErAT-qxQsn(b@L=9z0;Z4ax!jbVRIFA_k6_lvQxHO6Q?!`oLgk;WQ zZ+@`YNfIP>eo4~jn$LPtN0Fpt`_u0VdR(`uuWN^TY58Jkq${{H){wCH{-d`Ys^0vn z-aM+_8dbeDAX?U^WC}>j@2ir$|HQNmZ>PnNQY z>ggnf@_&d7w`y(psedF>QHg;UwUZxd>VnC$19l<*V#c+>PI&h;p?K6IF4D3?II(97 zx<@bJ%-(kdZ$wCK)8f--J{K;`?{lsEqG*30ZJ;*v20jz#FWFvBQF$zP4n+QLDi0 z-fF{VV`q22{pNFD3@9e^;P)dVFdPWehCdsOAslW&OW3z?$Sb3BpcVnYj$T6kCp&=o OqXFFZTS<$tp!rWQK9e{A delta 3031 zcmb7GYfPKh89v7su+3*`z}!P{(u8m|pSe1KFA$SU2N-Zxr3oVebBR+(DBv`Ztakcy zLZbCMZK>KOZL>=zty+S$O4GWo>N2U-rmg+aYMb^Wllo)Q_G1^&MyAAj-Y+_p>lw4}dieIC@u5+4*3Nkh4jCp`(S#WD-u z<|8#2sRp>8%dRc@1ZtLo8Sevj1LZ(1uou_?Q~^%`4L}#Tb;@ph3zQzT4*&sxY-W22 zGx`!50|0NrCCGza1@-1i5F^0-mxoppx|v*mt^ZG~XCeCHwVIya`>%Rtc`@T{Nz3}> ztg9ez=;&^CnMVQ18yL3g0@V2c3t>f_x7DA6+6>r%CjbjzqoMrbiV9H7fy++N4uI|A z1lrhYHEePh&<->K%|Hv#3a~yZ;0EsB8mg2D%js6$JQLS2_y+JM@D^|#_!jVO;5)!~ zfg8!^a>FvAEXvm@s>I}Lw4tPwqZo0p>?jG#NOCcEMZSEh#GT2VRnKgjwzYYTO~Ey} z^RMKw+?fmZ)4jZ6vk$%O!xu=JD^2Nfsx~`Jq4es((zxyXR)eGM0zh{P94z*EP3%P$ z+sv*nXLBd-75qcWS81a#COs4_ipeh8C<-bNB~^rRt~rWjCq;`xCXTIimzhOC8#~-9 zJw&$^l@`ke4Qy<>)3cjYo#py^nNB`M8#`k12t_MWvV)>KW716<__kBDKV;&FPjk#_ zL&GHKZr)C^<(mM5!g0VGaU79aa>bffoa;6=Oko#>JOBq^dX$aStQl!5vR4xMcEdw+ z)ZbP(pzDG3=Codals;7IX|W+l2g+Q=6%58`vp**Ll1sb)C1ox}_oT@0G|+{iOEQNx z_Qs@{qE$hKgO<}T%}Zt{H-s&MU zp(Oz$eROvb7Om=v5!_7TPTjY+uM>* zOX$yPHQgyMNx1CzQ(QICVV9fyE(6_G2lW$Tl05A-Nxv&@TC=Z9xuE$R4uQ}2!{-B5 z!MXW})7_fW*-~lEvf03B(`8Rh!hMXc?k}R@uAB6M$E%k@QjTjMy>zCC;vN%K>lCtk zRl4mtOaUikRqgb3Z#~7m1`7DxA_Sb+1&s<_9gaPXu#`~y>z+Jr(m%bGrj!>kJ25rB{A|fqt)@w=g%ZpM;fH= zrk&pVN>5CPDG^2R%m`i(5WS*Dd|4cV7mtcz(Tyvyml^r#P= z!;~|KmjGgY9AZv`el)n8VnP$1H||F4FG1izD8MCSn}@p?XqT>djBnFMtQ*6MX>lIh z=aE4XhwQ{q|Vw(Fhhv_Fk(9#?Sg3-a5-H*=p+Au_ty@-BkiuQUJ5Op9h+O2z<9$@bxKp0 z505Y?2h6sB-y}RXjx`Zb3z*pt>e#Q@00Jsb!IvZ8IuDc0V#f36n-|Zb&x!X@FJdKQ z%=~bW-k+{6oe_NTv)dNHh4*oaWB6v1JQJf`qXU$C@~V6Vy3EkK5hs2B8;?*;FUR&%`-uDcGs#5$;egl=Pl1lT@WEvHd2pI{NmF7k_u$ zWG_DP`S>`lBQ@b`#`SL{zpv50{gj7kwR70}n1c>({NlXl2z&HQ$GP|Pw!>f0HD8mJ Kryfq<2mb~D5o$^R diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 75febdb..378ecfb 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -1,10 +1,101 @@ using System.Linq; using UnityEngine; +using Mirror; namespace Synapse.Api { public static class Map { - + /// Gives you the Position of the Door + /// Name of the Door you want + /// + public static Vector3 GetDoorpos(string Doorname) + { + Vector3 vector = Vector3.down; + Door door = UnityEngine.Object.FindObjectsOfType().FirstOrDefault((Door dr) => dr.DoorName.ToUpper() == Doorname); + vector = door.transform.position; + vector.y += 2.5f; + for (byte b = 0; b < 21; b += 1) + { + if (b == 0) + { + vector.x += 1.5f; + } + else if (b < 3) + { + vector.x += 1f; + } + else if (b == 4) + { + vector = door.transform.position; + vector.y += 2.5f; + vector.z += 1.5f; + } + else if (b < 10 && b % 2 == 0) + { + vector.z += 1f; + } + else if (b < 10) + { + vector.x += 1f; + } + else if (b == 10) + { + vector = door.transform.position; + vector.y += 2.5f; + vector.x -= 1.5f; + } + else if (b < 13) + { + vector.x -= 1f; + } + else if (b == 14) + { + vector = door.transform.position; + vector.y += 2.5f; + vector.z -= 1.5f; + } + else if (b % 2 == 0) + { + vector.z -= 1f; + } + else + { + vector.x -= 1f; + } + if (FallDamage.CheckUnsafePosition(vector)) + { + break; + } + if (b == 20) + { + vector = Vector3.zero; + } + } + + return vector; + } + + /// Gives you the Position of the cubes you can see when you write "showrids" in the console! + /// + /// + public static Vector3 GetRidPos(string Room) + { + Vector3 position = new Vector3(53f, 1020f, -44f); + GameObject[] array = GameObject.FindGameObjectsWithTag("RoomID"); + foreach (GameObject gameObject2 in array) + { + if (gameObject2.GetComponent().id == Room) + { + position = gameObject2.transform.position; + } + } + return position; + } + + /// Gives you the Spawn Position of a Role + /// The Role you want to get s spawn position + /// + public static Vector3 GetRandomSpawnpoint(this RoleType type) => UnityEngine.Object.FindObjectOfType().GetRandomPosition(type).transform.position; } } diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 933d989..e0721cd 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Synapse +namespace Synapse { public abstract class Plugin { diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index a8a8e4b..7413888 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -35,8 +35,12 @@ ..\..\Exiled Verweise\Assembly-CSharp-firstpass.dll - - ..\..\Exiled Verweise\Assembly-CSharp_publicized.SynapseMod.dll + + ..\..\Synaps Verweise\Assembly-CSharp.SynapseModLoader.dll + + + False + ..\..\Synaps Verweise\Mirror.dll From 7b372152004cce22af12b5602e65da587660c611 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 18:48:55 +0200 Subject: [PATCH 007/199] Yay Working Harmony Patches! --- .vs/Synapse/v16/.suo | Bin 28160 -> 38400 bytes Synapse/Events/Eventargs.cs | 9 +++++++ Synapse/Events/Events.cs | 26 +++++++++++++++++++ Synapse/Events/Patches/PatchHandler.cs | 34 +++++++++++++++++++++++++ Synapse/MainLoader.cs | 11 +++++++- Synapse/PluginManager.cs | 17 ++++++++++++- Synapse/Synapse.csproj | 7 +++++ 7 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 Synapse/Events/Eventargs.cs create mode 100644 Synapse/Events/Events.cs create mode 100644 Synapse/Events/Patches/PatchHandler.cs diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index 9c6894f2cb129a2fb58c712d99422d0c09518a2f..36ea60766488391db723318d454d8d1c9f8632bc 100644 GIT binary patch delta 4822 zcmeHLdu)@}6~Fh39qjNWz*2wMXd_|$Lh_T2qGzX3JVMMOkg61MhB>3c+n?lqUP+8HNLllq4 zbI+Q8qO}ga#Xtd23SepirLb%oFza8OLr1hzo%G+=;gxX1{6M$$S7Kj5@ z0?9xMumOkxcnu4%3hgK$6-Wcpfi(b+XQIvq;^_D$+%#Vf*vFDTsRdM9WrU;|jt zjld>=#~L7LgSiBhb|pcvi~La|wkhZq>)wYizLnW#In4Muo6*4LWY4m$dT%kN9cN7O42xHKM92AK7{rJ zMi%dk551duAI&H><6~I=FpZ||QP~s}0Q)V{rSyFBB#0S6(Dj5oX`_=7d4>okLziv- z4v2@t6C!NFN;%3Jnzoqef?8z0h>@p5qYWx+ChJ(3d%&02Dh>JQ39~Z}gHY%n>ARz) z8BKn&@NDvBw5n{cxw=l-MAtGNl8u4GYg(krmKd)a4J>4;(w|%#EsW@8V_9OB+`_Wc zLh>7`2?K0VHwG69EtHY#kfnjq+((RO%O@n+%bi)Zm+RiWfBL02^Ifyw81}q=4okE( zybi^0nTgiyfi06e_yz+D791h1_WyX%d3Xj}@EMW}DjR8z?m*^Q5Z?l{C&kna`WG|K zVc;pMuB?J7sZ^K#^MF!V9id&7uec>zvW2q`2+Kzc#j|#P6$!9rJn~$}lLe}+|-`|^o_T-!64f&?k>dA}wHJBz+$_~BdNBi5ewm6b*y*6LXTDkwv0e9cA=VtQpB{2QQ;9zF(|yk1&MF!80Zn@ z!XXAJZgYCOS9ELh2GHYOw(eHiC60ifNBA()A-0L-`&^MazEd^wW3V2?;e9xm8`}l9 z(y{LN-yQkA;FW2L(X88|>`t~|t@@f?_TD>Lz5GsZ7JP|z<4QcDM-1RfhC~T2$4g^X z`^;9TdNHdzJzkYZ)OaRZzIk?4 z;j1Gpjx`74*lsxSHk-4PI3nt3vEY{~ z+gl+JW=;zhBvh)6eCv++6SM!D6vUoYdTaVY%D$n1uW(NJM5Z7ndZuDGoh~!oO(yOp z6QQi?ZZhGd!T!c|AK|bxud_VX;=c)c%iX?GH=CW}+F*3 t#k$&)`Ol4T;Rs;?vK_!j|hWY_=z delta 2531 zcmcImYfzMB6#m|Czg-sixGuUYAfj?BZi~xJ1X z(mi(hQRdJzW4FoN`qMOtBhy$@X_H!0{m{l{ntn9R1kFgLJ!fH=WpK)V^fC|Md(L~# zdEay1=X~Ezyd_V3FOHdobUZIX2&&MYJHBVeEB8h^EOVz^Mc2eiNs^}0X-pmyCuvr0 zRLxMN0CzA*WT)uLARLouOf#k%!PKOoInBD>2uyW=0f+_I{5BAYdCYSjDf4=DA z#Im55GW?0Xa`(haVNfFciH%~)iG{?A6lzk8F$xsCbzt0w9V}Jbg0y@o|@>xL4&F~sS)?qjU@X+<$5n^IH_gd70Ye)jp?CWlaDHd)9@>xLlHt<_s1gcegKRlu6u zNsV;Dm`5{7m(>s~FgpW_p?n0$OOlFK!=d06CN$;8z8De6il0TCzk@qqGf)oj72d4| zZ2fOF;Ht76Sq-K@9o$?8WuXSUBLvfmDGoD#0kqFRI7*`{xAHA(k3+hEwzT1b^<>Zf zh~(xfZ_fq|R@J034 zj0>x8H2H|u+dr-HwoLcH_P&`6#7m6z#pdK`A_S{*gO_rOHOG}8kRbiEBM{#508M8H9N9{Y+L4jMrVzpYN}7jXYT`ghc0R zHtJwGERB-2cFLP%Tiyv`6M2#vxEJu6nN1oO8_Bb#(ccq%;J{6VGada2NRsbP?RgQ- zUC&*kNUzdhU4eHcg8xsPtoC!ViaZH-L@{|18i^M(8$_!-Q}V6NT+ zKgnvjxS|r&OyBh;84RbYCJ*(T{`A0OHwr1HD3u(YSu{}{Y0QyaxYj{wNE(oOq|vXG z9R8GT3bt9h)Fwyr_{lc3aEo|L1+2>kq;^DUU5wX(=x)4To$z3Sy74~;7Q@)Bf6<>A z8VQD$Z%v5$9iQqgl`S@$+_s=oT5PsDS}VuNT8VBn6j6CYv3MC==?!rXcDMF92PwKO zQ@q3)tm#;yfx1bWuJ;KojWk%6TkCc8&cPhla2}bh>ERU!6C{T$$aJQyIcyIO$9->K z5=#=8N=v@aoqd98U2$rWrT74AFa#yL z;#nC}m0yvaUu`SQE-o&t$Tk<|lhtKS*m;S6%Ha3M!RYx->z)11&W<7MO%={mntC{c zVk%73l(w0odSiXhpU?>z<@~NbBl?@}XWQOB{lvEq>En#MZ??D7nYt`Z??5Nl$f&Cu z=tPigdr7NfXrOb*+1JA Event which is activated when a User Joins the Server + public static event Playerjoin PlayerjoinEvent; + public static void InvokePlayerjoinEvent(ReferenceHub player) + { + if (PlayerjoinEvent == null) return; + var ev = new PlayerJoinEvent() + { + Player = player, + }; + + PlayerjoinEvent.Invoke(ev); + } + } +} diff --git a/Synapse/Events/Patches/PatchHandler.cs b/Synapse/Events/Patches/PatchHandler.cs new file mode 100644 index 0000000..dbc4d30 --- /dev/null +++ b/Synapse/Events/Patches/PatchHandler.cs @@ -0,0 +1,34 @@ +using System; +using Harmony; + +namespace Synapse.Events.Patches +{ + public class PatchHandler + { + //Variablen + private HarmonyInstance instance; + private int patchFixer = 0; + + //Methoden + public void PatchMethods() + { + Log.Info("Harmony Patching started!"); + try + { + patchFixer++; + instance = HarmonyInstance.Create($"SynapsEvents.patches.{patchFixer}"); + instance.PatchAll(); + Log.Info("Harmony Patching Done!"); + } + catch (Exception e) + { + Log.Error($"Harmony Event Patch Error: {e}"); + } + } + + public void UnPatchMethods() + { + instance.UnpatchAll(); + } + } +} diff --git a/Synapse/MainLoader.cs b/Synapse/MainLoader.cs index 318063e..e2590d1 100644 --- a/Synapse/MainLoader.cs +++ b/Synapse/MainLoader.cs @@ -8,6 +8,8 @@ public class MainLoader /// This method is called by the Scp Server in the assembly-csharp public static void LoaderExecutionCode() { + Log.Info("Checking Files"); + if (!Directory.Exists(PluginManager.ConfigDirectory)) Directory.CreateDirectory(PluginManager.ConfigDirectory); @@ -24,7 +26,14 @@ public static void LoaderExecutionCode() Directory.CreateDirectory(PluginManager.DependenciesDirectory); CustomNetworkManager.Modded = true; - Timing.RunCoroutine(PluginManager.LoadPlugins()); + try + { + Timing.RunCoroutine(PluginManager.LoadPlugins()); + } + catch + { + Log.Error("PluginManager failed to Start restart the Server"); + } } } } \ No newline at end of file diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 3290532..5edccf3 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -3,7 +3,7 @@ using MEC; using System.IO; using System.Reflection; -using System.Linq; +using Synapse.Events.Patches; namespace Synapse { @@ -35,6 +35,7 @@ public static IEnumerator LoadPlugins() if (plugin.EndsWith(".dll")) LoadPlugin(plugin); } + HarmonyPatch(); OnEnable(); } @@ -52,6 +53,7 @@ private static void LoadDependencies() Assembly assembly = Assembly.LoadFrom(dll); LoadedDependencies.Add(assembly); + Log.Info($"Succesfully loaded {dll}"); } } @@ -113,6 +115,19 @@ private static void OnEnable() } } + private static void HarmonyPatch() + { + try + { + var PatchHandler = new PatchHandler(); + PatchHandler.PatchMethods(); + } + catch (Exception e) + { + Log.Error($"PatchError: {e}"); + } + } + public static byte[] ReadFile(string path) { FileStream fileStream = File.Open(path, FileMode.Open); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 7413888..8d62056 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -32,6 +32,9 @@ 4 + + ..\..\Synaps Verweise\0Harmony.dll + ..\..\Exiled Verweise\Assembly-CSharp-firstpass.dll @@ -55,12 +58,16 @@ + + + + + + diff --git a/SynapseModLoaderPatcher/Program.cs b/SynapseModLoaderPatcher/Program.cs new file mode 100644 index 0000000..8b86987 --- /dev/null +++ b/SynapseModLoaderPatcher/Program.cs @@ -0,0 +1,109 @@ +using System; +using System.Linq; +using dnlib.DotNet; +using dnlib.DotNet.Emit; +using dnlib.DotNet.Writer; + +namespace SynapseModLoaderPatcher +{ + internal class Program + { + public static void Main(string[] args) + { + if (args.Length != 1) + { + Console.WriteLine("Missing File Argument"); + return; + } + + var module = ModuleDefMD.Load(args[0]); + + if (module == null) + { + Console.WriteLine("File Not Found"); + return; + } + + module.IsILOnly = true; + module.VTableFixups = null; + module.Assembly.PublicKey = null; + module.Assembly.HasPublicKey = false; + + var opts = new ModuleWriterOptions(module); + + Console.WriteLine($"Synapse: Loaded {module.Name}"); + Console.WriteLine("Synapse-Assemble: Resolving Ref.."); + + var modCtx = ModuleDef.CreateModuleContext(); + var asmResolver = (AssemblyResolver) modCtx.AssemblyResolver; + + module.Context = modCtx; + + ((AssemblyResolver) module.Context.AssemblyResolver).AddToCache(module); + Console.WriteLine("Synapse-Injection: Injection of ModLoader"); + + var modLoader = ModuleDefMD.Load("ModLoader.dll"); + + Console.WriteLine($"Synapse-Inject: Loaded {modLoader.Name}"); + + var modClass = modLoader.Types[0]; + + foreach (var type in modLoader.Types) + { + if (type.Name != "ModLoader") continue; + modClass = type; + Console.WriteLine($"Synapse-Inject: Hooked to: {type.Namespace}.{type.Name}"); + } + + var modRefType = modClass; + + modLoader.Types.Remove(modClass); + modRefType.DeclaringType = null; + module.Types.Add(modRefType); + + MethodDef call = FindMethod(modRefType, "LoadModSystem"); + + if (call == null) + { + Console.WriteLine("Failed to get 'LoadModSystem'. Perm Err?"); + return; + } + + Console.WriteLine("Synapse-Inject: Injected!"); + Console.WriteLine("Synapse: Patching..."); + + TypeDef def = FindType(module.Assembly, "ServerConsoleSender"); + + MethodDef bctor = new MethodDefUser(".ctor", MethodSig.CreateInstance(module.CorLibTypes.Void), + MethodImplAttributes.IL | MethodImplAttributes.Managed, + MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName); + + if (FindMethod(def, ".ctor") != null) + { + bctor = FindMethod(def, ".ctor"); + Console.WriteLine("Synapse: Re-using constructor."); + } + else def.Methods.Add(bctor); + + CilBody body; + bctor.Body = body = new CilBody(); + + body.Instructions.Add(OpCodes.Call.ToInstruction(call)); + body.Instructions.Add(OpCodes.Ret.ToInstruction()); + + module.Write("Assembly-CSharp-Synapse.dll"); + Console.WriteLine("Synapse: Patch Complete!"); + } + + private static MethodDef FindMethod(TypeDef type, string methodName) + { + if (type == null) return null; + return type.Methods.FirstOrDefault(method => method.Name == methodName); + } + + private static TypeDef FindType(AssemblyDef asm, string classPath) + { + return asm.Modules.SelectMany(module => module.Types).FirstOrDefault(type => type.FullName == classPath); + } + } +} \ No newline at end of file diff --git a/SynapseModLoaderPatcher/Properties/AssemblyInfo.cs b/SynapseModLoaderPatcher/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..17a8cd7 --- /dev/null +++ b/SynapseModLoaderPatcher/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SynapseModLoaderPatcher")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SynapseModLoaderPatcher")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj b/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj new file mode 100644 index 0000000..57c6aa6 --- /dev/null +++ b/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4} + Exe + Properties + SynapseModLoaderPatcher + SynapseModLoaderPatcher + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\dnlib.3.3.2\lib\net45\dnlib.dll + True + + + + + + + + + + + + + + + + + diff --git a/SynapseModLoaderPatcher/packages.config b/SynapseModLoaderPatcher/packages.config new file mode 100644 index 0000000..99bb478 --- /dev/null +++ b/SynapseModLoaderPatcher/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 3dedfa22d46fb30da647c0a5697d8887389b0dd3 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 19:38:26 +0200 Subject: [PATCH 011/199] Working Join Event --- .vs/Synapse/v16/.suo | Bin 57344 -> 57344 bytes Synapse/Events/Eventargs.cs | 9 ++++++++- Synapse/Events/Events.cs | 10 ++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo index 27983ca762fa6158b6b0da48fff69838a9d4f316..f5e75688a52ecc0e21ce1136a0a5e7d396c1599c 100644 GIT binary patch delta 1210 zcmZoTz}#?vc|#5pYr*n&4n>m-nVK0_P5#Q%%(S0zaustGW69>P%;ik14!=*C0cF`R zW!cv=P2R$#GBH75^9`;!jEu#TOL^)Uiza{N`Og!?z`(GU9Y_GdB(5d6)UkrqZT=}J z&nWTl|Ns9W>;uG;4TMElKoXNZI8`R+2#2V^RKn;opehi%97tCHaU~FM zej;o_eKSP`I2a2jf0g~u=rQ@LTs@=v=2H239&{nya8X4CEy=~#!jhhSI;r9`_l)7q zIiXIKAa6Yc!bb9QfIi{}Vg?3A5aJ64`Z13ok)eR0m?4#c zX|nvv+Q}8GQx>gaoV;jd#AK5-=^)hxPzcgD`P^!wO=}yNxInQY3>08y*zB;umyvPH zWXBD~lleC}P43;uH`!ss(#e6F9y3}@HgHg%T(FIO@`Ej`lNW4eVbU^36AI?y1sVg2 zEth3LGb$#>ZPcH6I^ o7-k@FBeOql?TV&bQ5+)T(NB_+HeWbkz&41ZK?N8pBP1Fa0e^F>mH+?% delta 1201 zcmd6kQAkr!7{|}K*W28CUEwOx9zNIC_d$z7)|*)XN@v$lG^UFXbMBpgNb|<@^5s^PPJx|H%wL znc){Ma>DH!>NkTh#7)zA$aB-&O%5jb2|CX5{1_*gLZ_4HZrkdr;#}E7LP!jGggk~j znkM#2bBoe2jEWID26<5y&!Dxc!WXV4P(;a=Ai zRG^3VLXAly*qnzvry#SmXQ%(9*YEA~4e#p>ws?JQHt)e6snut(YT>}F3)amQaDVx1 z;;EgRdqQEOb~o!;IZq*z-h^ze7S457Kz(`+BxeU)HJRAPYJ#$vX93~gN0j~x5wU^f OJT(-{A Event which is activated when a User Joins the Server + /// It need to hook ref PlayerJoinEvent ev public static event Playerjoin PlayerjoinEvent; public static void InvokePlayerjoinEvent(ReferenceHub player,ref string nick) { if (PlayerjoinEvent == null) return; - var ev = new PlayerJoinEvent() + var ev = new PlayerJoinEvent(player) { - Player = player, Nick = nick, }; - PlayerjoinEvent.Invoke(ev); + PlayerjoinEvent.Invoke(ref ev); + + nick = ev.Nick; } } } From 89c400e4dac3db53f55d1e41e25adc08d07d5a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 31 May 2020 19:40:33 +0200 Subject: [PATCH 012/199] Update Gitignore --- .gitignore | 365 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 360 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index add57be..83ba081 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,360 @@ -bin/ -obj/ -/packages/ -riderModule.iml -/_ReSharper.Caches/ \ No newline at end of file +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*[.json, .xml, .info] + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd From bd855852150581d6c6d78f0a1e704090da983a13 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 May 2020 19:44:05 +0200 Subject: [PATCH 013/199] Delete VS --- .vs/Synapse/v16/.suo | Bin 57344 -> 0 bytes .vs/VSWorkspaceState.json | 6 ------ .vs/slnx.sqlite | Bin 90112 -> 0 bytes 3 files changed, 6 deletions(-) delete mode 100644 .vs/Synapse/v16/.suo delete mode 100644 .vs/VSWorkspaceState.json delete mode 100644 .vs/slnx.sqlite diff --git a/.vs/Synapse/v16/.suo b/.vs/Synapse/v16/.suo deleted file mode 100644 index f5e75688a52ecc0e21ce1136a0a5e7d396c1599c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 57344 zcmeHQdvILUdB1C3hVlrQccBPlz<^iivDV8xyjn@NK*GZEgU141?XG0Wt6fzqKZI=p zl%y?jNFXVc6cPe0p>!D9DJi81Z72MbPzcFP!z8rRfoVh2=_G$74CzcJaeu#a?%8|p z-FtWMU9DxUbI;DV_jT_1zVrTG=iKkTbLRVB{hJFvFdX3q<2d6thfg+6)b2;LbK?_+ zu^iXS0KYkW_%I*wIZngSKqau*DBw3|G#ULy9>-Z@o>l2PoNJs=s`E>#yfyQ+pRJ$m zd^ggBc=yL-htmj7j95Fri`Y!<|_##O8hAkNh6aRT)%?E*{U} zf0@~_Pr~`H)yvwEefk_cV>Ipd;j^^sT{vevhC!UOOn(<}F5m*dg@CgG7XwJ+c>u;e zAIBAdGXR}{m4M3ts{oe+t^hOxRN8#!N?h}(!nL?=0ki_z0PO%askML(0N?G#k?}W} zNA<4X<3_x<18{YX@B6`%LfT`1G#~?Ddm9H#0CoZ<0aF0>tsGz)kO!O!@RNSEIE&f; z*Z=Cx4)*^Z&>r@G6avE0?*FQNoB&!l4zS;xj&pUN$K!F$`={W@{=WurCLjsm^Q&-V z|L1wNaE%s^{l8Lt;yev;q5$^)F2F^A)qqOx>Cb-0j5~}Y$KC4zHvnz~tOvvay?_Lu z56}-70Neyn>9GIb3>X5Crdx2_1Q-F_3fK%71#AIq1#AOs2iyj@9dHNWP5}GxU4Xj* z_W)1+0IvZ)Yu^7Hj-NNrAH(qrfG?WY zkK_0R;7;z->Z1< z@3nWof%9*g*Fn-@+&A&wznJg7jpKLC^Y7vKee*nMnoA{qFF2lpu?zD`3cSWHjr%~x ze1wa@e?$;ZwPhc#7)3;4A7(g)~e@Nc#69DpoX8~3KDC<#Xr2Kat;C#RZ0Lp=s z3(31FS&+O?6W~(7O2B1+Re;L@R{*XAaE>5vN&f2^0Qt@+pc!y2paswhXalqZbb2`_ z=-298=l{s>-3L(oALI1nn*5)NPrmjhz|8>if5QML|HrtaxL=L`OCpZW|Lwqa3NQvp z12TXtU>q<3*a?^fOaXQQa)4<-9#8+IslwOJ)+rezlAHx0}R#ivv+$3;wN4e zyklBV-ofb;=4EyK%$;{2e(IdqUr2*@OzX+t;qny&1Ng=N4~Y9& zGtp}JnYT)z7X9ZVNbpl;qSf%TT~!LqKj)Po_5Ud1zhNd?4L{4aQXu~05FrTuuOPnP z{I`l(&YOZ-+W&Wu9OZI`3CuXNm{HS0reRJp(1Y|qw~Tcm%?mR#MAQYIG#-6{;-InFr5lad+Lm-A1NyNED24Hx}sz|0qPX)Q-FKs zh~iFQuBKdD#OSH8N{Mq8v{1ffhyWgr)VH*)To+O1BcOtk^iGtE{dyywP|mE@{wt5Z zE3r-|;7oxGw-0>{520pmP$nmB*PZB^l4_zX|w{$HU72e({sXQR!_%xokm= z6i{Ph_}_>2Ow4=GX45#U7FGg3+Y|X?zxa0}E@@^ML?0SOYn%sX+XgN+h8EL}J|D-7 z+K*p{m|109w}1BkRd_)D+Asd!M_kSq43+c`TTwPFi$2kc$f=fxW~6j7ZeI@Yi(fDQ zQBm^L^hh0t)U%A^Y64mjjy>v0Id0xrgZ!U{<4S;E{2LK>k68elQ0r3|n>fxnbv)aI z#u{2LHgmA^GoY(t*2(E2#3K;#OcmibpN|J6wQ3;<=d(fNF8rkG8R zhM`=4gpu}rWaneF%QrBi{U_STZj7~`Mm{gZ@mm^QsSpFG1>Wg15KS@R6hkZY}>z`lw zw^iA<9^adP^Hm2G)yDsj|39|*f6lmLqRYu{wq1<4ieq47sT?r>+8TA`*z#!?4%8Jf zIPv#lq{)JYU6>OKVi?f1?eZP{e>KM6OL5~Y0K1g_%9PwpOv}WPk-W9%P#J^YjbYj-=??zoH|Kc#ficTF5moc@^iNQ+j)M> zNGOl`W>KGFBp*4o01VZ}|4{yCL-7ucF8^1n|4{z(u6sTS<-bt=Yh?M)$$y0WUuAyF zIT|bh{?Eq7IO%h{*7?6)ut{lf+m!7KkOQa_RLoN)y^l(l`6q7&nc6r1xejraUfo^) zLqBwCwk2ABd5Y;yU-iwMJ+Jjlt-MQt%mZa zm4P%fRKlMy%c6iX*kHEL8Cc(GkDxxA;f5OIFY4ZCe_-&7U+IXcjijYRgt`tu<+$XbP9xk@{cO`;~a;xBk~7?jxoG(mDRq|BYh++dlQL)pX#*e>&1T zGXQ>;{kNzzM)1Zzk6NZiJ|`o3{MR!6>h0f&e;6%m8d$jwMsFKdjoS%<{#lee%bvmh z)cuO~f-UAFCw_PRhfaw-%^2`gcN;|hXVEM9e*l(-e%Kpg_)lO|j=~1fg5vr{~1`82=)x zaYjEYzvX`baaH|qMM^oOD3v9dQcX**SFcttP>VmvKY{bF_rGfRssE}J)cAKbBKggK z5d7?)d(aQmeC4F2mj18f-ze&wwN8E`hyMXF=E-(&c_+mgl+sR=hheO*Vf$RJ0uW!(i%cnGNz4_741C%ng164v}I-{n8+pLo~c+%Nt=LR`+74Au0X z?J}C@e=YX+KSpYAm?>7n?=|lzf~bFP#zhOjZ~hM^U2Y~$mmc~xeln~aB4C?R7hon|GDoJ0yy{K>o3|2d8Ydcl$8Lf>cqAb#o;ny$X!xp%jXefab5tm=LGt=1nswY7Ji z=l899dtm4%AFlX!oD+Rd`UkgN^lf?0aggs@d6-%M^;5oig&v3Rc!hHMXV!bgb-Uj? zJg|lO<7VhJ`Z3a5^UPi`1Mh-|lbi=Ak8l>g9{gww@jC%+CEELuPA%`ZZ5th7-g^_H zBUj%3S6^7M;+g(u@0)tz%>(;Cpq;$FwoALOsB}=7!F)mv?E8D3{K_;|hf_Pacvzc- zj)@$G3OCjre?j<|B_U_(yk@hQ=jdTazOxx6P!#p6=wPi-vtn^*2Oz8Gp_gcaBs>DG z(T5PaZ|WUQpzactV~!>gLn>YUNKRxNC6L39Ex8YEuoo$BFxH_hZU(*t?l6$YYek!* zZeX2x)`qh-+-WiW&tYn;Y(P)M1-#7qTZM?lHkh=sS*Z{JI|T>RbP+ z{H>C7dMP)9(_k5pep$w{gmLLgt>Rw!To2TOU5j+cA594V<5|?I?6*B;?l<%f4U+qD z^NVJk^EpQ)yC<)8W%p)QZxFK;hrYi0mF#IM?#i;b<$l7Z$hgiA8f_3r*?^t z)X2G!!&hF%y4Q)KidwO9&k^;MHKThzsQb*f{+5%6r(e5@%Ra*A%#E^fSPmj87CmXD zR-W2^u0)oyM-nwg?+)q*$56-fB^|xJJlKBST3oFod~+GzIB24UgguC!vy_Z18v6Q& z2HA!MZcaFQGc{Za2}cmPOH~UphTE!uAyd0GLVW*IMz;u+j@dA zQGfKRQIczU%|tP7aV0tX$_!*f`V+G!&f!Y><@=%i)&AO*T*}Ks{EXt9y7-ki6Y(M$j(ZKaty+3Bka%US_IFObv)*86(K+}p>|KtD8 zIQd@>J$de<+mVJ)HBjBqi?RL0d5?i{JOk%pW&d;fPg?fJW7qyiPJ4@4 zI@T;E{jY1V|3zp^lEq%7;7y$5K9&8alK#`D{lA2}YQ>xQL;Js_{|)W`ii?x&|F@z4 z*V+Cbxc}?+f4jfB92MNwd3mk*ovWR}bYt#yp;Z@Q?Lu$*y>m95eg12&KXy;-$6w$3 z3iau>K}ZcmH1wATiYJ6yGT=<>ynfA#ekGv&`WJ6~{^OMotT_4G`}eONUHvGjQ$zO$ zAnJYX+PxacqS65=2X?n;%#SUw{Qdb~NO^b)l8AFx)LQ&MsNoC!KTrq=LF{kROC$9E zkR>PoL;sJ3`QJGCPstBbM)Yt0=KvPk|K%{Qw@t6}rDXq?UJXlAA7j^6+y7+2(H2lW50%rn+*ca<4m6e1qi0Zcn)LMS`c`TXE9IFh zBo~%`FnnA+P+xpX=~FqM*VP@bomsAoz3&KPx2#)or<}^vtgkyY?iMF+D%eBwzNp~7 zB1PC0Xqn+UgE^eD2Nz%$8N?aIur2tfcUu$AT@V=e8N&=%7^Tmg}V}Mbg*aOSV(}RF^&x-Ihc4*~OMN*{|Gbc2cLyp7MM&(GTxb z|2vNA{$SEC%6tDIRr6~9qDpcgTMl_(wbLni_Dpt9HdmOL&gSRD{zv7$NP|K`E`Yz4 zd#o;FhD)KCj2Da9>9O4WV1B$1z{k86uYA)xA6RB)3sb_soP@9pSi&Wu0-UJwbG~oS zrA*N69-p|~U&y^6X-dlE{so6{QC+h3BTsF^tU#&ClBI?*?#R1bOGwY{4)Naw&nNoS zCWWk&##lt@j53-0p3ae`Cy4!lo^#>)AJt;yvC-H6B+>T#wZ}BP<>+H4zw30Q+ogZH zq}N^!WAS438UM5ug|>ur9o?~oev+)aB93WWIjPnx$6GO)t07%Is(9qQ9_R%}Y72dz zUe3fHuKx+w|0ur9$*0+`B_B3}p1@T{;rgF&{g2%~7q0)2JGh4Hf5P=Yv)GS5T>n$s zw@}aQ_yW{smC4cGthdqD2%_!`-|p)~k@`pk}oYO&;OsgsfG zxh##oS1lepntZMY_R8fDo>kXR1kv<{{$Hv@y**NBRS5mR+`p3JwR%FXtG3Ih)%?vu z|1V1J?u#RW^l7{IS?K>2`hSJ~Uzj*W;8-5|f3Xx6PlgKpza~xZ&!xX3gz6{i$d=NW z5>jQ|#*wmhJMB^XU=5Gi>{3gEE-pKr7Ib|HRb5@CSgi7r>n>C&8ph*Gin>Yc@x}dI zX!rc`lA?_Jy5#Y-ivoOjxa-={w-~EBRF+vv^IY1ySS9DS2-|y)Ecu=DF&{l42q$iR z1J(LkGHtpK)ftcb8VjdR*3Dn5-d~H>J=ENGER*)^dSkUqJhIf?cLJhS-mY6xeuYk3 zf8)-4GUra+V0q3}47Z%`Kshyze%oH7mbOs8@0QDBM{5}R|DwSPpZ&)3|0U&NI1(km zKJWD3^@~T17tZ(n`tK5t-?)C`1xZuolix2p1UPy;J~`9H_y6_p%NY892KV7EE_wgY zr6FgB@_*&E0Zu6~l>aHaSMQI`atr1EoX~m%FS$LKo7n2q-ni6IJabg%OK07ZLhc~I zFQakK0l9|e=<4mb?|BZijDt4I`(9le#!{qC(#-l@O4OBeM<7rHuk|bTviEvFVy<2& zUytSQ{o_q4s`HKR8Zq+E>jAaCFFgn(5tZk1Z~XFY>pzHX{r#W$+jG`R-G0XJN|5(v zP_hI!LKMM$|3>qnJU}Km#c+POr1JZGN)Y=$K7|v~AZ|sB)2R!w)_5*+-pFOdZsv0J zfO|PPHfYpR6B{<#uCwAB5gf5NpRE%*Hw*iBB~=!&>JuUhN6h@^nHPQsmia%yI1!^K z+M&PiJK-BpGuhd>$?SuXg|%FJd8-y2%=3DAvAvjk?7hLOUjC>r`ro&Fglv>H)l{2n z@}66$Uy<7DQooWbPPPI)i+v+Mn4rW5khsSY*V1N<1Hhnv(We=l0>8*9zn0RAnAE*mrGI1H>9O{I3`z@kF^+?; zVY}Ibyd*&TgrIi0aT<=^DRckVbr`n!{!4J=T!FLWjOQYKJuUd{?{1IxuI+B?jJCG7 zwnt-Y<1Nv6TW5c?BOdQc#5)t6z5T5R52!EAIo7midXiY%u6>`bn4T%-lEwLaYNnVi z9kFUZKUYl316SQ2*dOmmbjD)wu4qetEFO&wBs!v9T^;dgOGm7&tG#7ytfMn_@cE-f zWNLPz7=X@Kjsl%Csk!vdY%w{LOU-9zrwWsKaVG%P7`Y-Gy%;9fH$;Ot-srt{bW2Zb zTNj&dYimcQt*yH)nr-jQL}RV#Of=Qf*%{4_rP8T%EZvn(#}4*2M8;0;7hMFk*X5HZ zkS`=l?_J$l8gv5E zxPO6K0;jBH_Xlx$z`J?naF@)fI#Z!`pLN4W1;C*?K8LlE z{9otqXXs7e%`xi7FaF~%vu9j$%B?5Grj2i0`Z_2siTaPAwY-D+d<QaVv zSLV2D>)h81>EFea-&w79A6+UQfk)OOP9GW6xJ!?rrR;~eqrOe4d=S25Z0}ERNq%eV zPggx~Xl~tQ|BLb{^_)@<;`giNZ9c9R;)w8q8HuZorlCPlUwjOlX zm7?`IDChh28&xfA#JyPgSFMRMte+Zn=HId&uqW9|)2+97S;gi;Eb z-lC`3W0fQ-E<^io9c|O0{kM`WTH0?z`|siysYCnk(sT$2?Y~LoiLsRJzpF4ihW6j& zXkuh^s8nHY6=#k!bv7o3_FvOCCba+R_R-M(3%z$`J)P1AhW6ijS=>Hwsf0ehc{BCS$|Eks#V8`&gh~sc|>7|AzKoryVV{|4NHD p{A@&@boWZpdy}{Q)M>x8TP*EqSXZI_cNUyu9=xNo{DRtl{~zI=2^RnW diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index 6b61141..0000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "ExpandedNodes": [ - "" - ], - "PreviewInSolutionExplorer": false -} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite deleted file mode 100644 index ed9933d632ef28c8e568ca25a2d437bd63de11f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90112 zcmeI4&u<&Y700tZ~ zrA;m!3r!ES9RrO41NjpQ6lkvf3wkNgb8kfh^i&kR6={J2L2~HK?#}+0U5bj_s!;kR z^n<(e-prfNy!Uo~P^xW}bW@Y=b$bV@DP4;#!~`MsBT0(IVhQqnfqb*qIr4_yV=sZd zIpTLBwz6EABmzSEYby47`s=yR=N4vfCtuFInEpbHPi@6NoA_#?I`RGywV>#15SXTB z4!=JyX71#K;g)XfX^(4%2fN))LA$3Lx~X@Kmi^Y)U)MWYaj#X35=zTeC0|#hV!5Dv zAnhEhj%F$;k=JH9EZ>xtc7n||v%~W#F(VT*Z$_J0Ru8mjjXo zYH=f9y(`^T?n?PaeY035)ov)|I!ApFv$6W5-2JtCB-XZ#@GPM+xe<|D_>o@di{FV zHJIbdRMrQb&f(TT?dbP(Z7-^V;CL{-+r&#eUaZHgG~aG({l31dcW4(~th^ZKgCRMu z%YJ|~P-=&LQ#)`G^0z2T$~wrUt!PgdLawN}`4JIZ*$xnPv>#UtzS#T>6gd@tO3GyAlWv?A_#(~3A=i@%-? zMjT&E+Gi2R7x`o67!l_TXq3$%&k01F)$VwQc{P7wVeRh}^Y?%?Owe^+b|V!3(Lr86 zd_b}!%T%lh7I}63Kub>;?1pVv z(izr9xwzGEpFB*)Rr0wPD|0$Vo-yo>Z8Dcg+|q5W*C&A%%KT4a(_$u@6`sCp`5~*! zu0D7*6ZFAgq0a+Zfq#&W;d!=axCYzZ@zU&-v00Y2>vr`x%5=zXh+;;`u_5Cfxm8hn znqjtR+UCoqBgc=I^4H)SN?wdk7^0re%j9upnZPShUmmVaiJ1>c<~#H}ifME((11>8*sFq-8Hj`)KiY zP6h*nFZP89Uv#oiv2FIe{1`Klkz?THIxCOS`4oMfU`p_68NS%3Y?{(qF+2?{seN;E zx3BdcX=GaDWnO2tC>50Te4|vC+Jl}Iu_jB?B*?pQF|)cT4BxcEq^6msZtPnz?aa6B zJBgq_h2<U3;#eoX}G*m3UqT+X?3YM!>Ob_Qe|Iqz(cwc2aR6!|$h|5Ysg zxAbq*zfM0RZ}9>F5C8!X009sH0T2KI5C8!X0D#Wz&m25(Wa++%zf`t&L4ra= z+aQNgspQY!N+e?PYXxn0uwPeu`%c& zn5!2j60zJhxu>b7wzt`9JlLaeu3TTawz_il%GE2<>N_{yxqf4H^@5OyUCh+T3Cw}& z?8>gLTwA$L*Z&jgKgZJlBtP&10T2KI5C8!X009sH0T2KI5C8!XID-VvO~i9E{3l#y zh4`Z2>@G|uNv|f;&tmC6rGJ(FUHV!2?`N=^Fc}0u00ck)1V8`;KmY_l00ck)1kM0~ zH{-H!#K#aOY55VK4oIAjUlu|i4T!%H&k6ho111*Y7iR(=0-)#rLi(>U@`V=&fB*=9 z00@8p2!H?xfB*=900@AzAI|?}zCZW* z+`{bbTX!mqO zH}$U3vfmo}>v~5k?zM_hLTS0GVXz*-252hJk2pCQNgApZcOo?j~|5j{^OmuxN}h{e4o;agX3DpjdcEpFticct6PT`AwFZx+j>+6|>#CsvW~ zMya&y)KcknAL)Bq&#%p7Y!NyLRb^eNDrH%zNjpqKF-+Y&Y%aMsNEKO6g^XLHQlKCR z2033)0!0O-qVDTS`o)<@z=A#h~tY%`z+%4B7e*rBjTI^jj}o9If00? z+8ysOujVf-to@y0{vNP~3A)b9ZiM1LI>_sX4@j0|nTj>RBCoC=Xnj*Xc+iw+@~9U# zNG2uuih5#hM$BB!3Qy9OC$eT~eJ%Qf-LMTyI>Xv17q=SjlZVN;NIl zUYfl!Hp{Yh-L4)-nGV?vQOqbgHe|dbw<>B+Gt3rE+kDw{|ZA{;e=*0O+|FkI7 zETs}{@YEQCJy!4;hR>N)HKu7jeRSoo%yzXClU0gu$<*a)^y)i7!|bH%EVOW(k0=p z6o8?JE4AkM!`G_%8-f|yxc6rN~SosMnJuZch%JI-C7 z%Q<&W&C|Bk&VY;~=biRL(pvw=UdGbpxtFv5n%$gU6+fQ(eWDcqCAoR(ujdPIi05;; z=@)k%>Dothu3k~i`_>as*ZTam!+E=?+>!V)N$sbScZ&5}ByQwJwN~6#!ZP`qGgYJU zRU=Cbxh{qCft0UFYid6*2QTg|OQQmq%FDLj+amT8oT|_?5hynAOY7CmjZmvzM_jK+4aYIR^ zE1pcTTqdi~_sP05M1o4L*T}NolO~;s7^V08_Ryrmu#=RNO0v|}-EU2axUP)&8@D#+tQ#V!O>X|Ql) z9g&Y|S{+TaUL6c`GyClE>(&JJ7nitaG*$8x=+*gPjtmz1Qf08{SH=8W`d&ibJfu}wbw7YTCPRda$Deo~beja~Ims5Fi`#Kf z&$j>VLL^`poe(x9H@%EV9{l8G From 65de0eb9c5fcdae2550a75440252d14f61e370b7 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 May 2020 19:48:32 +0200 Subject: [PATCH 014/199] Add the Other Projects to Solution --- Synapse.sln | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Synapse.sln b/Synapse.sln index be683a9..3366402 100644 --- a/Synapse.sln +++ b/Synapse.sln @@ -1,7 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29926.136 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse", "Synapse\Synapse.csproj", "{93AB5927-1313-45A0-A27E-6AA8CA7C7BE1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SynapseModLoader", "SynapseModLoader\SynapseModLoader.csproj", "{4AAEE3B0-0C6C-4E26-83CC-AA16DDAD4F2B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SynapseModLoaderPatcher", "SynapseModLoaderPatcher\SynapseModLoaderPatcher.csproj", "{738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +19,19 @@ Global {93AB5927-1313-45A0-A27E-6AA8CA7C7BE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {93AB5927-1313-45A0-A27E-6AA8CA7C7BE1}.Release|Any CPU.ActiveCfg = Release|Any CPU {93AB5927-1313-45A0-A27E-6AA8CA7C7BE1}.Release|Any CPU.Build.0 = Release|Any CPU + {4AAEE3B0-0C6C-4E26-83CC-AA16DDAD4F2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AAEE3B0-0C6C-4E26-83CC-AA16DDAD4F2B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AAEE3B0-0C6C-4E26-83CC-AA16DDAD4F2B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AAEE3B0-0C6C-4E26-83CC-AA16DDAD4F2B}.Release|Any CPU.Build.0 = Release|Any CPU + {738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {738E5567-B0C5-4BB4-9F2B-9DAE6E9EE7A4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7D9EC85E-8616-4FAC-B714-001D688AD829} EndGlobalSection EndGlobal From a1ff00463a6d23a813812793640455de7a695246 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 20:35:35 +0200 Subject: [PATCH 015/199] More Api --- Synapse/Api/AmmoType.cs | 15 ++++++++++ Synapse/Api/Map.cs | 42 +++++++++++++++++++++++++++ Synapse/Api/Player.cs | 60 +++++++++++++++++++++++++++++++++++++++ Synapse/Api/RaCategory.cs | 19 +++++++++++++ Synapse/Api/Room.cs | 43 ++++++++++++++++++++++++++++ Synapse/Api/ZoneType.cs | 17 +++++++++++ Synapse/Synapse.csproj | 5 ++++ 7 files changed, 201 insertions(+) create mode 100644 Synapse/Api/AmmoType.cs create mode 100644 Synapse/Api/Player.cs create mode 100644 Synapse/Api/RaCategory.cs create mode 100644 Synapse/Api/Room.cs create mode 100644 Synapse/Api/ZoneType.cs diff --git a/Synapse/Api/AmmoType.cs b/Synapse/Api/AmmoType.cs new file mode 100644 index 0000000..458935e --- /dev/null +++ b/Synapse/Api/AmmoType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse.Api +{ + public enum AmmoType + { + Dropped5, + Dropped7, + Dropped9, + } +} diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 378ecfb..068926a 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -1,11 +1,15 @@ using System.Linq; using UnityEngine; using Mirror; +using System.Collections.Generic; namespace Synapse.Api { public static class Map { + //Variablen + private static List _rooms = new List(); + //Methoden /// Gives you the Position of the Door /// Name of the Door you want /// @@ -93,9 +97,47 @@ public static Vector3 GetRidPos(string Room) return position; } + /// The name of the Room you want + /// Gives you the Position of the Room + public static Vector3 GetRoomPos(string name) => Rooms.Where(room => room.Name.ToUpper() == name.ToUpper()).FirstOrDefault().Position; + /// Gives you the Spawn Position of a Role /// The Role you want to get s spawn position /// public static Vector3 GetRandomSpawnpoint(this RoleType type) => UnityEngine.Object.FindObjectOfType().GetRandomPosition(type).transform.position; + + /// Gives You a List with all Rooms on the Server + public static List Rooms + { + get + { + if (_rooms == null || _rooms.Count == 0) + _rooms = Object.FindObjectsOfType().Where(transform => transform.CompareTag("Room")).Select(obj => new Room { Name = obj.name, Position = obj.position, Transform = obj.transform }).ToList(); + + return _rooms; + } + } + + /// Starts the AlphaWarhead + public static void StartNuke() + { + var alpha = PlayerManager.localPlayer.GetComponent(); + alpha.InstantPrepare(); + alpha.StartDetonation(); + } + + /// Stops the AlphaWarhead + public static void StopNuke() + { + var alpha = PlayerManager.localPlayer.GetComponent(); + alpha.CancelDetonation(); + } + + /// Detonate the AlphaWarhead instantly + public static void DetonateNuke() + { + var alpha = PlayerManager.localPlayer.GetComponent(); + alpha.Detonate(); + } } } diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs new file mode 100644 index 0000000..35870ee --- /dev/null +++ b/Synapse/Api/Player.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse.Api +{ + public static class Player + { + /// Gives a User a Message im Remote Admin + /// The User who you send the Message + /// The Name from which is it at the begining of the Meessage + /// The Message you want to send + /// True = green the command is right you have permission and execute it sucessfully + /// In Which Category should you see it too? + public static void RAMessage(this CommandSender sender, string pluginname,string message, bool success = true, RaCategory Type = RaCategory.None) + { + string category = ""; + if (Type == RaCategory.None) category = ""; + if (Type == RaCategory.Playerinfo) category = "PlayerInfo"; + if (Type == RaCategory.ServerEvents) category = "ServerEvents"; + if (Type == RaCategory.DoorsManagement) category = "DoorsManagement"; + if (Type == RaCategory.AdminTools) category = "AdminTools"; + if (Type == RaCategory.ServerConfigs) category = "ServerConfigs"; + if (Type == RaCategory.PlayersManamgement) category = "PlayersManagement"; + + sender.RaReply($"{pluginname}#" + message, success, true, category); + } + + + /// Sends a Broadcast to a user + /// The User you want to send a Broadcast + /// How Long should he see it? + /// The message you send + public static void Broadcast(this ReferenceHub rh, ushort time, string message) => + rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, new global::Broadcast.BroadcastFlags()); + + /// Sends a broadcast to the user and delete all previous so that he see it instantly + /// The user + /// How long should the new Broadcast be shwon? + /// the broadcast message + public static void Broadcastinstant(this ReferenceHub rh, ushort time, string message) + { + rh.ClearBroadcasts(); + rh.Broadcast(time, message); + } + + /// Clears all of the current Broadcast the user has + /// The Player whicht Broadcast should be cleared + public static void ClearBroadcasts(this ReferenceHub player) => player.GetComponent().TargetClearElements(player.scp079PlayerScript.connectionToClient); + + /// A List of all Players on the Server which are not the Server + public static IEnumerable GetHubs() => ReferenceHub.Hubs.Values.Where(h => !h.isLocalPlayer); + + /// The User you want the Id of + /// The User ID (1234@steam) of the User + public static string GetUserId(this ReferenceHub player) => player.characterClassManager.UserId; + } +} diff --git a/Synapse/Api/RaCategory.cs b/Synapse/Api/RaCategory.cs new file mode 100644 index 0000000..583fcfd --- /dev/null +++ b/Synapse/Api/RaCategory.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse.Api +{ + public enum RaCategory + { + None = 0, + Playerinfo, + ServerEvents, + DoorsManagement, + AdminTools, + ServerConfigs, + PlayersManamgement, + } +} diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs new file mode 100644 index 0000000..53dc878 --- /dev/null +++ b/Synapse/Api/Room.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Synapse.Api +{ + public class Room + { + private ZoneType zone = ZoneType.Unspecified; + public string Name { get; set; } + public Transform Transform { get; set; } + public Vector3 Position { get; set; } + + public ZoneType Zone + { + get + { + if (zone != ZoneType.Unspecified) + return zone; + + if (Position.y == -1997f) + zone = ZoneType.Unspecified; + + else if (Position.y >= 0f && Position.y < 500f) + zone = ZoneType.LightContainment; + + else if (Position.y < -100 && Position.y > -1000f) + zone = ZoneType.HeavyContainment; + + else if (Name.Contains("ENT") || Name.Contains("INTERCOM")) + zone = ZoneType.Entrance; + + else if (Position.y >= 5) + zone = ZoneType.Surface; + + return zone; + } + } + } +} diff --git a/Synapse/Api/ZoneType.cs b/Synapse/Api/ZoneType.cs new file mode 100644 index 0000000..4c8f1c9 --- /dev/null +++ b/Synapse/Api/ZoneType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse.Api +{ + public enum ZoneType + { + Surface, + Entrance, + HeavyContainment, + LightContainment, + Unspecified, + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index daf9508..8b64eb2 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -58,6 +58,11 @@ + + + + + From f884420be7f2ad5b33fa823b66960b84669922bf Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 May 2020 20:42:19 +0200 Subject: [PATCH 016/199] Fixing a lot of Warnings and overall Code Quality. --- Synapse/Api/Map.cs | 35 ++++----- Synapse/Api/Player.cs | 58 ++++++++------ Synapse/Api/RaCategory.cs | 4 +- Synapse/Api/Room.cs | 18 ++--- Synapse/Events/Eventargs.cs | 6 +- Synapse/Events/Events.cs | 12 +-- Synapse/Events/Patches/PatchHandler.cs | 16 ++-- Synapse/Events/Patches/PlayerJoinPatch.cs | 8 +- Synapse/Log.cs | 10 +-- Synapse/MainLoader.cs | 15 ++-- Synapse/Plugin.cs | 2 +- Synapse/PluginManager.cs | 92 +++++++++++------------ Synapse/Synapse.csproj | 20 +++-- 13 files changed, 148 insertions(+), 148 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 068926a..095b07c 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -7,17 +7,17 @@ namespace Synapse.Api { public static class Map { - //Variablen + // Variables private static List _rooms = new List(); - //Methoden + // Methods /// Gives you the Position of the Door - /// Name of the Door you want + /// Name of the Door you want /// - public static Vector3 GetDoorpos(string Doorname) + public static Vector3 GetDoorPos(string doorName) { - Vector3 vector = Vector3.down; - Door door = UnityEngine.Object.FindObjectsOfType().FirstOrDefault((Door dr) => dr.DoorName.ToUpper() == Doorname); - vector = door.transform.position; + var door = Object.FindObjectsOfType().FirstOrDefault((dr) => dr.DoorName.ToUpper() == doorName); + if (door == null) return Vector3.one; + var vector = door.transform.position; vector.y += 2.5f; for (byte b = 0; b < 21; b += 1) { @@ -81,15 +81,15 @@ public static Vector3 GetDoorpos(string Doorname) } /// Gives you the Position of the cubes you can see when you write "showrids" in the console! - /// + /// /// - public static Vector3 GetRidPos(string Room) + public static Vector3 GetRidPos(string room) { - Vector3 position = new Vector3(53f, 1020f, -44f); - GameObject[] array = GameObject.FindGameObjectsWithTag("RoomID"); - foreach (GameObject gameObject2 in array) + var position = new Vector3(53f, 1020f, -44f); + var array = GameObject.FindGameObjectsWithTag("RoomID"); + foreach (var gameObject2 in array) { - if (gameObject2.GetComponent().id == Room) + if (gameObject2.GetComponent().id == room) { position = gameObject2.transform.position; } @@ -97,15 +97,11 @@ public static Vector3 GetRidPos(string Room) return position; } - /// The name of the Room you want - /// Gives you the Position of the Room - public static Vector3 GetRoomPos(string name) => Rooms.Where(room => room.Name.ToUpper() == name.ToUpper()).FirstOrDefault().Position; - /// Gives you the Spawn Position of a Role /// The Role you want to get s spawn position /// - public static Vector3 GetRandomSpawnpoint(this RoleType type) => UnityEngine.Object.FindObjectOfType().GetRandomPosition(type).transform.position; - + public static Vector3 GetRandomSpawnPoint(this RoleType type) => UnityEngine.Object.FindObjectOfType().GetRandomPosition(type).transform.position; + /// Gives You a List with all Rooms on the Server public static List Rooms { @@ -139,5 +135,6 @@ public static void DetonateNuke() var alpha = PlayerManager.localPlayer.GetComponent(); alpha.Detonate(); } + } } diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 35870ee..d315386 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Synapse.Api { @@ -10,22 +7,39 @@ public static class Player { /// Gives a User a Message im Remote Admin /// The User who you send the Message - /// The Name from which is it at the begining of the Meessage + /// The Name from which is it at the beginning of the Message /// The Message you want to send - /// True = green the command is right you have permission and execute it sucessfully - /// In Which Category should you see it too? - public static void RAMessage(this CommandSender sender, string pluginname,string message, bool success = true, RaCategory Type = RaCategory.None) + /// True = green the command is right you have permission and execute it successfully + /// In Which Category should you see it too? + public static void RaMessage(this CommandSender sender, string pluginName,string message, bool success = true, RaCategory type = RaCategory.None) { - string category = ""; - if (Type == RaCategory.None) category = ""; - if (Type == RaCategory.Playerinfo) category = "PlayerInfo"; - if (Type == RaCategory.ServerEvents) category = "ServerEvents"; - if (Type == RaCategory.DoorsManagement) category = "DoorsManagement"; - if (Type == RaCategory.AdminTools) category = "AdminTools"; - if (Type == RaCategory.ServerConfigs) category = "ServerConfigs"; - if (Type == RaCategory.PlayersManamgement) category = "PlayersManagement"; - - sender.RaReply($"{pluginname}#" + message, success, true, category); + var category = ""; + switch (type) + { + case RaCategory.None: + category = ""; + break; + case RaCategory.PlayerInfo: + category = "PlayerInfo"; + break; + case RaCategory.ServerEvents: + category = "ServerEvents"; + break; + case RaCategory.DoorsManagement: + category = "DoorsManagement"; + break; + case RaCategory.AdminTools: + category = "AdminTools"; + break; + case RaCategory.ServerConfigs: + category = "ServerConfigs"; + break; + case RaCategory.PlayersManagement: + category = "PlayersManagement"; + break; + } + + sender.RaReply($"{pluginName}#" + message, success, true, category); } @@ -34,20 +48,20 @@ public static void RAMessage(this CommandSender sender, string pluginname,string /// How Long should he see it? /// The message you send public static void Broadcast(this ReferenceHub rh, ushort time, string message) => - rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, new global::Broadcast.BroadcastFlags()); + rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, new Broadcast.BroadcastFlags()); /// Sends a broadcast to the user and delete all previous so that he see it instantly /// The user - /// How long should the new Broadcast be shwon? + /// How long should the new Broadcast be shown? /// the broadcast message - public static void Broadcastinstant(this ReferenceHub rh, ushort time, string message) + public static void BroadcastInstant(this ReferenceHub rh, ushort time, string message) { rh.ClearBroadcasts(); rh.Broadcast(time, message); } /// Clears all of the current Broadcast the user has - /// The Player whicht Broadcast should be cleared + /// The Player which Broadcast should be cleared public static void ClearBroadcasts(this ReferenceHub player) => player.GetComponent().TargetClearElements(player.scp079PlayerScript.connectionToClient); /// A List of all Players on the Server which are not the Server diff --git a/Synapse/Api/RaCategory.cs b/Synapse/Api/RaCategory.cs index 583fcfd..99185d0 100644 --- a/Synapse/Api/RaCategory.cs +++ b/Synapse/Api/RaCategory.cs @@ -9,11 +9,11 @@ namespace Synapse.Api public enum RaCategory { None = 0, - Playerinfo, + PlayerInfo, ServerEvents, DoorsManagement, AdminTools, ServerConfigs, - PlayersManamgement, + PlayersManagement, } } diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index 53dc878..6019000 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -9,7 +9,7 @@ namespace Synapse.Api { public class Room { - private ZoneType zone = ZoneType.Unspecified; + private ZoneType _zone = ZoneType.Unspecified; public string Name { get; set; } public Transform Transform { get; set; } public Vector3 Position { get; set; } @@ -18,25 +18,25 @@ public ZoneType Zone { get { - if (zone != ZoneType.Unspecified) - return zone; + if (_zone != ZoneType.Unspecified) + return _zone; if (Position.y == -1997f) - zone = ZoneType.Unspecified; + _zone = ZoneType.Unspecified; else if (Position.y >= 0f && Position.y < 500f) - zone = ZoneType.LightContainment; + _zone = ZoneType.LightContainment; else if (Position.y < -100 && Position.y > -1000f) - zone = ZoneType.HeavyContainment; + _zone = ZoneType.HeavyContainment; else if (Name.Contains("ENT") || Name.Contains("INTERCOM")) - zone = ZoneType.Entrance; + _zone = ZoneType.Entrance; else if (Position.y >= 5) - zone = ZoneType.Surface; + _zone = ZoneType.Surface; - return zone; + return _zone; } } } diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index 3f0a759..b68083e 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -1,15 +1,17 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events { + [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class PlayerJoinEvent : EventArgs { - //Eigenschaften + // Properties public ReferenceHub Player { get; private set; } public string Nick { get; set; } - //Konstruktor + // Constructor public PlayerJoinEvent(ReferenceHub player) { Player = player; diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index dd0984d..fdc8b14 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -6,22 +6,22 @@ namespace Synapse.Events { - public class Events + public static class Events { //JoinEvent - public delegate void Playerjoin(ref PlayerJoinEvent ev); + public delegate void PlayerJoin(ref PlayerJoinEvent ev); /// A Event which is activated when a User Joins the Server /// It need to hook ref PlayerJoinEvent ev - public static event Playerjoin PlayerjoinEvent; - public static void InvokePlayerjoinEvent(ReferenceHub player,ref string nick) + public static event PlayerJoin PlayerJoinEvent; + public static void InvokePlayerJoinEvent(ReferenceHub player,ref string nick) { - if (PlayerjoinEvent == null) return; + if (PlayerJoinEvent == null) return; var ev = new PlayerJoinEvent(player) { Nick = nick, }; - PlayerjoinEvent.Invoke(ref ev); + PlayerJoinEvent.Invoke(ref ev); nick = ev.Nick; } diff --git a/Synapse/Events/Patches/PatchHandler.cs b/Synapse/Events/Patches/PatchHandler.cs index dbc4d30..95a7ccc 100644 --- a/Synapse/Events/Patches/PatchHandler.cs +++ b/Synapse/Events/Patches/PatchHandler.cs @@ -5,19 +5,19 @@ namespace Synapse.Events.Patches { public class PatchHandler { - //Variablen - private HarmonyInstance instance; - private int patchFixer = 0; + // Variables + private HarmonyInstance _instance; + private int _patchFixer = 0; - //Methoden + // Methods public void PatchMethods() { Log.Info("Harmony Patching started!"); try { - patchFixer++; - instance = HarmonyInstance.Create($"SynapsEvents.patches.{patchFixer}"); - instance.PatchAll(); + _patchFixer++; + _instance = HarmonyInstance.Create($"SynapseEvents.patches.{_patchFixer}"); + _instance.PatchAll(); Log.Info("Harmony Patching Done!"); } catch (Exception e) @@ -28,7 +28,7 @@ public void PatchMethods() public void UnPatchMethods() { - instance.UnpatchAll(); + _instance.UnpatchAll(); } } } diff --git a/Synapse/Events/Patches/PlayerJoinPatch.cs b/Synapse/Events/Patches/PlayerJoinPatch.cs index 28db87f..b2a13e6 100644 --- a/Synapse/Events/Patches/PlayerJoinPatch.cs +++ b/Synapse/Events/Patches/PlayerJoinPatch.cs @@ -6,14 +6,14 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(NicknameSync), nameof(NicknameSync.UpdateNickname))] public static class PlayerJoinPatch { - public static bool Prefix(NicknameSync __instance, ref string n) + public static bool Prefix(NicknameSync instance, ref string n) { try { - ReferenceHub Player = __instance.GetComponent(); + var player = instance.GetComponent(); - if (!string.IsNullOrEmpty(Player.characterClassManager.UserId)) - Events.InvokePlayerjoinEvent(Player, ref n); + if (!string.IsNullOrEmpty(player.characterClassManager.UserId)) + Events.InvokePlayerJoinEvent(player, ref n); } catch (Exception e) { diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 78c2698..4006ddc 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -10,18 +10,18 @@ namespace Synapse public static class Log { /// Send a Information in the Console - /// The Information + /// Information Message public static void Info(string message) { - Assembly assembly = Assembly.GetCallingAssembly(); + var assembly = Assembly.GetCallingAssembly(); ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}"); } /// Sends a Warn in the Console - /// Warnmessage + /// Warning Message public static void Warn(string message) { - Assembly assembly = Assembly.GetCallingAssembly(); + var assembly = Assembly.GetCallingAssembly(); ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); } @@ -29,7 +29,7 @@ public static void Warn(string message) /// Error Message public static void Error(string message) { - Assembly assembly = Assembly.GetCallingAssembly(); + var assembly = Assembly.GetCallingAssembly(); ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); } } diff --git a/Synapse/MainLoader.cs b/Synapse/MainLoader.cs index e2590d1..25fe264 100644 --- a/Synapse/MainLoader.cs +++ b/Synapse/MainLoader.cs @@ -1,11 +1,14 @@ -using MEC; +using System.Diagnostics.CodeAnalysis; +using MEC; using System.IO; namespace Synapse { + [SuppressMessage("ReSharper", "UnusedType.Global")] public class MainLoader { /// This method is called by the Scp Server in the assembly-csharp + // ReSharper disable once UnusedMember.Global public static void LoaderExecutionCode() { Log.Info("Checking Files"); @@ -13,14 +16,8 @@ public static void LoaderExecutionCode() if (!Directory.Exists(PluginManager.ConfigDirectory)) Directory.CreateDirectory(PluginManager.ConfigDirectory); - if (!File.Exists(PluginManager.ConfigPath)) - File.Create(PluginManager.ConfigPath).Close(); - - if (!Directory.Exists(PluginManager.MainPluginDirectoty)) - Directory.CreateDirectory(PluginManager.MainPluginDirectoty); - - if (!Directory.Exists(PluginManager.ServerPluginDirectory)) - Directory.CreateDirectory(PluginManager.ServerPluginDirectory); + if (!Directory.Exists(PluginManager.MainPluginDirectory)) + Directory.CreateDirectory(PluginManager.MainPluginDirectory); if (!Directory.Exists(PluginManager.DependenciesDirectory)) Directory.CreateDirectory(PluginManager.DependenciesDirectory); diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index e0721cd..04591e1 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -3,7 +3,7 @@ public abstract class Plugin { public static YamlConfig Config; - public abstract string getName { get; } + public abstract string GetName { get; } /// The Method ist always activated when the Server starts /// You can use it to hook Events diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 5edccf3..33cafa1 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -2,33 +2,38 @@ using System.Collections.Generic; using MEC; using System.IO; +using System.Linq; using System.Reflection; using Synapse.Events.Patches; +using Loader; namespace Synapse { - public class PluginManager + public static class PluginManager { - //Variablen - private static List LoadedDependencies = new List(); - public static readonly List _plugins = new List(); - public static string SynapseDirectoty { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); - public static string MainPluginDirectoty { get; } = Path.Combine(SynapseDirectoty, "Plugins"); - public static string ServerPluginDirectory { get; } = Path.Combine(MainPluginDirectoty,$"Server{ServerConsole.Port} Plugins"); - public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectoty,"dependencies"); - public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectoty, "ServerConfigs"); - public static string ConfigPath { get; } = Path.Combine(ConfigDirectory,$"Server{ServerConsole.Port}-config.yml"); - - //Methoden + // Variables + private static readonly List LoadedDependencies = new List(); + private static readonly List Plugins = new List(); + private static string SynapseDirectory { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); + public static string MainPluginDirectory { get; } = Path.Combine(SynapseDirectory, "Plugins"); + public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectory,"dependencies"); + public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); + + // Methods public static IEnumerator LoadPlugins() { yield return Timing.WaitForSeconds(0.5f); LoadDependencies(); - string[] plugins = Directory.GetFiles(ServerPluginDirectory); + var serverPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerConsole.Port} Plugins"); - foreach (string plugin in plugins) + if (!Directory.Exists(serverPluginDirectory)) + Directory.CreateDirectory(serverPluginDirectory); + + var plugins = Directory.GetFiles(serverPluginDirectory); + + foreach (var plugin in plugins) { if (plugin.EndsWith("Synapse.dll")) continue; @@ -37,12 +42,17 @@ public static IEnumerator LoadPlugins() HarmonyPatch(); OnEnable(); + + var configPath = Path.Combine(ConfigDirectory, $"Server{ServerConsole.Port}-config.yml"); + + if (!File.Exists(configPath)) + File.Create(configPath).Close(); } private static void LoadDependencies() { - Log.Info("Dependencies werden geladen"); - string[] depends = Directory.GetFiles(DependenciesDirectory); + Log.Info("Loading Dependencies..."); + var depends = Directory.GetFiles(DependenciesDirectory); foreach (string dll in depends) { @@ -51,31 +61,26 @@ private static void LoadDependencies() if (IsLoaded(dll)) return; - Assembly assembly = Assembly.LoadFrom(dll); + var assembly = Assembly.LoadFrom(dll); LoadedDependencies.Add(assembly); - Log.Info($"Succesfully loaded {dll}"); + Log.Info($"Successfully loaded {dll}"); } } private static bool IsLoaded(string path) { - foreach (Assembly assembly in LoadedDependencies) - { - if (assembly.Location == path) - return true; - } - return false; + return LoadedDependencies.Any(assembly => assembly.Location == path); } - private static void LoadPlugin(string pluginpath) + private static void LoadPlugin(string pluginPath) { - Log.Info($"Loading {pluginpath}"); + Log.Info($"Loading {pluginPath}"); try { - byte[] file = ReadFile(pluginpath); - Assembly assembly = Assembly.Load(file); + var file = ModLoader.ReadFile(pluginPath); + var assembly = Assembly.Load(file); - foreach (Type type in assembly.GetTypes()) + foreach (var type in assembly.GetTypes()) { if (type.IsAbstract) { @@ -86,23 +91,23 @@ private static void LoadPlugin(string pluginpath) if (!typeof(Plugin).IsAssignableFrom(type)) continue; - object plugin = Activator.CreateInstance(type); + var plugin = Activator.CreateInstance(type); if (!(plugin is Plugin p)) continue; - _plugins.Add(p); - Log.Info($"Succesfully loaded {p.getName}"); + Plugins.Add(p); + Log.Info($"Successfully loaded {p.GetName}"); } } catch (Exception e) { - Log.Error($"Error while initializing {pluginpath}: {e}"); + Log.Error($"Error while initializing {pluginPath}: {e}"); } } private static void OnEnable() { - foreach (Plugin plugin in _plugins) + foreach (var plugin in Plugins) { try { @@ -110,7 +115,7 @@ private static void OnEnable() } catch (Exception e) { - Log.Error($"Plugin {plugin.getName} threw an exception while enabling {e}"); + Log.Error($"Plugin {plugin.GetName} threw an exception while enabling {e}"); } } } @@ -119,26 +124,13 @@ private static void HarmonyPatch() { try { - var PatchHandler = new PatchHandler(); - PatchHandler.PatchMethods(); + var patchHandler = new PatchHandler(); + patchHandler.PatchMethods(); } catch (Exception e) { Log.Error($"PatchError: {e}"); } } - - public static byte[] ReadFile(string path) - { - FileStream fileStream = File.Open(path, FileMode.Open); - byte[] result; - using (MemoryStream memoryStream = new MemoryStream()) - { - fileStream.CopyTo(memoryStream); - result = memoryStream.ToArray(); - } - fileStream.Close(); - return result; - } } } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 8b64eb2..c908e54 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -32,29 +32,27 @@ 4 - - ..\..\Synaps Verweise\0Harmony.dll + + D:\Downloads\Synaps_Verweise\Synaps Verweise\0Harmony.dll - ..\..\Exiled Verweise\Assembly-CSharp-firstpass.dll + D:\Downloads\Synaps_Verweise\Synaps Verweise\Assembly-CSharp-firstpass.dll - - False - ..\..\Synaps Verweise\Assembly-CSharp_publicized.SynapseMod.dll + + D:\Downloads\Synaps_Verweise\Synaps Verweise\Assembly-CSharp_publicized.SynapseMod.dll - - False - ..\..\Synaps Verweise\Mirror.dll + + D:\Downloads\Synaps_Verweise\Synaps Verweise\Mirror.dll - ..\..\Synaps Verweise\UnityEngine.dll + D:\Downloads\Synaps_Verweise\Synaps Verweise\UnityEngine.dll - ..\..\Exiled Verweise\UnityEngine.CoreModule.dll + D:\Downloads\Synaps_Verweise\Synaps Verweise\UnityEngine.CoreModule.dll From 0cdb201a018f84abb89ea6872ce6467838c03d0d Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 20:50:46 +0200 Subject: [PATCH 017/199] More Api --- Synapse/Api/Map.cs | 8 ++++++++ Synapse/Api/Player.cs | 33 +++++++++++++++++++++++++++++++++ Synapse/Synapse.csproj | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 068926a..14520de 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -2,6 +2,8 @@ using UnityEngine; using Mirror; using System.Collections.Generic; +using CustomPlayerEffects; +using LightContainmentZoneDecontamination; namespace Synapse.Api { @@ -139,5 +141,11 @@ public static void DetonateNuke() var alpha = PlayerManager.localPlayer.GetComponent(); alpha.Detonate(); } + + /// Gets The Status of is the NukeDetonated + public static bool IsNukeDetonated => PlayerManager.localPlayer.GetComponent().detonated; + + /// Gets The Status of is the NukeInProgress + public static bool IsNukeInProgress => PlayerManager.localPlayer.GetComponent().inProgress; } } diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 35870ee..c091819 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using UnityEngine; namespace Synapse.Api { @@ -56,5 +57,37 @@ public static void Broadcastinstant(this ReferenceHub rh, ushort time, string me /// The User you want the Id of /// The User ID (1234@steam) of the User public static string GetUserId(this ReferenceHub player) => player.characterClassManager.UserId; + + /// Gives you The Position of the User + /// The User which Position you want to have + public static Vector3 GetPosition(this ReferenceHub player) => player.playerMovementSync.transform.position; + + /// Gives You the Current Room the user is in + /// + public static Room GetCurrentRoom(this ReferenceHub player) + { + Vector3 playerpos = player.GetPosition(); + Vector3 end = playerpos - new Vector3(0f, 10f, 0f); + bool flag = Physics.Linecast(playerpos, end, out RaycastHit raycastHit, -84058629); + + if (!flag || raycastHit.transform == null) + return null; + + Transform transform = raycastHit.transform; + + while (transform.parent != null && transform.parent.parent != null) + transform = transform.parent; + + foreach (Room room in Map.Rooms) + if (room.Position == transform.position) + return room; + + return new Room + { + Name = transform.name, + Position = transform.position, + Transform = transform + }; + } } } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 8b64eb2..3cb548f 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -56,6 +56,10 @@ ..\..\Exiled Verweise\UnityEngine.CoreModule.dll + + False + ..\..\Synaps Verweise\UnityEngine.PhysicsModule.dll + From 8e9494a56c6c597cdd06aedfc3f9e8d516f27baf Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 21:16:57 +0200 Subject: [PATCH 018/199] Add RemoteCommandEvent --- Synapse/Api/Map.cs | 3 --- Synapse/Api/Player.cs | 5 +--- Synapse/Events/Eventargs.cs | 22 ++++++++++++++++ Synapse/Events/Events.cs | 20 +++++++++++++++ Synapse/Events/Patches/RemoteAdminPatch.cs | 29 ++++++++++++++++++++++ Synapse/Synapse.csproj | 1 + 6 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 Synapse/Events/Patches/RemoteAdminPatch.cs diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 9512c37..bdfcdda 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -1,9 +1,6 @@ using System.Linq; using UnityEngine; -using Mirror; using System.Collections.Generic; -using CustomPlayerEffects; -using LightContainmentZoneDecontamination; namespace Synapse.Api { diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index ad26dbe..2cbb814 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; namespace Synapse.Api diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index b68083e..910091c 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -17,4 +17,26 @@ public PlayerJoinEvent(ReferenceHub player) Player = player; } } + + public class RemoteCommandEvent : EventArgs + { + //Eigenschaften + public CommandSender Sender { get; private set; } + + public ReferenceHub Player + { + get => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" ? ReferenceHub.GetHub(PlayerManager.localPlayer) : ReferenceHub.GetHub(int.Parse(Sender.SenderId)); + } + + public bool Allow { get; set; } + + public string Command { get; private set; } + + //Konstruktor + public RemoteCommandEvent(CommandSender sender,string command) + { + Sender = sender; + Command = command; + } + } } diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index fdc8b14..6ca3f56 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -25,5 +25,25 @@ public static void InvokePlayerJoinEvent(ReferenceHub player,ref string nick) nick = ev.Nick; } + + + //RemoteCommandEvent + public delegate void RemoteCommand(ref RemoteCommandEvent ev); + /// A Event which is activated when a user send a Command in the Remote Admin + /// It need to hook ref RemoteCommandEvent ev + public static event RemoteCommand RemoteCommandEvent; + public static void InvokeRemoteCommandEvent(CommandSender sender,string command,ref bool allow) + { + if (RemoteCommandEvent == null) return; + + var ev = new RemoteCommandEvent(sender, command) + { + Allow = allow, + }; + + RemoteCommandEvent.Invoke(ref ev); + + allow = ev.Allow; + } } } diff --git a/Synapse/Events/Patches/RemoteAdminPatch.cs b/Synapse/Events/Patches/RemoteAdminPatch.cs new file mode 100644 index 0000000..ae29663 --- /dev/null +++ b/Synapse/Events/Patches/RemoteAdminPatch.cs @@ -0,0 +1,29 @@ +using System; +using Harmony; +using RemoteAdmin; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(CommandProcessor), nameof(CommandProcessor.ProcessQuery), typeof(string), typeof(CommandSender))] + public class RemoteAdminPatch + { + public static bool Prefix(ref string q, ref CommandSender sender) + { + try + { + if (q.Contains("REQUEST_DATA PLAYER_LIST SILENT")) + return true; + + bool allow = true; + Events.InvokeRemoteCommandEvent(sender, q, ref allow); + + return allow; + } + catch (Exception e) + { + Log.Error($"RemoteAdminCommand Event Error: {e}"); + return true; + } + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index be59c30..d7f7a86 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -68,6 +68,7 @@ + From 853237fb4c03d2b3039062cac2b77b49c74eae31 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 21:35:41 +0200 Subject: [PATCH 019/199] ServerNamePatch --- Synapse/Events/Patches/ServerNamePatch.cs | 14 ++++++++++++++ Synapse/Log.cs | 6 +++--- Synapse/Synapse.csproj | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 Synapse/Events/Patches/ServerNamePatch.cs diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs new file mode 100644 index 0000000..686c9f4 --- /dev/null +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -0,0 +1,14 @@ +using Harmony; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.ReloadServerName))] + public static class ServerNamePatch + { + public static void Postfix() + { + ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); + ServerConsole._serverName += $" Synapse-Alpha.v1.0"; + } + } +} diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 4006ddc..9c6f9b0 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -14,7 +14,7 @@ public static class Log public static void Info(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}"); + ServerConsole.AddLog($"Information from: [{assembly.GetName().ToString().Split(',')[0]}] {message}"); } /// Sends a Warn in the Console @@ -22,7 +22,7 @@ public static void Info(string message) public static void Warn(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); + ServerConsole.AddLog($"Warning from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); } /// Sends a Error in the Console @@ -30,7 +30,7 @@ public static void Warn(string message) public static void Error(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); + ServerConsole.AddLog($"Error Message from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); } } } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index d7f7a86..fca5476 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -68,6 +68,7 @@ + From cbef8b11fd17e621bb4bf5cd59caad5b42c711ad Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 22:31:08 +0200 Subject: [PATCH 020/199] Bugfix --- Synapse/Events/Patches/ServerNamePatch.cs | 2 +- Synapse/Log.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index 686c9f4..80669a8 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -5,7 +5,7 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.ReloadServerName))] public static class ServerNamePatch { - public static void Postfix() + public static void Postfix(ServerConsole __instance) { ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); ServerConsole._serverName += $" Synapse-Alpha.v1.0"; diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 9c6f9b0..0b0d534 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -14,7 +14,7 @@ public static class Log public static void Info(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"Information from: [{assembly.GetName().ToString().Split(',')[0]}] {message}"); + ServerConsole.AddLog($"[INFO] from: [{assembly.GetName().ToString().Split(',')[0]}] {message}"); } /// Sends a Warn in the Console @@ -22,7 +22,7 @@ public static void Info(string message) public static void Warn(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"Warning from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); + ServerConsole.AddLog($"[WARN] from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); } /// Sends a Error in the Console @@ -30,7 +30,7 @@ public static void Warn(string message) public static void Error(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"Error Message from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); + ServerConsole.AddLog($"[ERROR] from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); } } } From 8df6b3ee8701ad46ec25421986ce08bc1ef60275 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 22:37:55 +0200 Subject: [PATCH 021/199] Bugfix --- Synapse/Events/Patches/PlayerJoinPatch.cs | 4 ++-- Synapse/Events/Patches/ServerNamePatch.cs | 2 +- Synapse/Log.cs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Synapse/Events/Patches/PlayerJoinPatch.cs b/Synapse/Events/Patches/PlayerJoinPatch.cs index b2a13e6..ec0875d 100644 --- a/Synapse/Events/Patches/PlayerJoinPatch.cs +++ b/Synapse/Events/Patches/PlayerJoinPatch.cs @@ -6,11 +6,11 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(NicknameSync), nameof(NicknameSync.UpdateNickname))] public static class PlayerJoinPatch { - public static bool Prefix(NicknameSync instance, ref string n) + public static bool Prefix(NicknameSync __instance, ref string n) { try { - var player = instance.GetComponent(); + var player = __instance.GetComponent(); if (!string.IsNullOrEmpty(player.characterClassManager.UserId)) Events.InvokePlayerJoinEvent(player, ref n); diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index 80669a8..686c9f4 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -5,7 +5,7 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.ReloadServerName))] public static class ServerNamePatch { - public static void Postfix(ServerConsole __instance) + public static void Postfix() { ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); ServerConsole._serverName += $" Synapse-Alpha.v1.0"; diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 0b0d534..4006ddc 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -14,7 +14,7 @@ public static class Log public static void Info(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[INFO] from: [{assembly.GetName().ToString().Split(',')[0]}] {message}"); + ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}"); } /// Sends a Warn in the Console @@ -22,7 +22,7 @@ public static void Info(string message) public static void Warn(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[WARN] from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); + ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); } /// Sends a Error in the Console @@ -30,7 +30,7 @@ public static void Warn(string message) public static void Error(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[ERROR] from [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); + ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); } } } From da67c22da29accc9c09efa92dabbb480855ec217 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 May 2020 23:16:17 +0200 Subject: [PATCH 022/199] New Loading Message --- Synapse/MainLoader.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Synapse/MainLoader.cs b/Synapse/MainLoader.cs index 25fe264..486f04d 100644 --- a/Synapse/MainLoader.cs +++ b/Synapse/MainLoader.cs @@ -11,6 +11,9 @@ public class MainLoader // ReSharper disable once UnusedMember.Global public static void LoaderExecutionCode() { + Log.Info("Now starting Synapse Version v.0.1.0 alpha"); + Log.Info("Created by Dimenzio and SirRoob"); + Log.Info("Checking Files"); if (!Directory.Exists(PluginManager.ConfigDirectory)) From 1d1e3340db497abb7753a364c0f3ea62f7f9c976 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 May 2020 23:16:42 +0200 Subject: [PATCH 023/199] Rollback to Old Binary Loading without the ModLoader --- Synapse/PluginManager.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 33cafa1..d08a28a 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using Synapse.Events.Patches; -using Loader; namespace Synapse { @@ -30,7 +29,7 @@ public static IEnumerator LoadPlugins() if (!Directory.Exists(serverPluginDirectory)) Directory.CreateDirectory(serverPluginDirectory); - + var plugins = Directory.GetFiles(serverPluginDirectory); foreach (var plugin in plugins) @@ -77,7 +76,7 @@ private static void LoadPlugin(string pluginPath) Log.Info($"Loading {pluginPath}"); try { - var file = ModLoader.ReadFile(pluginPath); + var file = ReadFile(pluginPath); var assembly = Assembly.Load(file); foreach (var type in assembly.GetTypes()) @@ -132,5 +131,18 @@ private static void HarmonyPatch() Log.Error($"PatchError: {e}"); } } + + public static byte[] ReadFile(string path) + { + FileStream fileStream = File.Open(path, FileMode.Open); + byte[] result; + using (MemoryStream memoryStream = new MemoryStream()) + { + fileStream.CopyTo(memoryStream); + result = memoryStream.ToArray(); + } + fileStream.Close(); + return result; + } } } From 9bf87d8528f426bab497a34b8ddc8247ffe6d580 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 May 2020 23:16:53 +0200 Subject: [PATCH 024/199] Change Version Number --- Synapse/Events/Patches/ServerNamePatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index 686c9f4..bd84e5f 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -8,7 +8,7 @@ public static class ServerNamePatch public static void Postfix() { ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); - ServerConsole._serverName += $" Synapse-Alpha.v1.0"; + ServerConsole._serverName += $" Synapse-Alpha.v0.1.0"; } } } From 6b0fc79cd057e11a362df6a45fb1b19d292a23d0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 23:24:53 +0200 Subject: [PATCH 025/199] added SpeakEvent --- Synapse/Events/Eventargs.cs | 26 ++++++++++++++++++- Synapse/Events/Events.cs | 28 +++++++++++++++++++- Synapse/Events/Patches/SpeakPatch.cs | 38 ++++++++++++++++++++++++++++ Synapse/Synapse.csproj | 1 + 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 Synapse/Events/Patches/SpeakPatch.cs diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index 910091c..91822ed 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -1,4 +1,5 @@ -using System; +using Assets._Scripts.Dissonance; +using System; using System.Diagnostics.CodeAnalysis; namespace Synapse.Events @@ -39,4 +40,27 @@ public RemoteCommandEvent(CommandSender sender,string command) Command = command; } } + + public class SpeakEvent : EventArgs + { + public ReferenceHub Player { get; } + + public DissonanceUserSetup DissonanceUserSetup { get; } + + public bool Scp939Talk { get; set; } + + public bool IntercomTalk { get; set; } + + public bool RadioTalk { get; set; } + + public bool ScpChat { get; set; } + + public bool SpectatorChat { get; set; } + + public SpeakEvent(ReferenceHub player, DissonanceUserSetup setup) + { + Player = player; + DissonanceUserSetup = setup; + } + } } diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index 6ca3f56..59b50ac 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -1,4 +1,5 @@ -using System; +using Assets._Scripts.Dissonance; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -45,5 +46,30 @@ public static void InvokeRemoteCommandEvent(CommandSender sender,string command, allow = ev.Allow; } + + //Speak Event + public delegate void Speak(ref SpeakEvent ev); + public static event Speak SpeakEvent; + public static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool intercom, ref bool radio, ref bool scp939, ref bool scpchat, ref bool spectator) + { + if (SpeakEvent == null) return; + + SpeakEvent ev = new SpeakEvent(dissonance.gameObject.GetComponent(), dissonance) + { + IntercomTalk = intercom, + RadioTalk = radio, + Scp939Talk = scp939, + ScpChat = scpchat, + SpectatorChat = spectator + }; + + SpeakEvent.Invoke(ref ev); + + intercom = ev.IntercomTalk; + radio = ev.RadioTalk; + scp939 = ev.Scp939Talk; + scpchat = ev.ScpChat; + spectator = ev.SpectatorChat; + } } } diff --git a/Synapse/Events/Patches/SpeakPatch.cs b/Synapse/Events/Patches/SpeakPatch.cs new file mode 100644 index 0000000..89f3e75 --- /dev/null +++ b/Synapse/Events/Patches/SpeakPatch.cs @@ -0,0 +1,38 @@ +using Assets._Scripts.Dissonance; +using System; +using Harmony; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(DissonanceUserSetup), nameof(DissonanceUserSetup.CallCmdAltIsActive))] + public class SpeakPatch + { + public static bool Prefix(DissonanceUserSetup __instance, bool value) + { + try + { + bool intercom = __instance.IntercomAsHuman; + bool radio = __instance.RadioAsHuman; + bool scp939 = __instance.MimicAs939; + bool scpchat = __instance.SCPChat; + bool spectator = __instance.SpectatorChat; + + Events.InvokeSpeakEvent(__instance, ref intercom, ref radio, ref scp939, ref scpchat, ref spectator); + + __instance.SCPChat = scpchat; + __instance.SpectatorChat = spectator; + __instance.IntercomAsHuman = intercom; + + if (scp939) __instance.MimicAs939 = value; + if (radio) __instance.RadioAsHuman = value; + + return true; + } + catch (Exception e) + { + Log.Error($"SpeakEvent Error: {e}"); + return true; + } + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index fca5476..2b4d196 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -68,6 +68,7 @@ + From 0ccfcde1cbefc4a1ae9dae21c05e9aaf05417f3d Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 23:38:44 +0200 Subject: [PATCH 026/199] added Scp049Recall Event --- Synapse/Events/Eventargs.cs | 20 +++ Synapse/Events/Events.cs | 25 +++ Synapse/Events/Patches/Scp049RecallPatch.cs | 161 ++++++++++++++++++++ Synapse/Synapse.csproj | 1 + 4 files changed, 207 insertions(+) create mode 100644 Synapse/Events/Patches/Scp049RecallPatch.cs diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index 91822ed..de0a82b 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -63,4 +63,24 @@ public SpeakEvent(ReferenceHub player, DissonanceUserSetup setup) DissonanceUserSetup = setup; } } + + public class Scp049RecallEvent : EventArgs + { + public ReferenceHub Player { get; set; } + + public ReferenceHub Target { get; set; } + + public bool Allow { get; set; } + + public RoleType RespawnRole { get; set; } + + public float TargetHealth { get; set; } + + public Ragdoll Ragdoll { get; set; } + + public Scp049RecallEvent(ReferenceHub player) + { + Player = player; + } + } } diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index 59b50ac..18c58fb 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -71,5 +71,30 @@ public static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool int scpchat = ev.ScpChat; spectator = ev.SpectatorChat; } + + //Scp049RecallEvent + public delegate void Scp049Recall(ref Scp049RecallEvent ev); + public static event Scp049Recall Scp049RecallEvent; + public static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ragdoll, ref ReferenceHub target, ref bool allow, ref RoleType role, ref float lives) + { + if (Scp049RecallEvent == null) return; + + Scp049RecallEvent ev = new Scp049RecallEvent(player) + { + Allow = allow, + Ragdoll = ragdoll, + Target = target, + RespawnRole = role, + TargetHealth = lives, + }; + + Scp049RecallEvent.Invoke(ref ev); + + ragdoll = ev.Ragdoll; + target = ev.Target; + role = ev.RespawnRole; + lives = ev.TargetHealth; + allow = ev.Allow; + } } } diff --git a/Synapse/Events/Patches/Scp049RecallPatch.cs b/Synapse/Events/Patches/Scp049RecallPatch.cs new file mode 100644 index 0000000..213eef3 --- /dev/null +++ b/Synapse/Events/Patches/Scp049RecallPatch.cs @@ -0,0 +1,161 @@ +using System; +using Harmony; +using Mirror; +using PlayableScps; +using UnityEngine; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(Scp049), nameof(Scp049.BodyCmd_ByteAndGameObject))] + public class Scp049RecallPatch + { + public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) + { + try + { + if (num == 0) + { + if (!__instance._interactRateLimit.CanExecute(true)) + { + return false; + } + if (go == null) + { + return false; + } + if (Vector3.Distance(go.transform.position, __instance.Hub.playerMovementSync.RealModelPosition) >= Scp049.AttackDistance * 1.25f) + { + return false; + } + __instance.Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(4949f, __instance.Hub.nicknameSync.MyNick + " (" + __instance.Hub.characterClassManager.UserId + ")", DamageTypes.Scp049, __instance.Hub.queryProcessor.PlayerId), go); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Sent 'death time' RPC", MessageImportance.LessImportant, false); + __instance.Hub.scpsController.RpcTransmit_Byte(0); + return false; + } + else + { + if (num != 1) + { + if (num == 2) + { + if (!__instance._interactRateLimit.CanExecute(true)) + { + return false; + } + if (go == null) + { + return false; + } + Ragdoll component = go.GetComponent(); + if (component == null) + { + return false; + } + ReferenceHub referenceHub = null; + foreach (GameObject player in PlayerManager.players) + { + ReferenceHub hub = ReferenceHub.GetHub(player); + if (hub.queryProcessor.PlayerId == component.owner.PlayerId) + { + referenceHub = hub; + break; + } + } + if (referenceHub == null) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant, false); + return false; + } + if (!__instance._recallInProgressServer || referenceHub.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "PASSED" : ("ERROR - " + __instance._recallInProgressServer.ToString())), MessageImportance.LessImportant, true); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub == __instance._recallObjectServer) ? "PASSED" : string.Concat(new object[] + { + "ERROR - ", + referenceHub.queryProcessor.PlayerId, + "-", + (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString() + })), MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "PASSED" : ("ERROR - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true); + return false; + } + if (referenceHub.characterClassManager.CurClass != RoleType.Spectator) + { + return false; + } + + //Event + bool allow = true; + RoleType role = RoleType.Scp0492; + float live = (float)referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; + Events.InvokeScp049RecallEvent(__instance.Hub, ref component, ref referenceHub, ref allow, ref role, ref live); + + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant, false); + RoundSummary.changed_into_zombies++; + referenceHub.characterClassManager.SetClassID(role); + referenceHub.GetComponent().Health = live; + if (component.CompareTag("Ragdoll")) + { + NetworkServer.Destroy(component.gameObject); + } + __instance._recallInProgressServer = false; + __instance._recallObjectServer = null; + __instance._recallProgressServer = 0f; + } + return false; + } + if (!__instance._interactRateLimit.CanExecute(true)) + { + return false; + } + if (go == null) + { + return false; + } + Ragdoll component2 = go.GetComponent(); + if (component2 == null) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant, false); + return false; + } + if (!component2.allowRecall) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant, false); + return false; + } + ReferenceHub referenceHub2 = null; + foreach (GameObject player2 in PlayerManager.players) + { + ReferenceHub hub2 = ReferenceHub.GetHub(player2); + if (hub2 != null && hub2.queryProcessor.PlayerId == component2.owner.PlayerId) + { + referenceHub2 = hub2; + break; + } + } + if (referenceHub2 == null) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant, false); + return false; + } + if (Vector3.Distance(component2.transform.position, __instance.Hub.PlayerCameraReference.transform.position) >= Scp049.ReviveDistance * 1.3f) + { + return false; + } + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant, false); + __instance._recallObjectServer = referenceHub2.gameObject; + __instance._recallProgressServer = 0f; + __instance._recallInProgressServer = true; + + return false; + } + } + catch (Exception e) + { + Log.Error($"Scp049RecallEvent Error: {e}"); + return true; + } + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 2b4d196..d322b27 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -68,6 +68,7 @@ + From 3ded1580508f307fd4898d057ca7f634595ededa Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 31 May 2020 23:59:20 +0200 Subject: [PATCH 027/199] Documentary --- Synapse/Events/Events.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index 18c58fb..7dd7e76 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -49,6 +49,7 @@ public static void InvokeRemoteCommandEvent(CommandSender sender,string command, //Speak Event public delegate void Speak(ref SpeakEvent ev); + /// A Event which is activated when a user press any voice hotkey public static event Speak SpeakEvent; public static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool intercom, ref bool radio, ref bool scp939, ref bool scpchat, ref bool spectator) { @@ -74,6 +75,7 @@ public static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool int //Scp049RecallEvent public delegate void Scp049Recall(ref Scp049RecallEvent ev); + /// A Event which is activated when Scp049 Recalls a Player public static event Scp049Recall Scp049RecallEvent; public static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ragdoll, ref ReferenceHub target, ref bool allow, ref RoleType role, ref float lives) { From bb5ac1faef311423cffb3eda072e63525683ce01 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 00:07:26 +0200 Subject: [PATCH 028/199] Typo --- SynapseModLoader/ModLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SynapseModLoader/ModLoader.cs b/SynapseModLoader/ModLoader.cs index d21f4da..5cd906e 100644 --- a/SynapseModLoader/ModLoader.cs +++ b/SynapseModLoader/ModLoader.cs @@ -28,7 +28,7 @@ public static void LoadModSystem() { return; } - ServerConsole.AddLog("Synpase Mod-Loader is now intialising.. :)", ConsoleColor.Blue); + ServerConsole.AddLog("Synapse Mod-Loader is now intialising.. :)", ConsoleColor.Blue); string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Synapse"); if (!Directory.Exists(text)) { From 073cf461ec013044249575ed64b2624160697fc4 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 00:07:37 +0200 Subject: [PATCH 029/199] Add Color to the Information Log --- Synapse/Log.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 4006ddc..3a49096 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -14,7 +14,7 @@ public static class Log public static void Info(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}"); + ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}", ConsoleColor.Blue); } /// Sends a Warn in the Console @@ -22,7 +22,7 @@ public static void Info(string message) public static void Warn(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Yellow); + ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}", ConsoleColor.Yellow); } /// Sends a Error in the Console @@ -30,7 +30,7 @@ public static void Warn(string message) public static void Error(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}",ConsoleColor.Red); + ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}", ConsoleColor.Red); } } } From c5c30bf7f0df68ae462fc35a00d945301deff759 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 00:42:34 +0200 Subject: [PATCH 030/199] Add Overwatch Getter-Setters --- Synapse/Api/Player.cs | 213 +++++++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 98 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 2cbb814..b1895e0 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -6,102 +6,119 @@ namespace Synapse.Api { public static class Player { - /// Gives a User a Message im Remote Admin - /// The User who you send the Message - /// The Name from which is it at the beginning of the Message - /// The Message you want to send - /// True = green the command is right you have permission and execute it successfully - /// In Which Category should you see it too? - public static void RaMessage(this CommandSender sender, string pluginName,string message, bool success = true, RaCategory type = RaCategory.None) - { - var category = ""; - switch (type) - { - case RaCategory.None: - category = ""; - break; - case RaCategory.PlayerInfo: - category = "PlayerInfo"; - break; - case RaCategory.ServerEvents: - category = "ServerEvents"; - break; - case RaCategory.DoorsManagement: - category = "DoorsManagement"; - break; - case RaCategory.AdminTools: - category = "AdminTools"; - break; - case RaCategory.ServerConfigs: - category = "ServerConfigs"; - break; - case RaCategory.PlayersManagement: - category = "PlayersManagement"; - break; - } - - sender.RaReply($"{pluginName}#" + message, success, true, category); - } - - - /// Sends a Broadcast to a user - /// The User you want to send a Broadcast - /// How Long should he see it? - /// The message you send - public static void Broadcast(this ReferenceHub rh, ushort time, string message) => - rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, new Broadcast.BroadcastFlags()); - - /// Sends a broadcast to the user and delete all previous so that he see it instantly - /// The user - /// How long should the new Broadcast be shown? - /// the broadcast message - public static void BroadcastInstant(this ReferenceHub rh, ushort time, string message) - { - rh.ClearBroadcasts(); - rh.Broadcast(time, message); - } - - /// Clears all of the current Broadcast the user has - /// The Player which Broadcast should be cleared - public static void ClearBroadcasts(this ReferenceHub player) => player.GetComponent().TargetClearElements(player.scp079PlayerScript.connectionToClient); - - /// A List of all Players on the Server which are not the Server - public static IEnumerable GetHubs() => ReferenceHub.Hubs.Values.Where(h => !h.isLocalPlayer); - - /// The User you want the Id of - /// The User ID (1234@steam) of the User - public static string GetUserId(this ReferenceHub player) => player.characterClassManager.UserId; - - /// Gives you The Position of the User - /// The User which Position you want to have - public static Vector3 GetPosition(this ReferenceHub player) => player.playerMovementSync.transform.position; - - /// Gives You the Current Room the user is in - /// - public static Room GetCurrentRoom(this ReferenceHub player) + /// Gives a User a Message im Remote Admin + /// The User who you send the Message + /// The Name from which is it at the beginning of the Message + /// The Message you want to send + /// True = green the command is right you have permission and execute it successfully + /// In Which Category should you see it too? + public static void RaMessage(this CommandSender sender, string pluginName,string message, bool success = true, RaCategory type = RaCategory.None) { - Vector3 playerpos = player.GetPosition(); - Vector3 end = playerpos - new Vector3(0f, 10f, 0f); - bool flag = Physics.Linecast(playerpos, end, out RaycastHit raycastHit, -84058629); - - if (!flag || raycastHit.transform == null) - return null; - - Transform transform = raycastHit.transform; - - while (transform.parent != null && transform.parent.parent != null) - transform = transform.parent; - - foreach (Room room in Map.Rooms) - if (room.Position == transform.position) - return room; - - return new Room - { - Name = transform.name, - Position = transform.position, - Transform = transform - }; - } - } -} + var category = ""; + switch (type) + { + case RaCategory.None: + category = ""; + break; + case RaCategory.PlayerInfo: + category = "PlayerInfo"; + break; + case RaCategory.ServerEvents: + category = "ServerEvents"; + break; + case RaCategory.DoorsManagement: + category = "DoorsManagement"; + break; + case RaCategory.AdminTools: + category = "AdminTools"; + break; + case RaCategory.ServerConfigs: + category = "ServerConfigs"; + break; + case RaCategory.PlayersManagement: + category = "PlayersManagement"; + break; + } + + sender.RaReply($"{pluginName}#" + message, success, true, category); + } + + + /// Sends a Broadcast to a user + /// The User you want to send a Broadcast + /// How Long should he see it? + /// The message you send + public static void Broadcast(this ReferenceHub rh, ushort time, string message) => + rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, new Broadcast.BroadcastFlags()); + + /// Sends a broadcast to the user and delete all previous so that he see it instantly + /// The user + /// How long should the new Broadcast be shown? + /// the broadcast message + public static void BroadcastInstant(this ReferenceHub rh, ushort time, string message) + { + rh.ClearBroadcasts(); + rh.Broadcast(time, message); + } + + /// Clears all of the current Broadcast the user has + /// The Player which Broadcast should be cleared + public static void ClearBroadcasts(this ReferenceHub player) => player.GetComponent().TargetClearElements(player.scp079PlayerScript.connectionToClient); + + /// A List of all Players on the Server which are not the Server + public static IEnumerable GetHubs() => ReferenceHub.Hubs.Values.Where(h => !h.isLocalPlayer); + + /// The User you want the Id of + /// The User ID (1234@steam) of the User + public static string GetUserId(this ReferenceHub player) => player.characterClassManager.UserId; + + /// Gives you The Position of the User + /// The User which Position you want to have + public static Vector3 GetPosition(this ReferenceHub player) => player.playerMovementSync.transform.position; + + /// Gives You the Current Room the user is in + /// + public static Room GetCurrentRoom(this ReferenceHub player) + { + Vector3 playerpos = player.GetPosition(); + Vector3 end = playerpos - new Vector3(0f, 10f, 0f); + bool flag = Physics.Linecast(playerpos, end, out RaycastHit raycastHit, -84058629); + + if (!flag || raycastHit.transform == null) + return null; + + Transform transform = raycastHit.transform; + + while (transform.parent != null && transform.parent.parent != null) + transform = transform.parent; + + foreach (Room room in Map.Rooms) + if (room.Position == transform.position) + return room; + + return new Room + { + Name = transform.name, + Position = transform.position, + Transform = transform + }; + } + + /// + /// Gets' a players overwatch status + /// + /// The Player that needs to be checked + /// The Overwatch Status + public static bool GetOverwatch(this ReferenceHub player) => player.serverRoles.OverwatchEnabled; + + /// + /// Sets' a players overwatch status + /// + /// player to be modified + /// new status to modify + public static void SetOverwatch(this ReferenceHub player, bool newStatus) => + player.serverRoles.SetOverwatchStatus(newStatus); + + + } +} \ No newline at end of file From d750a08fff75ff43bf6c900963ed5b9cd96163ae Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 00:53:20 +0200 Subject: [PATCH 031/199] SetRole and GetRole for ClassManagement --- Synapse/Api/Player.cs | 47 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index b1895e0..b968335 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -12,7 +12,8 @@ public static class Player /// The Message you want to send /// True = green the command is right you have permission and execute it successfully /// In Which Category should you see it too? - public static void RaMessage(this CommandSender sender, string pluginName,string message, bool success = true, RaCategory type = RaCategory.None) + public static void RaMessage(this CommandSender sender, string pluginName, string message, bool success = true, + RaCategory type = RaCategory.None) { var category = ""; switch (type) @@ -48,8 +49,9 @@ public static void RaMessage(this CommandSender sender, string pluginName,string /// The User you want to send a Broadcast /// How Long should he see it? /// The message you send - public static void Broadcast(this ReferenceHub rh, ushort time, string message) => - rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, new Broadcast.BroadcastFlags()); + public static void Broadcast(this ReferenceHub rh, ushort time, string message) => + rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, + new Broadcast.BroadcastFlags()); /// Sends a broadcast to the user and delete all previous so that he see it instantly /// The user @@ -63,7 +65,8 @@ public static void BroadcastInstant(this ReferenceHub rh, ushort time, string me /// Clears all of the current Broadcast the user has /// The Player which Broadcast should be cleared - public static void ClearBroadcasts(this ReferenceHub player) => player.GetComponent().TargetClearElements(player.scp079PlayerScript.connectionToClient); + public static void ClearBroadcasts(this ReferenceHub player) => player.GetComponent() + .TargetClearElements(player.scp079PlayerScript.connectionToClient); /// A List of all Players on the Server which are not the Server public static IEnumerable GetHubs() => ReferenceHub.Hubs.Values.Where(h => !h.isLocalPlayer); @@ -103,7 +106,7 @@ public static Room GetCurrentRoom(this ReferenceHub player) Transform = transform }; } - + /// /// Gets' a players overwatch status /// @@ -118,7 +121,39 @@ public static Room GetCurrentRoom(this ReferenceHub player) /// new status to modify public static void SetOverwatch(this ReferenceHub player, bool newStatus) => player.serverRoles.SetOverwatchStatus(newStatus); + + /// + /// Get the active role that the player currently is. + /// + /// The Player to be checked + /// A RoleType identifier + public static RoleType GetRole(this ReferenceHub player) => player.characterClassManager.CurClass; + + /// + /// Setting the player as a different Role + /// + /// the player to be changed + /// the role the player should change to + public static void SetRole(this ReferenceHub player, RoleType roleType) => + player.characterClassManager.SetPlayersClass(roleType, player.gameObject); - + /// + /// Setting the player as a different Role + /// + /// the player to be changed + /// the role the player should change to + /// set the player to the current position on the screen. + public static void SetRole(this ReferenceHub player, RoleType roleType, bool stayAtPosition) + { + if (stayAtPosition) + { + player.characterClassManager.NetworkCurClass = roleType; + player.playerStats.SetHPAmount(player.characterClassManager.Classes.SafeGet(player.GetRole()).maxHP); + } + else + { + SetRole(player, roleType); + } + } } } \ No newline at end of file From 11a96d88184421d546ba62c57b314b5591eab868 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 09:21:26 +0200 Subject: [PATCH 032/199] More Events and Api --- Synapse/Api/Player.cs | 54 ++++++++++++++++++- Synapse/Events/Eventargs.cs | 16 +++++- Synapse/Events/Events.cs | 22 ++++++++ Synapse/Events/Patches/ConsoleCommandPatch.cs | 31 +++++++++++ Synapse/Synapse.csproj | 1 + 5 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 Synapse/Events/Patches/ConsoleCommandPatch.cs diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index b968335..91e653f 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -69,7 +69,57 @@ public static void ClearBroadcasts(this ReferenceHub player) => player.GetCompon .TargetClearElements(player.scp079PlayerScript.connectionToClient); /// A List of all Players on the Server which are not the Server - public static IEnumerable GetHubs() => ReferenceHub.Hubs.Values.Where(h => !h.isLocalPlayer); + public static IEnumerable GetHubs() + { + List list = new List(); + + foreach (GameObject gameObject in PlayerManager.players) + { + if (gameObject == PlayerManager.localPlayer || gameObject == null) continue; + + list.Add(gameObject.GetComponent()); + } + + return list; + } + + /// PlayerId of the User + /// Object Referncehub from the USer with the id + public static ReferenceHub GetPlayer(int id) + { + foreach (ReferenceHub hub in GetHubs()) + { + if (hub.GetPlayerID() == id) + return hub; + } + return null; + } + + public static ReferenceHub GetPlayer(string args) + { + if (short.TryParse(args, out short playerid)) + return GetPlayer(playerid); + + if (args.EndsWith("@steam") || args.EndsWith("@discord") || args.EndsWith("@northwood") || args.EndsWith("@patreon")) + { + foreach (ReferenceHub player in GetHubs()) + if (player.GetUserId() == args) + return player; + } + + foreach (ReferenceHub hub in GetHubs()) + if (hub.GetNickName().ToLower().Contains(args.ToLower())) + return hub; + + return null; + + } + + public static string GetNickName(this ReferenceHub player) => player.nicknameSync.MyNick; + + /// + /// The PlayerID of the User + public static int GetPlayerID(this ReferenceHub player) => player.queryProcessor.NetworkPlayerId; /// The User you want the Id of /// The User ID (1234@steam) of the User @@ -79,6 +129,8 @@ public static void ClearBroadcasts(this ReferenceHub player) => player.GetCompon /// The User which Position you want to have public static Vector3 GetPosition(this ReferenceHub player) => player.playerMovementSync.transform.position; + public static void SetPosition(this ReferenceHub player, Vector3 position, bool forceground = false) => player.playerMovementSync.OverridePosition(position, 0f, forceground); + /// Gives You the Current Room the user is in /// public static Room GetCurrentRoom(this ReferenceHub player) diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index de0a82b..aafb31e 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -1,4 +1,5 @@ using Assets._Scripts.Dissonance; +using Synapse.Api; using System; using System.Diagnostics.CodeAnalysis; @@ -26,7 +27,7 @@ public class RemoteCommandEvent : EventArgs public ReferenceHub Player { - get => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" ? ReferenceHub.GetHub(PlayerManager.localPlayer) : ReferenceHub.GetHub(int.Parse(Sender.SenderId)); + get => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" ? ReferenceHub.GetHub(PlayerManager.localPlayer) : Synapse.Api.Player.GetPlayer(Sender.SenderId); } public bool Allow { get; set; } @@ -66,7 +67,7 @@ public SpeakEvent(ReferenceHub player, DissonanceUserSetup setup) public class Scp049RecallEvent : EventArgs { - public ReferenceHub Player { get; set; } + public ReferenceHub Player { get; private set; } public ReferenceHub Target { get; set; } @@ -83,4 +84,15 @@ public Scp049RecallEvent(ReferenceHub player) Player = player; } } + + public class ConsoleCommandEvent + { + public ReferenceHub Player { get; internal set; } + + public string Command { get; internal set; } + + public string ReturnMessage { get; set; } + + public string Color { get; set; } + } } diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index 7dd7e76..6b5373c 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -47,6 +47,28 @@ public static void InvokeRemoteCommandEvent(CommandSender sender,string command, allow = ev.Allow; } + //ConsoleCommandEvent + public delegate void ConsoleCommand(ref ConsoleCommandEvent ev); + /// A Event which is activated when a user send a Command in the Remote Admin + public static event ConsoleCommand ConsoleCommandEvent; + public static void InvokeConsoleCommandEvent(ReferenceHub player,string command,out string color,out string returning) + { + color = "red"; + returning = ""; + if (ConsoleCommandEvent == null) return; + + var ev = new ConsoleCommandEvent() + { + Command = command, + Player = player, + }; + + ConsoleCommandEvent.Invoke(ref ev); + + color = ev.Color; + returning = ev.ReturnMessage; + } + //Speak Event public delegate void Speak(ref SpeakEvent ev); /// A Event which is activated when a user press any voice hotkey diff --git a/Synapse/Events/Patches/ConsoleCommandPatch.cs b/Synapse/Events/Patches/ConsoleCommandPatch.cs new file mode 100644 index 0000000..622174d --- /dev/null +++ b/Synapse/Events/Patches/ConsoleCommandPatch.cs @@ -0,0 +1,31 @@ +using System; +using Harmony; +using RemoteAdmin; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(QueryProcessor), nameof(QueryProcessor.ProcessGameConsoleQuery))] + public class ConsoleCommandPatch + { + public static bool Prefix(QueryProcessor __instance,ref string query, bool encrypted) + { + try + { + Events.InvokeConsoleCommandEvent(__instance.GetComponent(),query,out string color, out string returning); + + if (string.IsNullOrEmpty(color)) + color = "red"; + + if (!string.IsNullOrEmpty(returning)) + __instance.GCT.SendToClient(__instance.connectionToClient, returning, color); + + return false; + } + catch (Exception e) + { + Log.Error($"ConsoleCommand Event Error: {e}"); + return true; + } + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index d322b27..04520b9 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -68,6 +68,7 @@ + From 5260d78880b2d0b13b908dff8c68957c134e6067 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 09:47:39 +0200 Subject: [PATCH 033/199] added Player Leave Event --- Synapse/Events/Eventargs.cs | 34 ++++++-------------- Synapse/Events/Events.cs | 36 +++++++++++++++++++--- Synapse/Events/Patches/PlayerLeavePatch.cs | 25 +++++++++++++++ Synapse/Synapse.csproj | 1 + 4 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 Synapse/Events/Patches/PlayerLeavePatch.cs diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index aafb31e..51b025a 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -22,8 +22,7 @@ public PlayerJoinEvent(ReferenceHub player) public class RemoteCommandEvent : EventArgs { - //Eigenschaften - public CommandSender Sender { get; private set; } + public CommandSender Sender { get; internal set; } public ReferenceHub Player { @@ -32,21 +31,14 @@ public ReferenceHub Player public bool Allow { get; set; } - public string Command { get; private set; } - - //Konstruktor - public RemoteCommandEvent(CommandSender sender,string command) - { - Sender = sender; - Command = command; - } + public string Command { get; internal set; } } public class SpeakEvent : EventArgs { - public ReferenceHub Player { get; } + public ReferenceHub Player { get; internal set; } - public DissonanceUserSetup DissonanceUserSetup { get; } + public DissonanceUserSetup DissonanceUserSetup { get; internal set; } public bool Scp939Talk { get; set; } @@ -57,17 +49,11 @@ public class SpeakEvent : EventArgs public bool ScpChat { get; set; } public bool SpectatorChat { get; set; } - - public SpeakEvent(ReferenceHub player, DissonanceUserSetup setup) - { - Player = player; - DissonanceUserSetup = setup; - } } public class Scp049RecallEvent : EventArgs { - public ReferenceHub Player { get; private set; } + public ReferenceHub Player { get; internal set; } public ReferenceHub Target { get; set; } @@ -78,11 +64,6 @@ public class Scp049RecallEvent : EventArgs public float TargetHealth { get; set; } public Ragdoll Ragdoll { get; set; } - - public Scp049RecallEvent(ReferenceHub player) - { - Player = player; - } } public class ConsoleCommandEvent @@ -95,4 +76,9 @@ public class ConsoleCommandEvent public string Color { get; set; } } + + public class PlayerLeaveEvent + { + public ReferenceHub Player { get; internal set; } + } } diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index 6b5373c..af67f37 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -37,9 +37,11 @@ public static void InvokeRemoteCommandEvent(CommandSender sender,string command, { if (RemoteCommandEvent == null) return; - var ev = new RemoteCommandEvent(sender, command) + var ev = new RemoteCommandEvent() { Allow = allow, + Sender = sender, + Command = command, }; RemoteCommandEvent.Invoke(ref ev); @@ -47,6 +49,7 @@ public static void InvokeRemoteCommandEvent(CommandSender sender,string command, allow = ev.Allow; } + //ConsoleCommandEvent public delegate void ConsoleCommand(ref ConsoleCommandEvent ev); /// A Event which is activated when a user send a Command in the Remote Admin @@ -69,7 +72,8 @@ public static void InvokeConsoleCommandEvent(ReferenceHub player,string command, returning = ev.ReturnMessage; } - //Speak Event + + //SpeakEvent public delegate void Speak(ref SpeakEvent ev); /// A Event which is activated when a user press any voice hotkey public static event Speak SpeakEvent; @@ -77,13 +81,15 @@ public static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool int { if (SpeakEvent == null) return; - SpeakEvent ev = new SpeakEvent(dissonance.gameObject.GetComponent(), dissonance) + var ev = new SpeakEvent() { IntercomTalk = intercom, RadioTalk = radio, Scp939Talk = scp939, ScpChat = scpchat, - SpectatorChat = spectator + SpectatorChat = spectator, + DissonanceUserSetup = dissonance, + Player = dissonance.gameObject.GetComponent(), }; SpeakEvent.Invoke(ref ev); @@ -95,6 +101,7 @@ public static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool int spectator = ev.SpectatorChat; } + //Scp049RecallEvent public delegate void Scp049Recall(ref Scp049RecallEvent ev); /// A Event which is activated when Scp049 Recalls a Player @@ -103,13 +110,14 @@ public static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ragd { if (Scp049RecallEvent == null) return; - Scp049RecallEvent ev = new Scp049RecallEvent(player) + Scp049RecallEvent ev = new Scp049RecallEvent() { Allow = allow, Ragdoll = ragdoll, Target = target, RespawnRole = role, TargetHealth = lives, + Player = player }; Scp049RecallEvent.Invoke(ref ev); @@ -120,5 +128,23 @@ public static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ragd lives = ev.TargetHealth; allow = ev.Allow; } + + + //PlayerLeaveEvent + public delegate void PlayerLeave(PlayerLeaveEvent ev); + /// + /// A Event which is activated when a User leave the server + /// + public static event PlayerLeave PlayerLeaveEvent; + public static void InvokePlayerLeaveEvent(ReferenceHub player) + { + if (PlayerLeaveEvent == null) return; + + var ev = new PlayerLeaveEvent() + { + Player = player, + }; + PlayerLeaveEvent.Invoke(ev); + } } } diff --git a/Synapse/Events/Patches/PlayerLeavePatch.cs b/Synapse/Events/Patches/PlayerLeavePatch.cs new file mode 100644 index 0000000..f517b0c --- /dev/null +++ b/Synapse/Events/Patches/PlayerLeavePatch.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse.Events.Patches +{ + public static class PlayerLeavePatch + { + public static bool Prefix(ReferenceHub __instance) + { + try + { + Events.InvokePlayerLeaveEvent(__instance); + } + catch (Exception e) + { + Log.Error($"Player Leave Event Error: {e}"); + } + + return true; + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 04520b9..8f7b1cf 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -68,6 +68,7 @@ + From 725b4d7ee5edcfb81f1f8901b773bf38ed0ae64a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 10:37:33 +0200 Subject: [PATCH 034/199] Added for each Plugin a own Directory for special configs and added for each Plugin this.Config for the main Yaml Config! --- Synapse/Plugin.cs | 19 ++++++++++++++++++- Synapse/PluginManager.cs | 8 +++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 04591e1..416699f 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -1,8 +1,25 @@ -namespace Synapse +using System.IO; + +namespace Synapse { public abstract class Plugin { + private string ownPluginFolder; + public static YamlConfig Config; + + public string OwnPluginFolder + { + get + { + if (!Directory.Exists(ownPluginFolder)) + Directory.CreateDirectory(ownPluginFolder); + + return ownPluginFolder + Path.DirectorySeparatorChar.ToString(); + } + internal set => ownPluginFolder = value; + } + public abstract string GetName { get; } /// The Method ist always activated when the Server starts diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index d08a28a..3881439 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -17,6 +17,7 @@ public static class PluginManager public static string MainPluginDirectory { get; } = Path.Combine(SynapseDirectory, "Plugins"); public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectory,"dependencies"); public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); + public static string ServerPluginDirectoty { get; internal set; } // Methods public static IEnumerator LoadPlugins() @@ -26,6 +27,7 @@ public static IEnumerator LoadPlugins() LoadDependencies(); var serverPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerConsole.Port} Plugins"); + ServerPluginDirectoty = serverPluginDirectory; if (!Directory.Exists(serverPluginDirectory)) Directory.CreateDirectory(serverPluginDirectory); @@ -40,12 +42,15 @@ public static IEnumerator LoadPlugins() } HarmonyPatch(); - OnEnable(); var configPath = Path.Combine(ConfigDirectory, $"Server{ServerConsole.Port}-config.yml"); if (!File.Exists(configPath)) File.Create(configPath).Close(); + + Plugin.Config = new YamlConfig(configPath); + + OnEnable(); } private static void LoadDependencies() @@ -111,6 +116,7 @@ private static void OnEnable() try { plugin.OnEnable(); + plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectoty, plugin.GetName); } catch (Exception e) { From 8d96f093430bede12c0537cd0c89eeb1df43c52c Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 10:39:52 +0200 Subject: [PATCH 035/199] OwnPluginFolder activates first --- Synapse/PluginManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 3881439..c61fa55 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -115,8 +115,8 @@ private static void OnEnable() { try { - plugin.OnEnable(); plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectoty, plugin.GetName); + plugin.OnEnable(); } catch (Exception e) { From 8e975458ece2ae2f3e9a5927682388209e63a847 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 10:52:10 +0200 Subject: [PATCH 036/199] Warning Fixes and better Quality Code --- Synapse/Api/AmmoType.cs | 8 +- Synapse/Api/Map.cs | 2 +- Synapse/Api/Player.cs | 5 +- Synapse/Api/RaCategory.cs | 8 +- Synapse/Api/Room.cs | 7 +- Synapse/Api/ZoneType.cs | 8 +- Synapse/Events/Eventargs.cs | 3 +- Synapse/Events/Events.cs | 5 - Synapse/Events/Patches/ConsoleCommandPatch.cs | 1 + Synapse/Events/Patches/PatchHandler.cs | 2 +- Synapse/Events/Patches/PlayerJoinPatch.cs | 1 + Synapse/Events/Patches/PlayerLeavePatch.cs | 5 +- Synapse/Events/Patches/Scp049RecallPatch.cs | 144 ++++++++---------- Synapse/Events/Patches/ServerNamePatch.cs | 2 +- Synapse/Events/Patches/SpeakPatch.cs | 3 +- Synapse/Log.cs | 4 - Synapse/Plugin.cs | 10 +- SynapseModLoader/ModLoader.cs | 8 +- SynapseModLoaderPatcher/Program.cs | 1 + 19 files changed, 88 insertions(+), 139 deletions(-) diff --git a/Synapse/Api/AmmoType.cs b/Synapse/Api/AmmoType.cs index 458935e..6b3d6f6 100644 --- a/Synapse/Api/AmmoType.cs +++ b/Synapse/Api/AmmoType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Synapse.Api +namespace Synapse.Api { public enum AmmoType { diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index bdfcdda..5a016da 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -103,7 +103,7 @@ public static Vector3 GetRidPos(string room) /// Gives you the Spawn Position of a Role /// The Role you want to get s spawn position /// - public static Vector3 GetRandomSpawnPoint(this RoleType type) => UnityEngine.Object.FindObjectOfType().GetRandomPosition(type).transform.position; + public static Vector3 GetRandomSpawnPoint(this RoleType type) => Object.FindObjectOfType().GetRandomPosition(type).transform.position; /// Gives You a List with all Rooms on the Server public static List Rooms diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 91e653f..d0aeffc 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using UnityEngine; namespace Synapse.Api @@ -89,7 +88,7 @@ public static ReferenceHub GetPlayer(int id) { foreach (ReferenceHub hub in GetHubs()) { - if (hub.GetPlayerID() == id) + if (hub.GetPlayerId() == id) return hub; } return null; @@ -119,7 +118,7 @@ public static ReferenceHub GetPlayer(string args) /// /// The PlayerID of the User - public static int GetPlayerID(this ReferenceHub player) => player.queryProcessor.NetworkPlayerId; + public static int GetPlayerId(this ReferenceHub player) => player.queryProcessor.NetworkPlayerId; /// The User you want the Id of /// The User ID (1234@steam) of the User diff --git a/Synapse/Api/RaCategory.cs b/Synapse/Api/RaCategory.cs index 99185d0..a2c570c 100644 --- a/Synapse/Api/RaCategory.cs +++ b/Synapse/Api/RaCategory.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Synapse.Api +namespace Synapse.Api { public enum RaCategory { diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index 6019000..54f9d35 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; +using UnityEngine; namespace Synapse.Api { diff --git a/Synapse/Api/ZoneType.cs b/Synapse/Api/ZoneType.cs index 4c8f1c9..88f04c0 100644 --- a/Synapse/Api/ZoneType.cs +++ b/Synapse/Api/ZoneType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Synapse.Api +namespace Synapse.Api { public enum ZoneType { diff --git a/Synapse/Events/Eventargs.cs b/Synapse/Events/Eventargs.cs index 51b025a..b92a5ca 100644 --- a/Synapse/Events/Eventargs.cs +++ b/Synapse/Events/Eventargs.cs @@ -1,5 +1,4 @@ using Assets._Scripts.Dissonance; -using Synapse.Api; using System; using System.Diagnostics.CodeAnalysis; @@ -26,7 +25,7 @@ public class RemoteCommandEvent : EventArgs public ReferenceHub Player { - get => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" ? ReferenceHub.GetHub(PlayerManager.localPlayer) : Synapse.Api.Player.GetPlayer(Sender.SenderId); + get => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" ? ReferenceHub.GetHub(PlayerManager.localPlayer) : Api.Player.GetPlayer(Sender.SenderId); } public bool Allow { get; set; } diff --git a/Synapse/Events/Events.cs b/Synapse/Events/Events.cs index af67f37..80b8900 100644 --- a/Synapse/Events/Events.cs +++ b/Synapse/Events/Events.cs @@ -1,9 +1,4 @@ using Assets._Scripts.Dissonance; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Synapse.Events { diff --git a/Synapse/Events/Patches/ConsoleCommandPatch.cs b/Synapse/Events/Patches/ConsoleCommandPatch.cs index 622174d..a5bb0ba 100644 --- a/Synapse/Events/Patches/ConsoleCommandPatch.cs +++ b/Synapse/Events/Patches/ConsoleCommandPatch.cs @@ -7,6 +7,7 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(QueryProcessor), nameof(QueryProcessor.ProcessGameConsoleQuery))] public class ConsoleCommandPatch { + // ReSharper disable once InconsistentNaming public static bool Prefix(QueryProcessor __instance,ref string query, bool encrypted) { try diff --git a/Synapse/Events/Patches/PatchHandler.cs b/Synapse/Events/Patches/PatchHandler.cs index 95a7ccc..6c92938 100644 --- a/Synapse/Events/Patches/PatchHandler.cs +++ b/Synapse/Events/Patches/PatchHandler.cs @@ -7,7 +7,7 @@ public class PatchHandler { // Variables private HarmonyInstance _instance; - private int _patchFixer = 0; + private int _patchFixer; // Methods public void PatchMethods() diff --git a/Synapse/Events/Patches/PlayerJoinPatch.cs b/Synapse/Events/Patches/PlayerJoinPatch.cs index ec0875d..d4ad5c2 100644 --- a/Synapse/Events/Patches/PlayerJoinPatch.cs +++ b/Synapse/Events/Patches/PlayerJoinPatch.cs @@ -6,6 +6,7 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(NicknameSync), nameof(NicknameSync.UpdateNickname))] public static class PlayerJoinPatch { + // ReSharper disable once InconsistentNaming public static bool Prefix(NicknameSync __instance, ref string n) { try diff --git a/Synapse/Events/Patches/PlayerLeavePatch.cs b/Synapse/Events/Patches/PlayerLeavePatch.cs index f517b0c..8010b63 100644 --- a/Synapse/Events/Patches/PlayerLeavePatch.cs +++ b/Synapse/Events/Patches/PlayerLeavePatch.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Synapse.Events.Patches { public static class PlayerLeavePatch { + // ReSharper disable once InconsistentNaming public static bool Prefix(ReferenceHub __instance) { try diff --git a/Synapse/Events/Patches/Scp049RecallPatch.cs b/Synapse/Events/Patches/Scp049RecallPatch.cs index 213eef3..246c778 100644 --- a/Synapse/Events/Patches/Scp049RecallPatch.cs +++ b/Synapse/Events/Patches/Scp049RecallPatch.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Harmony; using Mirror; using PlayableScps; @@ -9,13 +10,14 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(Scp049), nameof(Scp049.BodyCmd_ByteAndGameObject))] public class Scp049RecallPatch { - public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) + // ReSharper disable once InconsistentNaming + public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) { try { if (num == 0) { - if (!__instance._interactRateLimit.CanExecute(true)) + if (!__instance._interactRateLimit.CanExecute()) { return false; } @@ -28,7 +30,7 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) return false; } __instance.Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(4949f, __instance.Hub.nicknameSync.MyNick + " (" + __instance.Hub.characterClassManager.UserId + ")", DamageTypes.Scp049, __instance.Hub.queryProcessor.PlayerId), go); - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Sent 'death time' RPC", MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Sent 'death time' RPC", MessageImportance.LessImportant); __instance.Hub.scpsController.RpcTransmit_Byte(0); return false; } @@ -36,76 +38,65 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) { if (num != 1) { - if (num == 2) + if (num != 2) return false; + if (!__instance._interactRateLimit.CanExecute()) { - if (!__instance._interactRateLimit.CanExecute(true)) - { - return false; - } - if (go == null) - { - return false; - } - Ragdoll component = go.GetComponent(); - if (component == null) - { - return false; - } - ReferenceHub referenceHub = null; - foreach (GameObject player in PlayerManager.players) - { - ReferenceHub hub = ReferenceHub.GetHub(player); - if (hub.queryProcessor.PlayerId == component.owner.PlayerId) - { - referenceHub = hub; - break; - } - } - if (referenceHub == null) - { - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant, false); - return false; - } - if (!__instance._recallInProgressServer || referenceHub.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) - { - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant, false); - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "PASSED" : ("ERROR - " + __instance._recallInProgressServer.ToString())), MessageImportance.LessImportant, true); - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub == __instance._recallObjectServer) ? "PASSED" : string.Concat(new object[] - { - "ERROR - ", - referenceHub.queryProcessor.PlayerId, - "-", - (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString() - })), MessageImportance.LessImportant, false); - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "PASSED" : ("ERROR - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true); - return false; - } - if (referenceHub.characterClassManager.CurClass != RoleType.Spectator) + return false; + } + if (go == null) + { + return false; + } + var component = go.GetComponent(); + if (component == null) + { + return false; + } + var referenceHub = PlayerManager.players.Select(ReferenceHub.GetHub).FirstOrDefault(hub => hub.queryProcessor.PlayerId == component.owner.PlayerId); + if (referenceHub == null) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant); + return false; + } + if (!__instance._recallInProgressServer || referenceHub.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) + { + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "PASSED" : ("ERROR - " + __instance._recallInProgressServer.ToString())), MessageImportance.LessImportant, true); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub == __instance._recallObjectServer) ? "PASSED" : string.Concat(new object[] { - return false; - } + "ERROR - ", + referenceHub.queryProcessor.PlayerId, + "-", + (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString() + })), MessageImportance.LessImportant); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "PASSED" : ("ERROR - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true); + return false; + } + if (referenceHub.characterClassManager.CurClass != RoleType.Spectator) + { + return false; + } - //Event - bool allow = true; - RoleType role = RoleType.Scp0492; - float live = (float)referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; - Events.InvokeScp049RecallEvent(__instance.Hub, ref component, ref referenceHub, ref allow, ref role, ref live); + //Event + var allow = true; + var role = RoleType.Scp0492; + float live = referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; + Events.InvokeScp049RecallEvent(__instance.Hub, ref component, ref referenceHub, ref allow, ref role, ref live); - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant, false); - RoundSummary.changed_into_zombies++; - referenceHub.characterClassManager.SetClassID(role); - referenceHub.GetComponent().Health = live; - if (component.CompareTag("Ragdoll")) - { - NetworkServer.Destroy(component.gameObject); - } - __instance._recallInProgressServer = false; - __instance._recallObjectServer = null; - __instance._recallProgressServer = 0f; + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant); + RoundSummary.changed_into_zombies++; + referenceHub.characterClassManager.SetClassID(role); + referenceHub.GetComponent().Health = live; + if (component.CompareTag("Ragdoll")) + { + NetworkServer.Destroy(component.gameObject); } + __instance._recallInProgressServer = false; + __instance._recallObjectServer = null; + __instance._recallProgressServer = 0f; return false; } - if (!__instance._interactRateLimit.CanExecute(true)) + if (!__instance._interactRateLimit.CanExecute()) { return false; } @@ -113,37 +104,28 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) { return false; } - Ragdoll component2 = go.GetComponent(); + var component2 = go.GetComponent(); if (component2 == null) { - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant); return false; } if (!component2.allowRecall) { - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant); return false; } - ReferenceHub referenceHub2 = null; - foreach (GameObject player2 in PlayerManager.players) - { - ReferenceHub hub2 = ReferenceHub.GetHub(player2); - if (hub2 != null && hub2.queryProcessor.PlayerId == component2.owner.PlayerId) - { - referenceHub2 = hub2; - break; - } - } + var referenceHub2 = PlayerManager.players.Select(ReferenceHub.GetHub).FirstOrDefault(hub2 => hub2 != null && hub2.queryProcessor.PlayerId == component2.owner.PlayerId); if (referenceHub2 == null) { - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant); return false; } if (Vector3.Distance(component2.transform.position, __instance.Hub.PlayerCameraReference.transform.position) >= Scp049.ReviveDistance * 1.3f) { return false; } - GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant, false); + GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant); __instance._recallObjectServer = referenceHub2.gameObject; __instance._recallProgressServer = 0f; __instance._recallInProgressServer = true; diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index bd84e5f..019b77a 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -8,7 +8,7 @@ public static class ServerNamePatch public static void Postfix() { ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); - ServerConsole._serverName += $" Synapse-Alpha.v0.1.0"; + ServerConsole._serverName += $" Synapse-Alpha.v0.1.0"; } } } diff --git a/Synapse/Events/Patches/SpeakPatch.cs b/Synapse/Events/Patches/SpeakPatch.cs index 89f3e75..8fb488c 100644 --- a/Synapse/Events/Patches/SpeakPatch.cs +++ b/Synapse/Events/Patches/SpeakPatch.cs @@ -7,7 +7,8 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(DissonanceUserSetup), nameof(DissonanceUserSetup.CallCmdAltIsActive))] public class SpeakPatch { - public static bool Prefix(DissonanceUserSetup __instance, bool value) + // ReSharper disable once InconsistentNaming + public static bool Prefix(DissonanceUserSetup __instance, bool value) { try { diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 3a49096..bf650fb 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Synapse { diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 416699f..eddeb29 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -4,7 +4,7 @@ namespace Synapse { public abstract class Plugin { - private string ownPluginFolder; + private string _ownPluginFolder; public static YamlConfig Config; @@ -12,12 +12,12 @@ public string OwnPluginFolder { get { - if (!Directory.Exists(ownPluginFolder)) - Directory.CreateDirectory(ownPluginFolder); + if (!Directory.Exists(_ownPluginFolder)) + Directory.CreateDirectory(_ownPluginFolder); - return ownPluginFolder + Path.DirectorySeparatorChar.ToString(); + return _ownPluginFolder + Path.DirectorySeparatorChar.ToString(); } - internal set => ownPluginFolder = value; + internal set => _ownPluginFolder = value; } public abstract string GetName { get; } diff --git a/SynapseModLoader/ModLoader.cs b/SynapseModLoader/ModLoader.cs index 5cd906e..043a8ae 100644 --- a/SynapseModLoader/ModLoader.cs +++ b/SynapseModLoader/ModLoader.cs @@ -24,7 +24,7 @@ public static byte[] ReadFile(string path) // Token: 0x060027B4 RID: 10164 RVA: 0x000C1828 File Offset: 0x000BFA28 public static void LoadModSystem() { - if (loaded) + if (_loaded) { return; } @@ -39,16 +39,16 @@ public static void LoadModSystem() ServerConsole.AddLog("Error while loading Synapse! The Synapse.dll is missing!", ConsoleColor.Red); return; } - MethodInfo methodInfo = Assembly.Load(ReadFile(Path.Combine(text, "Synapse.dll"))).GetTypes().SelectMany((Type p) => p.GetMethods()).FirstOrDefault((MethodInfo f) => f.Name == "LoaderExecutionCode"); + var methodInfo = Assembly.Load(ReadFile(Path.Combine(text, "Synapse.dll"))).GetTypes().SelectMany((p) => p.GetMethods()).FirstOrDefault((f) => f.Name == "LoaderExecutionCode"); if (!(methodInfo != null)) { return; } methodInfo.Invoke(null, null); - loaded = true; + _loaded = true; } // Token: 0x040022BC RID: 8892 - private static bool loaded; + private static bool _loaded; } } \ No newline at end of file diff --git a/SynapseModLoaderPatcher/Program.cs b/SynapseModLoaderPatcher/Program.cs index 8b86987..94f8a37 100644 --- a/SynapseModLoaderPatcher/Program.cs +++ b/SynapseModLoaderPatcher/Program.cs @@ -3,6 +3,7 @@ using dnlib.DotNet; using dnlib.DotNet.Emit; using dnlib.DotNet.Writer; +// ReSharper disable UnusedVariable namespace SynapseModLoaderPatcher { From 4d30f9d7c4b51951cbc206c73220bf15dd4d5f67 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 10:53:40 +0200 Subject: [PATCH 037/199] ServeNamePatch --- Synapse/Events/Patches/ServerNamePatch.cs | 7 ++++--- Synapse/PluginManager.cs | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index bd84e5f..e9aff04 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -5,10 +5,11 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.ReloadServerName))] public static class ServerNamePatch { - public static void Postfix() + public static void Postfix(ServerConsole __instance) { - ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); - ServerConsole._serverName += $" Synapse-Alpha.v0.1.0"; + Log.Info(ServerConsole._serverName); + //ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); + //ServerConsole._serverName += $" Synapse-Alpha.v0.1.0"; } } } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index c61fa55..b57d6c0 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -42,6 +42,14 @@ public static IEnumerator LoadPlugins() } HarmonyPatch(); + try + { + PlayerManager.localPlayer.GetComponent().RefreshServerName(); + } + catch (Exception e) + { + Log.Error($"NameRefreh Error : {e}"); + } var configPath = Path.Combine(ConfigDirectory, $"Server{ServerConsole.Port}-config.yml"); From c199fe4ef5481d454530809616d5dd38d4042353 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 11:11:13 +0200 Subject: [PATCH 038/199] enable unsafe code --- Synapse/PluginManager.cs | 3 ++- Synapse/Synapse.csproj | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index b57d6c0..9b964e2 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Reflection; using Synapse.Events.Patches; +using UnityEngine; namespace Synapse { @@ -44,7 +45,7 @@ public static IEnumerator LoadPlugins() HarmonyPatch(); try { - PlayerManager.localPlayer.GetComponent().RefreshServerName(); + ServerConsole.ReloadServerName(); } catch (Exception e) { diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 8f7b1cf..25fed92 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + true AnyCPU From 9127cae63349dbc5e8f027b3a60129e68e6eda8a Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 11:49:35 +0200 Subject: [PATCH 039/199] Usage of static elements --- Synapse/Events/Patches/ServerNamePatch.cs | 4 ++-- Synapse/PluginManager.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index e9aff04..6b8098f 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -7,9 +7,9 @@ public static class ServerNamePatch { public static void Postfix(ServerConsole __instance) { + ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); + ServerConsole._serverName += $" SM119.Synapse-Alpha.v0.1.0"; Log.Info(ServerConsole._serverName); - //ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); - //ServerConsole._serverName += $" Synapse-Alpha.v0.1.0"; } } } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 9b964e2..fc1566b 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -18,7 +18,7 @@ public static class PluginManager public static string MainPluginDirectory { get; } = Path.Combine(SynapseDirectory, "Plugins"); public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectory,"dependencies"); public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); - public static string ServerPluginDirectoty { get; internal set; } + public static string ServerPluginDirectory { get; internal set; } // Methods public static IEnumerator LoadPlugins() @@ -27,8 +27,8 @@ public static IEnumerator LoadPlugins() LoadDependencies(); - var serverPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerConsole.Port} Plugins"); - ServerPluginDirectoty = serverPluginDirectory; + var serverPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerStatic.ServerPort} Plugins"); + ServerPluginDirectory = serverPluginDirectory; if (!Directory.Exists(serverPluginDirectory)) Directory.CreateDirectory(serverPluginDirectory); @@ -52,7 +52,7 @@ public static IEnumerator LoadPlugins() Log.Error($"NameRefreh Error : {e}"); } - var configPath = Path.Combine(ConfigDirectory, $"Server{ServerConsole.Port}-config.yml"); + var configPath = Path.Combine(ConfigDirectory, $"Server{ServerStatic.ServerPort}-config.yml"); if (!File.Exists(configPath)) File.Create(configPath).Close(); @@ -67,7 +67,7 @@ private static void LoadDependencies() Log.Info("Loading Dependencies..."); var depends = Directory.GetFiles(DependenciesDirectory); - foreach (string dll in depends) + foreach (var dll in depends) { if (!dll.EndsWith(".dll")) continue; @@ -124,7 +124,7 @@ private static void OnEnable() { try { - plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectoty, plugin.GetName); + plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectory, plugin.GetName); plugin.OnEnable(); } catch (Exception e) From 6b249a420ba76c7f6a895628b6b0757531f4fc5e Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 11:53:54 +0200 Subject: [PATCH 040/199] ServerName test + Directory paths are now internal --- Synapse/Events/Patches/ServerNamePatch.cs | 2 +- Synapse/PluginManager.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index 6b8098f..9381345 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -8,7 +8,7 @@ public static class ServerNamePatch public static void Postfix(ServerConsole __instance) { ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); - ServerConsole._serverName += $" SM119.Synapse-Alpha.v0.1.0"; + ServerConsole._serverName += $" SM119.{1}.{0}.{0} Synaps"; Log.Info(ServerConsole._serverName); } } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index fc1566b..c31f3a9 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -15,10 +15,10 @@ public static class PluginManager private static readonly List LoadedDependencies = new List(); private static readonly List Plugins = new List(); private static string SynapseDirectory { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); - public static string MainPluginDirectory { get; } = Path.Combine(SynapseDirectory, "Plugins"); - public static string DependenciesDirectory { get; } = Path.Combine(SynapseDirectory,"dependencies"); - public static string ConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); - public static string ServerPluginDirectory { get; internal set; } + static internal string MainPluginDirectory { get; } = Path.Combine(SynapseDirectory, "Plugins"); + static internal string DependenciesDirectory { get; } = Path.Combine(SynapseDirectory,"dependencies"); + static internal string ConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); + static internal string ServerPluginDirectory { get; set; } // Methods public static IEnumerator LoadPlugins() From e427c8cabbc9aa68ac773d6835e0ddc73fef63df Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Jun 2020 12:59:05 +0200 Subject: [PATCH 041/199] Create the Publicized DLL with the Patcher --- Synapse/Synapse.csproj | 6 ++--- SynapseModLoaderPatcher/Program.cs | 42 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 25fed92..5c08718 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -36,12 +36,12 @@ D:\Downloads\Synaps_Verweise\Synaps Verweise\0Harmony.dll + + ..\SynapseModLoaderPatcher\bin\Debug\Assembly-CSharp-Synapse_publizied.dll + D:\Downloads\Synaps_Verweise\Synaps Verweise\Assembly-CSharp-firstpass.dll - - D:\Downloads\Synaps_Verweise\Synaps Verweise\Assembly-CSharp_publicized.SynapseMod.dll - D:\Downloads\Synaps_Verweise\Synaps Verweise\Mirror.dll diff --git a/SynapseModLoaderPatcher/Program.cs b/SynapseModLoaderPatcher/Program.cs index 94f8a37..8291b36 100644 --- a/SynapseModLoaderPatcher/Program.cs +++ b/SynapseModLoaderPatcher/Program.cs @@ -1,8 +1,14 @@ using System; +using System.Collections.Generic; using System.Linq; using dnlib.DotNet; using dnlib.DotNet.Emit; using dnlib.DotNet.Writer; +using FieldAttributes = dnlib.DotNet.FieldAttributes; +using MethodAttributes = dnlib.DotNet.MethodAttributes; +using MethodImplAttributes = dnlib.DotNet.MethodImplAttributes; +using TypeAttributes = dnlib.DotNet.TypeAttributes; + // ReSharper disable UnusedVariable namespace SynapseModLoaderPatcher @@ -93,7 +99,43 @@ public static void Main(string[] args) body.Instructions.Add(OpCodes.Ret.ToInstruction()); module.Write("Assembly-CSharp-Synapse.dll"); + Console.WriteLine("Synapse: Patch Complete!"); + + Console.WriteLine("Synapse-Public: Creating Publicized DLL"); + + var allTypes = module.Assembly.Modules.SelectMany(t => t.Types); + var allMethods = allTypes.SelectMany(t => t.Methods); + var allFields = allTypes.SelectMany(t => t.Fields); + + foreach (var type in allTypes) + { + if (!type?.IsPublic ?? false && !type.IsNestedPublic) + { + type.Attributes = type.IsNested ? TypeAttributes.NestedPublic : TypeAttributes.Public; + } + } + + foreach (var method in allMethods) + { + if (!method?.IsPublic ?? false) + { + method.Access = MethodAttributes.Public; + } + } + + + foreach (var field in allFields) + { + if (!field?.IsPublic ?? false) + { + field.Access = FieldAttributes.Public; + } + } + + module.Write("Assembly-CSharp-Synapse_publizied.dll"); + + Console.WriteLine("Synapse-Public: Created Publizied DLL"); } private static MethodDef FindMethod(TypeDef type, string methodName) From c6b9ae135f4549ca54a17c4df6fac783bc8f26d7 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 1 Jun 2020 13:06:18 +0200 Subject: [PATCH 042/199] Directory --- Synapse/MainLoader.cs | 4 +-- Synapse/Plugin.cs | 7 +++++ Synapse/PluginManager.cs | 67 ++++++++++++++++++++++++---------------- Synapse/Synapse.csproj | 5 ++- 4 files changed, 51 insertions(+), 32 deletions(-) diff --git a/Synapse/MainLoader.cs b/Synapse/MainLoader.cs index 486f04d..3ebf352 100644 --- a/Synapse/MainLoader.cs +++ b/Synapse/MainLoader.cs @@ -16,8 +16,8 @@ public static void LoaderExecutionCode() Log.Info("Checking Files"); - if (!Directory.Exists(PluginManager.ConfigDirectory)) - Directory.CreateDirectory(PluginManager.ConfigDirectory); + if (!Directory.Exists(PluginManager.ServerConfigDirectory)) + Directory.CreateDirectory(PluginManager.ServerConfigDirectory); if (!Directory.Exists(PluginManager.MainPluginDirectory)) Directory.CreateDirectory(PluginManager.MainPluginDirectory); diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index eddeb29..8a9874e 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -6,8 +6,15 @@ public abstract class Plugin { private string _ownPluginFolder; + /// + /// The Main Config from the current Server which all Plugins can use + /// public static YamlConfig Config; + /// + /// A Directory especially for your Plugin which are created by Synapse for you! + /// + ///The Name of the Directory is based on the GetName string from your Plugin! public string OwnPluginFolder { get diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index c31f3a9..32460d3 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -15,51 +15,64 @@ public static class PluginManager private static readonly List LoadedDependencies = new List(); private static readonly List Plugins = new List(); private static string SynapseDirectory { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"Synapse"); + static internal string MainPluginDirectory { get; } = Path.Combine(SynapseDirectory, "Plugins"); static internal string DependenciesDirectory { get; } = Path.Combine(SynapseDirectory,"dependencies"); - static internal string ConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); + static internal string MainConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); + + static internal string ServerConfigDirectory { get; set; } static internal string ServerPluginDirectory { get; set; } // Methods public static IEnumerator LoadPlugins() { yield return Timing.WaitForSeconds(0.5f); + try + { + LoadDependencies(); - LoadDependencies(); + var serverPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerStatic.ServerPort} Plugins"); + ServerPluginDirectory = serverPluginDirectory; - var serverPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerStatic.ServerPort} Plugins"); - ServerPluginDirectory = serverPluginDirectory; + if (!Directory.Exists(serverPluginDirectory)) + Directory.CreateDirectory(serverPluginDirectory); - if (!Directory.Exists(serverPluginDirectory)) - Directory.CreateDirectory(serverPluginDirectory); - - var plugins = Directory.GetFiles(serverPluginDirectory); + var plugins = Directory.GetFiles(serverPluginDirectory); - foreach (var plugin in plugins) - { - if (plugin.EndsWith("Synapse.dll")) continue; + foreach (var plugin in plugins) + { + if (plugin.EndsWith("Synapse.dll")) continue; - if (plugin.EndsWith(".dll")) LoadPlugin(plugin); - } + if (plugin.EndsWith(".dll")) LoadPlugin(plugin); + } - HarmonyPatch(); - try - { - ServerConsole.ReloadServerName(); - } - catch (Exception e) - { - Log.Error($"NameRefreh Error : {e}"); - } + HarmonyPatch(); + try + { + ServerConsole.ReloadServerName(); + } + catch (Exception e) + { + Log.Error($"NameRefreh Error : {e}"); + } + + ServerConfigDirectory = Path.Combine(MainConfigDirectory, $"Server{ServerStatic.ServerPort}-Configs"); + if (!Directory.Exists(ServerConfigDirectory)) + Directory.CreateDirectory(ServerConfigDirectory); - var configPath = Path.Combine(ConfigDirectory, $"Server{ServerStatic.ServerPort}-config.yml"); + var configPath = Path.Combine(ServerConfigDirectory, $"Server{ServerStatic.ServerPort}-config.yml"); - if (!File.Exists(configPath)) - File.Create(configPath).Close(); + if (!File.Exists(configPath)) + File.Create(configPath).Close(); - Plugin.Config = new YamlConfig(configPath); + Plugin.Config = new YamlConfig(configPath); - OnEnable(); + OnEnable(); + } + catch (Exception e) + { + Log.Error($"Synapse could not Start : {e}"); + } } private static void LoadDependencies() diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 25fed92..d6abfb5 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -39,8 +39,8 @@ D:\Downloads\Synaps_Verweise\Synaps Verweise\Assembly-CSharp-firstpass.dll - - D:\Downloads\Synaps_Verweise\Synaps Verweise\Assembly-CSharp_publicized.SynapseMod.dll + + ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll D:\Downloads\Synaps_Verweise\Synaps Verweise\Mirror.dll @@ -83,7 +83,6 @@ - - - + \ No newline at end of file From c0a64fd385804919a41cb6e4e6b6508c4fb3368e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Fri, 5 Jun 2020 17:23:57 +0200 Subject: [PATCH 087/199] Fix SyncData Event and hook EventHandler --- Synapse/Events/EventHandler.cs | 4 +--- Synapse/Events/Patches/SyncDataPatch.cs | 4 +--- Synapse/PluginManager.cs | 5 +++++ Synapse/Synapse.csproj | 7 +++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index ed77fb7..830b147 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -29,11 +29,9 @@ public EventHandler() // Methods private static void OnSyncData(ref SyncDataClass ev) { - Log.Info("SyncData"); if (ev.Player.GetRole() != RoleType.ClassD && ev.Player.GetRole() != RoleType.Scientist && - !(Vector3.Distance(ev.Player.GetPosition(), ev.Player.GetComponent().worldPosition) >= - Escape.radius * 2)) + !(Vector3.Distance(ev.Player.GetPosition(), ev.Player.GetComponent().worldPosition) >= Escape.radius)) ev.Player.characterClassManager.CmdRegisterEscape(); } diff --git a/Synapse/Events/Patches/SyncDataPatch.cs b/Synapse/Events/Patches/SyncDataPatch.cs index 3d93da3..812a445 100644 --- a/Synapse/Events/Patches/SyncDataPatch.cs +++ b/Synapse/Events/Patches/SyncDataPatch.cs @@ -7,12 +7,10 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(AnimationController), nameof(AnimationController.CallCmdSyncData))] public class SyncDataPatch { - public static bool Prefix(AnimationController __instance, int state, Vector2 v2) + public static bool Prefix(AnimationController __instance, int state, ref Vector2 v2) { try { - if (!__instance._mSyncRateLimit.CanExecute(false)) return false; - var allow = true; Events.InvokeSyncDataEvent(__instance.gameObject, ref allow, ref v2, state); diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index bd330b2..32614a6 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using MEC; +using Synapse.Events; using Synapse.Events.Patches; using Synapse.Permissions; @@ -24,6 +25,8 @@ public static class PluginManager private static string ServerPluginDirectory { get; set; } internal static string ServerConfigDirectory { get; private set; } + internal static Events.EventHandler EventHandler; + // Methods public static IEnumerator LoadPlugins() { @@ -49,6 +52,8 @@ public static IEnumerator LoadPlugins() } HarmonyPatch(); + + EventHandler = new Events.EventHandler(); ServerConfigDirectory = Path.Combine(MainConfigDirectory, $"Server{ServerStatic.ServerPort}-Configs"); if (!Directory.Exists(ServerConfigDirectory)) diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 7b1edb8..f8ea4db 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -36,13 +36,12 @@ ..\..\..\Documents\0Harmony.dll + + ..\SynapseModLoaderPatcher\bin\Debug\Assembly-CSharp-Synapse_publizied.dll + ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll - - False - ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll - ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll From 23099be81975124254f042d12638d1035db968da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Fri, 5 Jun 2020 17:40:51 +0200 Subject: [PATCH 088/199] Rename All delgates, please dimenzio --- Synapse/Events/PlayerEvents.cs | 62 ++++++++++++++-------------------- Synapse/Events/ScpEvents.cs | 4 +-- Synapse/Events/ServerEvents.cs | 24 +++---------- 3 files changed, 31 insertions(+), 59 deletions(-) diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 49c6212..94f7c10 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -8,41 +8,9 @@ namespace Synapse.Events [SuppressMessage("ReSharper", "EventNeverSubscribedTo.Global")] public static partial class Events { - // PlayerBanEvent - public delegate void OnPlayerBanEvent(ref PlayerBanEvent ev); - - //PlayerCuffedEvent - public delegate void OnPlayerCuffed(ref PlayerCuffedEvent ev); - - //PlayerDieEvent - public delegate void OnPlayerDeath(PlayerDeathEvent ev); - - //PlayerEscapeEvent - public delegate void OnPlayerEscape(ref PlayerEscapeEvent ev); - - //PlayerHurtEvent - public delegate void OnPlayerHurt(ref PlayerHurtEvent ev); - - //JoinEvent - public delegate void OnPlayerJoin(ref PlayerJoinEvent ev); - - //PlayerLeaveEvent - public delegate void OnPlayerLeave(PlayerLeaveEvent ev); - - //SpeakEvent - public delegate void OnSpeak(ref SpeakEventEvent ev); - - //SyncDataEvent - public delegate void OnSyncDataEvent(ref SyncDataEvent ev); - - //PlayerReloadEvent - public delegate void OnPlayerReload(ref PlayerReloadEvent ev); - - //FemurEnterEvent - public delegate void OnFemurEnter(); - /// A Event which is activated when a User Joins the Server /// It need to hook ref PlayerJoinEvent ev + public delegate void OnPlayerJoin(ref PlayerJoinEvent ev); public static event OnPlayerJoin PlayerJoinEvent; internal static void InvokePlayerJoinEvent(ReferenceHub player, ref string nick) @@ -59,6 +27,7 @@ internal static void InvokePlayerJoinEvent(ReferenceHub player, ref string nick) } /// A Event which is activated when a user press any voice HotKey + public delegate void OnSpeak(ref SpeakEventEvent ev); public static event OnSpeak SpeakEvent; internal static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool intercom, ref bool radio, @@ -89,6 +58,7 @@ internal static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool i /// /// A Event which is activated when a User leave the server /// + public delegate void OnPlayerLeave(PlayerLeaveEvent ev); public static event OnPlayerLeave PlayerLeaveEvent; internal static void InvokePlayerLeaveEvent(ReferenceHub player) @@ -101,7 +71,9 @@ internal static void InvokePlayerLeaveEvent(ReferenceHub player) }; PlayerLeaveEvent.Invoke(ev); } - + + // PlayerBanEvent + public delegate void OnPlayerBanEvent(ref PlayerBanEvent ev); public static event OnPlayerBanEvent PlayerBanEvent; internal static void InvokePlayerBanEvent(ReferenceHub player, string userId, int duration, ref bool allow, @@ -122,7 +94,9 @@ internal static void InvokePlayerBanEvent(ReferenceHub player, string userId, in allow = ev.Allowed; } - + + //PlayerDieEvent + public delegate void OnPlayerDeath(PlayerDeathEvent ev); public static event OnPlayerDeath PlayerDeathEvent; internal static void InvokePlayerDieEvent(ReferenceHub player, ReferenceHub killer, PlayerStats.HitInfo infos) @@ -139,6 +113,8 @@ internal static void InvokePlayerDieEvent(ReferenceHub player, ReferenceHub kill PlayerDeathEvent.Invoke(ev); } + //PlayerHurtEvent + public delegate void OnPlayerHurt(ref PlayerHurtEvent ev); public static event OnPlayerHurt PlayerHurtEvent; internal static void InvokePlayerHurtEvent(ReferenceHub player, ReferenceHub attacker, @@ -157,7 +133,9 @@ internal static void InvokePlayerHurtEvent(ReferenceHub player, ReferenceHub att info = ev.Info; } - + + //PlayerCuffedEvent + public delegate void OnPlayerCuffed(ref PlayerCuffedEvent ev); public static event OnPlayerCuffed PlayerCuffedEvent; internal static void InvokePlayerCuffedEvent(ReferenceHub cuffed, ReferenceHub target, ref bool allow) @@ -176,6 +154,8 @@ internal static void InvokePlayerCuffedEvent(ReferenceHub cuffed, ReferenceHub t allow = ev.Allow; } + //PlayerEscapeEvent + public delegate void OnPlayerEscape(ref PlayerEscapeEvent ev); public static event OnPlayerEscape PlayerEscapeEvent; internal static void InvokePlayerEscapeEvent(ReferenceHub player, ref bool allow, ref RoleType spawnRole, @@ -198,6 +178,8 @@ internal static void InvokePlayerEscapeEvent(ReferenceHub player, ref bool allow spawnRole = ev.SpawnRole; } + //SyncDataEvent + public delegate void OnSyncDataEvent(ref SyncDataEvent ev); public static event OnSyncDataEvent SyncDataEvent; internal static void InvokeSyncDataEvent(GameObject player, ref bool allow, ref Vector2 speed, int state) @@ -218,6 +200,8 @@ internal static void InvokeSyncDataEvent(GameObject player, ref bool allow, ref speed = ev.Speed; } + //PlayerReloadEvent + public delegate void OnPlayerReload(ref PlayerReloadEvent ev); public static event OnPlayerReload PlayerReloadEvent; internal static void InvokePlayerReloadEvent(ReferenceHub player,ref bool allow,ref WeaponManager.Weapon weapon,Inventory.SyncItemInfo syncItem) @@ -237,7 +221,9 @@ internal static void InvokePlayerReloadEvent(ReferenceHub player,ref bool allow, allow = ev.Allow; weapon = ev.Weapon; } - + + //FemurEnterEvent + public delegate void OnFemurEnter(); public static event OnFemurEnter FemurEnterEvent; internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow) @@ -246,5 +232,7 @@ internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow) } + //DroppedItemEvent + public delegate void OnDropItem(); } } \ No newline at end of file diff --git a/Synapse/Events/ScpEvents.cs b/Synapse/Events/ScpEvents.cs index 4111627..903d2a2 100644 --- a/Synapse/Events/ScpEvents.cs +++ b/Synapse/Events/ScpEvents.cs @@ -6,10 +6,8 @@ namespace Synapse.Events [SuppressMessage("ReSharper", "EventNeverSubscribedTo.Global")] public static partial class Events { - //Scp049RecallEvent + /// A Event which is activated when Scp049 Respawnes a Player public delegate void OnScp049Recall(ref Scp049RecallEvent ev); - - /// A Event which is activated when Scp049 Recalls a Player public static event OnScp049Recall Scp049RecallEvent; internal static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ragdoll, ref ReferenceHub target, diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index 5ef179e..64a01fe 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -8,26 +8,7 @@ namespace Synapse.Events [SuppressMessage("ReSharper", "EventNeverSubscribedTo.Global")] public static partial class Events { - //ConsoleCommandEvent - public delegate void OnConsoleCommand(ref ConsoleCommandEvent ev); - - - //RemoteCommandEvent - public delegate void OnRemoteCommand(ref RemoteCommandEvent ev); - - //RoundEndEvent - public delegate void OnRoundEnd(); - - // RoundRestartEvent public delegate void OnRoundRestart(); - - - // RoundStartEvent - public delegate void OnRoundStart(); - - //TeamRespawnEvent - public delegate void TeamRespawn(ref TeamRespawnEvent ev); - public static event OnRoundRestart RoundRestartEvent; internal static void InvokeRoundRestart() @@ -38,6 +19,7 @@ internal static void InvokeRoundRestart() /// /// A Event which activate when the Round Ends (not a Restart!) /// + public delegate void OnRoundEnd(); public static event OnRoundEnd RoundEndEvent; internal static void InvokeRoundEndEvent() @@ -45,6 +27,7 @@ internal static void InvokeRoundEndEvent() RoundEndEvent?.Invoke(); } + public delegate void OnRoundStart(); public static event OnRoundStart RoundStartEvent; internal static void InvokeRoundStart() @@ -54,6 +37,7 @@ internal static void InvokeRoundStart() /// A Event which is activated when a user send a Command in the Remote Admin /// It need to hook ref RemoteCommandEvent ev + public delegate void OnRemoteCommand(ref RemoteCommandEvent ev); public static event OnRemoteCommand RemoteCommandEvent; internal static void InvokeRemoteCommandEvent(CommandSender sender, string command, ref bool allow) @@ -73,6 +57,7 @@ internal static void InvokeRemoteCommandEvent(CommandSender sender, string comma } /// A Event which is activated when a user send a Command in the Remote Admin + public delegate void OnConsoleCommand(ref ConsoleCommandEvent ev); public static event OnConsoleCommand ConsoleCommandEvent; internal static void InvokeConsoleCommandEvent(ReferenceHub player, string command, out string color, @@ -94,6 +79,7 @@ internal static void InvokeConsoleCommandEvent(ReferenceHub player, string comma returning = ev.ReturnMessage; } + public delegate void TeamRespawn(ref TeamRespawnEvent ev); public static event TeamRespawn TeamRespawnEvent; internal static void InvokeTeamRespawnEvent(ref List respawnlist, ref bool ischaos, ref bool allow ,ref bool useticktes) From 5365f5f5687c35a6272cf4b5a3d62b06baa0fa11 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Jun 2020 17:52:48 +0200 Subject: [PATCH 089/199] added IsGroupAllowed to the Api --- Synapse/Api/Map.cs | 18 +++++++++++- Synapse/Events/EventHandler.cs | 2 +- Synapse/Permissions/PermissionReader.cs | 38 ++++++++++++++++++++++++- Synapse/Synapse.csproj | 7 +++-- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 8ab416a..d6b33a8 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -1,4 +1,5 @@ -using System; +using Synapse.Permissions; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -152,5 +153,20 @@ public static void DetonateNuke() var alpha = PlayerManager.localPlayer.GetComponent(); alpha.Detonate(); } + + /// Name of the group you want to check + /// Permission you want to check + /// Have the Group the permissions? + public static bool IsGroupAllowed(string group, string permission) + { + try + { + return PermissionReader.CheckGroupPermission(group, permission); + } + catch + { + return false; + } + } } } \ No newline at end of file diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 916f6b4..f80ef2e 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -8,7 +8,7 @@ namespace Synapse.Events { // ReSharper disable once UnusedType.Global - internal class EventHandler + public class EventHandler { // Variables private bool _roundInProgress; diff --git a/Synapse/Permissions/PermissionReader.cs b/Synapse/Permissions/PermissionReader.cs index c0991bd..0edcd05 100644 --- a/Synapse/Permissions/PermissionReader.cs +++ b/Synapse/Permissions/PermissionReader.cs @@ -9,7 +9,7 @@ namespace Synapse.Permissions { - internal static class PermissionReader + public static class PermissionReader { // Variables private static Yml _permissionsConfig; @@ -124,6 +124,42 @@ internal static bool CheckPermission(ReferenceHub player, string permission) return false; } + + internal static bool CheckGroupPermission(string groupname,string permission) + { + if (string.IsNullOrEmpty(permission)) + { + Log.Error("Permission checked was null."); + return false; + } + + if (string.IsNullOrEmpty(groupname)) + { + Log.Error("GroupName checked was null."); + return false; + } + + if (_permissionsConfig == null) + { + Log.Error("Permission config is null."); + return false; + } + + if (!_permissionsConfig.Groups.Any()) + { + Log.Error("No permission group."); + return false; + } + + Group group = null; + if (!_permissionsConfig.Groups.TryGetValue(groupname, out group)) + group = GetDefaultGroup(); + + foreach (var grouppermission in group.Permissions) + if (permission == grouppermission) return true; + + return false; + } } internal class Yml diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 23b4340..6a75e06 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -36,12 +36,13 @@ ..\..\Synaps Verweise\0Harmony.dll - - ..\SynapseModLoaderPatcher\bin\Debug\Assembly-CSharp-Synapse_publizied.dll - ..\..\Synaps Verweise\Assembly-CSharp-firstpass.dll + + False + ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll + ..\..\Synaps Verweise\Mirror.dll From 48753d45ac29c80fdece195873dc543d79991152 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Jun 2020 18:00:59 +0200 Subject: [PATCH 090/199] added "*" permission support for IsGroupAllowed --- Synapse/Permissions/PermissionReader.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Synapse/Permissions/PermissionReader.cs b/Synapse/Permissions/PermissionReader.cs index 0edcd05..bb48ada 100644 --- a/Synapse/Permissions/PermissionReader.cs +++ b/Synapse/Permissions/PermissionReader.cs @@ -155,8 +155,13 @@ internal static bool CheckGroupPermission(string groupname,string permission) if (!_permissionsConfig.Groups.TryGetValue(groupname, out group)) group = GetDefaultGroup(); - foreach (var grouppermission in group.Permissions) - if (permission == grouppermission) return true; + if (group != null) + { + if (group.Permissions.Any(s => s == ".*")) return true; + if (group.Permissions.Any(s => s == "*")) return true; + if (group.Permissions.Contains(permission.Split('.')[0] + ".*")) return true; + if (group.Permissions.Any(s => s == permission)) return true; + } return false; } From 4f3e2d09ebd1723e10a0253d06a6b2bb487d0b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Fri, 5 Jun 2020 18:12:52 +0200 Subject: [PATCH 091/199] DropItemEvent Build but not tested --- Synapse/Events/Classes/DropItemEvent.cs | 9 ++++++ Synapse/Events/Patches/DropItemPatch.cs | 43 +++++++++++++++++++++++++ Synapse/Events/PlayerEvents.cs | 20 +++++++++++- Synapse/Synapse.csproj | 2 ++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Synapse/Events/Classes/DropItemEvent.cs create mode 100644 Synapse/Events/Patches/DropItemPatch.cs diff --git a/Synapse/Events/Classes/DropItemEvent.cs b/Synapse/Events/Classes/DropItemEvent.cs new file mode 100644 index 0000000..8e4b9d4 --- /dev/null +++ b/Synapse/Events/Classes/DropItemEvent.cs @@ -0,0 +1,9 @@ +namespace Synapse.Events.Classes +{ + public class DropItemEvent + { + public ReferenceHub Player { get; internal set; } + public Inventory.SyncItemInfo Item { get; set; } + public bool Allow { get; set; } + } +} \ No newline at end of file diff --git a/Synapse/Events/Patches/DropItemPatch.cs b/Synapse/Events/Patches/DropItemPatch.cs new file mode 100644 index 0000000..e5f5c2a --- /dev/null +++ b/Synapse/Events/Patches/DropItemPatch.cs @@ -0,0 +1,43 @@ +using System; +using Harmony; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(Inventory), nameof(Inventory.CallCmdDropItem))] + public class DropItemPatch + { + public static bool Prefix(Inventory __instance, int itemInventoryIndex) + { + try + { + if (!__instance._iawRateLimit.CanExecute() || itemInventoryIndex < 0 || + itemInventoryIndex >= __instance.items.Count) return false; + + var syncItemInfo = __instance.items[itemInventoryIndex]; + + if (__instance.items[itemInventoryIndex].id != syncItemInfo.id) return false; + + var allow = true; + + Events.InvokeDropItem(__instance.gameObject, ref syncItemInfo, ref allow); + + if (!allow) return false; + + var dropped = __instance.SetPickup(syncItemInfo.id, syncItemInfo.durability, + __instance.transform.position, __instance.camera.transform.rotation, syncItemInfo.modSight, + syncItemInfo.modBarrel, syncItemInfo.modOther); + + __instance.items.RemoveAt(itemInventoryIndex); + + //TODO: InvokeItemDroped + + return false; + } + catch (Exception e) + { + Log.Error($"DropItemPatch Err: {e}"); + return true; + } + } + } +} \ No newline at end of file diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 94f7c10..0ab157b 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -233,6 +233,24 @@ internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow) } //DroppedItemEvent - public delegate void OnDropItem(); + public delegate void OnDropItem(ref DropItemEvent ev); + public static event OnDropItem DropItemEvent; + + public static void InvokeDropItem(GameObject player, ref Inventory.SyncItemInfo item, ref bool allow) + { + if (DropItemEvent == null) return; + + DropItemEvent ev = new DropItemEvent() + { + Player = player.GetComponent(), + Item = item, + Allow = allow + }; + + DropItemEvent.Invoke(ref ev); + + allow = ev.Allow; + item = ev.Item; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 23b4340..20e0502 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -69,11 +69,13 @@ + + From e8c547adc39204e4f6197a241b132bab06579fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 7 Jun 2020 17:57:06 +0200 Subject: [PATCH 092/199] Add Containment and Dimension Enter Event --- .../Events/Classes/PocketDimensionEvent.cs | 8 +++ .../Events/Classes/Scp106ContainmentEvent.cs | 8 +++ .../Patches/PocketDimensionEnterPatch.cs | 65 +++++++++++++++++++ .../Events/Patches/Scp106ContaimentPatch.cs | 25 +++++++ Synapse/Events/ScpEvents.cs | 37 ++++++++++- Synapse/Synapse.csproj | 11 ++-- 6 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 Synapse/Events/Classes/PocketDimensionEvent.cs create mode 100644 Synapse/Events/Classes/Scp106ContainmentEvent.cs create mode 100644 Synapse/Events/Patches/PocketDimensionEnterPatch.cs create mode 100644 Synapse/Events/Patches/Scp106ContaimentPatch.cs diff --git a/Synapse/Events/Classes/PocketDimensionEvent.cs b/Synapse/Events/Classes/PocketDimensionEvent.cs new file mode 100644 index 0000000..896fdd9 --- /dev/null +++ b/Synapse/Events/Classes/PocketDimensionEvent.cs @@ -0,0 +1,8 @@ +namespace Synapse.Events.Classes +{ + public class PocketDimensionEvent + { + public ReferenceHub Player { get; internal set; } + public bool Allow { get; set; } + } +} \ No newline at end of file diff --git a/Synapse/Events/Classes/Scp106ContainmentEvent.cs b/Synapse/Events/Classes/Scp106ContainmentEvent.cs new file mode 100644 index 0000000..25d0e0c --- /dev/null +++ b/Synapse/Events/Classes/Scp106ContainmentEvent.cs @@ -0,0 +1,8 @@ +namespace Synapse.Events.Classes +{ + public class Scp106ContainmentEvent + { + public ReferenceHub Player { get; internal set; } + public bool Allow { get; set; } + } +} \ No newline at end of file diff --git a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs new file mode 100644 index 0000000..18e2015 --- /dev/null +++ b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs @@ -0,0 +1,65 @@ +using System; +using System.Runtime.CompilerServices; +using CustomPlayerEffects; +using Harmony; +using UnityEngine; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(Scp106PlayerScript), nameof(Scp106PlayerScript.CallCmdMovePlayer))] + public class PocketDimensionEnterPatch + { + public static bool Prefix(Scp106PlayerScript __instance, GameObject ply, int t) + { + try + { + if (!__instance._iawRateLimit.CanExecute()) return false; + if (ply == null) return false; + + var player = ply.GetComponent(); + var charClassManager = player.characterClassManager; + + if (charClassManager == null || charClassManager.GodMode || charClassManager.IsAnyScp()) return false; + + if (!ServerTime.CheckSynchronization(t) || !__instance.iAm106 || + Vector3.Distance(__instance.hub.playerMovementSync.RealModelPosition, ply.transform.position) >= + 3f || !charClassManager.IsHuman()) return false; + + if (Scp106PlayerScript.blastDoor.isClosed) + { + __instance.hub.characterClassManager.RpcPlaceBlood(ply.transform.position, 1, 2f); + __instance.hub.playerStats.HurtPlayer( + new PlayerStats.HitInfo(500f, + $"{__instance.GetComponent().MyNick} ({__instance.hub.characterClassManager.UserId})", + DamageTypes.Scp106, __instance.GetComponent().PlayerId), ply); + } + else + { + //TODO: Implement SCP079 Shit + } + + var canEnter = true; + Events.InvokePocketDimensionEnterEvent(player, ref canEnter); + if (!canEnter) return false; + + //TODO: Implement Damage Event + + __instance.hub.playerStats.HurtPlayer( + new PlayerStats.HitInfo(40f, + $"{__instance.GetComponent().MyNick} ({__instance.hub.characterClassManager.UserId})", + DamageTypes.Scp106, __instance.GetComponent().PlayerId), ply); + + player.playerMovementSync.OverridePosition(Vector3.down * 1998.5f, 0f, true); + player.playerEffectsController.GetEffect().IsInPd = true; + player.playerEffectsController.EnableEffect(); + + return false; + } + catch (Exception e) + { + Log.Error($"PocketDimEnter Err: {e}"); + return true; + } + } + } +} \ No newline at end of file diff --git a/Synapse/Events/Patches/Scp106ContaimentPatch.cs b/Synapse/Events/Patches/Scp106ContaimentPatch.cs new file mode 100644 index 0000000..34aa401 --- /dev/null +++ b/Synapse/Events/Patches/Scp106ContaimentPatch.cs @@ -0,0 +1,25 @@ +using System; +using Harmony; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(PlayerInteract), nameof(PlayerInteract.CallCmdContain106))] + public class Scp106ContaimentPatch + { + public static bool Prefix(PlayerInteract __instance) + { + try + { + var allow = true; + Events.InvokeScp106ContaimentEvent(__instance.gameObject.GetComponent(), ref allow); + + return allow; + } + catch (Exception e) + { + Log.Error($"Scp106ContaimentErr: {e}"); + return true; + } + } + } +} \ No newline at end of file diff --git a/Synapse/Events/ScpEvents.cs b/Synapse/Events/ScpEvents.cs index 903d2a2..26674ad 100644 --- a/Synapse/Events/ScpEvents.cs +++ b/Synapse/Events/ScpEvents.cs @@ -3,7 +3,6 @@ namespace Synapse.Events { - [SuppressMessage("ReSharper", "EventNeverSubscribedTo.Global")] public static partial class Events { /// A Event which is activated when Scp049 Respawnes a Player @@ -33,5 +32,41 @@ internal static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ra lives = ev.TargetHealth; allow = ev.Allow; } + + public delegate void OnPocketDimensionEnter(ref PocketDimensionEvent ev); + public static event OnPocketDimensionEnter PocketDimensionEnterEvent; + + internal static void InvokePocketDimensionEnterEvent(ReferenceHub player, ref bool allow) + { + if (PocketDimensionEnterEvent == null) return; + + var ev = new PocketDimensionEvent() + { + Player = player, + Allow = allow + }; + + PocketDimensionEnterEvent.Invoke(ref ev); + + allow = ev.Allow; + } + + public delegate void OnScp106Containment(ref Scp106ContainmentEvent ev); + public static event OnScp106Containment Scp106ContaimentEvent; + + internal static void InvokeScp106ContaimentEvent(ReferenceHub player, ref bool allow) + { + if (Scp106ContaimentEvent == null) return; + + var ev = new Scp106ContainmentEvent() + { + Player = player, + Allow = allow + }; + + Scp106ContaimentEvent.Invoke(ref ev); + + allow = ev.Allow; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 86cf641..03af53f 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -36,13 +36,12 @@ ..\..\Synaps Verweise\0Harmony.dll + + ..\SynapseModLoaderPatcher\bin\Debug\Assembly-CSharp-Synapse_publizied.dll + ..\..\Synaps Verweise\Assembly-CSharp-firstpass.dll - - False - ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll - ..\..\Synaps Verweise\Mirror.dll @@ -72,6 +71,8 @@ + + @@ -79,6 +80,8 @@ + + From fa4de107fab2d7af03221697c3cc7d707ff27846 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 8 Jun 2020 14:21:45 +0200 Subject: [PATCH 093/199] removed unused Mthod --- Synapse/Events/Patches/PatchHandler.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Synapse/Events/Patches/PatchHandler.cs b/Synapse/Events/Patches/PatchHandler.cs index 1e63788..4bdfaa4 100644 --- a/Synapse/Events/Patches/PatchHandler.cs +++ b/Synapse/Events/Patches/PatchHandler.cs @@ -25,11 +25,5 @@ public void PatchMethods() Log.Error($"Harmony Event Patch Error: {e}"); } } - - // ReSharper disable once UnusedMember.Global - public void UnPatchMethods() - { - _instance.UnpatchAll(); - } } } \ No newline at end of file From 5df69859da6a80b60a544ed1a9acfa8bb2b60aa1 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 8 Jun 2020 15:00:29 +0200 Subject: [PATCH 094/199] added FemurEnterEvent --- Synapse/Configs.cs | 21 +++++++++++++++++++++ Synapse/Events/Classes/FemurEnterEvent.cs | 17 +++++++++++++++++ Synapse/Events/Patches/FemurEnterPatch.cs | 12 +++++++++++- Synapse/Events/PlayerEvents.cs | 16 +++++++++++++--- Synapse/PluginManager.cs | 1 + Synapse/Synapse.csproj | 2 ++ 6 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 Synapse/Configs.cs create mode 100644 Synapse/Events/Classes/FemurEnterEvent.cs diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs new file mode 100644 index 0000000..6b4c7b1 --- /dev/null +++ b/Synapse/Configs.cs @@ -0,0 +1,21 @@ +using System.IO; + +namespace Synapse +{ + internal static class Configs + { + //Variablen + private static YamlConfig Config; + + //Configs + internal static int requiredforFemur; + + //Methods + internal static void ReloadConfig() + { + if (Config == null) Config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); + + requiredforFemur = Config.GetInt("synapse.femur",1); + } + } +} diff --git a/Synapse/Events/Classes/FemurEnterEvent.cs b/Synapse/Events/Classes/FemurEnterEvent.cs new file mode 100644 index 0000000..693a097 --- /dev/null +++ b/Synapse/Events/Classes/FemurEnterEvent.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Synapse.Events.Classes +{ + public class FemurEnterEvent + { + public ReferenceHub Player { get; internal set; } + + public bool Allow { get; set; } + + public bool CloseFemur { get; set; } + } +} diff --git a/Synapse/Events/Patches/FemurEnterPatch.cs b/Synapse/Events/Patches/FemurEnterPatch.cs index 1b7c3e2..27b39b3 100644 --- a/Synapse/Events/Patches/FemurEnterPatch.cs +++ b/Synapse/Events/Patches/FemurEnterPatch.cs @@ -8,6 +8,8 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(CharacterClassManager), nameof(CharacterClassManager.AllowContain))] public class FemurEnterPatch { + public static int femurBrokePeople; + public static bool Prefix(CharacterClassManager __instance) { try @@ -23,8 +25,16 @@ public static bool Prefix(CharacterClassManager __instance) PlayerStats component2 = gameObject.GetComponent(); if (component.CurRole.team != Team.SCP && component.CurClass != RoleType.Spectator && !component.GodMode) { + var allow = true; + var CloseFemur = femurBrokePeople + 1 >= Configs.requiredforFemur; + var player = __instance.GetComponent(); + + Events.InvokeFemurEnterEvent(player, ref allow, ref CloseFemur); + + if (!allow) return false; component2.HurtPlayer(new PlayerStats.HitInfo(10000f, "WORLD", DamageTypes.Lure, 0), gameObject); - __instance._lureSpj.SetState(true); + femurBrokePeople++; + if (CloseFemur) __instance._lureSpj.SetState(true); } } } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 0ab157b..4449b66 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -223,14 +223,24 @@ internal static void InvokePlayerReloadEvent(ReferenceHub player,ref bool allow, } //FemurEnterEvent - public delegate void OnFemurEnter(); + public delegate void OnFemurEnter(ref FemurEnterEvent ev); public static event OnFemurEnter FemurEnterEvent; - internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow) + internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow,ref bool closeFemur) { if (FemurEnterEvent == null) return; - + var ev = new FemurEnterEvent() + { + Player = player, + Allow = allow, + CloseFemur = closeFemur, + }; + + FemurEnterEvent.Invoke(ref ev); + + allow = ev.Allow; + closeFemur = ev.CloseFemur; } //DroppedItemEvent public delegate void OnDropItem(ref DropItemEvent ev); diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 32614a6..fe2ff09 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -64,6 +64,7 @@ public static IEnumerator LoadPlugins() if (!File.Exists(configPath)) File.Create(configPath).Close(); + Configs.ReloadConfig(); Plugin.Config = new YamlConfig(configPath); OnEnable(); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 86cf641..0d27f8b 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -70,6 +70,8 @@ + + From 2c067833c476f3235ace5adbbf7d0cc115b4fd3e Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 8 Jun 2020 15:58:00 +0200 Subject: [PATCH 095/199] added WaitingForPlayers Event --- Synapse/Events/Patches/FemurEnterPatch.cs | 5 +++-- .../Events/Patches/WaitingForPlayersPatch.cs | 21 +++++++++++++++++++ Synapse/Events/ServerEvents.cs | 10 +++++++++ Synapse/Synapse.csproj | 8 ++++--- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 Synapse/Events/Patches/WaitingForPlayersPatch.cs diff --git a/Synapse/Events/Patches/FemurEnterPatch.cs b/Synapse/Events/Patches/FemurEnterPatch.cs index 27b39b3..6ccd549 100644 --- a/Synapse/Events/Patches/FemurEnterPatch.cs +++ b/Synapse/Events/Patches/FemurEnterPatch.cs @@ -23,9 +23,10 @@ public static bool Prefix(CharacterClassManager __instance) { CharacterClassManager component = gameObject.GetComponent(); PlayerStats component2 = gameObject.GetComponent(); - if (component.CurRole.team != Team.SCP && component.CurClass != RoleType.Spectator && !component.GodMode) + if (component.CurClass != RoleType.Spectator && !component.GodMode) { - var allow = true; + var allow = component.CurRole.team != Team.SCP; + var CloseFemur = femurBrokePeople + 1 >= Configs.requiredforFemur; var player = __instance.GetComponent(); diff --git a/Synapse/Events/Patches/WaitingForPlayersPatch.cs b/Synapse/Events/Patches/WaitingForPlayersPatch.cs new file mode 100644 index 0000000..c9e214e --- /dev/null +++ b/Synapse/Events/Patches/WaitingForPlayersPatch.cs @@ -0,0 +1,21 @@ +using System; +using Harmony; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.AddLog))] + public class WaitingForPlayersPatch + { + public static void Prefix(ref string q) + { + try + { + if (q == "Waiting for players..") Events.InvokeWaitingforPlayers(); + } + catch (Exception e) + { + Log.Error($"WaitingForPlayersEvent error: {e}"); + } + } + } +} diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index 64a01fe..5d6a594 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -101,5 +101,15 @@ internal static void InvokeTeamRespawnEvent(ref List respawnlist, allow = ev.Allow; useticktes = ev.UseTickets; } + + //WaitingforPlayersEvent + public delegate void OnWaitingforPlayers(); + public static event OnWaitingforPlayers WaitingforPlayersEvent; + internal static void InvokeWaitingforPlayers() + { + if (WaitingforPlayersEvent == null) return; + + WaitingforPlayersEvent.Invoke(); + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 3e3bc62..debeb23 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -36,12 +36,13 @@ ..\..\Synaps Verweise\0Harmony.dll - - ..\SynapseModLoaderPatcher\bin\Debug\Assembly-CSharp-Synapse_publizied.dll - ..\..\Synaps Verweise\Assembly-CSharp-firstpass.dll + + False + ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll + ..\..\Synaps Verweise\Mirror.dll @@ -79,6 +80,7 @@ + From b71de0820f99eb4e1cc6c632c0822d38f1e92fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Mon, 8 Jun 2020 16:22:36 +0200 Subject: [PATCH 096/199] PreAuthenticationEvent done. --- .../Events/Classes/PreAuthenticationEvent.cs | 11 ++++ .../Events/Patches/PreAuthenticationPatch.cs | 55 +++++++++++++++++++ Synapse/Events/ServerEvents.cs | 20 ++++++- Synapse/Synapse.csproj | 3 + 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 Synapse/Events/Classes/PreAuthenticationEvent.cs create mode 100644 Synapse/Events/Patches/PreAuthenticationPatch.cs diff --git a/Synapse/Events/Classes/PreAuthenticationEvent.cs b/Synapse/Events/Classes/PreAuthenticationEvent.cs new file mode 100644 index 0000000..dd76d7c --- /dev/null +++ b/Synapse/Events/Classes/PreAuthenticationEvent.cs @@ -0,0 +1,11 @@ +using LiteNetLib; + +namespace Synapse.Events.Classes +{ + public class PreAuthenticationEvent + { + public string UserId { get; internal set; } + public ConnectionRequest Request { get; internal set; } + public bool Allow { get; set; } + } +} \ No newline at end of file diff --git a/Synapse/Events/Patches/PreAuthenticationPatch.cs b/Synapse/Events/Patches/PreAuthenticationPatch.cs new file mode 100644 index 0000000..2a0177b --- /dev/null +++ b/Synapse/Events/Patches/PreAuthenticationPatch.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using Harmony; +using LiteNetLib; +using LiteNetLib.Utils; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(CustomLiteNetLib4MirrorTransport), nameof(CustomLiteNetLib4MirrorTransport.ProcessConnectionRequest))] + public class PreAuthenticationPatch + { + public static void Postfix(CustomLiteNetLib4MirrorTransport __instance, ConnectionRequest request) + { + var allow = true; + + if (!request.Data.EndOfData) + { + Log.Warn("Server is not finished handling Authentication"); + return; + } + + var userId = CustomLiteNetLib4MirrorTransport.UserIds[request.RemoteEndPoint].UserId; + + Events.InvokePreAuthentication(userId, request, request.Data.Position, 0, null, ref allow); + + if (allow) + { + request.Accept(); + return; + } + var data = new NetDataWriter(); + data.Put((byte) 10); + request.RejectForce(data); + } + + static IEnumerable Transpiler(IEnumerable instructions) + { + var codes = new List(instructions); + + foreach (var code in codes.Select((x,i) => new {Value =x, Index = i })) + { + if (code.Value.opcode != OpCodes.Callvirt) continue; + if (codes[code.Index + 2].opcode != OpCodes.Ldstr) continue; + var strOperrand = codes[code.Index + 2].operand as string; + if (strOperrand == "Player {0} preauthenticated from endpoint {1}.") + { + code.Value.opcode = OpCodes.Nop; + } + } + + return codes.AsEnumerable(); + } + } +} \ No newline at end of file diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index 64a01fe..1ef0219 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; +using LiteNetLib; using Synapse.Events.Classes; namespace Synapse.Events @@ -101,5 +101,23 @@ internal static void InvokeTeamRespawnEvent(ref List respawnlist, allow = ev.Allow; useticktes = ev.UseTickets; } + + public delegate void OnPreAuthenticationEvent(ref PreAuthenticationEvent ev); + public static event OnPreAuthenticationEvent PreAuthenticationEvent; + + internal static void InvokePreAuthentication(string userId, ConnectionRequest request, int position, byte flags, + string country, ref bool allow) + { + var ev = new PreAuthenticationEvent() + { + Allow = allow, + Request = request, + UserId = userId + }; + + PreAuthenticationEvent?.Invoke(ref ev); + + allow = ev.Allow; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 03af53f..a4398fc 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -72,6 +72,7 @@ + @@ -81,6 +82,7 @@ + @@ -113,6 +115,7 @@ + From 4182037107006f19a512b13201817ad23bd8cf56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Mon, 8 Jun 2020 16:23:00 +0200 Subject: [PATCH 097/199] WarheadDetonationEvent --- Synapse/Events/MapEvents.cs | 5 +++++ .../Events/Patches/WarheadDetonationPatch.cs | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Synapse/Events/Patches/WarheadDetonationPatch.cs diff --git a/Synapse/Events/MapEvents.cs b/Synapse/Events/MapEvents.cs index 9cb9dde..bdbe0c2 100644 --- a/Synapse/Events/MapEvents.cs +++ b/Synapse/Events/MapEvents.cs @@ -46,5 +46,10 @@ internal static void InvokeTeslaTrigger(GameObject player, bool inRange, ref boo activated = ev.Triggerable; } + + public delegate void OnWarheadDetonation(); + public static event OnWarheadDetonation WarheadDetonationEvent; + + internal static void InvokeWarheadDetonation() => WarheadDetonationEvent?.Invoke(); } } \ No newline at end of file diff --git a/Synapse/Events/Patches/WarheadDetonationPatch.cs b/Synapse/Events/Patches/WarheadDetonationPatch.cs new file mode 100644 index 0000000..870396d --- /dev/null +++ b/Synapse/Events/Patches/WarheadDetonationPatch.cs @@ -0,0 +1,21 @@ +using System; +using Harmony; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(AlphaWarheadController), nameof(AlphaWarheadController.Detonate))] + public class WarheadDetonationPatch + { + public static void Prefix() + { + try + { + Events.InvokeWarheadDetonation(); + } + catch (Exception e) + { + Log.Error($"WarheadDetonationErr: {e}"); + } + } + } +} \ No newline at end of file From 34a48eee3ba021a8eff1196b02a97d5a7bda881d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Mon, 8 Jun 2020 16:23:53 +0200 Subject: [PATCH 098/199] Add KickPlayer API Reference --- Synapse/Api/Player.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index e2e7e9f..7b09a8b 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -278,5 +278,15 @@ public static void SetRole(this ReferenceHub player, RoleType roleType, bool sta SetRole(player, roleType); } } + + /// + /// Disconnects a Player from the Server + /// + /// the player to be kicked + /// the message shown to the player + public static void KickPlayer(this ReferenceHub player, string message) + { + ServerConsole.Disconnect(player.gameObject, message); + } } } \ No newline at end of file From a14677332da1edfad6feb7ff4a5924231e0cfeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Mon, 8 Jun 2020 16:24:41 +0200 Subject: [PATCH 099/199] Add TODO --- Synapse/Events/Patches/PreAuthenticationPatch.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Synapse/Events/Patches/PreAuthenticationPatch.cs b/Synapse/Events/Patches/PreAuthenticationPatch.cs index 2a0177b..a44a0e0 100644 --- a/Synapse/Events/Patches/PreAuthenticationPatch.cs +++ b/Synapse/Events/Patches/PreAuthenticationPatch.cs @@ -33,7 +33,8 @@ public static void Postfix(CustomLiteNetLib4MirrorTransport __instance, Connecti data.Put((byte) 10); request.RejectForce(data); } - + + //TODO: Explain this code to other contrib. static IEnumerable Transpiler(IEnumerable instructions) { var codes = new List(instructions); From 86cd0af3a4a1ae97670a098df4bb27e8943438b9 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 9 Jun 2020 12:25:31 +0200 Subject: [PATCH 100/199] added get/set Scale --- Synapse/Api/Player.cs | 47 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index e2e7e9f..9696ab4 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,7 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Reflection; using Hints; +using Mirror; using Synapse.Permissions; using UnityEngine; @@ -11,6 +14,19 @@ namespace Synapse.Api [SuppressMessage("ReSharper", "UnusedMember.Global")] public static class Player { + private static MethodInfo sendSpawnMessage; + public static MethodInfo SendSpawnMessage + { + get + { + if (sendSpawnMessage == null) + sendSpawnMessage = typeof(NetworkServer).GetMethod("SendSpawnMessage",BindingFlags.Instance | BindingFlags.InvokeMethod + | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public); + + return sendSpawnMessage; + } + } + /// Gives a User a Message im Remote Admin /// The User who you send the Message /// The Name from which is it at the beginning of the Message @@ -278,5 +294,34 @@ public static void SetRole(this ReferenceHub player, RoleType roleType, bool sta SetRole(player, roleType); } } + + /// + /// Gives you the size the Player currently is + /// + /// + /// Vector3 with the x y z scales of the player + public static Vector3 GetScale(this ReferenceHub player) => player.transform.localScale; + + /// + /// Changes The Scale of the Player + /// + /// + /// + /// + /// + public static void SetScale(this ReferenceHub player, float x, float y, float z) + { + try + { + player.transform.localScale = new Vector3(x, y, z); + + foreach (ReferenceHub hub in GetHubs()) + SendSpawnMessage?.Invoke(null, new object[] { player.GetComponent(), hub.scp079PlayerScript.connectionToClient }); + } + catch (Exception e) + { + Log.Error($"SetScale Error. {e}"); + } + } } } \ No newline at end of file From d258c1ebd7716508e7bcc96b21d6ec10f7ffa5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 9 Jun 2020 12:41:47 +0200 Subject: [PATCH 101/199] Add a short description for the WaitingForPlayers --- Synapse/Events/Patches/WaitingForPlayersPatch.cs | 10 +++++++++- Synapse/Events/ServerEvents.cs | 12 +++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Synapse/Events/Patches/WaitingForPlayersPatch.cs b/Synapse/Events/Patches/WaitingForPlayersPatch.cs index c9e214e..3eb8c42 100644 --- a/Synapse/Events/Patches/WaitingForPlayersPatch.cs +++ b/Synapse/Events/Patches/WaitingForPlayersPatch.cs @@ -3,6 +3,14 @@ namespace Synapse.Events.Patches { + + /// + /// The WaitingForPlayers Patch is a special one. + /// + /// This solution is currently the only way to check if a server is finished with initialisation or not. + /// Since the "Init"-Method (where the Server States that it is indeed "ready for players" is an IEnumerator, Harmony didn't really have a way of patching + /// the IEnumerator. Until Northwood does a better Handling of this, this is here to stay. + /// [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.AddLog))] public class WaitingForPlayersPatch { @@ -10,7 +18,7 @@ public static void Prefix(ref string q) { try { - if (q == "Waiting for players..") Events.InvokeWaitingforPlayers(); + if (q == "Waiting for players...") Events.InvokeWaitingForPlayers(); } catch (Exception e) { diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index 22508d3..27cfac8 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -120,14 +120,8 @@ internal static void InvokePreAuthentication(string userId, ConnectionRequest re allow = ev.Allow; } - //WaitingforPlayersEvent - public delegate void OnWaitingforPlayers(); - public static event OnWaitingforPlayers WaitingforPlayersEvent; - internal static void InvokeWaitingforPlayers() - { - if (WaitingforPlayersEvent == null) return; - - WaitingforPlayersEvent.Invoke(); - } + public delegate void OnWaitingForPlayers(); + public static event OnWaitingForPlayers WaitingForPlayersEvent; + internal static void InvokeWaitingForPlayers() => WaitingForPlayersEvent?.Invoke(); } } \ No newline at end of file From ebe07030d95944ede669be0561fd4330fbc9f811 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 11 Jun 2020 16:47:01 +0200 Subject: [PATCH 102/199] ? --- Synapse/Api/Player.cs | 20 ++++++++++---------- Synapse/Events/ServerEvents.cs | 10 ---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 47fa928..f4e6d80 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -294,6 +294,16 @@ public static void SetRole(this ReferenceHub player, RoleType roleType, bool sta SetRole(player, roleType); } } + + /// + /// Disconnects a Player from the Server + /// + /// the player to be kicked + /// the message shown to the player + public static void KickPlayer(this ReferenceHub player, string message) + { + ServerConsole.Disconnect(player.gameObject, message); + } /// /// Gives you the size the Player currently is @@ -323,15 +333,5 @@ public static void SetScale(this ReferenceHub player, float x, float y, float z) Log.Error($"SetScale Error. {e}"); } } - - /// - /// Disconnects a Player from the Server - /// - /// the player to be kicked - /// the message shown to the player - public static void KickPlayer(this ReferenceHub player, string message) - { - ServerConsole.Disconnect(player.gameObject, message); - } } } \ No newline at end of file diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index 22508d3..1ef0219 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -119,15 +119,5 @@ internal static void InvokePreAuthentication(string userId, ConnectionRequest re allow = ev.Allow; } - - //WaitingforPlayersEvent - public delegate void OnWaitingforPlayers(); - public static event OnWaitingforPlayers WaitingforPlayersEvent; - internal static void InvokeWaitingforPlayers() - { - if (WaitingforPlayersEvent == null) return; - - WaitingforPlayersEvent.Invoke(); - } } } \ No newline at end of file From c83db522a690e59c0ce98180b63ed91f84bfe23a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 11 Jun 2020 18:48:30 +0200 Subject: [PATCH 103/199] added RemoteKeyCard --- Synapse/Configs.cs | 2 ++ Synapse/Events/EventHandler.cs | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index 6b4c7b1..45c0e2a 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -9,6 +9,7 @@ internal static class Configs //Configs internal static int requiredforFemur; + internal static bool remotekeycard; //Methods internal static void ReloadConfig() @@ -16,6 +17,7 @@ internal static void ReloadConfig() if (Config == null) Config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); requiredforFemur = Config.GetInt("synapse.femur",1); + remotekeycard = Config.GetBool("synapse.remote.keycard", true); } } } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index f80ef2e..1b7280d 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -8,7 +8,7 @@ namespace Synapse.Events { // ReSharper disable once UnusedType.Global - public class EventHandler + internal class EventHandler { // Variables private bool _roundInProgress; @@ -24,6 +24,24 @@ public EventHandler() Events.RoundStartEvent += OnRoundStart; Events.RoundEndEvent += OnRoundEnd; Events.RoundRestartEvent += OnRoundRestart; + Events.DoorInteractEvent += OnDoorInteract; + } + + private void OnDoorInteract(ref DoorInteractEvent ev) + { + if (Configs.remotekeycard) + { + if (ev.Allow) return; + + foreach (var item in ev.Player.inventory.items) + { + if (ev.Player.inventory.GetItemByID(item.id).permissions.Contains(ev.Door.permissionLevel)) + { + ev.Allow = true; + return; + } + } + } } // Methods From 2b7761992cf52f380dbffd83f55e533b6ef90e9b Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 11 Jun 2020 19:29:55 +0200 Subject: [PATCH 104/199] added OwnTranslationFile to Plugin in ServerConfig --- Synapse/Events/EventHandler.cs | 3 ++- Synapse/Plugin.cs | 15 +++++++++++++++ Synapse/PluginManager.cs | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 1b7280d..6f693dd 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using MEC; using Synapse.Api; using Synapse.Events.Classes; @@ -35,7 +36,7 @@ private void OnDoorInteract(ref DoorInteractEvent ev) foreach (var item in ev.Player.inventory.items) { - if (ev.Player.inventory.GetItemByID(item.id).permissions.Contains(ev.Door.permissionLevel)) + if (ev.Player.inventory.GetItemByID(item.id).permissions.Contains(ev.Door.permissionLevel))//update to backwardsCompatPermissions when neccesary { ev.Allow = true; return; diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 4f8e350..e7c7501 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -12,6 +12,8 @@ public abstract class Plugin private string _ownPluginFolder; + private string _owntransTranslationFile; + /// /// A Directory especially for your Plugin which are created by Synapse for you! /// @@ -29,6 +31,19 @@ public string OwnPluginFolder internal set => _ownPluginFolder = value; } + public string OwnTranslationFile + { + // ReSharper disable once UnusedMember.Global + get + { + if (!File.Exists(_owntransTranslationFile)) + File.Create(_owntransTranslationFile); + + return OwnTranslationFile; + } + internal set => _owntransTranslationFile = value; + } + public abstract string GetName { get; } /// The Method ist always activated when the Server starts diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index fe2ff09..d284523 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -141,6 +141,7 @@ private static void OnEnable() foreach (var plugin in Plugins) try { + plugin.OwnTranslationFile = Path.Combine(ServerConfigDirectory, plugin.GetName + "-translation.txt"); plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectory, plugin.GetName); plugin.OnEnable(); } From c3be7f2333ce027ca988fcf8091ef0958962d39f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 11 Jun 2020 20:30:07 +0200 Subject: [PATCH 105/199] PluginManager Rework --- Synapse/MainLoader.cs | 2 +- Synapse/Plugin.cs | 2 +- Synapse/PluginManager.cs | 79 +++++++++++++++++++++++----------------- Synapse/Synapse.csproj | 1 + 4 files changed, 48 insertions(+), 36 deletions(-) diff --git a/Synapse/MainLoader.cs b/Synapse/MainLoader.cs index 10b633a..5d99043 100644 --- a/Synapse/MainLoader.cs +++ b/Synapse/MainLoader.cs @@ -28,7 +28,7 @@ public static void LoaderExecutionCode() CustomNetworkManager.Modded = true; try { - Timing.RunCoroutine(PluginManager.LoadPlugins()); + Timing.RunCoroutine(PluginManager.StartSynapse()); } catch { diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index e7c7501..30c732c 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -39,7 +39,7 @@ public string OwnTranslationFile if (!File.Exists(_owntransTranslationFile)) File.Create(_owntransTranslationFile); - return OwnTranslationFile; + return _owntransTranslationFile; } internal set => _owntransTranslationFile = value; } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index d284523..757cbe9 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -24,65 +24,76 @@ public static class PluginManager internal static string MainConfigDirectory { get; } = Path.Combine(SynapseDirectory, "ServerConfigs"); private static string ServerPluginDirectory { get; set; } internal static string ServerConfigDirectory { get; private set; } + private static string ServerConfigFile { get; set; } internal static Events.EventHandler EventHandler; // Methods - public static IEnumerator LoadPlugins() + internal static IEnumerator StartSynapse() { yield return Timing.WaitForSeconds(0.5f); try { - LoadDependencies(); + Files(); - var serverPluginDirectory = - Path.Combine(MainPluginDirectory, $"Server{ServerStatic.ServerPort} Plugins"); - ServerPluginDirectory = serverPluginDirectory; + LoadPlugins(); - if (!Directory.Exists(serverPluginDirectory)) - Directory.CreateDirectory(serverPluginDirectory); + LoadSynapse(); + } + catch (Exception e) + { + Log.Error($"Synapse could not Start : {e}"); + } + } - var plugins = Directory.GetFiles(serverPluginDirectory); + private static void Files() + { + ServerPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerStatic.ServerPort} Plugins"); + if (!Directory.Exists(ServerPluginDirectory)) + Directory.CreateDirectory(ServerPluginDirectory); - foreach (var plugin in plugins) - { - if (plugin.EndsWith("Synapse.dll")) continue; + ServerConfigDirectory = Path.Combine(MainConfigDirectory, $"Server{ServerStatic.ServerPort}-Configs"); + if (!Directory.Exists(ServerConfigDirectory)) + Directory.CreateDirectory(ServerConfigDirectory); - if (plugin.EndsWith(".dll")) LoadPlugin(plugin); - } + ServerConfigFile = Path.Combine(ServerConfigDirectory, "server-config.yml"); + if (!File.Exists(ServerConfigFile)) + File.Create(ServerConfigFile).Close(); + } - HarmonyPatch(); - - EventHandler = new Events.EventHandler(); + private static void LoadPlugins() + { + LoadDependencies(); - ServerConfigDirectory = Path.Combine(MainConfigDirectory, $"Server{ServerStatic.ServerPort}-Configs"); - if (!Directory.Exists(ServerConfigDirectory)) - Directory.CreateDirectory(ServerConfigDirectory); + var plugins = Directory.GetFiles(ServerPluginDirectory); - var configPath = Path.Combine(ServerConfigDirectory, "server-config.yml"); + foreach (var plugin in plugins) + { + if (plugin.EndsWith("Synapse.dll")) continue; - if (!File.Exists(configPath)) - File.Create(configPath).Close(); + if (plugin.EndsWith(".dll")) LoadPlugin(plugin); + } + Plugin.Config = new YamlConfig(ServerConfigFile); + OnEnable(); + } - Configs.ReloadConfig(); - Plugin.Config = new YamlConfig(configPath); + private static void LoadSynapse() + { + Configs.ReloadConfig(); + HarmonyPatch(); + EventHandler = new Events.EventHandler(); - OnEnable(); - try - { - PermissionReader.Init(); - } - catch (Exception e) - { - Log.Error($"Your Permission in invalid: {e}"); - } + try + { + PermissionReader.Init(); } catch (Exception e) { - Log.Error($"Synapse could not Start : {e}"); + Log.Error($"Your Permission in invalid: {e}"); } } + private static void LoadDependencies() { Log.Info("Loading Dependencies..."); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index c657dfa..558c4e1 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -31,6 +31,7 @@ TRACE prompt 4 + true From 99f5a620ab98be4e945f267ccf2dfea5ac0d2c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Fri, 12 Jun 2020 10:21:29 +0200 Subject: [PATCH 106/199] Change all to Set Directories for CI --- Synapse/Events/Classes/CheckRoundEndEvent.cs | 7 +++++++ Synapse/Events/ServerEvents.cs | 2 ++ Synapse/Synapse.csproj | 17 +++++++++-------- SynapseModLoader/SynapseModLoader.csproj | 4 ++-- 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 Synapse/Events/Classes/CheckRoundEndEvent.cs diff --git a/Synapse/Events/Classes/CheckRoundEndEvent.cs b/Synapse/Events/Classes/CheckRoundEndEvent.cs new file mode 100644 index 0000000..007d038 --- /dev/null +++ b/Synapse/Events/Classes/CheckRoundEndEvent.cs @@ -0,0 +1,7 @@ +namespace Synapse.Events.Classes +{ + public class CheckRoundEndEvent + { + + } +} \ No newline at end of file diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index 27cfac8..a85de44 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -123,5 +123,7 @@ internal static void InvokePreAuthentication(string userId, ConnectionRequest re public delegate void OnWaitingForPlayers(); public static event OnWaitingForPlayers WaitingForPlayersEvent; internal static void InvokeWaitingForPlayers() => WaitingForPlayersEvent?.Invoke(); + + public delegate void OnCheckRoundEnd(ref CheckRoundEndEvent ev); } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 558c4e1..a03626f 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -35,33 +35,33 @@ - ..\..\Synaps Verweise\0Harmony.dll + ..\..\Synapse_Dependencies\0Harmony.dll - ..\..\Synaps Verweise\Assembly-CSharp-firstpass.dll + ..\..\Synapse_Dependencies\Assembly-CSharp-firstpass.dll False - ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll + ..\..\Synapse_Dependencies\Assembly-CSharp-Synapse_publizied.dll - ..\..\Synaps Verweise\Mirror.dll + ..\..\Synapse_Dependencies\Mirror.dll - ..\..\Synaps Verweise\UnityEngine.dll + ..\..\Synapse_Dependencies\UnityEngine.dll - ..\..\Synaps Verweise\UnityEngine.CoreModule.dll + ..\..\Synapse_Dependencies\UnityEngine.CoreModule.dll - ..\..\Synaps Verweise\UnityEngine.PhysicsModule.dll + ..\..\Synapse_Dependencies\UnityEngine.PhysicsModule.dll - ..\..\Synaps Verweise\YamlDotNet.dll + ..\..\Synapse_Dependencies\YamlDotNet.dll @@ -72,6 +72,7 @@ + diff --git a/SynapseModLoader/SynapseModLoader.csproj b/SynapseModLoader/SynapseModLoader.csproj index 7d4eff2..d67dabd 100644 --- a/SynapseModLoader/SynapseModLoader.csproj +++ b/SynapseModLoader/SynapseModLoader.csproj @@ -33,14 +33,14 @@ - D:\Assemblies\Assembly-CSharp.Vanilla.dll + ..\..\Synapse_Dependencies\Assembly-CSharp.dll - ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll + ..\..\Synapse_Dependencies\UnityEngine.CoreModule.dll From bb4954db323fc0ad4e5dba223fe67b3cc03c7f0f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 11:31:43 +0200 Subject: [PATCH 107/199] added Translation support --- Synapse/Plugin.cs | 17 ++---------- Synapse/PluginManager.cs | 4 +-- Synapse/Synapse.csproj | 1 + Synapse/Translation.cs | 56 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 Synapse/Translation.cs diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 30c732c..de4cedd 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -10,9 +10,9 @@ public abstract class Plugin // ReSharper disable once NotAccessedField.Global public static YamlConfig Config; - private string _ownPluginFolder; + public Translation Translation { get; internal set; } - private string _owntransTranslationFile; + private string _ownPluginFolder; /// /// A Directory especially for your Plugin which are created by Synapse for you! @@ -31,19 +31,6 @@ public string OwnPluginFolder internal set => _ownPluginFolder = value; } - public string OwnTranslationFile - { - // ReSharper disable once UnusedMember.Global - get - { - if (!File.Exists(_owntransTranslationFile)) - File.Create(_owntransTranslationFile); - - return _owntransTranslationFile; - } - internal set => _owntransTranslationFile = value; - } - public abstract string GetName { get; } /// The Method ist always activated when the Server starts diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 757cbe9..26566eb 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Reflection; using MEC; -using Synapse.Events; using Synapse.Events.Patches; using Synapse.Permissions; @@ -152,7 +151,8 @@ private static void OnEnable() foreach (var plugin in Plugins) try { - plugin.OwnTranslationFile = Path.Combine(ServerConfigDirectory, plugin.GetName + "-translation.txt"); + plugin.Translation = new Translation(); + plugin.Translation.plugin = plugin; plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectory, plugin.GetName); plugin.OnEnable(); } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 558c4e1..b087e04 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -71,6 +71,7 @@ + diff --git a/Synapse/Translation.cs b/Synapse/Translation.cs new file mode 100644 index 0000000..dbb3b87 --- /dev/null +++ b/Synapse/Translation.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Synapse +{ + public class Translation + { + private Dictionary translation = new Dictionary(); + private string translationpath; + internal Plugin plugin; + + public void CreateTranslations(Dictionary translations) + { + translationpath = Path.Combine(PluginManager.ServerConfigDirectory, plugin.GetName + "-translation.txt"); + if (!File.Exists(translationpath)) + File.Create(translationpath).Close(); + var dictionary = new Dictionary(); + string[] lines = File.ReadAllLines(translationpath); + List newlines = new List(); + int position = 0; + + foreach (var pair in translations.ToList()) + { + if (lines.Count() > position) + { + dictionary.Add(pair.Key, lines[position]); + newlines.Add(lines[position]); + } + else + { + dictionary.Add(pair.Key, pair.Value); + newlines.Add(pair.Value); + } + + position++; + File.WriteAllLines(translationpath, newlines.ToArray()); + } + + translation = dictionary; + } + + public string GetTranslation(string translationName) + { + try + { + string trans = translation.FirstOrDefault(x => x.Key == translationName).Value; + return trans; + } + catch + { + return $"Invalid Translations Name"; + } + } + } +} From a096b69409886c414839776d8325f99370f2605f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 11:43:32 +0200 Subject: [PATCH 108/199] Translation Empty/null exception Check --- Synapse/Translation.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Synapse/Translation.cs b/Synapse/Translation.cs index dbb3b87..eb46c9a 100644 --- a/Synapse/Translation.cs +++ b/Synapse/Translation.cs @@ -24,8 +24,16 @@ public void CreateTranslations(Dictionary translations) { if (lines.Count() > position) { - dictionary.Add(pair.Key, lines[position]); - newlines.Add(lines[position]); + if (string.IsNullOrEmpty(lines[position])) + { + dictionary.Add(pair.Key, pair.Value); + newlines.Add(pair.Value); + } + else + { + dictionary.Add(pair.Key, lines[position]); + newlines.Add(lines[position]); + } } else { From a0c52612294b2a89d1f9ece7d64da2f7968c8e3a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 18:17:46 +0200 Subject: [PATCH 109/199] started with the 5 Generator Events --- Synapse/Events/Patches/GeneratorPatches.cs | 114 +++++++++++++++++++++ Synapse/Synapse.csproj | 1 + 2 files changed, 115 insertions(+) create mode 100644 Synapse/Events/Patches/GeneratorPatches.cs diff --git a/Synapse/Events/Patches/GeneratorPatches.cs b/Synapse/Events/Patches/GeneratorPatches.cs new file mode 100644 index 0000000..0cf8e4e --- /dev/null +++ b/Synapse/Events/Patches/GeneratorPatches.cs @@ -0,0 +1,114 @@ +using System; +using Harmony; +using UnityEngine; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(Generator079), nameof(Generator079.Interact))] + public static class GeneratorTabletPatches + { + public static bool Prefix(Generator079 __instance, GameObject person, string command) + { + try + { + if (command.StartsWith("EPS_DOOR")) return true; + + if (command.StartsWith("EPS_TABLET")) + { + if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance.localTime <= 0f || Generator079.mainGenerator.forcedOvercharge) return false; + + var component = person.GetComponent(); + var enumerator = component.items.GetEnumerator(); + while (enumerator.MoveNext()) + { + Inventory.SyncItemInfo syncItemInfo = enumerator.Current; + if (syncItemInfo.id == ItemType.WeaponManagerTablet) + { + bool allow = true; + //Tablet inserted Event + if (allow) + { + component.items.Remove(syncItemInfo); + __instance.NetworkisTabletConnected = true; + } + return false; + } + } + } + + if (command.StartsWith("EPS_CANCEL")) + { + if (!__instance.isTabletConnected) return false; + bool allow = true; + + //Tablet ejectet Event + return allow; + } + return true; + } + catch (Exception e) + { + Log.Error($"GeneratorTablet Event Error: {e}"); + return true; + } + } + } + + [HarmonyPatch(typeof(Generator079), nameof(Generator079.OpenClose))] + public static class GeneratorDoorPatches + { + public static bool Prefix(Generator079 __instance, GameObject person) + { + Inventory component = person.GetComponent(); + if (component == null || __instance.doorAnimationCooldown > 0f || __instance.deniedCooldown > 0f) return false; + + //Check if the Generator can be open or must be unlocked + if (__instance.isDoorUnlocked) + { + bool allow = true; + if (!__instance.NetworkisDoorOpen) + { + //GeneratorOpenEvent + } + else + { + //GeneratorCloseEvent + } + + if (!allow) + { + __instance.RpcDenied(); + return false; + } + + __instance.doorAnimationCooldown = 1.5f; + __instance.NetworkisDoorOpen = !__instance.isDoorOpen; + __instance.RpcDoSound(__instance.isDoorOpen); + return false; + } + + //Unlock The Generator + bool flag = person.GetComponent().BypassMode; + if (component.curItem > ItemType.KeycardJanitor) + { + string[] permissions = component.GetItemByID(component.curItem).permissions; + + for (int i = 0; i < permissions.Length; i++) + if (permissions[i] == "ARMORY_LVL_2") + flag = true; + } + + //Generator unlock event player = person,allow = flag,__instance + + if (flag) + { + __instance.NetworkisDoorUnlocked = true; + __instance.doorAnimationCooldown = 0.5f; + return false; + } + __instance.RpcDenied(); + + return false; + } + } +} diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 2a27219..327af82 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -71,6 +71,7 @@ + From add0740d0a3f6ab4223e57f5d27194db9af0cae7 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 20:10:13 +0200 Subject: [PATCH 110/199] Huge Api Change! Events will be updated soon --- Synapse/Api/AmmoType.cs | 12 - Synapse/Api/Player.cs | 355 ++++--------------- Synapse/Api/PlayerExtensions.cs | 98 +++++ Synapse/Events/Classes/RemoteCommandEvent.cs | 9 +- Synapse/Events/EventHandler.cs | 8 +- Synapse/Events/Patches/ComponentsPatch.cs | 16 + Synapse/Events/Patches/PlayerBanPatch.cs | 4 +- Synapse/Events/Patches/PlayerDamagePatch.cs | 4 +- Synapse/Events/Patches/PlayerEscapePatch.cs | 2 +- Synapse/Events/Patches/Scp049RecallPatch.cs | 4 +- Synapse/Permissions/PermissionReader.cs | 8 +- Synapse/Synapse.csproj | 5 +- 12 files changed, 213 insertions(+), 312 deletions(-) delete mode 100644 Synapse/Api/AmmoType.cs create mode 100644 Synapse/Api/PlayerExtensions.cs create mode 100644 Synapse/Events/Patches/ComponentsPatch.cs diff --git a/Synapse/Api/AmmoType.cs b/Synapse/Api/AmmoType.cs deleted file mode 100644 index c1cdb0d..0000000 --- a/Synapse/Api/AmmoType.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Synapse.Api -{ - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public enum AmmoType - { - Dropped5, - Dropped7, - Dropped9 - } -} \ No newline at end of file diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index f4e6d80..1fb3c98 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Reflection; using Hints; using Mirror; using Synapse.Permissions; @@ -10,328 +8,127 @@ namespace Synapse.Api { - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public static class Player + public class Player : MonoBehaviour { - private static MethodInfo sendSpawnMessage; - public static MethodInfo SendSpawnMessage - { - get - { - if (sendSpawnMessage == null) - sendSpawnMessage = typeof(NetworkServer).GetMethod("SendSpawnMessage",BindingFlags.Instance | BindingFlags.InvokeMethod - | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public); - - return sendSpawnMessage; - } - } - - /// Gives a User a Message im Remote Admin - /// The User who you send the Message - /// The Name from which is it at the beginning of the Message - /// The Message you want to send - /// True = green the command is right you have permission and execute it successfully - /// In Which Category should you see it too? - public static void RaMessage(this CommandSender sender, string pluginName, string message, bool success = true, - RaCategory type = RaCategory.None) - { - var category = ""; - // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault - switch (type) - { - case RaCategory.None: - category = ""; - break; - case RaCategory.PlayerInfo: - category = "PlayerInfo"; - break; - case RaCategory.ServerEvents: - category = "ServerEvents"; - break; - case RaCategory.DoorsManagement: - category = "DoorsManagement"; - break; - case RaCategory.AdminTools: - category = "AdminTools"; - break; - case RaCategory.ServerConfigs: - category = "ServerConfigs"; - break; - case RaCategory.PlayersManagement: - category = "PlayersManagement"; - break; - } + public static Player Server { get => PlayerManager.localPlayer.GetPlayer(); } - sender.RaReply($"{pluginName}#" + message, success, true, category); - } - - /// - /// Gives The Player a Hint on the screen - /// - /// Player who becomes the Hint - /// Message The Player becomes - /// How long should the player see it? - public static void GiveTextHint(this ReferenceHub player,string message,float duration = 5f) - { - player.hints.Show(new TextHint(message, new HintParameter[] - { - new StringHintParameter("") - }, HintEffectPresets.FadeInAndOut(duration), duration)); - } + public ReferenceHub Hub { get => this.GetComponent(); } - /// Sends a Broadcast to a user - /// The User you want to send a Broadcast - /// How Long should he see it? - /// The message you send - public static void Broadcast(this ReferenceHub rh, ushort time, string message) - { - rh.GetComponent().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, - new Broadcast.BroadcastFlags()); - } + public string NickName { get => Hub.nicknameSync.MyNick; set => Hub.nicknameSync.MyNick = value; } - /// Sends a broadcast to the user and delete all previous so that he see it instantly - /// The user - /// How long should the new Broadcast be shown? - /// the broadcast message - public static void BroadcastInstant(this ReferenceHub rh, ushort time, string message) - { - rh.ClearBroadcasts(); - rh.Broadcast(time, message); - } + public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } - /// Clears all of the current Broadcast the user has - /// The Player which Broadcast should be cleared - public static void ClearBroadcasts(this ReferenceHub player) - { - player.GetComponent() - .TargetClearElements(player.scp079PlayerScript.connectionToClient); - } + public string UserID { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } - /// - /// Sets the Ammo a user have - /// - /// Player you want to set ammo - /// The AmmoType you give - /// How much ammo - public static void SetAmmo(this ReferenceHub player, AmmoType ammoType, uint amount) - { - player.ammoBox.amount[(int) ammoType] = amount; - } + public bool OverWatch { get => Hub.serverRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } - /// - /// Have the Player the Permission? - /// - public static bool IsAllowed(this ReferenceHub hub, string permission) - { - if (hub == PlayerManager.localPlayer) return true; - try - { - return PermissionReader.CheckPermission(hub, permission); - } - catch + public Vector3 Scale + { + get => Hub.transform.localScale; + set { - return false; + try + { + Hub.transform.localScale = value; + + foreach (var player in PlayerExtensions.GetAllPlayers()) + PlayerExtensions.SendSpawnMessage?.Invoke(null, new object[] { Hub.GetComponent(), player.Connection }); + } + catch (Exception e) + { + Log.Error($"SetScale Error. {e}"); + } } } - /// A List of all Players on the Server which are not the Server - public static IEnumerable GetHubs() - { - return (from gameObject in PlayerManager.players - where gameObject != PlayerManager.localPlayer && gameObject != null - select gameObject.GetComponent()).ToList(); - } + public Vector3 Position { get => Hub.transform.position; set => Hub.transform.position = value; } - /// PlayerId of the User - /// Object ReferenceHub from the USer with the id - public static ReferenceHub GetPlayer(int id) + public RoleType Role { - return GetHubs().FirstOrDefault(hub => hub.GetPlayerId() == id); + get => Hub.characterClassManager.NetworkCurClass; + set => Hub.characterClassManager.SetPlayersClass(value, gameObject); } - public static ReferenceHub GetPlayer(string args) - { - if (short.TryParse(args, out var playerId)) - return GetPlayer(playerId); - - if (!args.EndsWith("@steam") && !args.EndsWith("@discord") && !args.EndsWith("@northwood") && - !args.EndsWith("@patreon")) - return GetHubs().FirstOrDefault(hub => hub.GetNickName().ToLower().Contains(args.ToLower())); - foreach (var player in GetHubs()) - if (player.GetUserId() == args) - return player; - - return GetHubs().FirstOrDefault(hub => hub.GetNickName().ToLower().Contains(args.ToLower())); - } + public Team Team { get => Hub.characterClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } - public static ReferenceHub GetCuffs(this ReferenceHub player) + public Room CurRoom { - return GetPlayer(player.GetComponent().CufferId); - } + get + { + var playerPos = Position; + var end = playerPos - new Vector3(0f, 10f, 0f); + var flag = Physics.Linecast(playerPos, end, out var rayCastHit, -84058629); - public static string GetNickName(this ReferenceHub player) - { - return player.nicknameSync.MyNick; - } + if (!flag || rayCastHit.transform == null) + return null; - /// - /// The PlayerID of the User - public static int GetPlayerId(this ReferenceHub player) - { - return player.queryProcessor.NetworkPlayerId; - } + var transform = rayCastHit.transform; - /// The User you want the Id of - /// The User ID (1234@steam) of the User - public static string GetUserId(this ReferenceHub player) - { - return player.characterClassManager.UserId; - } + while (transform.parent != null && transform.parent.parent != null) + transform = transform.parent; - /// Gives you The Position of the User - /// The User which Position you want to have - public static Vector3 GetPosition(this ReferenceHub player) - { - return player.playerMovementSync.transform.position; - } + foreach (var room in Map.Rooms.Where(room => room.Position == transform.position)) + return room; - public static void SetPosition(this ReferenceHub player, Vector3 position, bool forceGround = false) - { - player.playerMovementSync.OverridePosition(position, 0f, forceGround); + return new Room + { + Name = transform.name, + Position = transform.position, + Transform = transform + }; + } + set => Position = Map.Rooms.FirstOrDefault(x => x == value).Position; } - /// Gives You the Current Room the user is in - /// - public static Room GetCurrentRoom(this ReferenceHub player) - { - var playerPos = player.GetPosition(); - var end = playerPos - new Vector3(0f, 10f, 0f); - var flag = Physics.Linecast(playerPos, end, out var rayCastHit, -84058629); - - if (!flag || rayCastHit.transform == null) - return null; - - var transform = rayCastHit.transform; - - while (transform.parent != null && transform.parent.parent != null) - transform = transform.parent; + public NetworkConnection Connection { get => Hub.scp079PlayerScript.connectionToClient; } - foreach (var room in Map.Rooms.Where(room => room.Position == transform.position)) - return room; + public Player Cuffer { get => PlayerExtensions.GetPlayer(GetComponent().CufferId); } - return new Room - { - Name = transform.name, - Position = transform.position, - Transform = transform - }; - } + public uint Ammo5 { get => Hub.ammoBox.amount[0]; set => Hub.ammoBox.amount[0] = value; } - /// - /// Gets' a players OverWatch status - /// - /// The Player that needs to be checked - /// The OverWatch Status - public static bool GetOverWatch(this ReferenceHub player) - { - return player.serverRoles.OverwatchEnabled; - } + public uint Ammo7 { get => Hub.ammoBox.amount[1]; set => Hub.ammoBox.amount[1] = value; } - /// - /// Sets' a players OverWatch status - /// - /// player to be modified - /// new status to modify - public static void SetOverWatch(this ReferenceHub player, bool newStatus) - { - player.serverRoles.SetOverwatchStatus(newStatus); - } + public uint Ammo9 { get => Hub.ammoBox.amount[2]; set => Hub.ammoBox.amount[2] = value; } - /// - /// Gives you the Team of the player - /// - /// - /// The Team of the Player which is stored in the Role so anyone can change it - public static Team GetTeam(this ReferenceHub player) => player.characterClassManager.CurRole.team; - /// - /// Get the active role that the player currently is. - /// - /// The Player to be checked - /// A RoleType identifier - public static RoleType GetRole(this ReferenceHub player) - { - return player.characterClassManager.CurClass; - } + public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); - /// - /// Setting the player as a different Role - /// - /// the player to be changed - /// the role the player should change to - public static void SetRole(this ReferenceHub player, RoleType roleType) + public void ChangeRoleAtPosition(RoleType role) { - player.characterClassManager.SetPlayersClass(roleType, player.gameObject); + Hub.characterClassManager.NetworkCurClass = role; + Hub.playerStats.SetHPAmount(Hub.characterClassManager.Classes.SafeGet(Role).maxHP); } - /// - /// Setting the player as a different Role - /// - /// the player to be changed - /// the role the player should change to - /// set the player to the current position on the screen. - public static void SetRole(this ReferenceHub player, RoleType roleType, bool stayAtPosition) + public bool CheckPermission(string permission) { - if (stayAtPosition) + if (Hub == PlayerManager.localPlayer) return true; + try { - player.characterClassManager.NetworkCurClass = roleType; - player.playerStats.SetHPAmount(player.characterClassManager.Classes.SafeGet(player.GetRole()).maxHP); + return PermissionReader.CheckPermission(this, permission); } - else + catch { - SetRole(player, roleType); + return false; } } - - /// - /// Disconnects a Player from the Server - /// - /// the player to be kicked - /// the message shown to the player - public static void KickPlayer(this ReferenceHub player, string message) + + public void GiveTextHint(string message, float duration = 5f) { - ServerConsole.Disconnect(player.gameObject, message); + Hub.hints.Show(new TextHint(message, new HintParameter[] + { + new StringHintParameter("") + }, HintEffectPresets.FadeInAndOut(duration), duration)); } - /// - /// Gives you the size the Player currently is - /// - /// - /// Vector3 with the x y z scales of the player - public static Vector3 GetScale(this ReferenceHub player) => player.transform.localScale; + public void ClearBroadcasts() => GetComponent().TargetClearElements(Connection); - /// - /// Changes The Scale of the Player - /// - /// - /// - /// - /// - public static void SetScale(this ReferenceHub player, float x, float y, float z) - { - try - { - player.transform.localScale = new Vector3(x, y, z); + public void Broadcast(ushort time,string message) => GetComponent().TargetAddElement(Connection, message, time, new Broadcast.BroadcastFlags()); - foreach (ReferenceHub hub in GetHubs()) - SendSpawnMessage?.Invoke(null, new object[] { player.GetComponent(), hub.scp079PlayerScript.connectionToClient }); - } - catch (Exception e) - { - Log.Error($"SetScale Error. {e}"); - } + public void InstantBroadcast(ushort time, string message) + { + ClearBroadcasts(); + GetComponent().TargetAddElement(Connection, message, time, new Broadcast.BroadcastFlags()); } } -} \ No newline at end of file +} diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs new file mode 100644 index 0000000..31689d8 --- /dev/null +++ b/Synapse/Api/PlayerExtensions.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Reflection; +using Hints; +using Mirror; +using Synapse.Permissions; +using UnityEngine; + +namespace Synapse.Api +{ + [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] + [SuppressMessage("ReSharper", "UnusedMember.Global")] + public static class PlayerExtensions + { + private static MethodInfo sendSpawnMessage; + public static MethodInfo SendSpawnMessage + { + get + { + if (sendSpawnMessage == null) + sendSpawnMessage = typeof(NetworkServer).GetMethod("SendSpawnMessage",BindingFlags.Instance | BindingFlags.InvokeMethod + | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public); + + return sendSpawnMessage; + } + } + + /// Gives a User a Message im Remote Admin + /// The User who you send the Message + /// The Name from which is it at the beginning of the Message + /// The Message you want to send + /// True = green the command is right you have permission and execute it successfully + /// In Which Category should you see it too? + public static void RaMessage(this CommandSender sender, string pluginName, string message, bool success = true, + RaCategory type = RaCategory.None) + { + var category = ""; + // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault + switch (type) + { + case RaCategory.None: + category = ""; + break; + case RaCategory.PlayerInfo: + category = "PlayerInfo"; + break; + case RaCategory.ServerEvents: + category = "ServerEvents"; + break; + case RaCategory.DoorsManagement: + category = "DoorsManagement"; + break; + case RaCategory.AdminTools: + category = "AdminTools"; + break; + case RaCategory.ServerConfigs: + category = "ServerConfigs"; + break; + case RaCategory.PlayersManagement: + category = "PlayersManagement"; + break; + } + + + sender.RaReply($"{pluginName}#" + message, success, true, category); + } + + public static IEnumerable GetAllPlayers() + { + return (from gameobject in PlayerManager.players + where gameobject != PlayerManager.localPlayer && gameobject != null + select gameobject.GetComponent()).ToList(); + } + + public static Player GetPlayer(this ReferenceHub hub) => hub.GetComponent(); + + public static Player GetPlayer(this GameObject playerobject) => playerobject.GetComponent(); + + public static Player GetPlayer(int id) => GetAllPlayers().FirstOrDefault(p => p.PlayerId == id); + + public static Player GetPlayer(string arg) + { + if (short.TryParse(arg, out var playerId)) + return GetPlayer(playerId); + + if (!arg.EndsWith("@steam") && !arg.EndsWith("@discord") && !arg.EndsWith("@northwood") && + !arg.EndsWith("@patreon")) + return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower())); + foreach (var player in GetAllPlayers()) + if (player.UserID == arg) + return player; + + return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower())); + } + } +} \ No newline at end of file diff --git a/Synapse/Events/Classes/RemoteCommandEvent.cs b/Synapse/Events/Classes/RemoteCommandEvent.cs index f62c088..5562984 100644 --- a/Synapse/Events/Classes/RemoteCommandEvent.cs +++ b/Synapse/Events/Classes/RemoteCommandEvent.cs @@ -1,4 +1,5 @@ -using System; +using Synapse.Api; +using System; namespace Synapse.Events.Classes { @@ -6,9 +7,9 @@ public class RemoteCommandEvent : EventArgs { public CommandSender Sender { get; internal set; } - public ReferenceHub Player => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" - ? ReferenceHub.GetHub(PlayerManager.localPlayer) - : Api.Player.GetPlayer(Sender.SenderId); + public Player Player => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" + ? Player.Server + : Api.PlayerExtensions.GetPlayer(Sender.SenderId); public bool Allow { get; set; } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 6f693dd..97f4836 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -48,9 +48,9 @@ private void OnDoorInteract(ref DoorInteractEvent ev) // Methods private static void OnSyncData(ref SyncDataEvent ev) { - if (ev.Player.GetRole() != RoleType.ClassD && - ev.Player.GetRole() != RoleType.Scientist && - !(Vector3.Distance(ev.Player.GetPosition(), ev.Player.GetComponent().worldPosition) >= Escape.radius)) + if (ev.Player.GetPlayer().Role != RoleType.ClassD && + ev.Player.GetPlayer().Role != RoleType.Scientist && + !(Vector3.Distance(ev.Player.GetPlayer().Position, ev.Player.GetComponent().worldPosition) >= Escape.radius)) ev.Player.characterClassManager.CmdRegisterEscape(); } @@ -61,7 +61,7 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) { case "RELOADPERMISSION": { - if (!ev.Player.IsAllowed("sy.reload")) + if (!ev.Player.CheckPermission("sy.reload")) { ev.Sender.RaMessage("Synapse", "You have no Permission for Reload", false, RaCategory.AdminTools); diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs new file mode 100644 index 0000000..3c83584 --- /dev/null +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -0,0 +1,16 @@ +using System; +using Harmony; +using Synapse.Api; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(ReferenceHub), nameof(ReferenceHub.LoadComponents))] + public static class ComponentsPatch + { + public static void Prefix(ReferenceHub __instance) + { + if (__instance.GetComponent() == null) + __instance.gameObject.AddComponent(); + } + } +} diff --git a/Synapse/Events/Patches/PlayerBanPatch.cs b/Synapse/Events/Patches/PlayerBanPatch.cs index a9d0d06..c1f65de 100644 --- a/Synapse/Events/Patches/PlayerBanPatch.cs +++ b/Synapse/Events/Patches/PlayerBanPatch.cs @@ -15,9 +15,9 @@ public static bool Prefix(GameObject user, int duration, string reason, string i try { var player = user.GetComponent(); - var banIssuer = Player.GetPlayer(issuer); + var banIssuer = PlayerExtensions.GetPlayer(issuer); var allow = true; - Events.InvokePlayerBanEvent(player, player.GetUserId(), duration, ref allow, reason, banIssuer); + Events.InvokePlayerBanEvent(player, player.GetPlayer().UserID, duration, ref allow, reason, banIssuer.Hub); return isGlobalBan && ConfigFile.ServerConfig.GetBool("gban_ban_ip") || allow; } diff --git a/Synapse/Events/Patches/PlayerDamagePatch.cs b/Synapse/Events/Patches/PlayerDamagePatch.cs index 8881c64..bd66f86 100644 --- a/Synapse/Events/Patches/PlayerDamagePatch.cs +++ b/Synapse/Events/Patches/PlayerDamagePatch.cs @@ -17,7 +17,7 @@ public static void Prefix(PlayerStats __instance, ref PlayerStats.HitInfo info, var killer = __instance.GetComponent(); if (info.GetDamageType() == DamageTypes.Grenade) - killer = Player.GetPlayer(info.PlayerId); + killer = PlayerExtensions.GetPlayer(info.PlayerId).Hub; var player = go.GetComponent(); @@ -36,7 +36,7 @@ public static void Postfix(PlayerStats __instance, PlayerStats.HitInfo info, Gam var killer = __instance.GetComponent(); var player = go.GetComponent(); - if (player.GetRole() == RoleType.Spectator) + if (player.GetPlayer().Role == RoleType.Spectator) Events.InvokePlayerDieEvent(player, killer, info); } catch (Exception e) diff --git a/Synapse/Events/Patches/PlayerEscapePatch.cs b/Synapse/Events/Patches/PlayerEscapePatch.cs index 2e53c10..bc4a30e 100644 --- a/Synapse/Events/Patches/PlayerEscapePatch.cs +++ b/Synapse/Events/Patches/PlayerEscapePatch.cs @@ -24,7 +24,7 @@ public static bool Prefix(CharacterClassManager __instance) //Event vars var player = __instance.GetComponent(); - var spawnRole = player.GetRole(); + var spawnRole = player.GetPlayer().Role; var cufferRole = RoleType.None; var allow = true; var isCuffed = false; diff --git a/Synapse/Events/Patches/Scp049RecallPatch.cs b/Synapse/Events/Patches/Scp049RecallPatch.cs index e0a6b7c..65d07f3 100644 --- a/Synapse/Events/Patches/Scp049RecallPatch.cs +++ b/Synapse/Events/Patches/Scp049RecallPatch.cs @@ -92,8 +92,8 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) var pos3 = component.transform.position; pos3.y += 2; - referenceHub.SetRole(role, true); - Timing.CallDelayed(0.5f, () => referenceHub.SetPosition(pos3)); + referenceHub.GetPlayer().ChangeRoleAtPosition(role); + Timing.CallDelayed(0.5f, () => referenceHub.GetPlayer().Position = pos3); referenceHub.GetComponent().Health = live; if (component.CompareTag("Ragdoll")) NetworkServer.Destroy(component.gameObject); __instance._recallInProgressServer = false; diff --git a/Synapse/Permissions/PermissionReader.cs b/Synapse/Permissions/PermissionReader.cs index bb48ada..e1da39b 100644 --- a/Synapse/Permissions/PermissionReader.cs +++ b/Synapse/Permissions/PermissionReader.cs @@ -62,7 +62,7 @@ private static Group GetNwGroup() return (from gr in _permissionsConfig.Groups where gr.Value.Northwood select gr.Value).FirstOrDefault(); } - internal static bool CheckPermission(ReferenceHub player, string permission) + internal static bool CheckPermission(Player player, string permission) { if (player == null) { @@ -77,13 +77,13 @@ internal static bool CheckPermission(ReferenceHub player, string permission) return false; } - var userGroup = ServerStatic.GetPermissionsHandler().GetUserGroup(player.GetUserId()); + var userGroup = ServerStatic.GetPermissionsHandler().GetUserGroup(player.UserID); Group group = null; if (userGroup != null) { var groupName = ServerStatic.GetPermissionsHandler()._groups - .FirstOrDefault(g => g.Value == player.serverRoles.Group).Key; + .FirstOrDefault(g => g.Value == player.Hub.serverRoles.Group).Key; if (_permissionsConfig == null) { Log.Error("Permission config is null."); @@ -104,7 +104,7 @@ internal static bool CheckPermission(ReferenceHub player, string permission) } else { - if (player.serverRoles.Staff || player.GetUserId().EndsWith("@northwood")) group = GetNwGroup(); + if (player.Hub.serverRoles.Staff || player.UserID.EndsWith("@northwood")) group = GetNwGroup(); else group = GetDefaultGroup(); } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 327af82..177bb83 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -65,12 +65,13 @@ - + - + + From 120d48973054e1def1b282ed2fd09d947aa2f3e6 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 21:09:44 +0200 Subject: [PATCH 111/199] Rework Every Event for the new Api --- Synapse/Api/Player.cs | 8 ++++- Synapse/Api/PlayerExtensions.cs | 6 ++-- Synapse/Events/Classes/ConsoleCommandEvent.cs | 5 +-- Synapse/Events/Classes/DoorInteractEvent.cs | 5 +-- Synapse/Events/Classes/DropItemEvent.cs | 6 ++-- Synapse/Events/Classes/FemurEnterEvent.cs | 5 +-- Synapse/Events/Classes/PlayerBanEvent.cs | 7 ++-- Synapse/Events/Classes/PlayerCuffedEvent.cs | 7 ++-- Synapse/Events/Classes/PlayerDeathEvent.cs | 7 ++-- Synapse/Events/Classes/PlayerEscapeEvent.cs | 5 +-- Synapse/Events/Classes/PlayerHurtEvent.cs | 7 ++-- Synapse/Events/Classes/PlayerJoinEvent.cs | 12 ++----- Synapse/Events/Classes/PlayerLeaveEvent.cs | 5 +-- Synapse/Events/Classes/PlayerReloadEvent.cs | 6 ++-- .../Events/Classes/PocketDimensionEvent.cs | 6 ++-- Synapse/Events/Classes/Scp049RecallEvent.cs | 7 ++-- .../Events/Classes/Scp106ContainmentEvent.cs | 6 ++-- Synapse/Events/Classes/SpeakEventEvent.cs | 3 +- Synapse/Events/Classes/SyncDataEvent.cs | 5 +-- Synapse/Events/Classes/TeamRespawnEvent.cs | 5 +-- Synapse/Events/Classes/TeslaTriggerEvent.cs | 5 +-- Synapse/Events/EventHandler.cs | 12 +++---- Synapse/Events/MapEvents.cs | 7 ++-- Synapse/Events/Patches/ConsoleCommandPatch.cs | 3 +- Synapse/Events/Patches/DoorInteractPatch.cs | 3 +- Synapse/Events/Patches/DropItemPatch.cs | 3 +- Synapse/Events/Patches/FemurEnterPatch.cs | 3 +- Synapse/Events/Patches/PlayerBanPatch.cs | 4 +-- Synapse/Events/Patches/PlayerCuffPatch.cs | 5 +-- Synapse/Events/Patches/PlayerDamagePatch.cs | 12 +++---- Synapse/Events/Patches/PlayerEscapePatch.cs | 4 +-- Synapse/Events/Patches/PlayerJoinPatch.cs | 5 +-- Synapse/Events/Patches/PlayerLeavePatch.cs | 3 +- Synapse/Events/Patches/PlayerReloadPatch.cs | 3 +- .../Patches/PocketDimensionEnterPatch.cs | 13 +++---- Synapse/Events/Patches/Scp049RecallPatch.cs | 24 ++++++------- .../Events/Patches/Scp106ContaimentPatch.cs | 3 +- Synapse/Events/Patches/SyncDataPatch.cs | 3 +- Synapse/Events/Patches/TeamRespawnPatch.cs | 7 ++-- Synapse/Events/PlayerEvents.cs | 34 ++++++++++--------- Synapse/Events/ScpEvents.cs | 7 ++-- Synapse/Events/ServerEvents.cs | 5 +-- 42 files changed, 165 insertions(+), 126 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 1fb3c98..6cb3898 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -15,6 +15,10 @@ public class Player : MonoBehaviour public ReferenceHub Hub { get => this.GetComponent(); } + public CharacterClassManager ClassManager { get => Hub.characterClassManager; } + + public PlayerEffectsController EffectsController { get => Hub.playerEffectsController; } + public string NickName { get => Hub.nicknameSync.MyNick; set => Hub.nicknameSync.MyNick = value; } public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } @@ -42,7 +46,7 @@ public Vector3 Scale } } - public Vector3 Position { get => Hub.transform.position; set => Hub.transform.position = value; } + public Vector3 Position { get => Hub.transform.position; set => Hub.playerMovementSync.OverridePosition(value,0f,true); } public RoleType Role { @@ -83,6 +87,8 @@ public Room CurRoom public NetworkConnection Connection { get => Hub.scp079PlayerScript.connectionToClient; } + public Inventory.SyncListItemInfo Items { get => Hub.inventory.items; set => Hub.inventory.items = value; } + public Player Cuffer { get => PlayerExtensions.GetPlayer(GetComponent().CufferId); } public uint Ammo5 { get => Hub.ammoBox.amount[0]; set => Hub.ammoBox.amount[0] = value; } diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 31689d8..1f5acfb 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -71,12 +71,12 @@ public static IEnumerable GetAllPlayers() { return (from gameobject in PlayerManager.players where gameobject != PlayerManager.localPlayer && gameobject != null - select gameobject.GetComponent()).ToList(); + select gameobject.GetPlayer()).ToList(); } - public static Player GetPlayer(this ReferenceHub hub) => hub.GetComponent(); + public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent(); - public static Player GetPlayer(this GameObject playerobject) => playerobject.GetComponent(); + public static Player GetPlayer(this GameObject gameObject) => gameObject.GetComponent(); public static Player GetPlayer(int id) => GetAllPlayers().FirstOrDefault(p => p.PlayerId == id); diff --git a/Synapse/Events/Classes/ConsoleCommandEvent.cs b/Synapse/Events/Classes/ConsoleCommandEvent.cs index 21e6ed9..ffbe4bd 100644 --- a/Synapse/Events/Classes/ConsoleCommandEvent.cs +++ b/Synapse/Events/Classes/ConsoleCommandEvent.cs @@ -1,11 +1,12 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class ConsoleCommandEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public string Command { get; internal set; } diff --git a/Synapse/Events/Classes/DoorInteractEvent.cs b/Synapse/Events/Classes/DoorInteractEvent.cs index b2f17f4..c43e953 100644 --- a/Synapse/Events/Classes/DoorInteractEvent.cs +++ b/Synapse/Events/Classes/DoorInteractEvent.cs @@ -1,11 +1,12 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class DoorInteractEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public bool Allow { get; set; } = true; diff --git a/Synapse/Events/Classes/DropItemEvent.cs b/Synapse/Events/Classes/DropItemEvent.cs index 8e4b9d4..1e694d2 100644 --- a/Synapse/Events/Classes/DropItemEvent.cs +++ b/Synapse/Events/Classes/DropItemEvent.cs @@ -1,8 +1,10 @@ -namespace Synapse.Events.Classes +using Synapse.Api; + +namespace Synapse.Events.Classes { public class DropItemEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public Inventory.SyncItemInfo Item { get; set; } public bool Allow { get; set; } } diff --git a/Synapse/Events/Classes/FemurEnterEvent.cs b/Synapse/Events/Classes/FemurEnterEvent.cs index 693a097..d355cd3 100644 --- a/Synapse/Events/Classes/FemurEnterEvent.cs +++ b/Synapse/Events/Classes/FemurEnterEvent.cs @@ -1,4 +1,5 @@ -using System; +using Synapse.Api; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,7 @@ namespace Synapse.Events.Classes { public class FemurEnterEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public bool Allow { get; set; } diff --git a/Synapse/Events/Classes/PlayerBanEvent.cs b/Synapse/Events/Classes/PlayerBanEvent.cs index 3060b61..4fb00e3 100644 --- a/Synapse/Events/Classes/PlayerBanEvent.cs +++ b/Synapse/Events/Classes/PlayerBanEvent.cs @@ -1,11 +1,12 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class PlayerBanEvent { - public ReferenceHub BannedPlayer { get; internal set; } + public Player BannedPlayer { get; internal set; } // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global public bool Allowed { get; set; } = true; @@ -14,7 +15,7 @@ public class PlayerBanEvent public int Duration { get; internal set; } - public ReferenceHub Issuer { get; internal set; } + public Player Issuer { get; internal set; } public string Reason { get; internal set; } } diff --git a/Synapse/Events/Classes/PlayerCuffedEvent.cs b/Synapse/Events/Classes/PlayerCuffedEvent.cs index 90b1df5..c3327a5 100644 --- a/Synapse/Events/Classes/PlayerCuffedEvent.cs +++ b/Synapse/Events/Classes/PlayerCuffedEvent.cs @@ -1,13 +1,14 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class PlayerCuffedEvent { - public ReferenceHub Cuffed { get; internal set; } + public Player Cuffed { get; internal set; } - public ReferenceHub Target { get; internal set; } + public Player Target { get; internal set; } public bool Allow { get; set; } } diff --git a/Synapse/Events/Classes/PlayerDeathEvent.cs b/Synapse/Events/Classes/PlayerDeathEvent.cs index 91dd45f..d9ae2ca 100644 --- a/Synapse/Events/Classes/PlayerDeathEvent.cs +++ b/Synapse/Events/Classes/PlayerDeathEvent.cs @@ -1,13 +1,14 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class PlayerDeathEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } - public ReferenceHub Killer { get; internal set; } + public Player Killer { get; internal set; } public PlayerStats.HitInfo Info { get; internal set; } } diff --git a/Synapse/Events/Classes/PlayerEscapeEvent.cs b/Synapse/Events/Classes/PlayerEscapeEvent.cs index 75e66ef..0f67883 100644 --- a/Synapse/Events/Classes/PlayerEscapeEvent.cs +++ b/Synapse/Events/Classes/PlayerEscapeEvent.cs @@ -1,11 +1,12 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class PlayerEscapeEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public RoleType SpawnRole { get; set; } diff --git a/Synapse/Events/Classes/PlayerHurtEvent.cs b/Synapse/Events/Classes/PlayerHurtEvent.cs index 5a3f6a3..abf2180 100644 --- a/Synapse/Events/Classes/PlayerHurtEvent.cs +++ b/Synapse/Events/Classes/PlayerHurtEvent.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { @@ -12,8 +13,8 @@ public class PlayerHurtEvent private PlayerStats.HitInfo _info; // Properties - public ReferenceHub Player { get; internal set; } - public ReferenceHub Attacker { get; internal set; } + public Player Player { get; internal set; } + public Player Attacker { get; internal set; } public PlayerStats.HitInfo Info { diff --git a/Synapse/Events/Classes/PlayerJoinEvent.cs b/Synapse/Events/Classes/PlayerJoinEvent.cs index 6b24436..2e89e6e 100644 --- a/Synapse/Events/Classes/PlayerJoinEvent.cs +++ b/Synapse/Events/Classes/PlayerJoinEvent.cs @@ -1,4 +1,5 @@ -using System; +using Synapse.Api; +using System; using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes @@ -7,14 +8,7 @@ namespace Synapse.Events.Classes [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class PlayerJoinEvent : EventArgs { - // Constructor - public PlayerJoinEvent(ReferenceHub player) - { - Player = player; - } - - // Properties - public ReferenceHub Player { get; } + public Player Player { get; internal set; } public string Nick { get; set; } } diff --git a/Synapse/Events/Classes/PlayerLeaveEvent.cs b/Synapse/Events/Classes/PlayerLeaveEvent.cs index 4140a12..c119704 100644 --- a/Synapse/Events/Classes/PlayerLeaveEvent.cs +++ b/Synapse/Events/Classes/PlayerLeaveEvent.cs @@ -1,10 +1,11 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class PlayerLeaveEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } } } \ No newline at end of file diff --git a/Synapse/Events/Classes/PlayerReloadEvent.cs b/Synapse/Events/Classes/PlayerReloadEvent.cs index 169c5f4..52d0f48 100644 --- a/Synapse/Events/Classes/PlayerReloadEvent.cs +++ b/Synapse/Events/Classes/PlayerReloadEvent.cs @@ -1,8 +1,10 @@ -namespace Synapse.Events.Classes +using Synapse.Api; + +namespace Synapse.Events.Classes { public class PlayerReloadEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public bool Allow { get; set; } diff --git a/Synapse/Events/Classes/PocketDimensionEvent.cs b/Synapse/Events/Classes/PocketDimensionEvent.cs index 896fdd9..c9084e3 100644 --- a/Synapse/Events/Classes/PocketDimensionEvent.cs +++ b/Synapse/Events/Classes/PocketDimensionEvent.cs @@ -1,8 +1,10 @@ -namespace Synapse.Events.Classes +using Synapse.Api; + +namespace Synapse.Events.Classes { public class PocketDimensionEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public bool Allow { get; set; } } } \ No newline at end of file diff --git a/Synapse/Events/Classes/Scp049RecallEvent.cs b/Synapse/Events/Classes/Scp049RecallEvent.cs index 732813f..ea58466 100644 --- a/Synapse/Events/Classes/Scp049RecallEvent.cs +++ b/Synapse/Events/Classes/Scp049RecallEvent.cs @@ -1,13 +1,14 @@ -using System; +using Synapse.Api; +using System; namespace Synapse.Events.Classes { public class Scp049RecallEvent : EventArgs { // ReSharper disable once UnusedAutoPropertyAccessor.Global - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } - public ReferenceHub Target { get; set; } + public Player Target { get; set; } public bool Allow { get; set; } diff --git a/Synapse/Events/Classes/Scp106ContainmentEvent.cs b/Synapse/Events/Classes/Scp106ContainmentEvent.cs index 25d0e0c..6f4f476 100644 --- a/Synapse/Events/Classes/Scp106ContainmentEvent.cs +++ b/Synapse/Events/Classes/Scp106ContainmentEvent.cs @@ -1,8 +1,10 @@ -namespace Synapse.Events.Classes +using Synapse.Api; + +namespace Synapse.Events.Classes { public class Scp106ContainmentEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public bool Allow { get; set; } } } \ No newline at end of file diff --git a/Synapse/Events/Classes/SpeakEventEvent.cs b/Synapse/Events/Classes/SpeakEventEvent.cs index 96056fb..ab79c50 100644 --- a/Synapse/Events/Classes/SpeakEventEvent.cs +++ b/Synapse/Events/Classes/SpeakEventEvent.cs @@ -1,13 +1,14 @@ using System; using System.Diagnostics.CodeAnalysis; using Assets._Scripts.Dissonance; +using Synapse.Api; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class SpeakEventEvent : EventArgs { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public DissonanceUserSetup DissonanceUserSetup { get; internal set; } diff --git a/Synapse/Events/Classes/SyncDataEvent.cs b/Synapse/Events/Classes/SyncDataEvent.cs index 975c552..aae1345 100644 --- a/Synapse/Events/Classes/SyncDataEvent.cs +++ b/Synapse/Events/Classes/SyncDataEvent.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; using UnityEngine; namespace Synapse.Events.Classes @@ -6,7 +7,7 @@ namespace Synapse.Events.Classes [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class SyncDataEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public int State { get; internal set; } diff --git a/Synapse/Events/Classes/TeamRespawnEvent.cs b/Synapse/Events/Classes/TeamRespawnEvent.cs index fca45eb..d82509a 100644 --- a/Synapse/Events/Classes/TeamRespawnEvent.cs +++ b/Synapse/Events/Classes/TeamRespawnEvent.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Synapse.Api; +using System.Collections.Generic; namespace Synapse.Events.Classes { @@ -6,7 +7,7 @@ public class TeamRespawnEvent { public bool IsChaos { get; set; } - public List RespawnList { get; set; } + public List RespawnList { get; set; } public bool Allow { get; set; } diff --git a/Synapse/Events/Classes/TeslaTriggerEvent.cs b/Synapse/Events/Classes/TeslaTriggerEvent.cs index 8a351bd..95dfa71 100644 --- a/Synapse/Events/Classes/TeslaTriggerEvent.cs +++ b/Synapse/Events/Classes/TeslaTriggerEvent.cs @@ -1,11 +1,12 @@ -using System.Diagnostics.CodeAnalysis; +using Synapse.Api; +using System.Diagnostics.CodeAnalysis; namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class TeslaTriggerEvent { - public ReferenceHub Player { get; internal set; } + public Player Player { get; internal set; } public bool IsHurtRange { get; internal set; } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 97f4836..3700df0 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -34,9 +34,9 @@ private void OnDoorInteract(ref DoorInteractEvent ev) { if (ev.Allow) return; - foreach (var item in ev.Player.inventory.items) + foreach (var item in ev.Player.Items) { - if (ev.Player.inventory.GetItemByID(item.id).permissions.Contains(ev.Door.permissionLevel))//update to backwardsCompatPermissions when neccesary + if (ev.Player.Hub.inventory.GetItemByID(item.id).permissions.Contains(ev.Door.permissionLevel))//update to backwardsCompatPermissions when neccesary { ev.Allow = true; return; @@ -48,10 +48,10 @@ private void OnDoorInteract(ref DoorInteractEvent ev) // Methods private static void OnSyncData(ref SyncDataEvent ev) { - if (ev.Player.GetPlayer().Role != RoleType.ClassD && - ev.Player.GetPlayer().Role != RoleType.Scientist && - !(Vector3.Distance(ev.Player.GetPlayer().Position, ev.Player.GetComponent().worldPosition) >= Escape.radius)) - ev.Player.characterClassManager.CmdRegisterEscape(); + if (ev.Player.Role != RoleType.ClassD && + ev.Player.Role != RoleType.Scientist && + !(Vector3.Distance(ev.Player.Position, ev.Player.GetComponent().worldPosition) >= Escape.radius)) + ev.Player.Hub.characterClassManager.CmdRegisterEscape(); } private static void OnRemoteCommand(ref RemoteCommandEvent ev) diff --git a/Synapse/Events/MapEvents.cs b/Synapse/Events/MapEvents.cs index bdbe0c2..3626f23 100644 --- a/Synapse/Events/MapEvents.cs +++ b/Synapse/Events/MapEvents.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Synapse.Api; using Synapse.Events.Classes; using UnityEngine; @@ -12,7 +13,7 @@ public static partial class Events public static event OnDoorInteract DoorInteractEvent; - internal static void InvokeDoorInteraction(ReferenceHub player, Door door, ref bool allow) + internal static void InvokeDoorInteraction(Player player, Door door, ref bool allow) { if (DoorInteractEvent == null) return; @@ -31,13 +32,13 @@ internal static void InvokeDoorInteraction(ReferenceHub player, Door door, ref b public delegate void OnTriggerTesla(ref TeslaTriggerEvent ev); public static event OnTriggerTesla TeslaTriggerEvent; - internal static void InvokeTeslaTrigger(GameObject player, bool inRange, ref bool activated) + internal static void InvokeTeslaTrigger(Player player, bool inRange, ref bool activated) { if (TeslaTriggerEvent == null) return; var ev = new TeslaTriggerEvent { - Player = player.GetComponent(), + Player = player, IsHurtRange = inRange, Triggerable = activated }; diff --git a/Synapse/Events/Patches/ConsoleCommandPatch.cs b/Synapse/Events/Patches/ConsoleCommandPatch.cs index d0b8c15..8f69e6a 100644 --- a/Synapse/Events/Patches/ConsoleCommandPatch.cs +++ b/Synapse/Events/Patches/ConsoleCommandPatch.cs @@ -1,6 +1,7 @@ using System; using Harmony; using RemoteAdmin; +using Synapse.Api; namespace Synapse.Events.Patches { @@ -12,7 +13,7 @@ public static bool Prefix(QueryProcessor __instance, ref string query, bool encr { try { - Events.InvokeConsoleCommandEvent(__instance.GetComponent(), query, out var color, + Events.InvokeConsoleCommandEvent(__instance.GetPlayer(), query, out var color, out var returning); if (string.IsNullOrEmpty(color)) diff --git a/Synapse/Events/Patches/DoorInteractPatch.cs b/Synapse/Events/Patches/DoorInteractPatch.cs index daf4725..6c809ef 100644 --- a/Synapse/Events/Patches/DoorInteractPatch.cs +++ b/Synapse/Events/Patches/DoorInteractPatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; using UnityEngine; namespace Synapse.Events.Patches @@ -13,7 +14,7 @@ public static bool Prefix(PlayerInteract __instance, GameObject doorId) { var allowed = true; var door = doorId.GetComponent(); - var player = __instance.gameObject.GetComponent(); + var player = __instance.GetPlayer(); Events.InvokeDoorInteraction(player, door, ref allowed); diff --git a/Synapse/Events/Patches/DropItemPatch.cs b/Synapse/Events/Patches/DropItemPatch.cs index e5f5c2a..6e8239b 100644 --- a/Synapse/Events/Patches/DropItemPatch.cs +++ b/Synapse/Events/Patches/DropItemPatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; namespace Synapse.Events.Patches { @@ -19,7 +20,7 @@ public static bool Prefix(Inventory __instance, int itemInventoryIndex) var allow = true; - Events.InvokeDropItem(__instance.gameObject, ref syncItemInfo, ref allow); + Events.InvokeDropItem(__instance.GetPlayer(), ref syncItemInfo, ref allow); if (!allow) return false; diff --git a/Synapse/Events/Patches/FemurEnterPatch.cs b/Synapse/Events/Patches/FemurEnterPatch.cs index 6ccd549..751e41a 100644 --- a/Synapse/Events/Patches/FemurEnterPatch.cs +++ b/Synapse/Events/Patches/FemurEnterPatch.cs @@ -1,6 +1,7 @@ using System; using Harmony; using Mirror; +using Synapse.Api; using UnityEngine; namespace Synapse.Events.Patches @@ -28,7 +29,7 @@ public static bool Prefix(CharacterClassManager __instance) var allow = component.CurRole.team != Team.SCP; var CloseFemur = femurBrokePeople + 1 >= Configs.requiredforFemur; - var player = __instance.GetComponent(); + var player = __instance.GetPlayer(); Events.InvokeFemurEnterEvent(player, ref allow, ref CloseFemur); diff --git a/Synapse/Events/Patches/PlayerBanPatch.cs b/Synapse/Events/Patches/PlayerBanPatch.cs index c1f65de..b668550 100644 --- a/Synapse/Events/Patches/PlayerBanPatch.cs +++ b/Synapse/Events/Patches/PlayerBanPatch.cs @@ -14,10 +14,10 @@ public static bool Prefix(GameObject user, int duration, string reason, string i { try { - var player = user.GetComponent(); + var player = user.GetPlayer(); var banIssuer = PlayerExtensions.GetPlayer(issuer); var allow = true; - Events.InvokePlayerBanEvent(player, player.GetPlayer().UserID, duration, ref allow, reason, banIssuer.Hub); + Events.InvokePlayerBanEvent(player, player.UserID, duration, ref allow, reason, banIssuer); return isGlobalBan && ConfigFile.ServerConfig.GetBool("gban_ban_ip") || allow; } diff --git a/Synapse/Events/Patches/PlayerCuffPatch.cs b/Synapse/Events/Patches/PlayerCuffPatch.cs index 3e014b4..9b4d029 100644 --- a/Synapse/Events/Patches/PlayerCuffPatch.cs +++ b/Synapse/Events/Patches/PlayerCuffPatch.cs @@ -1,6 +1,7 @@ using System; using GameCore; using Harmony; +using Synapse.Api; using UnityEngine; // ReSharper disable SwitchStatementMissingSomeEnumCasesNoDefault @@ -78,8 +79,8 @@ public static bool Prefix(Handcuffs __instance, GameObject target) } //Event - var cuffer = __instance.MyReferenceHub; - var target2 = handcuffs.MyReferenceHub; + var cuffer = __instance.GetPlayer(); + var target2 = handcuffs.GetPlayer(); Events.InvokePlayerCuffedEvent(cuffer, target2, ref flag); if (!flag) return false; diff --git a/Synapse/Events/Patches/PlayerDamagePatch.cs b/Synapse/Events/Patches/PlayerDamagePatch.cs index bd66f86..15d96fb 100644 --- a/Synapse/Events/Patches/PlayerDamagePatch.cs +++ b/Synapse/Events/Patches/PlayerDamagePatch.cs @@ -14,12 +14,12 @@ public static void Prefix(PlayerStats __instance, ref PlayerStats.HitInfo info, { if (go == null) return; - var killer = __instance.GetComponent(); + var killer = __instance.GetPlayer(); if (info.GetDamageType() == DamageTypes.Grenade) - killer = PlayerExtensions.GetPlayer(info.PlayerId).Hub; + killer = PlayerExtensions.GetPlayer(info.PlayerId); - var player = go.GetComponent(); + var player = go.GetPlayer(); Events.InvokePlayerHurtEvent(player, killer, ref info); } @@ -33,10 +33,10 @@ public static void Postfix(PlayerStats __instance, PlayerStats.HitInfo info, Gam { try { - var killer = __instance.GetComponent(); - var player = go.GetComponent(); + var killer = __instance.GetPlayer(); + var player = go.GetPlayer(); - if (player.GetPlayer().Role == RoleType.Spectator) + if (player.Role == RoleType.Spectator) Events.InvokePlayerDieEvent(player, killer, info); } catch (Exception e) diff --git a/Synapse/Events/Patches/PlayerEscapePatch.cs b/Synapse/Events/Patches/PlayerEscapePatch.cs index bc4a30e..3fcd710 100644 --- a/Synapse/Events/Patches/PlayerEscapePatch.cs +++ b/Synapse/Events/Patches/PlayerEscapePatch.cs @@ -23,8 +23,8 @@ public static bool Prefix(CharacterClassManager __instance) Escape.radius * 2) return false; //Event vars - var player = __instance.GetComponent(); - var spawnRole = player.GetPlayer().Role; + var player = __instance.GetPlayer(); + var spawnRole = player.Role; var cufferRole = RoleType.None; var allow = true; var isCuffed = false; diff --git a/Synapse/Events/Patches/PlayerJoinPatch.cs b/Synapse/Events/Patches/PlayerJoinPatch.cs index 84cd1ac..b77f713 100644 --- a/Synapse/Events/Patches/PlayerJoinPatch.cs +++ b/Synapse/Events/Patches/PlayerJoinPatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; namespace Synapse.Events.Patches { @@ -11,9 +12,9 @@ public static bool Prefix(NicknameSync __instance, ref string n) { try { - var player = __instance.GetComponent(); + var player = __instance.GetPlayer(); - if (!string.IsNullOrEmpty(player.characterClassManager.UserId)) + if (!string.IsNullOrEmpty(player.UserID)) Events.InvokePlayerJoinEvent(player, ref n); } catch (Exception e) diff --git a/Synapse/Events/Patches/PlayerLeavePatch.cs b/Synapse/Events/Patches/PlayerLeavePatch.cs index 30685d8..2f72f98 100644 --- a/Synapse/Events/Patches/PlayerLeavePatch.cs +++ b/Synapse/Events/Patches/PlayerLeavePatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; namespace Synapse.Events.Patches { @@ -11,7 +12,7 @@ public static bool Prefix(ReferenceHub __instance) { try { - Events.InvokePlayerLeaveEvent(__instance); + Events.InvokePlayerLeaveEvent(__instance.GetPlayer()); } catch (Exception e) { diff --git a/Synapse/Events/Patches/PlayerReloadPatch.cs b/Synapse/Events/Patches/PlayerReloadPatch.cs index 2b98f8e..7d984fd 100644 --- a/Synapse/Events/Patches/PlayerReloadPatch.cs +++ b/Synapse/Events/Patches/PlayerReloadPatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; namespace Synapse.Events.Patches { @@ -16,7 +17,7 @@ public static bool Prefix(WeaponManager __instance) var itemIndex = __instance.hub.inventory.GetItemIndex(); var weapon = __instance.weapons[__instance._reloadingWeapon]; var inventoryslot = __instance.hub.inventory.items[itemIndex]; - var player = __instance.hub; + var player = __instance.hub.GetPlayer(); if (itemIndex < 0 || itemIndex >= __instance.hub.inventory.items.Count) return false; if (__instance.curWeapon < 0 || __instance.hub.inventory.curItem != __instance.weapons[__instance.curWeapon].inventoryID) return false; diff --git a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs index 18e2015..239757a 100644 --- a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs +++ b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs @@ -2,6 +2,7 @@ using System.Runtime.CompilerServices; using CustomPlayerEffects; using Harmony; +using Synapse.Api; using UnityEngine; namespace Synapse.Events.Patches @@ -16,8 +17,8 @@ public static bool Prefix(Scp106PlayerScript __instance, GameObject ply, int t) if (!__instance._iawRateLimit.CanExecute()) return false; if (ply == null) return false; - var player = ply.GetComponent(); - var charClassManager = player.characterClassManager; + var player = ply.GetPlayer(); + var charClassManager = player.ClassManager; if (charClassManager == null || charClassManager.GodMode || charClassManager.IsAnyScp()) return false; @@ -48,10 +49,10 @@ public static bool Prefix(Scp106PlayerScript __instance, GameObject ply, int t) new PlayerStats.HitInfo(40f, $"{__instance.GetComponent().MyNick} ({__instance.hub.characterClassManager.UserId})", DamageTypes.Scp106, __instance.GetComponent().PlayerId), ply); - - player.playerMovementSync.OverridePosition(Vector3.down * 1998.5f, 0f, true); - player.playerEffectsController.GetEffect().IsInPd = true; - player.playerEffectsController.EnableEffect(); + + player.Position = Vector3.down * 1998.5f; + player.EffectsController.GetEffect().IsInPd = true; + player.EffectsController.EnableEffect(); return false; } diff --git a/Synapse/Events/Patches/Scp049RecallPatch.cs b/Synapse/Events/Patches/Scp049RecallPatch.cs index 65d07f3..9afc40d 100644 --- a/Synapse/Events/Patches/Scp049RecallPatch.cs +++ b/Synapse/Events/Patches/Scp049RecallPatch.cs @@ -40,9 +40,9 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) if (go == null) return false; var component = go.GetComponent(); if (component == null) return false; - var referenceHub = PlayerManager.players.Select(ReferenceHub.GetHub) - .FirstOrDefault(hub => hub.queryProcessor.PlayerId == component.owner.PlayerId); - if (referenceHub == null) + var target = PlayerManager.players.Select(ReferenceHub.GetHub) + .FirstOrDefault(hub => hub.queryProcessor.PlayerId == component.owner.PlayerId).GetPlayer(); + if (target == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant); @@ -50,7 +50,7 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) } if (!__instance._recallInProgressServer || - referenceHub.gameObject != __instance._recallObjectServer || + target.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", @@ -61,9 +61,9 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) : "ERROR - " + __instance._recallInProgressServer), MessageImportance.LessImportant, true); Console.AddDebugLog("SCPCTRL", - "SCP-049 | CONDITION#2 " + (referenceHub == __instance._recallObjectServer + "SCP-049 | CONDITION#2 " + (target == __instance._recallObjectServer ? "PASSED" - : string.Concat("ERROR - ", referenceHub.queryProcessor.PlayerId, + : string.Concat("ERROR - ", target.PlayerId, "-", __instance._recallObjectServer == null ? "null" @@ -77,13 +77,13 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) return false; } - if (referenceHub.characterClassManager.CurClass != RoleType.Spectator) return false; + if (target.Hub.characterClassManager.CurClass != RoleType.Spectator) return false; //Event var allow = true; var role = RoleType.Scp0492; - float live = referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; - Events.InvokeScp049RecallEvent(__instance.Hub, ref component, ref referenceHub, ref allow, ref role, + float live = target.Hub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; + Events.InvokeScp049RecallEvent(__instance.Hub.GetPlayer(), ref component, ref target, ref allow, ref role, ref live); Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", @@ -92,9 +92,9 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) var pos3 = component.transform.position; pos3.y += 2; - referenceHub.GetPlayer().ChangeRoleAtPosition(role); - Timing.CallDelayed(0.5f, () => referenceHub.GetPlayer().Position = pos3); - referenceHub.GetComponent().Health = live; + target.ChangeRoleAtPosition(role); + Timing.CallDelayed(0.5f, () => target.Position = pos3); + target.GetComponent().Health = live; if (component.CompareTag("Ragdoll")) NetworkServer.Destroy(component.gameObject); __instance._recallInProgressServer = false; __instance._recallObjectServer = null; diff --git a/Synapse/Events/Patches/Scp106ContaimentPatch.cs b/Synapse/Events/Patches/Scp106ContaimentPatch.cs index 34aa401..13a4176 100644 --- a/Synapse/Events/Patches/Scp106ContaimentPatch.cs +++ b/Synapse/Events/Patches/Scp106ContaimentPatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; namespace Synapse.Events.Patches { @@ -11,7 +12,7 @@ public static bool Prefix(PlayerInteract __instance) try { var allow = true; - Events.InvokeScp106ContaimentEvent(__instance.gameObject.GetComponent(), ref allow); + Events.InvokeScp106ContaimentEvent(__instance.GetPlayer(), ref allow); return allow; } diff --git a/Synapse/Events/Patches/SyncDataPatch.cs b/Synapse/Events/Patches/SyncDataPatch.cs index 812a445..8f33801 100644 --- a/Synapse/Events/Patches/SyncDataPatch.cs +++ b/Synapse/Events/Patches/SyncDataPatch.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; using UnityEngine; namespace Synapse.Events.Patches @@ -13,7 +14,7 @@ public static bool Prefix(AnimationController __instance, int state, ref Vector2 { var allow = true; - Events.InvokeSyncDataEvent(__instance.gameObject, ref allow, ref v2, state); + Events.InvokeSyncDataEvent(__instance.GetPlayer(), ref allow, ref v2, state); return allow; } diff --git a/Synapse/Events/Patches/TeamRespawnPatch.cs b/Synapse/Events/Patches/TeamRespawnPatch.cs index 361c30b..9ca6ef2 100644 --- a/Synapse/Events/Patches/TeamRespawnPatch.cs +++ b/Synapse/Events/Patches/TeamRespawnPatch.cs @@ -3,6 +3,7 @@ using System.Linq; using GameCore; using Harmony; +using Synapse.Api; using UnityEngine; namespace Synapse.Events.Patches @@ -44,17 +45,17 @@ public static bool Prefix(MTFRespawn __instance) //Event var allow = true; - var respawnlist = new List(); + var respawnlist = new List(); var usetickets = true; foreach (GameObject player in list) - respawnlist.Add(player.GetComponent()); + respawnlist.Add(player.GetPlayer()); Events.InvokeTeamRespawnEvent(ref respawnlist,ref __instance.nextWaveIsCI,ref allow,ref usetickets); if (!allow) return false; list.Clear(); - foreach (ReferenceHub hub in respawnlist) + foreach (Player hub in respawnlist) list.Add(hub.gameObject); if (usetickets) __instance.NextWaveRespawnTickets -= num2 - list.Count; diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 4449b66..dd7f5bf 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Assets._Scripts.Dissonance; +using Synapse.Api; using Synapse.Events.Classes; using UnityEngine; @@ -13,11 +14,12 @@ public static partial class Events public delegate void OnPlayerJoin(ref PlayerJoinEvent ev); public static event OnPlayerJoin PlayerJoinEvent; - internal static void InvokePlayerJoinEvent(ReferenceHub player, ref string nick) + internal static void InvokePlayerJoinEvent(Player player, ref string nick) { if (PlayerJoinEvent == null) return; - var ev = new PlayerJoinEvent(player) + var ev = new PlayerJoinEvent() { + Player = player, Nick = nick }; @@ -43,7 +45,7 @@ internal static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool i ScpChat = scpChat, SpectatorChat = spectator, DissonanceUserSetup = dissonance, - Player = dissonance.gameObject.GetComponent() + Player = dissonance.gameObject.GetPlayer() }; SpeakEvent.Invoke(ref ev); @@ -61,7 +63,7 @@ internal static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool i public delegate void OnPlayerLeave(PlayerLeaveEvent ev); public static event OnPlayerLeave PlayerLeaveEvent; - internal static void InvokePlayerLeaveEvent(ReferenceHub player) + internal static void InvokePlayerLeaveEvent(Player player) { if (PlayerLeaveEvent == null) return; @@ -76,8 +78,8 @@ internal static void InvokePlayerLeaveEvent(ReferenceHub player) public delegate void OnPlayerBanEvent(ref PlayerBanEvent ev); public static event OnPlayerBanEvent PlayerBanEvent; - internal static void InvokePlayerBanEvent(ReferenceHub player, string userId, int duration, ref bool allow, - string reason, ReferenceHub issuer) + internal static void InvokePlayerBanEvent(Player player, string userId, int duration, ref bool allow, + string reason, Player issuer) { if (PlayerBanEvent == null) return; @@ -99,7 +101,7 @@ internal static void InvokePlayerBanEvent(ReferenceHub player, string userId, in public delegate void OnPlayerDeath(PlayerDeathEvent ev); public static event OnPlayerDeath PlayerDeathEvent; - internal static void InvokePlayerDieEvent(ReferenceHub player, ReferenceHub killer, PlayerStats.HitInfo infos) + internal static void InvokePlayerDieEvent(Player player, Player killer, PlayerStats.HitInfo infos) { if (PlayerDeathEvent == null) return; @@ -117,7 +119,7 @@ internal static void InvokePlayerDieEvent(ReferenceHub player, ReferenceHub kill public delegate void OnPlayerHurt(ref PlayerHurtEvent ev); public static event OnPlayerHurt PlayerHurtEvent; - internal static void InvokePlayerHurtEvent(ReferenceHub player, ReferenceHub attacker, + internal static void InvokePlayerHurtEvent(Player player, Player attacker, ref PlayerStats.HitInfo info) { if (PlayerHurtEvent == null) return; @@ -138,7 +140,7 @@ internal static void InvokePlayerHurtEvent(ReferenceHub player, ReferenceHub att public delegate void OnPlayerCuffed(ref PlayerCuffedEvent ev); public static event OnPlayerCuffed PlayerCuffedEvent; - internal static void InvokePlayerCuffedEvent(ReferenceHub cuffed, ReferenceHub target, ref bool allow) + internal static void InvokePlayerCuffedEvent(Player cuffed, Player target, ref bool allow) { if (PlayerCuffedEvent == null) return; @@ -158,7 +160,7 @@ internal static void InvokePlayerCuffedEvent(ReferenceHub cuffed, ReferenceHub t public delegate void OnPlayerEscape(ref PlayerEscapeEvent ev); public static event OnPlayerEscape PlayerEscapeEvent; - internal static void InvokePlayerEscapeEvent(ReferenceHub player, ref bool allow, ref RoleType spawnRole, + internal static void InvokePlayerEscapeEvent(Player player, ref bool allow, ref RoleType spawnRole, RoleType cuffedRole, bool isCuffed) { if (PlayerEscapeEvent == null) return; @@ -182,14 +184,14 @@ internal static void InvokePlayerEscapeEvent(ReferenceHub player, ref bool allow public delegate void OnSyncDataEvent(ref SyncDataEvent ev); public static event OnSyncDataEvent SyncDataEvent; - internal static void InvokeSyncDataEvent(GameObject player, ref bool allow, ref Vector2 speed, int state) + internal static void InvokeSyncDataEvent(Player player, ref bool allow, ref Vector2 speed, int state) { if (SyncDataEvent == null) return; var ev = new SyncDataEvent { Allow = allow, - Player = player.GetComponent(), + Player = player, Speed = speed, State = state }; @@ -204,7 +206,7 @@ internal static void InvokeSyncDataEvent(GameObject player, ref bool allow, ref public delegate void OnPlayerReload(ref PlayerReloadEvent ev); public static event OnPlayerReload PlayerReloadEvent; - internal static void InvokePlayerReloadEvent(ReferenceHub player,ref bool allow,ref WeaponManager.Weapon weapon,Inventory.SyncItemInfo syncItem) + internal static void InvokePlayerReloadEvent(Player player,ref bool allow,ref WeaponManager.Weapon weapon,Inventory.SyncItemInfo syncItem) { if (PlayerReloadEvent == null) return; @@ -226,7 +228,7 @@ internal static void InvokePlayerReloadEvent(ReferenceHub player,ref bool allow, public delegate void OnFemurEnter(ref FemurEnterEvent ev); public static event OnFemurEnter FemurEnterEvent; - internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow,ref bool closeFemur) + internal static void InvokeFemurEnterEvent(Player player,ref bool allow,ref bool closeFemur) { if (FemurEnterEvent == null) return; @@ -246,13 +248,13 @@ internal static void InvokeFemurEnterEvent(ReferenceHub player,ref bool allow,re public delegate void OnDropItem(ref DropItemEvent ev); public static event OnDropItem DropItemEvent; - public static void InvokeDropItem(GameObject player, ref Inventory.SyncItemInfo item, ref bool allow) + public static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo item, ref bool allow) { if (DropItemEvent == null) return; DropItemEvent ev = new DropItemEvent() { - Player = player.GetComponent(), + Player = player, Item = item, Allow = allow }; diff --git a/Synapse/Events/ScpEvents.cs b/Synapse/Events/ScpEvents.cs index 26674ad..3d24556 100644 --- a/Synapse/Events/ScpEvents.cs +++ b/Synapse/Events/ScpEvents.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Synapse.Api; using Synapse.Events.Classes; namespace Synapse.Events @@ -9,7 +10,7 @@ public static partial class Events public delegate void OnScp049Recall(ref Scp049RecallEvent ev); public static event OnScp049Recall Scp049RecallEvent; - internal static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ragdoll, ref ReferenceHub target, + internal static void InvokeScp049RecallEvent(Player player, ref Ragdoll ragdoll, ref Player target, ref bool allow, ref RoleType role, ref float lives) { if (Scp049RecallEvent == null) return; @@ -36,7 +37,7 @@ internal static void InvokeScp049RecallEvent(ReferenceHub player, ref Ragdoll ra public delegate void OnPocketDimensionEnter(ref PocketDimensionEvent ev); public static event OnPocketDimensionEnter PocketDimensionEnterEvent; - internal static void InvokePocketDimensionEnterEvent(ReferenceHub player, ref bool allow) + internal static void InvokePocketDimensionEnterEvent(Player player, ref bool allow) { if (PocketDimensionEnterEvent == null) return; @@ -54,7 +55,7 @@ internal static void InvokePocketDimensionEnterEvent(ReferenceHub player, ref bo public delegate void OnScp106Containment(ref Scp106ContainmentEvent ev); public static event OnScp106Containment Scp106ContaimentEvent; - internal static void InvokeScp106ContaimentEvent(ReferenceHub player, ref bool allow) + internal static void InvokeScp106ContaimentEvent(Player player, ref bool allow) { if (Scp106ContaimentEvent == null) return; diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index a85de44..e1b0cc2 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using LiteNetLib; +using Synapse.Api; using Synapse.Events.Classes; namespace Synapse.Events @@ -60,7 +61,7 @@ internal static void InvokeRemoteCommandEvent(CommandSender sender, string comma public delegate void OnConsoleCommand(ref ConsoleCommandEvent ev); public static event OnConsoleCommand ConsoleCommandEvent; - internal static void InvokeConsoleCommandEvent(ReferenceHub player, string command, out string color, + internal static void InvokeConsoleCommandEvent(Player player, string command, out string color, out string returning) { color = "red"; @@ -82,7 +83,7 @@ internal static void InvokeConsoleCommandEvent(ReferenceHub player, string comma public delegate void TeamRespawn(ref TeamRespawnEvent ev); public static event TeamRespawn TeamRespawnEvent; - internal static void InvokeTeamRespawnEvent(ref List respawnlist, ref bool ischaos, ref bool allow ,ref bool useticktes) + internal static void InvokeTeamRespawnEvent(ref List respawnlist, ref bool ischaos, ref bool allow ,ref bool useticktes) { if (TeamRespawnEvent == null) return; From a2ae6cdf07c2192f8b1c98db3bd1cf7e19d37aec Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 21:17:13 +0200 Subject: [PATCH 112/199] added Health to the Api --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 6cb3898..8738cc5 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -48,6 +48,8 @@ public Vector3 Scale public Vector3 Position { get => Hub.transform.position; set => Hub.playerMovementSync.OverridePosition(value,0f,true); } + public float Health { get => Hub.playerStats.Health; set => Hub.playerStats.Health = value; } + public RoleType Role { get => Hub.characterClassManager.NetworkCurClass; From 13be9dd9474d4ea7ef50a8696dbc7722ac08c3fd Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 21:21:35 +0200 Subject: [PATCH 113/199] added Bypass --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 8738cc5..e3b92df 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -27,6 +27,8 @@ public class Player : MonoBehaviour public bool OverWatch { get => Hub.serverRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } + public bool Bypass { get => Hub.serverRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } + public Vector3 Scale { get => Hub.transform.localScale; From 2a970ee4520978e02c823a82952fdc4261350ff1 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 21:36:08 +0200 Subject: [PATCH 114/199] added Rank and Rotation to the Api --- Synapse/Api/Player.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index e3b92df..facfb10 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using Hints; using Mirror; @@ -48,7 +47,11 @@ public Vector3 Scale } } - public Vector3 Position { get => Hub.transform.position; set => Hub.playerMovementSync.OverridePosition(value,0f,true); } + public Vector3 Position { get => Hub.playerMovementSync.transform.position; set => Hub.playerMovementSync.OverridePosition(value,0f,true); } + + public Vector3 RotationVector { get => ClassManager._plyCam.transform.forward; set => ClassManager._plyCam.transform.forward = value; } + + public Vector2 Rotation { get => Hub.playerMovementSync.RotationSync; set => Hub.playerMovementSync.RotationSync = value; } public float Health { get => Hub.playerStats.Health; set => Hub.playerStats.Health = value; } @@ -101,6 +104,19 @@ public Room CurRoom public uint Ammo9 { get => Hub.ammoBox.amount[2]; set => Hub.ammoBox.amount[2] = value; } + public UserGroup Rank + { + get => Hub.serverRoles.Group; + set + { + Hub.serverRoles.SetGroup(value, false, false, false); + } + } + + public string RankColor { get => Rank.BadgeColor; set => Hub.serverRoles.SetColor(value); } + + public string RankName { get => Rank.BadgeText; set => Hub.serverRoles.SetText(value); } + public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); @@ -140,5 +156,7 @@ public void InstantBroadcast(ushort time, string message) ClearBroadcasts(); GetComponent().TargetAddElement(Connection, message, time, new Broadcast.BroadcastFlags()); } + + public void SendConsoleMessage(string message, string color) => ClassManager.TargetConsolePrint(Connection, message, color); } } From e7e9d1c71debafead1e042a33ca69059e6f37d8a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 12 Jun 2020 21:51:52 +0200 Subject: [PATCH 115/199] added more stuff to the api --- Synapse/Api/Player.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index facfb10..ee437f7 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -28,6 +28,8 @@ public class Player : MonoBehaviour public bool Bypass { get => Hub.serverRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } + public bool GodMode { get => ClassManager.GodMode; set => ClassManager.GodMode = value; } + public Vector3 Scale { get => Hub.transform.localScale; @@ -55,6 +57,12 @@ public Vector3 Scale public float Health { get => Hub.playerStats.Health; set => Hub.playerStats.Health = value; } + public int MaxHealth { get => Hub.playerStats.maxHP; set => Hub.playerStats.maxHP = value; } + + public float ArtificialHealth { get => Hub.playerStats.unsyncedArtificialHealth; set => Hub.playerStats.unsyncedArtificialHealth = value; } + + public int MaxArtificialHealth { get => Hub.playerStats.maxArtificialHealth; set => Hub.playerStats.maxArtificialHealth = value; } + public RoleType Role { get => Hub.characterClassManager.NetworkCurClass; @@ -117,6 +125,10 @@ public UserGroup Rank public string RankName { get => Rank.BadgeText; set => Hub.serverRoles.SetText(value); } + public bool IsMuted { get => ClassManager.NetworkMuted; set => ClassManager.NetworkMuted = value; } + + public bool IsIntercomMuted { get => ClassManager.NetworkIntercomMuted; set => ClassManager.NetworkIntercomMuted = value; } + public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); @@ -158,5 +170,11 @@ public void InstantBroadcast(ushort time, string message) } public void SendConsoleMessage(string message, string color) => ClassManager.TargetConsolePrint(Connection, message, color); + + public void HideTag() => ClassManager.CallCmdRequestHideTag(); + + public void ShowTag(bool global = false) => ClassManager.CallCmdRequestShowTag(global); + + public void GiveItem(ItemType itemType, float duration = float.NegativeInfinity, int sight = 0, int barrel = 0, int other = 0) => Hub.inventory.AddNewItem(itemType, duration, sight, barrel, other); } } From 4a898e790a740f827923e57a41d248b17b58144d Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:16:08 +0200 Subject: [PATCH 116/199] added LoadComponents event for easier adding components to Player --- Synapse/Api/Player.cs | 2 +- Synapse/Events/Classes/LoadComponentsEvent.cs | 9 +++++++++ Synapse/Events/Patches/ComponentsPatch.cs | 2 ++ Synapse/Events/PlayerEvents.cs | 11 ++++++++++- Synapse/Synapse.csproj | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 Synapse/Events/Classes/LoadComponentsEvent.cs diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index ee437f7..4c2a439 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -97,7 +97,7 @@ public Room CurRoom Transform = transform }; } - set => Position = Map.Rooms.FirstOrDefault(x => x == value).Position; + set => Position = value.Position; } public NetworkConnection Connection { get => Hub.scp079PlayerScript.connectionToClient; } diff --git a/Synapse/Events/Classes/LoadComponentsEvent.cs b/Synapse/Events/Classes/LoadComponentsEvent.cs new file mode 100644 index 0000000..77aa51b --- /dev/null +++ b/Synapse/Events/Classes/LoadComponentsEvent.cs @@ -0,0 +1,9 @@ +using Synapse.Api; + +namespace Synapse.Events.Classes +{ + public class LoadComponentsEvent + { + public Player Player { get; internal set; } + } +} diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs index 3c83584..8c5f05d 100644 --- a/Synapse/Events/Patches/ComponentsPatch.cs +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -11,6 +11,8 @@ public static void Prefix(ReferenceHub __instance) { if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); + + Events.InvokeLoadComponents(__instance.GetPlayer()); } } } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index dd7f5bf..e3c0223 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -248,7 +248,7 @@ internal static void InvokeFemurEnterEvent(Player player,ref bool allow,ref bool public delegate void OnDropItem(ref DropItemEvent ev); public static event OnDropItem DropItemEvent; - public static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo item, ref bool allow) + internal static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo item, ref bool allow) { if (DropItemEvent == null) return; @@ -264,5 +264,14 @@ public static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo item allow = ev.Allow; item = ev.Item; } + + public delegate void OnLoadComponents(LoadComponentsEvent ev); + public static event OnLoadComponents LoadComponentsEvent; + internal static void InvokeLoadComponents(Player player) + { + if (LoadComponentsEvent == null) return; + + LoadComponentsEvent.Invoke(new LoadComponentsEvent() { Player = player }); + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 177bb83..24e75f6 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -71,6 +71,7 @@ + From 29224e9e7b6bdcaef3a9322b2d2f3a91ec2b15b3 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:21:10 +0200 Subject: [PATCH 117/199] Changed Player Player to Gameobject Player because its easier to add Components --- Synapse/Events/Classes/LoadComponentsEvent.cs | 3 ++- Synapse/Events/Patches/ComponentsPatch.cs | 2 +- Synapse/Events/PlayerEvents.cs | 7 +------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Synapse/Events/Classes/LoadComponentsEvent.cs b/Synapse/Events/Classes/LoadComponentsEvent.cs index 77aa51b..8b6c956 100644 --- a/Synapse/Events/Classes/LoadComponentsEvent.cs +++ b/Synapse/Events/Classes/LoadComponentsEvent.cs @@ -1,9 +1,10 @@ using Synapse.Api; +using UnityEngine; namespace Synapse.Events.Classes { public class LoadComponentsEvent { - public Player Player { get; internal set; } + public GameObject Player { get; internal set; } } } diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs index 8c5f05d..f1ba8f8 100644 --- a/Synapse/Events/Patches/ComponentsPatch.cs +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -12,7 +12,7 @@ public static void Prefix(ReferenceHub __instance) if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); - Events.InvokeLoadComponents(__instance.GetPlayer()); + Events.InvokeLoadComponents(__instance.gameObject); } } } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index e3c0223..864b8fe 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -267,11 +267,6 @@ internal static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo it public delegate void OnLoadComponents(LoadComponentsEvent ev); public static event OnLoadComponents LoadComponentsEvent; - internal static void InvokeLoadComponents(Player player) - { - if (LoadComponentsEvent == null) return; - - LoadComponentsEvent.Invoke(new LoadComponentsEvent() { Player = player }); - } + internal static void InvokeLoadComponents(GameObject player) => LoadComponentsEvent?.Invoke(new LoadComponentsEvent() { Player = player }); } } \ No newline at end of file From 28b4987770571fb028ef755511561eb0c81a253c Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:25:05 +0200 Subject: [PATCH 118/199] added try catch to Load Components --- Synapse/Events/Patches/ComponentsPatch.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs index f1ba8f8..b3296b6 100644 --- a/Synapse/Events/Patches/ComponentsPatch.cs +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -11,8 +11,14 @@ public static void Prefix(ReferenceHub __instance) { if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); - - Events.InvokeLoadComponents(__instance.gameObject); + try + { + Events.InvokeLoadComponents(__instance.gameObject); + } + catch (Exception e) + { + Log.Error($"LoadComponentsEvent Error: {e}"); + } } } } From 674ac575e4abce941e879c65d6dcb4c4ac374dbd Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:46:31 +0200 Subject: [PATCH 119/199] added more to Player --- Synapse/Api/Player.cs | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 4c2a439..f9991be 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -18,12 +18,14 @@ public class Player : MonoBehaviour public PlayerEffectsController EffectsController { get => Hub.playerEffectsController; } - public string NickName { get => Hub.nicknameSync.MyNick; set => Hub.nicknameSync.MyNick = value; } + public string NickName { get => Hub.nicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } public string UserID { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } + public string IpAddress { get => Hub.queryProcessor._ipAddress; } + public bool OverWatch { get => Hub.serverRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } public bool Bypass { get => Hub.serverRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } @@ -71,6 +73,24 @@ public RoleType Role public Team Team { get => Hub.characterClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } + public Team Side + { + get + { + switch (Team) + { + case Team.RSC: + return Team.MTF; + + case Team.CDP: + return Team.CHI; + + default: + return Team; + } + } + } + public Room CurRoom { get @@ -104,7 +124,26 @@ public Room CurRoom public Inventory.SyncListItemInfo Items { get => Hub.inventory.items; set => Hub.inventory.items = value; } - public Player Cuffer { get => PlayerExtensions.GetPlayer(GetComponent().CufferId); } + /// + /// The Person Who has cuffed the Player + /// + /// Set Cuffer to null and he will be disarmed + public Player Cuffer + { + get => PlayerExtensions.GetPlayer(Hub.handcuffs.CufferId); + set + { + var handcuff = value.Hub.handcuffs; + + if (handcuff == null || value == null) + { + handcuff.NetworkCufferId = -1; + return; + } + + handcuff.NetworkCufferId = value.PlayerId; + } + } public uint Ammo5 { get => Hub.ammoBox.amount[0]; set => Hub.ammoBox.amount[0] = value; } @@ -132,6 +171,8 @@ public UserGroup Rank public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); + public void Ban(int duration, string reason, string issuer = "Plugin") => Server.GetComponent().BanUser(gameObject, duration, reason, issuer); + public void ChangeRoleAtPosition(RoleType role) { Hub.characterClassManager.NetworkCurClass = role; From 837eb0ee7aabc46eea791796bad8069aef182b42 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:48:14 +0200 Subject: [PATCH 120/199] added Kill to Player --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index f9991be..7c821cf 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -173,6 +173,8 @@ public UserGroup Rank public void Ban(int duration, string reason, string issuer = "Plugin") => Server.GetComponent().BanUser(gameObject, duration, reason, issuer); + public void Kill(DamageTypes.DamageType damageType = default) => Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(-1f, "WORLD", damageType, 0), gameObject); + public void ChangeRoleAtPosition(RoleType role) { Hub.characterClassManager.NetworkCurClass = role; From 2ef6759aa6e1606739a5438ee517e0948c2a84af Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:49:57 +0200 Subject: [PATCH 121/199] added GroupName to Player --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 7c821cf..6f1fed3 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -168,6 +168,8 @@ public UserGroup Rank public bool IsIntercomMuted { get => ClassManager.NetworkIntercomMuted; set => ClassManager.NetworkIntercomMuted = value; } + public string GroupName { get => ServerStatic.PermissionsHandler._members[UserID]; } + public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); From 40a6956cc84d12d35f6741f8fb6486e477c0d077 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 07:51:25 +0200 Subject: [PATCH 122/199] added FriendlyFire to Player --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 6f1fed3..058c212 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -170,6 +170,8 @@ public UserGroup Rank public string GroupName { get => ServerStatic.PermissionsHandler._members[UserID]; } + public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } + public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); From e48c9cb7b7d8ba9df196df218c7b9db457b4228f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 08:46:57 +0200 Subject: [PATCH 123/199] Api Changes --- Synapse/Api/Player.cs | 24 +++++++++++++++++++++--- Synapse/Api/PlayerExtensions.cs | 4 ++-- Synapse/Events/EventHandler.cs | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 058c212..7c47940 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -24,8 +24,12 @@ public class Player : MonoBehaviour public string UserID { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } + public string CustomUserId { get => ClassManager.UserId2; set => ClassManager.UserId2 = value; } + public string IpAddress { get => Hub.queryProcessor._ipAddress; } + public bool Noclip { get => Hub.serverRoles.NoclipReady; set => Hub.serverRoles.NoclipReady = value; } + public bool OverWatch { get => Hub.serverRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } public bool Bypass { get => Hub.serverRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } @@ -51,7 +55,7 @@ public Vector3 Scale } } - public Vector3 Position { get => Hub.playerMovementSync.transform.position; set => Hub.playerMovementSync.OverridePosition(value,0f,true); } + public Vector3 Position { get => Hub.playerMovementSync.GetRealPosition(); set => Hub.playerMovementSync.OverridePosition(value,RotationFloat,false); } public Vector3 RotationVector { get => ClassManager._plyCam.transform.forward; set => ClassManager._plyCam.transform.forward = value; } @@ -160,6 +164,8 @@ public UserGroup Rank } } + public string GroupName { get => ServerStatic.PermissionsHandler._members[UserID]; } + public string RankColor { get => Rank.BadgeColor; set => Hub.serverRoles.SetColor(value); } public string RankName { get => Rank.BadgeText; set => Hub.serverRoles.SetText(value); } @@ -168,11 +174,23 @@ public UserGroup Rank public bool IsIntercomMuted { get => ClassManager.NetworkIntercomMuted; set => ClassManager.NetworkIntercomMuted = value; } - public string GroupName { get => ServerStatic.PermissionsHandler._members[UserID]; } - public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } + public Camera079 Camera { get => Hub.scp079PlayerScript.currentCamera; set => Hub.scp079PlayerScript?.RpcSwitchCamera(value.cameraId, false); } + + + public float RotationFloat => Hub.transform.rotation.eulerAngles.y; + + public bool IsCuffed => (Cuffer == null) ? false : true; + + public bool IsReloading => Hub.weaponManager.IsReloading(); + + public bool IsZooming => Hub.weaponManager.ZoomInProgress(); + + public bool IsDead => Team == Team.RIP; + + //Methods public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); public void Ban(int duration, string reason, string issuer = "Plugin") => Server.GetComponent().BanUser(gameObject, duration, reason, issuer); diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 1f5acfb..10c9237 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -33,7 +33,7 @@ public static MethodInfo SendSpawnMessage /// The Message you want to send /// True = green the command is right you have permission and execute it successfully /// In Which Category should you see it too? - public static void RaMessage(this CommandSender sender, string pluginName, string message, bool success = true, + public static void RaMessage(this CommandSender sender, string message, bool success = true, RaCategory type = RaCategory.None) { var category = ""; @@ -64,7 +64,7 @@ public static void RaMessage(this CommandSender sender, string pluginName, strin } - sender.RaReply($"{pluginName}#" + message, success, true, category); + sender.RaReply($"{Assembly.GetCallingAssembly().GetName().Name}#" + message, success, true, category); } public static IEnumerable GetAllPlayers() diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 3700df0..454605c 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -63,13 +63,13 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) { if (!ev.Player.CheckPermission("sy.reload")) { - ev.Sender.RaMessage("Synapse", "You have no Permission for Reload", false, + ev.Sender.RaMessage("You have no Permission for Reload", false, RaCategory.AdminTools); return; } PermissionReader.ReloadPermission(); - ev.Sender.RaMessage("Synapse", "Permissions Reloaded!", true, RaCategory.AdminTools); + ev.Sender.RaMessage("Permissions Reloaded!", true, RaCategory.AdminTools); return; } } From 6076ba3c147e5c22ba5e95190d43276920ff70ca Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 08:47:42 +0200 Subject: [PATCH 124/199] added ClearInventory to Player --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 7c47940..cde2a4f 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -241,5 +241,7 @@ public void InstantBroadcast(ushort time, string message) public void ShowTag(bool global = false) => ClassManager.CallCmdRequestShowTag(global); public void GiveItem(ItemType itemType, float duration = float.NegativeInfinity, int sight = 0, int barrel = 0, int other = 0) => Hub.inventory.AddNewItem(itemType, duration, sight, barrel, other); + + public void ClearInventory() => Hub.inventory.Clear(); } } From 1ec14fbdc34f9e520c477614fe5fe5befa78729c Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 10:20:01 +0200 Subject: [PATCH 125/199] added GiveEffect to Player --- Synapse/Api/Enums/Effects.cs | 110 ++++++++++++++++++++++++++ Synapse/Api/{ => Enums}/RaCategory.cs | 0 Synapse/Api/{ => Enums}/ZoneType.cs | 0 Synapse/Api/Player.cs | 4 + Synapse/Synapse.csproj | 5 +- 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 Synapse/Api/Enums/Effects.cs rename Synapse/Api/{ => Enums}/RaCategory.cs (100%) rename Synapse/Api/{ => Enums}/ZoneType.cs (100%) diff --git a/Synapse/Api/Enums/Effects.cs b/Synapse/Api/Enums/Effects.cs new file mode 100644 index 0000000..2f23146 --- /dev/null +++ b/Synapse/Api/Enums/Effects.cs @@ -0,0 +1,110 @@ +namespace Synapse.Api.Enums +{ + public enum Effect + { + /// + /// The Player cant open his Inventory and Reload his Weapons + /// + /// 0 = Disabled,1 = Enabled + Amnesia, + /// + /// Quickly drains stamina then Health If theres none left + /// + /// 0 = Disabled,1 = Enabled + Asphyxiated, + /// + /// Damage-over time starting high and ramping low.Ticks every 5s. + /// + /// 0 = Disabled, 1 = Enabled + Bleeding, + /// + /// applies extrem screen blur + /// + Blinded, + /// + /// slightly inreases all damage taken + /// + /// 0 = Disabled, 1 = Enabled + Burned, + /// + /// Blurs the screen as the Player turns + /// + /// 0 = Disabled, 1 = Enabel + Concussed, + /// + /// Teleports to the Pocket Dimension and drains Hp until he escapes + /// + /// 1 = Enabled + Corroding, + /// + /// Heavily muffles all sounds + /// + /// 0 = Disabled, 1 = Enablked + Deafened, + /// + /// Remove 10% of max health each second + /// + /// 0 = Disabled, 1 = Enabled + Decontaminating, + /// + /// Slows all Movement speed + /// + /// 0 = Diabled, 1 = Enabled + Disabled, + /// + /// prevents all movement + /// + /// 0 = Disabled, 1 = Enabled + Ensnared, + /// + /// laves stamina capacity and regeneration rate + /// + /// 0 = Disabled, 1 = Enabled + Exhausted, + /// + /// Flash the Player + /// + /// 0 = Disabled, 1-244 = time in ms 255 = forever + Flashed, + /// + /// Sprinting drains 2 Hp/s + /// + /// 0 = Disabled, 1 = Enabled + Hemorrhage, + /// + /// Infinte Stamina + /// + /// 0 = Disabled, 1 = Enabled + Invigorated, + /// + /// slightly Increases stamina consumption + /// + /// 0 = Disabled, 1 = Enabled + Panic, + /// + /// Damage-over time starting low and ramping high.Ticks every 5s. + /// + /// 0 = Disabled, 1 = Enabled + Poisoned, + /// + /// The Player will walk faster + /// + /// 0 = Disabled, 1 = 1xCola, 2 = 2xCola, 3 = 3xCola, 4 = 4xCola + Scp207, + /// + /// The Player cant be seen by other Humans.He need do activate Scp268 in his Inventory + /// + /// 0 = Disabled,1 = Enabled + Scp268, + /// + /// Slows down Players but not Scps + /// + /// 0 = Disabled, 1 = Enabled + SinkHole, + /// + /// The Vision of Scp939 + /// + /// 0 = Disabled, 1 = OnlyMarker, 2 = Only Screen Filtest, 3 = Everything + Visuals939 + } +} diff --git a/Synapse/Api/RaCategory.cs b/Synapse/Api/Enums/RaCategory.cs similarity index 100% rename from Synapse/Api/RaCategory.cs rename to Synapse/Api/Enums/RaCategory.cs diff --git a/Synapse/Api/ZoneType.cs b/Synapse/Api/Enums/ZoneType.cs similarity index 100% rename from Synapse/Api/ZoneType.cs rename to Synapse/Api/Enums/ZoneType.cs diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index cde2a4f..5b034c6 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,7 +1,9 @@ using System; using System.Linq; +using CustomPlayerEffects; using Hints; using Mirror; +using Synapse.Api.Enums; using Synapse.Permissions; using UnityEngine; @@ -243,5 +245,7 @@ public void InstantBroadcast(ushort time, string message) public void GiveItem(ItemType itemType, float duration = float.NegativeInfinity, int sight = 0, int barrel = 0, int other = 0) => Hub.inventory.AddNewItem(itemType, duration, sight, barrel, other); public void ClearInventory() => Hub.inventory.Clear(); + + public void GiveEffect(Effect effect,byte intens = 1,float duration = 0) => EffectsController.ChangeByString(effect.ToString(), intens, duration); } } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 24e75f6..5f38a5e 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -65,11 +65,12 @@ + - + - + From cd81e4ea4a8236a47304a931b1189d65b965cec3 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 13 Jun 2020 10:36:24 +0200 Subject: [PATCH 126/199] small changes --- Synapse/Api/Enums/Effects.cs | 2 +- Synapse/Api/Player.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Synapse/Api/Enums/Effects.cs b/Synapse/Api/Enums/Effects.cs index 2f23146..1a61ff9 100644 --- a/Synapse/Api/Enums/Effects.cs +++ b/Synapse/Api/Enums/Effects.cs @@ -1,4 +1,4 @@ -namespace Synapse.Api.Enums +namespace Synapse.Api { public enum Effect { diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 5b034c6..4781b68 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,9 +1,7 @@ using System; using System.Linq; -using CustomPlayerEffects; using Hints; using Mirror; -using Synapse.Api.Enums; using Synapse.Permissions; using UnityEngine; @@ -246,6 +244,6 @@ public void InstantBroadcast(ushort time, string message) public void ClearInventory() => Hub.inventory.Clear(); - public void GiveEffect(Effect effect,byte intens = 1,float duration = 0) => EffectsController.ChangeByString(effect.ToString(), intens, duration); + public void GiveEffect(Effect effect,byte intens = 1,float duration = -1f) => EffectsController.ChangeByString(effect.ToString().ToLower(), intens, duration); } } From be15ca595faa8eb680517f9b8675f51461e71287 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 14 Jun 2020 08:03:06 +0200 Subject: [PATCH 127/199] added Jail --- Synapse/Api/Jail.cs | 60 ++++++++++++ Synapse/Api/Player.cs | 9 +- Synapse/Events/Classes/PlayerCuffedEvent.cs | 2 +- Synapse/Events/EventHandler.cs | 28 +++++- Synapse/Events/Patches/ComponentsPatch.cs | 4 + Synapse/Events/PlayerEvents.cs | 2 +- Synapse/Synapse.csproj | 1 + SynapseModLoader/SynapseModLoader.csproj | 101 ++++++++++---------- 8 files changed, 150 insertions(+), 57 deletions(-) create mode 100644 Synapse/Api/Jail.cs diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs new file mode 100644 index 0000000..80bd229 --- /dev/null +++ b/Synapse/Api/Jail.cs @@ -0,0 +1,60 @@ +using System; +using UnityEngine; + +namespace Synapse.Api +{ + public class Jail : MonoBehaviour + { + public bool IsJailed { get; private set; } + + public Player Player { get => this.GetPlayer(); } + + public Player Admin { get; set; } + + public RoleType Role { get; set; } + + public Vector3 Position { get; set; } + + public Inventory.SyncListItemInfo Items { get; set; } + + public float Health { get; set; } + + + + public void Awake() + { + IsJailed = false; + Role = RoleType.ClassD; + Position = Map.GetRandomSpawnPoint(Role); + } + + public void DoJail(Player admin) + { + if (IsJailed) return; + + var player = this.GetPlayer(); + Admin = admin; + Role = player.Role; + Position = player.Position; + if (Items != null) Items = player.Items; + Health = player.Health; + + player.Role = RoleType.Tutorial; + + IsJailed = true; + } + + public void UnJail() + { + if (!IsJailed) return; + + var player = this.GetPlayer(); + player.ChangeRoleAtPosition(Role); + player.Position = Position; + player.Health = Health; + player.Items = Items; + + IsJailed = false; + } + } +} diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 4781b68..51f4d1b 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -12,12 +12,14 @@ public class Player : MonoBehaviour public static Player Server { get => PlayerManager.localPlayer.GetPlayer(); } - public ReferenceHub Hub { get => this.GetComponent(); } + public ReferenceHub Hub { get => GetComponent(); } public CharacterClassManager ClassManager { get => Hub.characterClassManager; } public PlayerEffectsController EffectsController { get => Hub.playerEffectsController; } + public Jail Jail => GetComponent(); + public string NickName { get => Hub.nicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } @@ -71,8 +73,8 @@ public Vector3 Scale public RoleType Role { - get => Hub.characterClassManager.NetworkCurClass; - set => Hub.characterClassManager.SetPlayersClass(value, gameObject); + get => Hub.characterClassManager.CurClass; + set => Hub.characterClassManager.SetPlayersClass(value,gameObject); } public Team Team { get => Hub.characterClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } @@ -199,6 +201,7 @@ public UserGroup Rank public void ChangeRoleAtPosition(RoleType role) { + //TODO: Fix this shit Hub.characterClassManager.NetworkCurClass = role; Hub.playerStats.SetHPAmount(Hub.characterClassManager.Classes.SafeGet(Role).maxHP); } diff --git a/Synapse/Events/Classes/PlayerCuffedEvent.cs b/Synapse/Events/Classes/PlayerCuffedEvent.cs index c3327a5..c335db0 100644 --- a/Synapse/Events/Classes/PlayerCuffedEvent.cs +++ b/Synapse/Events/Classes/PlayerCuffedEvent.cs @@ -6,7 +6,7 @@ namespace Synapse.Events.Classes [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] public class PlayerCuffedEvent { - public Player Cuffed { get; internal set; } + public Player Cuffer { get; internal set; } public Player Target { get; internal set; } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 454605c..c894bef 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using Discord; using MEC; using Synapse.Api; using Synapse.Events.Classes; @@ -28,6 +29,7 @@ public EventHandler() Events.DoorInteractEvent += OnDoorInteract; } + // Methods private void OnDoorInteract(ref DoorInteractEvent ev) { if (Configs.remotekeycard) @@ -45,7 +47,6 @@ private void OnDoorInteract(ref DoorInteractEvent ev) } } - // Methods private static void OnSyncData(ref SyncDataEvent ev) { if (ev.Player.Role != RoleType.ClassD && @@ -72,6 +73,31 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) ev.Sender.RaMessage("Permissions Reloaded!", true, RaCategory.AdminTools); return; } + case "JAIL": + ev.Allow = false; + if (args.Length < 2) + { + ev.Sender.RaMessage("Jail Player"); + return; + } + + var Player = PlayerExtensions.GetPlayer(args[1]); + if (Player == null) + { + ev.Sender.RaMessage("Invalid Player"); + return; + } + var Jail = Player.GetComponent(); + + if (Jail.IsJailed) + { + Jail.UnJail(); + ev.Sender.RaMessage("User was unjailed"); + return; + } + Jail.DoJail(ev.Player); + ev.Sender.RaMessage("User was jailed"); + return; } } diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs index b3296b6..bcb2f82 100644 --- a/Synapse/Events/Patches/ComponentsPatch.cs +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -11,6 +11,10 @@ public static void Prefix(ReferenceHub __instance) { if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); + + if (__instance.GetComponent() == null) + __instance.gameObject.AddComponent(); + try { Events.InvokeLoadComponents(__instance.gameObject); diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 864b8fe..12525e1 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -146,7 +146,7 @@ internal static void InvokePlayerCuffedEvent(Player cuffed, Player target, ref b var ev = new PlayerCuffedEvent { - Cuffed = cuffed, + Cuffer = cuffed, Target = target, Allow = allow }; diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 5f38a5e..b596cc2 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -65,6 +65,7 @@ + diff --git a/SynapseModLoader/SynapseModLoader.csproj b/SynapseModLoader/SynapseModLoader.csproj index d67dabd..698273f 100644 --- a/SynapseModLoader/SynapseModLoader.csproj +++ b/SynapseModLoader/SynapseModLoader.csproj @@ -1,59 +1,58 @@  - - - Debug - AnyCPU - {4AAEE3B0-0C6C-4E26-83CC-AA16DDAD4F2B} - Library - Properties - SynapseModLoader - SynapseModLoader - v4.7.2 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\Synapse_Dependencies\Assembly-CSharp.dll - - - - - - - ..\..\Synapse_Dependencies\UnityEngine.CoreModule.dll - - - - - - - - - - + \ No newline at end of file From 46c4cd8d36a91ece6594b0815a9ad85d98bba373 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 14 Jun 2020 12:32:35 +0200 Subject: [PATCH 128/199] Removed Jail --- Synapse/Api/Jail.cs | 60 ----------------------- Synapse/Api/Player.cs | 2 - Synapse/Events/EventHandler.cs | 25 ---------- Synapse/Events/Patches/ComponentsPatch.cs | 3 -- Synapse/Synapse.csproj | 1 - 5 files changed, 91 deletions(-) delete mode 100644 Synapse/Api/Jail.cs diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs deleted file mode 100644 index 80bd229..0000000 --- a/Synapse/Api/Jail.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using UnityEngine; - -namespace Synapse.Api -{ - public class Jail : MonoBehaviour - { - public bool IsJailed { get; private set; } - - public Player Player { get => this.GetPlayer(); } - - public Player Admin { get; set; } - - public RoleType Role { get; set; } - - public Vector3 Position { get; set; } - - public Inventory.SyncListItemInfo Items { get; set; } - - public float Health { get; set; } - - - - public void Awake() - { - IsJailed = false; - Role = RoleType.ClassD; - Position = Map.GetRandomSpawnPoint(Role); - } - - public void DoJail(Player admin) - { - if (IsJailed) return; - - var player = this.GetPlayer(); - Admin = admin; - Role = player.Role; - Position = player.Position; - if (Items != null) Items = player.Items; - Health = player.Health; - - player.Role = RoleType.Tutorial; - - IsJailed = true; - } - - public void UnJail() - { - if (!IsJailed) return; - - var player = this.GetPlayer(); - player.ChangeRoleAtPosition(Role); - player.Position = Position; - player.Health = Health; - player.Items = Items; - - IsJailed = false; - } - } -} diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 51f4d1b..8ee73f3 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -18,8 +18,6 @@ public class Player : MonoBehaviour public PlayerEffectsController EffectsController { get => Hub.playerEffectsController; } - public Jail Jail => GetComponent(); - public string NickName { get => Hub.nicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index c894bef..85d84c1 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -73,31 +73,6 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) ev.Sender.RaMessage("Permissions Reloaded!", true, RaCategory.AdminTools); return; } - case "JAIL": - ev.Allow = false; - if (args.Length < 2) - { - ev.Sender.RaMessage("Jail Player"); - return; - } - - var Player = PlayerExtensions.GetPlayer(args[1]); - if (Player == null) - { - ev.Sender.RaMessage("Invalid Player"); - return; - } - var Jail = Player.GetComponent(); - - if (Jail.IsJailed) - { - Jail.UnJail(); - ev.Sender.RaMessage("User was unjailed"); - return; - } - Jail.DoJail(ev.Player); - ev.Sender.RaMessage("User was jailed"); - return; } } diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs index bcb2f82..4e4d78a 100644 --- a/Synapse/Events/Patches/ComponentsPatch.cs +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -12,9 +12,6 @@ public static void Prefix(ReferenceHub __instance) if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); - if (__instance.GetComponent() == null) - __instance.gameObject.AddComponent(); - try { Events.InvokeLoadComponents(__instance.gameObject); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index b596cc2..5f38a5e 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -65,7 +65,6 @@ - From 4f7d7c3bb83f13240ecc48388dec8f0f0160590b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 14 Jun 2020 13:09:00 +0200 Subject: [PATCH 129/199] Change Dependencies for CI. --- SynapseModLoader/SynapseModLoader.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SynapseModLoader/SynapseModLoader.csproj b/SynapseModLoader/SynapseModLoader.csproj index 698273f..634172b 100644 --- a/SynapseModLoader/SynapseModLoader.csproj +++ b/SynapseModLoader/SynapseModLoader.csproj @@ -33,14 +33,14 @@ - ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll + ..\..\Synapse_Dependencies\Assembly-CSharp-Synapse_publizied.dll - ..\..\Synaps Verweise\UnityEngine.CoreModule.dll + ..\..\Synapse_Dependencies\UnityEngine.CoreModule.dll From 7762b67ceaab4c741943acaafbc99d5a63e39564 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 14 Jun 2020 13:18:43 +0200 Subject: [PATCH 130/199] added GeneratorEvents --- Synapse/Api/Player.cs | 13 +-- Synapse/Events/Classes/GeneratorEvent.cs | 13 +++ Synapse/Events/Patches/GeneratorPatches.cs | 29 +++++-- Synapse/Events/PlayerEvents.cs | 94 +++++++++++++++++++++- Synapse/Synapse.csproj | 1 + 5 files changed, 132 insertions(+), 18 deletions(-) create mode 100644 Synapse/Events/Classes/GeneratorEvent.cs diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 8ee73f3..fdc709c 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -139,7 +139,9 @@ public Player Cuffer { var handcuff = value.Hub.handcuffs; - if (handcuff == null || value == null) + if (handcuff == null) return; + + if (value == null) { handcuff.NetworkCufferId = -1; return; @@ -155,14 +157,7 @@ public Player Cuffer public uint Ammo9 { get => Hub.ammoBox.amount[2]; set => Hub.ammoBox.amount[2] = value; } - public UserGroup Rank - { - get => Hub.serverRoles.Group; - set - { - Hub.serverRoles.SetGroup(value, false, false, false); - } - } + public UserGroup Rank { get => Hub.serverRoles.Group; set => Hub.serverRoles.SetGroup(value, false, false, false); } public string GroupName { get => ServerStatic.PermissionsHandler._members[UserID]; } diff --git a/Synapse/Events/Classes/GeneratorEvent.cs b/Synapse/Events/Classes/GeneratorEvent.cs new file mode 100644 index 0000000..b154ada --- /dev/null +++ b/Synapse/Events/Classes/GeneratorEvent.cs @@ -0,0 +1,13 @@ +using Synapse.Api; + +namespace Synapse.Events.Classes +{ + public class GeneratorEvent + { + public Player Player { get; internal set; } + + public Generator079 Generator { get; internal set; } + + public bool Allow { get; set; } + } +} diff --git a/Synapse/Events/Patches/GeneratorPatches.cs b/Synapse/Events/Patches/GeneratorPatches.cs index 0cf8e4e..da329ab 100644 --- a/Synapse/Events/Patches/GeneratorPatches.cs +++ b/Synapse/Events/Patches/GeneratorPatches.cs @@ -1,5 +1,6 @@ using System; using Harmony; +using Synapse.Api; using UnityEngine; namespace Synapse.Events.Patches @@ -11,6 +12,14 @@ public static bool Prefix(Generator079 __instance, GameObject person, string com { try { + var player = person.GetPlayer(); + + if (player == null) + { + Log.Error("GeneratorEventError: a gameobject which is not a Player used a Generator?"); + return false; + } + if (command.StartsWith("EPS_DOOR")) return true; if (command.StartsWith("EPS_TABLET")) @@ -24,8 +33,8 @@ public static bool Prefix(Generator079 __instance, GameObject person, string com Inventory.SyncItemInfo syncItemInfo = enumerator.Current; if (syncItemInfo.id == ItemType.WeaponManagerTablet) { - bool allow = true; - //Tablet inserted Event + bool allow = player.Team != Team.SCP; + Events.InvokeGeneratorInserted(player, __instance, ref allow); if (allow) { component.items.Remove(syncItemInfo); @@ -41,7 +50,7 @@ public static bool Prefix(Generator079 __instance, GameObject person, string com if (!__instance.isTabletConnected) return false; bool allow = true; - //Tablet ejectet Event + Events.InvokeGeneratorEjected(player, __instance, ref allow); return allow; } return true; @@ -59,6 +68,8 @@ public static class GeneratorDoorPatches { public static bool Prefix(Generator079 __instance, GameObject person) { + var player = person.GetPlayer(); + Inventory component = person.GetComponent(); if (component == null || __instance.doorAnimationCooldown > 0f || __instance.deniedCooldown > 0f) return false; @@ -68,11 +79,11 @@ public static bool Prefix(Generator079 __instance, GameObject person) bool allow = true; if (!__instance.NetworkisDoorOpen) { - //GeneratorOpenEvent + Events.InvokeGeneratorOpen(player, __instance, ref allow); } else { - //GeneratorCloseEvent + Events.InvokeGeneratorClose(player, __instance, ref allow); } if (!allow) @@ -88,8 +99,10 @@ public static bool Prefix(Generator079 __instance, GameObject person) } //Unlock The Generator - bool flag = person.GetComponent().BypassMode; - if (component.curItem > ItemType.KeycardJanitor) + bool flag = player.Bypass; + bool flag2 = player.Team != Team.SCP; + + if (flag2 && component.curItem > ItemType.KeycardJanitor) { string[] permissions = component.GetItemByID(component.curItem).permissions; @@ -98,7 +111,7 @@ public static bool Prefix(Generator079 __instance, GameObject person) flag = true; } - //Generator unlock event player = person,allow = flag,__instance + Events.InvokeGeneratorUnlock(player, __instance, ref flag); if (flag) { diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 12525e1..bb304ba 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -1,4 +1,6 @@ -using System.Diagnostics.CodeAnalysis; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Security.Permissions; using Assets._Scripts.Dissonance; using Synapse.Api; using Synapse.Events.Classes; @@ -268,5 +270,95 @@ internal static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo it public delegate void OnLoadComponents(LoadComponentsEvent ev); public static event OnLoadComponents LoadComponentsEvent; internal static void InvokeLoadComponents(GameObject player) => LoadComponentsEvent?.Invoke(new LoadComponentsEvent() { Player = player }); + + public delegate void OnGeneratorInserted(ref GeneratorEvent ev); + public static event OnGeneratorInserted GeneratorInsertedEvent; + internal static void InvokeGeneratorInserted(Player player, Generator079 generator, ref bool allow) + { + if (GeneratorInsertedEvent == null) return; + + var ev = new GeneratorEvent + { + Allow = allow, + Generator = generator, + Player = player + }; + + GeneratorInsertedEvent.Invoke(ref ev); + + allow = ev.Allow; + } + + public delegate void OnGeneratorEjected(ref GeneratorEvent ev); + public static event OnGeneratorEjected GeneratorEjectedEvent; + internal static void InvokeGeneratorEjected(Player player, Generator079 generator, ref bool allow) + { + if (GeneratorEjectedEvent == null) return; + + var ev = new GeneratorEvent + { + Allow = allow, + Generator = generator, + Player = player + }; + + GeneratorEjectedEvent.Invoke(ref ev); + + allow = ev.Allow; + } + + public delegate void OnGeneratorUnlock(ref GeneratorEvent ev); + public static event OnGeneratorUnlock GeneratorUnlockEvent; + internal static void InvokeGeneratorUnlock(Player player,Generator079 generator, ref bool allow) + { + if (GeneratorUnlockEvent == null) return; + + var ev = new GeneratorEvent + { + Allow = allow, + Generator = generator, + Player = player + }; + + GeneratorUnlockEvent.Invoke(ref ev); + + allow = ev.Allow; + } + + public delegate void OnGeneratorOpen(ref GeneratorEvent ev); + public static event OnGeneratorOpen GeneratorOpenEvent; + internal static void InvokeGeneratorOpen(Player player, Generator079 generator, ref bool allow) + { + if (GeneratorOpenEvent == null) return; + + var ev = new GeneratorEvent + { + Allow = allow, + Generator = generator, + Player = player + }; + + GeneratorOpenEvent.Invoke(ref ev); + + allow = ev.Allow; + } + + public delegate void OnGeneratorClose(ref GeneratorEvent ev); + public static event OnGeneratorClose GeneratorCloseEvent; + internal static void InvokeGeneratorClose(Player player, Generator079 generator, ref bool allow) + { + if (GeneratorCloseEvent == null) return; + + var ev = new GeneratorEvent + { + Allow = allow, + Generator = generator, + Player = player + }; + + GeneratorCloseEvent.Invoke(ref ev); + + allow = ev.Allow; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 5f38a5e..f79b35e 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -72,6 +72,7 @@ + From 5658fadba48ea71cb0cb87c5590712d2eb0fdc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 14 Jun 2020 13:30:04 +0200 Subject: [PATCH 131/199] Check for Issues --- SynapseModLoader/ModLoader.cs | 20 ++++++++++---------- SynapseModLoaderPatcher/Program.cs | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/SynapseModLoader/ModLoader.cs b/SynapseModLoader/ModLoader.cs index 043a8ae..926d94c 100644 --- a/SynapseModLoader/ModLoader.cs +++ b/SynapseModLoader/ModLoader.cs @@ -5,14 +5,14 @@ namespace SynapseModLoader { + // ReSharper disable once UnusedType.Global public class ModLoader { - // Token: 0x060027B3 RID: 10163 RVA: 0x000C17DC File Offset: 0x000BF9DC - public static byte[] ReadFile(string path) + private static byte[] ReadFile(string path) { - FileStream fileStream = File.Open(path, FileMode.Open); + var fileStream = File.Open(path, FileMode.Open); byte[] result; - using (MemoryStream memoryStream = new MemoryStream()) + using (var memoryStream = new MemoryStream()) { fileStream.CopyTo(memoryStream); result = memoryStream.ToArray(); @@ -20,16 +20,16 @@ public static byte[] ReadFile(string path) fileStream.Close(); return result; } - - // Token: 0x060027B4 RID: 10164 RVA: 0x000C1828 File Offset: 0x000BFA28 + + // ReSharper disable once UnusedMember.Global public static void LoadModSystem() { if (_loaded) { return; } - ServerConsole.AddLog("Synapse Mod-Loader is now intialising.. :)", ConsoleColor.Blue); - string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Synapse"); + ServerConsole.AddLog("Synapse Mod-Loader is now initialising.. :)", ConsoleColor.Blue); + var text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Synapse"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); @@ -39,7 +39,8 @@ public static void LoadModSystem() ServerConsole.AddLog("Error while loading Synapse! The Synapse.dll is missing!", ConsoleColor.Red); return; } - var methodInfo = Assembly.Load(ReadFile(Path.Combine(text, "Synapse.dll"))).GetTypes().SelectMany((p) => p.GetMethods()).FirstOrDefault((f) => f.Name == "LoaderExecutionCode"); + var methodInfo = Assembly.Load(ReadFile(Path.Combine(text, "Synapse.dll"))).GetTypes() + .SelectMany(p => p.GetMethods()).FirstOrDefault(f => f.Name == "LoaderExecutionCode"); if (!(methodInfo != null)) { return; @@ -48,7 +49,6 @@ public static void LoadModSystem() _loaded = true; } - // Token: 0x040022BC RID: 8892 private static bool _loaded; } } \ No newline at end of file diff --git a/SynapseModLoaderPatcher/Program.cs b/SynapseModLoaderPatcher/Program.cs index 7be3e29..ee72f20 100644 --- a/SynapseModLoaderPatcher/Program.cs +++ b/SynapseModLoaderPatcher/Program.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using dnlib.DotNet; using dnlib.DotNet.Emit; @@ -13,6 +12,7 @@ namespace SynapseModLoaderPatcher { + // ReSharper disable once ClassNeverInstantiated.Global internal class Program { public static void Main(string[] args) @@ -68,7 +68,7 @@ public static void Main(string[] args) modRefType.DeclaringType = null; module.Types.Add(modRefType); - MethodDef call = FindMethod(modRefType, "LoadModSystem"); + var call = FindMethod(modRefType, "LoadModSystem"); if (call == null) { @@ -79,8 +79,9 @@ public static void Main(string[] args) Console.WriteLine("Synapse-Inject: Injected!"); Console.WriteLine("Synapse: Patching..."); - TypeDef def = FindType(module.Assembly, "ServerConsoleSender"); + var def = FindType(module.Assembly, "ServerConsoleSender"); + // ReSharper disable once IdentifierTypo MethodDef bctor = new MethodDefUser(".ctor", MethodSig.CreateInstance(module.CorLibTypes.Void), MethodImplAttributes.IL | MethodImplAttributes.Managed, MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName); @@ -110,7 +111,7 @@ public static void Main(string[] args) foreach (var type in allTypes) { - if (!type?.IsPublic ?? false && !type.IsNestedPublic) + if (!type?.IsPublic ?? false) { type.Attributes = type.IsNested ? TypeAttributes.NestedPublic : TypeAttributes.Public; } @@ -133,15 +134,14 @@ public static void Main(string[] args) } } - module.Write("Assembly-CSharp-Synapse_publizied.dll"); + module.Write("Assembly-CSharp-Synapse_publicised.dll"); - Console.WriteLine("Synapse-Public: Created Publizied DLL"); + Console.WriteLine("Synapse-Public: Created Publicised DLL"); } private static MethodDef FindMethod(TypeDef type, string methodName) { - if (type == null) return null; - return type.Methods.FirstOrDefault(method => method.Name == methodName); + return type?.Methods.FirstOrDefault(method => method.Name == methodName); } private static TypeDef FindType(AssemblyDef asm, string classPath) From a6495b147058b0ede6dd692d49c92d3ca093dfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Mon, 15 Jun 2020 10:52:03 +0200 Subject: [PATCH 132/199] Fixed a lot of bad code principles --- Synapse/Api/Enums/Effects.cs | 49 ++++++++++--------- Synapse/Api/Enums/RaCategory.cs | 2 +- Synapse/Api/Enums/ZoneType.cs | 2 +- Synapse/Api/Player.cs | 46 +++++++++-------- Synapse/Api/PlayerExtensions.cs | 23 ++++----- Synapse/Api/Room.cs | 4 +- Synapse/Configs.cs | 18 +++---- Synapse/Events/Classes/FemurEnterEvent.cs | 5 -- Synapse/Events/Classes/LoadComponentsEvent.cs | 3 +- Synapse/Events/Classes/RemoteCommandEvent.cs | 2 +- Synapse/Events/EventHandler.cs | 24 ++++----- Synapse/Events/MapEvents.cs | 1 - Synapse/Events/Patches/FemurEnterPatch.cs | 2 +- Synapse/Events/Patches/PlayerBanPatch.cs | 2 +- Synapse/Events/Patches/PlayerJoinPatch.cs | 2 +- .../Events/Patches/PreAuthenticationPatch.cs | 8 +-- ...mentPatch.cs => Scp106ContainmentPatch.cs} | 6 +-- Synapse/Events/PlayerEvents.cs | 16 +++--- Synapse/Events/ScpEvents.cs | 17 +++---- Synapse/Events/ServerEvents.cs | 21 ++++---- Synapse/Permissions/PermissionReader.cs | 4 +- Synapse/Plugin.cs | 1 + Synapse/PluginManager.cs | 8 +-- Synapse/Synapse.csproj | 2 +- Synapse/Translation.cs | 30 ++++++------ 25 files changed, 147 insertions(+), 151 deletions(-) rename Synapse/Events/Patches/{Scp106ContaimentPatch.cs => Scp106ContainmentPatch.cs} (71%) diff --git a/Synapse/Api/Enums/Effects.cs b/Synapse/Api/Enums/Effects.cs index 1a61ff9..05ef312 100644 --- a/Synapse/Api/Enums/Effects.cs +++ b/Synapse/Api/Enums/Effects.cs @@ -1,45 +1,48 @@ -namespace Synapse.Api +using System.Diagnostics.CodeAnalysis; + +namespace Synapse.Api.Enums { + [SuppressMessage("ReSharper", "UnusedMember.Global")] public enum Effect { /// - /// The Player cant open his Inventory and Reload his Weapons + /// The Player can't open his inventory and reload his weapons /// - /// 0 = Disabled,1 = Enabled + /// 0 = Disabled, 1 = Enabled Amnesia, /// - /// Quickly drains stamina then Health If theres none left + /// Quickly drains stamina then health if there is none left /// - /// 0 = Disabled,1 = Enabled + /// 0 = Disabled, 1 = Enabled Asphyxiated, /// - /// Damage-over time starting high and ramping low.Ticks every 5s. + /// Damage-over time starting high and getting low. Ticks every 5s. /// /// 0 = Disabled, 1 = Enabled Bleeding, /// - /// applies extrem screen blur + /// Applies extreme screen blur /// Blinded, /// - /// slightly inreases all damage taken + /// Slightly increases all damage taken /// /// 0 = Disabled, 1 = Enabled Burned, /// /// Blurs the screen as the Player turns /// - /// 0 = Disabled, 1 = Enabel + /// 0 = Disabled, 1 = Enabled Concussed, /// - /// Teleports to the Pocket Dimension and drains Hp until he escapes + /// Teleports to the pocket dimension and drains hp until he escapes /// /// 1 = Enabled Corroding, /// /// Heavily muffles all sounds /// - /// 0 = Disabled, 1 = Enablked + /// 0 = Disabled, 1 = Enabled Deafened, /// /// Remove 10% of max health each second @@ -47,17 +50,17 @@ public enum Effect /// 0 = Disabled, 1 = Enabled Decontaminating, /// - /// Slows all Movement speed + /// Slows all movement /// - /// 0 = Diabled, 1 = Enabled + /// 0 = Disabled, 1 = Enabled Disabled, /// - /// prevents all movement + /// Prevents all movement /// /// 0 = Disabled, 1 = Enabled Ensnared, /// - /// laves stamina capacity and regeneration rate + /// Laves stamina capacity and regeneration rate /// /// 0 = Disabled, 1 = Enabled Exhausted, @@ -67,22 +70,22 @@ public enum Effect /// 0 = Disabled, 1-244 = time in ms 255 = forever Flashed, /// - /// Sprinting drains 2 Hp/s + /// Sprinting drains 2 hp/s /// /// 0 = Disabled, 1 = Enabled Hemorrhage, /// - /// Infinte Stamina + /// Infinite stamina /// /// 0 = Disabled, 1 = Enabled Invigorated, /// - /// slightly Increases stamina consumption + /// Slightly increases stamina consumption /// /// 0 = Disabled, 1 = Enabled Panic, /// - /// Damage-over time starting low and ramping high.Ticks every 5s. + /// Damage-over time starting low and rising high. Ticks every 5s. /// /// 0 = Disabled, 1 = Enabled Poisoned, @@ -92,19 +95,19 @@ public enum Effect /// 0 = Disabled, 1 = 1xCola, 2 = 2xCola, 3 = 3xCola, 4 = 4xCola Scp207, /// - /// The Player cant be seen by other Humans.He need do activate Scp268 in his Inventory + /// The Player cant be seen by other entities. He need do activate Scp268 in his inventory /// /// 0 = Disabled,1 = Enabled Scp268, /// - /// Slows down Players but not Scps + /// Slows down players but not SCP's /// /// 0 = Disabled, 1 = Enabled SinkHole, /// - /// The Vision of Scp939 + /// The vision of SCP-939 /// - /// 0 = Disabled, 1 = OnlyMarker, 2 = Only Screen Filtest, 3 = Everything + /// 0 = Disabled, 1 = OnlyMarker, 2 = Only Screen, 3 = Everything Visuals939 } } diff --git a/Synapse/Api/Enums/RaCategory.cs b/Synapse/Api/Enums/RaCategory.cs index 1a9c193..011462a 100644 --- a/Synapse/Api/Enums/RaCategory.cs +++ b/Synapse/Api/Enums/RaCategory.cs @@ -1,4 +1,4 @@ -namespace Synapse.Api +namespace Synapse.Api.Enums { public enum RaCategory { diff --git a/Synapse/Api/Enums/ZoneType.cs b/Synapse/Api/Enums/ZoneType.cs index 9c4f447..36e87ca 100644 --- a/Synapse/Api/Enums/ZoneType.cs +++ b/Synapse/Api/Enums/ZoneType.cs @@ -1,4 +1,4 @@ -namespace Synapse.Api +namespace Synapse.Api.Enums { public enum ZoneType { diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index fdc709c..fca6c48 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,34 +1,39 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Linq; using Hints; using Mirror; +using Synapse.Api.Enums; using Synapse.Permissions; using UnityEngine; namespace Synapse.Api { + [SuppressMessage("ReSharper", "UnusedMember.Global")] + [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] + // ReSharper disable once ClassNeverInstantiated.Global public class Player : MonoBehaviour { - public static Player Server { get => PlayerManager.localPlayer.GetPlayer(); } + public static Player Server => PlayerManager.localPlayer.GetPlayer(); - public ReferenceHub Hub { get => GetComponent(); } + public ReferenceHub Hub => GetComponent(); - public CharacterClassManager ClassManager { get => Hub.characterClassManager; } + public CharacterClassManager ClassManager => Hub.characterClassManager; - public PlayerEffectsController EffectsController { get => Hub.playerEffectsController; } + public PlayerEffectsController EffectsController => Hub.playerEffectsController; public string NickName { get => Hub.nicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } - public string UserID { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } + public string UserId { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } public string CustomUserId { get => ClassManager.UserId2; set => ClassManager.UserId2 = value; } - public string IpAddress { get => Hub.queryProcessor._ipAddress; } + public string IpAddress => Hub.queryProcessor._ipAddress; - public bool Noclip { get => Hub.serverRoles.NoclipReady; set => Hub.serverRoles.NoclipReady = value; } + public bool NoClip { get => Hub.serverRoles.NoclipReady; set => Hub.serverRoles.NoclipReady = value; } public bool OverWatch { get => Hub.serverRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } @@ -55,7 +60,7 @@ public Vector3 Scale } } - public Vector3 Position { get => Hub.playerMovementSync.GetRealPosition(); set => Hub.playerMovementSync.OverridePosition(value,RotationFloat,false); } + public Vector3 Position { get => Hub.playerMovementSync.GetRealPosition(); set => Hub.playerMovementSync.OverridePosition(value,RotationFloat); } public Vector3 RotationVector { get => ClassManager._plyCam.transform.forward; set => ClassManager._plyCam.transform.forward = value; } @@ -81,6 +86,7 @@ public Team Side { get { + // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault switch (Team) { case Team.RSC: @@ -106,25 +112,25 @@ public Room CurRoom if (!flag || rayCastHit.transform == null) return null; - var transform = rayCastHit.transform; + var infoTransform = rayCastHit.transform; - while (transform.parent != null && transform.parent.parent != null) - transform = transform.parent; + while (infoTransform.parent != null && infoTransform.parent.parent != null) + infoTransform = infoTransform.parent; - foreach (var room in Map.Rooms.Where(room => room.Position == transform.position)) + foreach (var room in Map.Rooms.Where(room => room.Position == infoTransform.position)) return room; return new Room { - Name = transform.name, - Position = transform.position, - Transform = transform + Name = infoTransform.name, + Position = infoTransform.position, + Transform = infoTransform }; } set => Position = value.Position; } - public NetworkConnection Connection { get => Hub.scp079PlayerScript.connectionToClient; } + public NetworkConnection Connection => Hub.scp079PlayerScript.connectionToClient; public Inventory.SyncListItemInfo Items { get => Hub.inventory.items; set => Hub.inventory.items = value; } @@ -157,9 +163,9 @@ public Player Cuffer public uint Ammo9 { get => Hub.ammoBox.amount[2]; set => Hub.ammoBox.amount[2] = value; } - public UserGroup Rank { get => Hub.serverRoles.Group; set => Hub.serverRoles.SetGroup(value, false, false, false); } + public UserGroup Rank { get => Hub.serverRoles.Group; set => Hub.serverRoles.SetGroup(value, false); } - public string GroupName { get => ServerStatic.PermissionsHandler._members[UserID]; } + public string GroupName => ServerStatic.PermissionsHandler._members[UserId]; public string RankColor { get => Rank.BadgeColor; set => Hub.serverRoles.SetColor(value); } @@ -176,7 +182,7 @@ public Player Cuffer public float RotationFloat => Hub.transform.rotation.eulerAngles.y; - public bool IsCuffed => (Cuffer == null) ? false : true; + public bool IsCuffed => Cuffer != null; public bool IsReloading => Hub.weaponManager.IsReloading(); @@ -240,6 +246,6 @@ public void InstantBroadcast(ushort time, string message) public void ClearInventory() => Hub.inventory.Clear(); - public void GiveEffect(Effect effect,byte intens = 1,float duration = -1f) => EffectsController.ChangeByString(effect.ToString().ToLower(), intens, duration); + public void GiveEffect(Effect effect,byte intensity = 1,float duration = -1f) => EffectsController.ChangeByString(effect.ToString().ToLower(), intensity, duration); } } diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 10c9237..5c9665c 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; -using Hints; using Mirror; -using Synapse.Permissions; +using Synapse.Api.Enums; using UnityEngine; namespace Synapse.Api @@ -14,22 +12,21 @@ namespace Synapse.Api [SuppressMessage("ReSharper", "UnusedMember.Global")] public static class PlayerExtensions { - private static MethodInfo sendSpawnMessage; + private static MethodInfo _sendSpawnMessage; public static MethodInfo SendSpawnMessage { get { - if (sendSpawnMessage == null) - sendSpawnMessage = typeof(NetworkServer).GetMethod("SendSpawnMessage",BindingFlags.Instance | BindingFlags.InvokeMethod + if (_sendSpawnMessage == null) + _sendSpawnMessage = typeof(NetworkServer).GetMethod("SendSpawnMessage",BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public); - return sendSpawnMessage; + return _sendSpawnMessage; } } /// Gives a User a Message im Remote Admin /// The User who you send the Message - /// The Name from which is it at the beginning of the Message /// The Message you want to send /// True = green the command is right you have permission and execute it successfully /// In Which Category should you see it too? @@ -69,9 +66,9 @@ public static void RaMessage(this CommandSender sender, string message, bool suc public static IEnumerable GetAllPlayers() { - return (from gameobject in PlayerManager.players - where gameobject != PlayerManager.localPlayer && gameobject != null - select gameobject.GetPlayer()).ToList(); + return (from gameObject in PlayerManager.players + where gameObject != PlayerManager.localPlayer && gameObject != null + select gameObject.GetPlayer()).ToList(); } public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent(); @@ -89,7 +86,7 @@ public static Player GetPlayer(string arg) !arg.EndsWith("@patreon")) return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower())); foreach (var player in GetAllPlayers()) - if (player.UserID == arg) + if (player.UserId == arg) return player; return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower())); diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index 29e7e98..bfff62d 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using Synapse.Api.Enums; +using UnityEngine; namespace Synapse.Api { @@ -11,6 +12,7 @@ public class Room public Transform Transform { get; set; } public Vector3 Position { get; set; } + // ReSharper disable once UnusedMember.Global public ZoneType Zone { get diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index 45c0e2a..ec30422 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -4,20 +4,20 @@ namespace Synapse { internal static class Configs { - //Variablen - private static YamlConfig Config; + // Variables + private static YamlConfig _config; - //Configs - internal static int requiredforFemur; - internal static bool remotekeycard; + // Configs + internal static int RequiredForFemur; + internal static bool RemoteKeyCard; - //Methods + // Methods internal static void ReloadConfig() { - if (Config == null) Config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); + if (_config == null) _config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); - requiredforFemur = Config.GetInt("synapse.femur",1); - remotekeycard = Config.GetBool("synapse.remote.keycard", true); + RequiredForFemur = _config.GetInt("synapse.femur",1); + RemoteKeyCard = _config.GetBool("synapse.remote.keyCard", true); } } } diff --git a/Synapse/Events/Classes/FemurEnterEvent.cs b/Synapse/Events/Classes/FemurEnterEvent.cs index d355cd3..47b78b9 100644 --- a/Synapse/Events/Classes/FemurEnterEvent.cs +++ b/Synapse/Events/Classes/FemurEnterEvent.cs @@ -1,9 +1,4 @@ using Synapse.Api; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Synapse.Events.Classes { diff --git a/Synapse/Events/Classes/LoadComponentsEvent.cs b/Synapse/Events/Classes/LoadComponentsEvent.cs index 8b6c956..98039a5 100644 --- a/Synapse/Events/Classes/LoadComponentsEvent.cs +++ b/Synapse/Events/Classes/LoadComponentsEvent.cs @@ -1,5 +1,4 @@ -using Synapse.Api; -using UnityEngine; +using UnityEngine; namespace Synapse.Events.Classes { diff --git a/Synapse/Events/Classes/RemoteCommandEvent.cs b/Synapse/Events/Classes/RemoteCommandEvent.cs index 5562984..84924c0 100644 --- a/Synapse/Events/Classes/RemoteCommandEvent.cs +++ b/Synapse/Events/Classes/RemoteCommandEvent.cs @@ -9,7 +9,7 @@ public class RemoteCommandEvent : EventArgs public Player Player => Sender.SenderId == "SERVER CONSOLE" || Sender.SenderId == "GAME CONSOLE" ? Player.Server - : Api.PlayerExtensions.GetPlayer(Sender.SenderId); + : PlayerExtensions.GetPlayer(Sender.SenderId); public bool Allow { get; set; } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 85d84c1..7bb1fc2 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; -using System.Linq; -using Discord; using MEC; using Synapse.Api; +using Synapse.Api.Enums; using Synapse.Events.Classes; using Synapse.Permissions; using UnityEngine; @@ -30,20 +29,17 @@ public EventHandler() } // Methods - private void OnDoorInteract(ref DoorInteractEvent ev) + private static void OnDoorInteract(ref DoorInteractEvent ev) { - if (Configs.remotekeycard) - { - if (ev.Allow) return; + if (!Configs.RemoteKeyCard) return; + if (ev.Allow) return; - foreach (var item in ev.Player.Items) - { - if (ev.Player.Hub.inventory.GetItemByID(item.id).permissions.Contains(ev.Door.permissionLevel))//update to backwardsCompatPermissions when neccesary - { - ev.Allow = true; - return; - } - } + foreach (var item in ev.Player.Items) + { + if (!ev.Player.Hub.inventory.GetItemByID(item.id).permissions + .Contains(ev.Door.permissionLevel)) continue; //update to backwardsCompatPermissions when necessary + ev.Allow = true; + return; } } diff --git a/Synapse/Events/MapEvents.cs b/Synapse/Events/MapEvents.cs index 3626f23..23ff2b0 100644 --- a/Synapse/Events/MapEvents.cs +++ b/Synapse/Events/MapEvents.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Synapse.Api; using Synapse.Events.Classes; -using UnityEngine; namespace Synapse.Events { diff --git a/Synapse/Events/Patches/FemurEnterPatch.cs b/Synapse/Events/Patches/FemurEnterPatch.cs index 751e41a..7dfa368 100644 --- a/Synapse/Events/Patches/FemurEnterPatch.cs +++ b/Synapse/Events/Patches/FemurEnterPatch.cs @@ -28,7 +28,7 @@ public static bool Prefix(CharacterClassManager __instance) { var allow = component.CurRole.team != Team.SCP; - var CloseFemur = femurBrokePeople + 1 >= Configs.requiredforFemur; + var CloseFemur = femurBrokePeople + 1 >= Configs.RequiredForFemur; var player = __instance.GetPlayer(); Events.InvokeFemurEnterEvent(player, ref allow, ref CloseFemur); diff --git a/Synapse/Events/Patches/PlayerBanPatch.cs b/Synapse/Events/Patches/PlayerBanPatch.cs index b668550..62909f7 100644 --- a/Synapse/Events/Patches/PlayerBanPatch.cs +++ b/Synapse/Events/Patches/PlayerBanPatch.cs @@ -17,7 +17,7 @@ public static bool Prefix(GameObject user, int duration, string reason, string i var player = user.GetPlayer(); var banIssuer = PlayerExtensions.GetPlayer(issuer); var allow = true; - Events.InvokePlayerBanEvent(player, player.UserID, duration, ref allow, reason, banIssuer); + Events.InvokePlayerBanEvent(player, player.UserId, duration, ref allow, reason, banIssuer); return isGlobalBan && ConfigFile.ServerConfig.GetBool("gban_ban_ip") || allow; } diff --git a/Synapse/Events/Patches/PlayerJoinPatch.cs b/Synapse/Events/Patches/PlayerJoinPatch.cs index b77f713..f0ac4e1 100644 --- a/Synapse/Events/Patches/PlayerJoinPatch.cs +++ b/Synapse/Events/Patches/PlayerJoinPatch.cs @@ -14,7 +14,7 @@ public static bool Prefix(NicknameSync __instance, ref string n) { var player = __instance.GetPlayer(); - if (!string.IsNullOrEmpty(player.UserID)) + if (!string.IsNullOrEmpty(player.UserId)) Events.InvokePlayerJoinEvent(player, ref n); } catch (Exception e) diff --git a/Synapse/Events/Patches/PreAuthenticationPatch.cs b/Synapse/Events/Patches/PreAuthenticationPatch.cs index a44a0e0..79a6d57 100644 --- a/Synapse/Events/Patches/PreAuthenticationPatch.cs +++ b/Synapse/Events/Patches/PreAuthenticationPatch.cs @@ -22,7 +22,7 @@ public static void Postfix(CustomLiteNetLib4MirrorTransport __instance, Connecti var userId = CustomLiteNetLib4MirrorTransport.UserIds[request.RemoteEndPoint].UserId; - Events.InvokePreAuthentication(userId, request, request.Data.Position, 0, null, ref allow); + Events.InvokePreAuthentication(userId, request, ref allow); if (allow) { @@ -35,7 +35,7 @@ public static void Postfix(CustomLiteNetLib4MirrorTransport __instance, Connecti } //TODO: Explain this code to other contrib. - static IEnumerable Transpiler(IEnumerable instructions) + private static IEnumerable Transpiler(IEnumerable instructions) { var codes = new List(instructions); @@ -43,8 +43,8 @@ static IEnumerable Transpiler(IEnumerable inst { if (code.Value.opcode != OpCodes.Callvirt) continue; if (codes[code.Index + 2].opcode != OpCodes.Ldstr) continue; - var strOperrand = codes[code.Index + 2].operand as string; - if (strOperrand == "Player {0} preauthenticated from endpoint {1}.") + var strOperand = codes[code.Index + 2].operand as string; + if (strOperand == "Player {0} preauthenticated from endpoint {1}.") { code.Value.opcode = OpCodes.Nop; } diff --git a/Synapse/Events/Patches/Scp106ContaimentPatch.cs b/Synapse/Events/Patches/Scp106ContainmentPatch.cs similarity index 71% rename from Synapse/Events/Patches/Scp106ContaimentPatch.cs rename to Synapse/Events/Patches/Scp106ContainmentPatch.cs index 13a4176..cf71a10 100644 --- a/Synapse/Events/Patches/Scp106ContaimentPatch.cs +++ b/Synapse/Events/Patches/Scp106ContainmentPatch.cs @@ -5,20 +5,20 @@ namespace Synapse.Events.Patches { [HarmonyPatch(typeof(PlayerInteract), nameof(PlayerInteract.CallCmdContain106))] - public class Scp106ContaimentPatch + public class Scp106ContainmentPatch { public static bool Prefix(PlayerInteract __instance) { try { var allow = true; - Events.InvokeScp106ContaimentEvent(__instance.GetPlayer(), ref allow); + Events.InvokeScp106ContainmentEvent(__instance.GetPlayer(), ref allow); return allow; } catch (Exception e) { - Log.Error($"Scp106ContaimentErr: {e}"); + Log.Error($"Scp106ContainmentErr: {e}"); return true; } } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index bb304ba..2bd64ae 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -1,6 +1,4 @@ -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Security.Permissions; +using System.Diagnostics.CodeAnalysis; using Assets._Scripts.Dissonance; using Synapse.Api; using Synapse.Events.Classes; @@ -19,7 +17,7 @@ public static partial class Events internal static void InvokePlayerJoinEvent(Player player, ref string nick) { if (PlayerJoinEvent == null) return; - var ev = new PlayerJoinEvent() + var ev = new PlayerJoinEvent { Player = player, Nick = nick @@ -212,7 +210,7 @@ internal static void InvokePlayerReloadEvent(Player player,ref bool allow,ref We { if (PlayerReloadEvent == null) return; - var ev = new PlayerReloadEvent() + var ev = new PlayerReloadEvent { Player = player, Allow = allow, @@ -234,11 +232,11 @@ internal static void InvokeFemurEnterEvent(Player player,ref bool allow,ref bool { if (FemurEnterEvent == null) return; - var ev = new FemurEnterEvent() + var ev = new FemurEnterEvent { Player = player, Allow = allow, - CloseFemur = closeFemur, + CloseFemur = closeFemur }; FemurEnterEvent.Invoke(ref ev); @@ -254,7 +252,7 @@ internal static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo it { if (DropItemEvent == null) return; - DropItemEvent ev = new DropItemEvent() + var ev = new DropItemEvent { Player = player, Item = item, @@ -269,7 +267,7 @@ internal static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo it public delegate void OnLoadComponents(LoadComponentsEvent ev); public static event OnLoadComponents LoadComponentsEvent; - internal static void InvokeLoadComponents(GameObject player) => LoadComponentsEvent?.Invoke(new LoadComponentsEvent() { Player = player }); + internal static void InvokeLoadComponents(GameObject player) => LoadComponentsEvent?.Invoke(new LoadComponentsEvent { Player = player }); public delegate void OnGeneratorInserted(ref GeneratorEvent ev); public static event OnGeneratorInserted GeneratorInsertedEvent; diff --git a/Synapse/Events/ScpEvents.cs b/Synapse/Events/ScpEvents.cs index 3d24556..cd63daa 100644 --- a/Synapse/Events/ScpEvents.cs +++ b/Synapse/Events/ScpEvents.cs @@ -1,12 +1,11 @@ -using System.Diagnostics.CodeAnalysis; -using Synapse.Api; +using Synapse.Api; using Synapse.Events.Classes; namespace Synapse.Events { public static partial class Events { - /// A Event which is activated when Scp049 Respawnes a Player + /// A Event which is activated when Scp049 respawns a Player public delegate void OnScp049Recall(ref Scp049RecallEvent ev); public static event OnScp049Recall Scp049RecallEvent; @@ -41,7 +40,7 @@ internal static void InvokePocketDimensionEnterEvent(Player player, ref bool all { if (PocketDimensionEnterEvent == null) return; - var ev = new PocketDimensionEvent() + var ev = new PocketDimensionEvent { Player = player, Allow = allow @@ -53,19 +52,19 @@ internal static void InvokePocketDimensionEnterEvent(Player player, ref bool all } public delegate void OnScp106Containment(ref Scp106ContainmentEvent ev); - public static event OnScp106Containment Scp106ContaimentEvent; + public static event OnScp106Containment Scp106ContainmentEvent; - internal static void InvokeScp106ContaimentEvent(Player player, ref bool allow) + internal static void InvokeScp106ContainmentEvent(Player player, ref bool allow) { - if (Scp106ContaimentEvent == null) return; + if (Scp106ContainmentEvent == null) return; - var ev = new Scp106ContainmentEvent() + var ev = new Scp106ContainmentEvent { Player = player, Allow = allow }; - Scp106ContaimentEvent.Invoke(ref ev); + Scp106ContainmentEvent.Invoke(ref ev); allow = ev.Allow; } diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index e1b0cc2..f689bca 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -83,33 +83,32 @@ internal static void InvokeConsoleCommandEvent(Player player, string command, ou public delegate void TeamRespawn(ref TeamRespawnEvent ev); public static event TeamRespawn TeamRespawnEvent; - internal static void InvokeTeamRespawnEvent(ref List respawnlist, ref bool ischaos, ref bool allow ,ref bool useticktes) + internal static void InvokeTeamRespawnEvent(ref List respawnList, ref bool isChaos, ref bool allow ,ref bool useTickets) { if (TeamRespawnEvent == null) return; - var ev = new TeamRespawnEvent() + var ev = new TeamRespawnEvent { Allow = allow, - IsChaos = ischaos, - RespawnList = respawnlist, - UseTickets = useticktes + IsChaos = isChaos, + RespawnList = respawnList, + UseTickets = useTickets }; TeamRespawnEvent.Invoke(ref ev); - respawnlist = ev.RespawnList; - ischaos = ev.IsChaos; + respawnList = ev.RespawnList; + isChaos = ev.IsChaos; allow = ev.Allow; - useticktes = ev.UseTickets; + useTickets = ev.UseTickets; } public delegate void OnPreAuthenticationEvent(ref PreAuthenticationEvent ev); public static event OnPreAuthenticationEvent PreAuthenticationEvent; - internal static void InvokePreAuthentication(string userId, ConnectionRequest request, int position, byte flags, - string country, ref bool allow) + internal static void InvokePreAuthentication(string userId, ConnectionRequest request, ref bool allow) { - var ev = new PreAuthenticationEvent() + var ev = new PreAuthenticationEvent { Allow = allow, Request = request, diff --git a/Synapse/Permissions/PermissionReader.cs b/Synapse/Permissions/PermissionReader.cs index e1da39b..e386bf2 100644 --- a/Synapse/Permissions/PermissionReader.cs +++ b/Synapse/Permissions/PermissionReader.cs @@ -77,7 +77,7 @@ internal static bool CheckPermission(Player player, string permission) return false; } - var userGroup = ServerStatic.GetPermissionsHandler().GetUserGroup(player.UserID); + var userGroup = ServerStatic.GetPermissionsHandler().GetUserGroup(player.UserId); Group group = null; if (userGroup != null) @@ -104,7 +104,7 @@ internal static bool CheckPermission(Player player, string permission) } else { - if (player.Hub.serverRoles.Staff || player.UserID.EndsWith("@northwood")) group = GetNwGroup(); + if (player.Hub.serverRoles.Staff || player.UserId.EndsWith("@northwood")) group = GetNwGroup(); else group = GetDefaultGroup(); } diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index de4cedd..3766b83 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -10,6 +10,7 @@ public abstract class Plugin // ReSharper disable once NotAccessedField.Global public static YamlConfig Config; + // ReSharper disable once UnusedAutoPropertyAccessor.Global public Translation Translation { get; internal set; } private string _ownPluginFolder; diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 26566eb..a6a07b5 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -25,7 +25,8 @@ public static class PluginManager internal static string ServerConfigDirectory { get; private set; } private static string ServerConfigFile { get; set; } - internal static Events.EventHandler EventHandler; + // ReSharper disable once NotAccessedField.Local + private static Events.EventHandler _eventHandler; // Methods internal static IEnumerator StartSynapse() @@ -80,7 +81,7 @@ private static void LoadSynapse() { Configs.ReloadConfig(); HarmonyPatch(); - EventHandler = new Events.EventHandler(); + _eventHandler = new Events.EventHandler(); try { @@ -151,8 +152,7 @@ private static void OnEnable() foreach (var plugin in Plugins) try { - plugin.Translation = new Translation(); - plugin.Translation.plugin = plugin; + plugin.Translation = new Translation {Plugin = plugin}; plugin.OwnPluginFolder = Path.Combine(ServerPluginDirectory, plugin.GetName); plugin.OnEnable(); } diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index f79b35e..056258a 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -95,7 +95,7 @@ - + diff --git a/Synapse/Translation.cs b/Synapse/Translation.cs index eb46c9a..d468393 100644 --- a/Synapse/Translation.cs +++ b/Synapse/Translation.cs @@ -1,28 +1,30 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; namespace Synapse { + [SuppressMessage("ReSharper", "UnusedMember.Global")] public class Translation { - private Dictionary translation = new Dictionary(); - private string translationpath; - internal Plugin plugin; + private Dictionary _translation = new Dictionary(); + private string _translationPath; + internal Plugin Plugin; public void CreateTranslations(Dictionary translations) { - translationpath = Path.Combine(PluginManager.ServerConfigDirectory, plugin.GetName + "-translation.txt"); - if (!File.Exists(translationpath)) - File.Create(translationpath).Close(); + _translationPath = Path.Combine(PluginManager.ServerConfigDirectory, Plugin.GetName + "-translation.txt"); + if (!File.Exists(_translationPath)) + File.Create(_translationPath).Close(); var dictionary = new Dictionary(); - string[] lines = File.ReadAllLines(translationpath); - List newlines = new List(); - int position = 0; + var lines = File.ReadAllLines(_translationPath); + var newlines = new List(); + var position = 0; foreach (var pair in translations.ToList()) { - if (lines.Count() > position) + if (lines.Length > position) { if (string.IsNullOrEmpty(lines[position])) { @@ -42,22 +44,22 @@ public void CreateTranslations(Dictionary translations) } position++; - File.WriteAllLines(translationpath, newlines.ToArray()); + File.WriteAllLines(_translationPath, newlines.ToArray()); } - translation = dictionary; + _translation = dictionary; } public string GetTranslation(string translationName) { try { - string trans = translation.FirstOrDefault(x => x.Key == translationName).Value; + var trans = _translation.FirstOrDefault(x => x.Key == translationName).Value; return trans; } catch { - return $"Invalid Translations Name"; + return "Invalid Translations Name"; } } } From 300665e23367d25535d7126119c97e75de865577 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 15 Jun 2020 16:04:14 +0200 Subject: [PATCH 133/199] merge --- Synapse/Api/Player.cs | 2 +- Synapse/Api/PlayerExtensions.cs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index fdc709c..a900600 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -50,7 +50,7 @@ public Vector3 Scale } catch (Exception e) { - Log.Error($"SetScale Error. {e}"); + Log.Error($"SetScale Error: {e}"); } } } diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 10c9237..9a304a8 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; -using Hints; using Mirror; -using Synapse.Permissions; using UnityEngine; namespace Synapse.Api From 1fd49d4a7b4556faf355bf608d72e83370796e86 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 15 Jun 2020 20:06:02 +0200 Subject: [PATCH 134/199] Changed Path Names --- Synapse/PluginManager.cs | 4 ++-- Synapse/Synapse.csproj | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index a6a07b5..3660bd3 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -48,11 +48,11 @@ internal static IEnumerator StartSynapse() private static void Files() { - ServerPluginDirectory = Path.Combine(MainPluginDirectory, $"Server{ServerStatic.ServerPort} Plugins"); + ServerPluginDirectory = Path.Combine(MainPluginDirectory, $"Server-{ServerStatic.ServerPort}"); if (!Directory.Exists(ServerPluginDirectory)) Directory.CreateDirectory(ServerPluginDirectory); - ServerConfigDirectory = Path.Combine(MainConfigDirectory, $"Server{ServerStatic.ServerPort}-Configs"); + ServerConfigDirectory = Path.Combine(MainConfigDirectory, $"Server-{ServerStatic.ServerPort}"); if (!Directory.Exists(ServerConfigDirectory)) Directory.CreateDirectory(ServerConfigDirectory); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 056258a..824f668 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -40,9 +40,8 @@ ..\..\Synapse_Dependencies\Assembly-CSharp-firstpass.dll - - False - ..\..\Synapse_Dependencies\Assembly-CSharp-Synapse_publizied.dll + + ..\..\Synapse_Dependencies\Assembly-CSharp-Synapse_publicised.dll ..\..\Synapse_Dependencies\Mirror.dll From e50363e2d533df26e0ecb745e8233ba690c92900 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 16 Jun 2020 18:20:15 +0200 Subject: [PATCH 135/199] added UseItem Event --- Synapse/Events/Classes/UseItemEvent.cs | 11 +++++++++++ Synapse/Events/Patches/UseItemPatch.cs | 24 ++++++++++++++++++++++++ Synapse/Events/PlayerEvents.cs | 18 ++++++++++++++++++ Synapse/Synapse.csproj | 2 ++ 4 files changed, 55 insertions(+) create mode 100644 Synapse/Events/Classes/UseItemEvent.cs create mode 100644 Synapse/Events/Patches/UseItemPatch.cs diff --git a/Synapse/Events/Classes/UseItemEvent.cs b/Synapse/Events/Classes/UseItemEvent.cs new file mode 100644 index 0000000..44f9f28 --- /dev/null +++ b/Synapse/Events/Classes/UseItemEvent.cs @@ -0,0 +1,11 @@ +using Synapse.Api; + +namespace Synapse.Events.Classes +{ + public class UseItemEvent + { + public Player Player { get; internal set; } + + public bool Allow { get; internal set; } + } +} diff --git a/Synapse/Events/Patches/UseItemPatch.cs b/Synapse/Events/Patches/UseItemPatch.cs new file mode 100644 index 0000000..824b3bb --- /dev/null +++ b/Synapse/Events/Patches/UseItemPatch.cs @@ -0,0 +1,24 @@ +using System; +using Harmony; +using Synapse.Api; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(ConsumableAndWearableItems), nameof(ConsumableAndWearableItems.UseMedicalItem))] + public class UseItemPatch + { + public static bool Prefix(ConsumableAndWearableItems __instance) + { + try + { + Events.InvokeUseItemEvent(__instance.GetPlayer(),out bool allow); + return allow; + } + catch (Exception e) + { + Log.Error($"UseItemEvent Error: {e}"); + return true; + } + } + } +} diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 2bd64ae..d752bc1 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -358,5 +358,23 @@ internal static void InvokeGeneratorClose(Player player, Generator079 generator, allow = ev.Allow; } + + public delegate void OnUseItem(UseItemEvent ev); + public static event OnUseItem UseItemEvent; + internal static void InvokeUseItemEvent(Player player, out bool allow) + { + allow = true; + if (UseItemEvent == null) return; + + var ev = new UseItemEvent + { + Player = player, + Allow = true + }; + + UseItemEvent.Invoke(ev); + + allow = ev.Allow; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 824f668..de78deb 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -71,8 +71,10 @@ + + From a419cd4416edc7b6fd305ddfa69a4292b6dc1743 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 16 Jun 2020 18:43:41 +0200 Subject: [PATCH 136/199] added Scp079GainLvlEvent --- Synapse/Events/Classes/Scp079GainLvlEvent.cs | 13 ++++++++++ Synapse/Events/Patches/Scp079GainLvlPatch.cs | 25 ++++++++++++++++++++ Synapse/Events/PlayerEvents.cs | 4 ++-- Synapse/Events/ScpEvents.cs | 20 ++++++++++++++++ Synapse/Synapse.csproj | 2 ++ 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Synapse/Events/Classes/Scp079GainLvlEvent.cs create mode 100644 Synapse/Events/Patches/Scp079GainLvlPatch.cs diff --git a/Synapse/Events/Classes/Scp079GainLvlEvent.cs b/Synapse/Events/Classes/Scp079GainLvlEvent.cs new file mode 100644 index 0000000..dbfcb41 --- /dev/null +++ b/Synapse/Events/Classes/Scp079GainLvlEvent.cs @@ -0,0 +1,13 @@ +using Synapse.Api; + +namespace Synapse.Events.Classes +{ + public class Scp079GainLvlEvent + { + public Player Player { get; internal set; } + + public bool Allow { get; set; } + + public int NewLvl { get; set; } + } +} diff --git a/Synapse/Events/Patches/Scp079GainLvlPatch.cs b/Synapse/Events/Patches/Scp079GainLvlPatch.cs new file mode 100644 index 0000000..ad53717 --- /dev/null +++ b/Synapse/Events/Patches/Scp079GainLvlPatch.cs @@ -0,0 +1,25 @@ +using System; +using Harmony; +using Synapse.Api; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(Scp079PlayerScript), nameof(Scp079PlayerScript.TargetLevelChanged))] + public static class Scp079GainLvlPatch + { + public static bool Prefix(Scp079PlayerScript __instance, ref int newLvl) + { + try + { + bool allow = true; + Events.InvokeScp079LvlEvent(__instance.GetPlayer(), ref newLvl, ref allow); + return allow; + } + catch (Exception e) + { + Log.Error($"Scp079GainLevelEvent Error: {e}"); + return true; + } + } + } +} diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index d752bc1..435e060 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -359,7 +359,7 @@ internal static void InvokeGeneratorClose(Player player, Generator079 generator, allow = ev.Allow; } - public delegate void OnUseItem(UseItemEvent ev); + public delegate void OnUseItem(ref UseItemEvent ev); public static event OnUseItem UseItemEvent; internal static void InvokeUseItemEvent(Player player, out bool allow) { @@ -372,7 +372,7 @@ internal static void InvokeUseItemEvent(Player player, out bool allow) Allow = true }; - UseItemEvent.Invoke(ev); + UseItemEvent.Invoke(ref ev); allow = ev.Allow; } diff --git a/Synapse/Events/ScpEvents.cs b/Synapse/Events/ScpEvents.cs index cd63daa..6023b21 100644 --- a/Synapse/Events/ScpEvents.cs +++ b/Synapse/Events/ScpEvents.cs @@ -68,5 +68,25 @@ internal static void InvokeScp106ContainmentEvent(Player player, ref bool allow) allow = ev.Allow; } + + + public delegate void OnScp079GainLvl(ref Scp079GainLvlEvent ev); + public static event OnScp079GainLvl Scp079GainLvlEvent; + internal static void InvokeScp079LvlEvent(Player player,ref int newlvl,ref bool allow) + { + if (Scp079GainLvlEvent == null) return; + + var ev = new Scp079GainLvlEvent + { + Allow = allow, + NewLvl = newlvl, + Player = player + }; + + Scp079GainLvlEvent.Invoke(ref ev); + + newlvl = ev.NewLvl; + allow = ev.Allow; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index de78deb..5ef6fe9 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -71,9 +71,11 @@ + + From e7415ebcf2429c96ee92d962bfaa365c4e4a94bc Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 16 Jun 2020 19:03:01 +0200 Subject: [PATCH 137/199] added RaLogin/Logout --- Synapse/Api/Player.cs | 17 +++++++++++++++++ Synapse/Events/Patches/Scp049RecallPatch.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 281862a..ee63ffa 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -198,6 +198,7 @@ public Player Cuffer public void Kill(DamageTypes.DamageType damageType = default) => Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(-1f, "WORLD", damageType, 0), gameObject); + [Obsolete("Didnt work properly in Scopophobia we will fix this")] public void ChangeRoleAtPosition(RoleType role) { //TODO: Fix this shit @@ -247,5 +248,21 @@ public void InstantBroadcast(ushort time, string message) public void ClearInventory() => Hub.inventory.Clear(); public void GiveEffect(Effect effect,byte intensity = 1,float duration = -1f) => EffectsController.ChangeByString(effect.ToString().ToLower(), intensity, duration); + + public void RaLogin() + { + Hub.serverRoles.RemoteAdmin = true; + Hub.serverRoles.Permissions = Hub.serverRoles.Group.Permissions; + Hub.serverRoles.RemoteAdminMode = ServerRoles.AccessMode.PasswordOverride; + Hub.serverRoles.TargetOpenRemoteAdmin(Connection, false); + } + + public void RaLogout() + { + Hub.serverRoles.RemoteAdmin = false; + Hub.serverRoles.Permissions = 0UL; + Hub.serverRoles.RemoteAdminMode = ServerRoles.AccessMode.LocalAccess; + Hub.serverRoles.TargetCloseRemoteAdmin(Connection); + } } } diff --git a/Synapse/Events/Patches/Scp049RecallPatch.cs b/Synapse/Events/Patches/Scp049RecallPatch.cs index 9afc40d..1f31bd3 100644 --- a/Synapse/Events/Patches/Scp049RecallPatch.cs +++ b/Synapse/Events/Patches/Scp049RecallPatch.cs @@ -92,7 +92,7 @@ public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go) var pos3 = component.transform.position; pos3.y += 2; - target.ChangeRoleAtPosition(role); + target.Role = role; Timing.CallDelayed(0.5f, () => target.Position = pos3); target.GetComponent().Health = live; if (component.CompareTag("Ragdoll")) NetworkServer.Destroy(component.gameObject); From 647e362901e80b08331bf51a18977593c7f87d8e Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 19 Jun 2020 21:04:24 +0200 Subject: [PATCH 138/199] small changes --- Synapse/Api/PlayerExtensions.cs | 5 ++++- Synapse/Log.cs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 5c9665c..55a15dd 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; @@ -71,6 +72,8 @@ public static IEnumerable GetAllPlayers() select gameObject.GetPlayer()).ToList(); } + public static IEnumerable GetAllPlayers(this RoleType role) => GetAllPlayers().Where(x => x.Role == role); + public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent(); public static Player GetPlayer(this GameObject gameObject) => gameObject.GetComponent(); diff --git a/Synapse/Log.cs b/Synapse/Log.cs index 5026977..5ec0581 100644 --- a/Synapse/Log.cs +++ b/Synapse/Log.cs @@ -10,7 +10,7 @@ public static class Log public static void Info(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[INFO] [{assembly.GetName().ToString().Split(',')[0]}] {message}", + ServerConsole.AddLog($"[INFO] [{assembly.GetName().Name}] {message}", ConsoleColor.Blue); } @@ -20,7 +20,7 @@ public static void Info(string message) public static void Warn(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[WARN] [{assembly.GetName().ToString().Split(',')[0]}] {message}", + ServerConsole.AddLog($"[WARN] [{assembly.GetName().Name}] {message}", ConsoleColor.Yellow); } @@ -29,7 +29,7 @@ public static void Warn(string message) public static void Error(string message) { var assembly = Assembly.GetCallingAssembly(); - ServerConsole.AddLog($"[ERROR] [{assembly.GetName().ToString().Split(',')[0]}] {message}", + ServerConsole.AddLog($"[ERROR] [{assembly.GetName().Name}] {message}", ConsoleColor.Red); } } From 37686f3d87d2143fe5cae8bd58566a5dc593c29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 21 Jun 2020 12:21:48 +0200 Subject: [PATCH 139/199] CheckRoundEndEvent done --- Synapse/Events/Classes/CheckRoundEndEvent.cs | 4 +- Synapse/Events/Patches/CheckRoundEndPatch.cs | 189 +++++++++++++++++++ Synapse/Events/ServerEvents.cs | 19 ++ 3 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 Synapse/Events/Patches/CheckRoundEndPatch.cs diff --git a/Synapse/Events/Classes/CheckRoundEndEvent.cs b/Synapse/Events/Classes/CheckRoundEndEvent.cs index 007d038..9e33f82 100644 --- a/Synapse/Events/Classes/CheckRoundEndEvent.cs +++ b/Synapse/Events/Classes/CheckRoundEndEvent.cs @@ -2,6 +2,8 @@ { public class CheckRoundEndEvent { - + public RoundSummary.LeadingTeam LeadingTeam { get; set; } + public bool ForceEnd { get; set; } + public bool Allow { get; set; } } } \ No newline at end of file diff --git a/Synapse/Events/Patches/CheckRoundEndPatch.cs b/Synapse/Events/Patches/CheckRoundEndPatch.cs new file mode 100644 index 0000000..ca4bde0 --- /dev/null +++ b/Synapse/Events/Patches/CheckRoundEndPatch.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using System.Runtime.Remoting.Messaging; +using GameCore; +using Harmony; +using UnityEngine; +using Console = System.Console; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(RoundSummary), nameof(RoundSummary.Start))] + public class CheckRoundEndPatch + { + private static readonly MethodInfo + CustomProcess = SymbolExtensions.GetMethodInfo(() => ProcessServerSide(null)); + + static IEnumerable Transpiler(IEnumerable instr) + { + var codes = new List(instr); + + foreach (var code in codes.Select((x,i) => new {Value =x, Index = i })) + { + if (code.Value.opcode != OpCodes.Call) continue; + + if (code.Value.operand != null && code.Value.operand is MethodBase methodBase && + methodBase.Name == nameof(RoundSummary._ProcessServerSideCode)) + { + codes[code.Index].operand = CustomProcess; + } + } + + return codes.AsEnumerable(); + } + + public static IEnumerator ProcessServerSide(RoundSummary instance) + { + Log.Info("Cool"); + var roundSummary = instance; + + Log.Info(roundSummary.ToString()); + + while (roundSummary != null) + { + while (RoundSummary.RoundLock || !RoundSummary.RoundInProgress() || + roundSummary.keepRoundOnOne && PlayerManager.players.Count < 2) yield return 0.0f; + + var newList = new RoundSummary.SumInfo_ClassList(); + + foreach (var chrClassManager in PlayerManager.players.Where(gameObject => gameObject != null).Select(gameObject => gameObject.GetComponent()).Where(chrClassManager => chrClassManager.Classes.CheckBounds(chrClassManager.CurClass))) + { + // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault + switch (chrClassManager.Classes.SafeGet(chrClassManager.CurClass).team) + { + case Team.SCP: + if (chrClassManager.CurClass == RoleType.Scp0492) + { + newList.zombies++; + continue; + } + + newList.scps_except_zombies++; + continue; + case Team.MTF: + newList.mtf_and_guards++; + continue; + case Team.CHI: + newList.chaos_insurgents++; + continue; + case Team.RSC: + newList.scientists++; + continue; + case Team.CDP: + newList.class_ds++; + continue; + default: + continue; + } + } + + newList.warhead_kills = + AlphaWarheadController.Host.detonated ? AlphaWarheadController.Host.warheadKills : -1; + + yield return float.NegativeInfinity; + newList.time = (int) Time.realtimeSinceStartup; + yield return float.NegativeInfinity; + + RoundSummary.roundTime = newList.time - roundSummary.classlistStart.time; + + var mtfSum = newList.mtf_and_guards + newList.scientists; + var chaosSum = newList.chaos_insurgents + newList.class_ds; + var scpSum = newList.scps_except_zombies + newList.zombies; + + Log.Warn($"mtfSum: {mtfSum} | chaosSum: {chaosSum} | scpSum: {scpSum}"); + + var escapedDs = (float)(roundSummary.classlistStart.class_ds == 0 ? 0 : (RoundSummary.escaped_ds + newList.class_ds) / roundSummary.classlistStart.class_ds); + var escapedScientists = (float)(roundSummary.classlistStart.scientists == 0 ? 1 : (RoundSummary.escaped_scientists + newList.scientists) / roundSummary.classlistStart.scientists); + + var allow = true; + var forceEnd = false; + var teamChanged = false; + var team = RoundSummary.LeadingTeam.Draw; + + try + { + Events.InvokeCheckRoundEnd(ref forceEnd, ref allow, ref team, ref teamChanged); + } + catch (Exception e) + { + Log.Error($"CheckRoundEnd err: {e}"); + continue; + } + + if (forceEnd) roundSummary.roundEnded = true; + + if(!allow) continue; + + if (newList.class_ds == 0 && mtfSum == 0) + { + roundSummary.roundEnded = true; + } + + else if (mtfSum == 0 && PlayerManager.localPlayer.GetComponent().MtfRespawnTickets == 0) + { + roundSummary.roundEnded = true; + } + + else + { + //Okay. SCP hat hier einfach wirklich nur Staub gefressen oder so. + var checkVar = 0; + + if (mtfSum > 0) checkVar++; + if (chaosSum > 0) checkVar++; + if (scpSum > 0) checkVar++; + + if (checkVar <= 1) roundSummary.roundEnded = true; + } + + + if (!roundSummary.roundEnded) continue; + var leadingTeam = RoundSummary.LeadingTeam.Draw; + + if (mtfSum > 0) + { + if (RoundSummary.escaped_ds == 0 && RoundSummary.escaped_scientists != 0) + leadingTeam = RoundSummary.LeadingTeam.FacilityForces; + } + else + leadingTeam = RoundSummary.escaped_ds != 0 + ? RoundSummary.LeadingTeam.ChaosInsurgency + : RoundSummary.LeadingTeam.Anomalies; + + if (teamChanged) leadingTeam = team; + + var text = $"Round finished! Anomalies:{scpSum} | Chaos: {chaosSum} | Facility Forces: {mtfSum} | D escaped percentage: {escapedDs} | S escaped percentage: {escapedScientists}"; + + GameCore.Console.AddLog(text, Color.gray); + ServerLogs.AddLog(ServerLogs.Modules.Logger, text, ServerLogs.ServerLogType.GameEvent); + + for (byte i = 0; i < 75; i += 1) + { + yield return 0f; + } + var timeToRoundRestart = Mathf.Clamp(ConfigFile.ServerConfig.GetInt("auto_round_restart_time", 10), 5, 1000); + if (roundSummary != null) + { + roundSummary.RpcShowRoundSummary(roundSummary.classlistStart, newList, leadingTeam, RoundSummary.escaped_ds, RoundSummary.escaped_scientists, RoundSummary.kills_by_scp, timeToRoundRestart); + } + int num7; + for (var j = 0; j < 50 * (timeToRoundRestart - 1); j = num7 + 1) + { + yield return 0f; + num7 = j; + } + roundSummary.RpcDimScreen(); + for (byte i = 0; i < 50; i += 1) + { + yield return 0f; + } + PlayerManager.localPlayer.GetComponent().Roundrestart(); + } + } + } +} \ No newline at end of file diff --git a/Synapse/Events/ServerEvents.cs b/Synapse/Events/ServerEvents.cs index f689bca..d716a86 100644 --- a/Synapse/Events/ServerEvents.cs +++ b/Synapse/Events/ServerEvents.cs @@ -125,5 +125,24 @@ internal static void InvokePreAuthentication(string userId, ConnectionRequest re internal static void InvokeWaitingForPlayers() => WaitingForPlayersEvent?.Invoke(); public delegate void OnCheckRoundEnd(ref CheckRoundEndEvent ev); + public static event OnCheckRoundEnd CheckRoundEndEvent; + + public static void InvokeCheckRoundEnd(ref bool forceEnd, ref bool allow, ref RoundSummary.LeadingTeam team, + ref bool teamChanged) + { + var ev = new CheckRoundEndEvent() + { + Allow = allow, + ForceEnd = forceEnd, + LeadingTeam = team + }; + + CheckRoundEndEvent?.Invoke(ref ev); + + teamChanged = team != ev.LeadingTeam; + team = ev.LeadingTeam; + allow = ev.Allow; + forceEnd = ev.ForceEnd; + } } } \ No newline at end of file From 86fa60698a2242a0d700b494fff26972c74b4a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 21 Jun 2020 12:22:17 +0200 Subject: [PATCH 140/199] Remove Debug Message --- Synapse/Events/Patches/PreAuthenticationPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Events/Patches/PreAuthenticationPatch.cs b/Synapse/Events/Patches/PreAuthenticationPatch.cs index 79a6d57..83c38fa 100644 --- a/Synapse/Events/Patches/PreAuthenticationPatch.cs +++ b/Synapse/Events/Patches/PreAuthenticationPatch.cs @@ -16,7 +16,7 @@ public static void Postfix(CustomLiteNetLib4MirrorTransport __instance, Connecti if (!request.Data.EndOfData) { - Log.Warn("Server is not finished handling Authentication"); + //The Server is not done handling the Authentication, so wait now. return; } From 35e9a6019b832930427f02ad16161539f9fdcc57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 21 Jun 2020 12:22:38 +0200 Subject: [PATCH 141/199] Fix Dependencies. :) --- Synapse/Synapse.csproj | 2 ++ SynapseModLoader/SynapseModLoader.csproj | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 5ef6fe9..2c63a86 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -76,6 +76,7 @@ + @@ -92,6 +93,7 @@ + diff --git a/SynapseModLoader/SynapseModLoader.csproj b/SynapseModLoader/SynapseModLoader.csproj index 634172b..c97ed57 100644 --- a/SynapseModLoader/SynapseModLoader.csproj +++ b/SynapseModLoader/SynapseModLoader.csproj @@ -33,7 +33,7 @@ - ..\..\Synapse_Dependencies\Assembly-CSharp-Synapse_publizied.dll + ..\..\Synapse_Dependencies\Assembly-CSharp-Synapse_publicised.dll From 7e39c906ab5478287a82ff273715bdf50a2fbc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 21 Jun 2020 12:23:20 +0200 Subject: [PATCH 142/199] Fix Modname not being shown in Server List --- Synapse/PluginManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 3660bd3..55831b7 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -82,6 +82,8 @@ private static void LoadSynapse() Configs.ReloadConfig(); HarmonyPatch(); _eventHandler = new Events.EventHandler(); + + ServerConsole.ReloadServerName(); try { From 413925f4f899059ca762f5958e80016292a671fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Sun, 21 Jun 2020 13:31:07 +0200 Subject: [PATCH 143/199] Remove Not needed Debug Messages --- Synapse/Events/Patches/CheckRoundEndPatch.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Synapse/Events/Patches/CheckRoundEndPatch.cs b/Synapse/Events/Patches/CheckRoundEndPatch.cs index ca4bde0..8850d9a 100644 --- a/Synapse/Events/Patches/CheckRoundEndPatch.cs +++ b/Synapse/Events/Patches/CheckRoundEndPatch.cs @@ -39,11 +39,8 @@ static IEnumerable Transpiler(IEnumerable inst public static IEnumerator ProcessServerSide(RoundSummary instance) { - Log.Info("Cool"); var roundSummary = instance; - Log.Info(roundSummary.ToString()); - while (roundSummary != null) { while (RoundSummary.RoundLock || !RoundSummary.RoundInProgress() || @@ -95,8 +92,6 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) var chaosSum = newList.chaos_insurgents + newList.class_ds; var scpSum = newList.scps_except_zombies + newList.zombies; - Log.Warn($"mtfSum: {mtfSum} | chaosSum: {chaosSum} | scpSum: {scpSum}"); - var escapedDs = (float)(roundSummary.classlistStart.class_ds == 0 ? 0 : (RoundSummary.escaped_ds + newList.class_ds) / roundSummary.classlistStart.class_ds); var escapedScientists = (float)(roundSummary.classlistStart.scientists == 0 ? 1 : (RoundSummary.escaped_scientists + newList.scientists) / roundSummary.classlistStart.scientists); From 228a9dd646ef109327ed1f70cd6254d254b89155 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 08:24:11 +0200 Subject: [PATCH 144/199] added PickupItem Event --- Synapse/Api/Player.cs | 4 +-- Synapse/Events/Classes/PickupItemEvent.cs | 13 +++++++ Synapse/Events/Patches/PickUpItemPatch.cs | 43 +++++++++++++++++++++++ Synapse/Events/PlayerEvents.cs | 18 ++++++++++ Synapse/Synapse.csproj | 3 +- 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 Synapse/Events/Classes/PickupItemEvent.cs create mode 100644 Synapse/Events/Patches/PickUpItemPatch.cs diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index ee63ffa..8d09d73 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -198,12 +198,10 @@ public Player Cuffer public void Kill(DamageTypes.DamageType damageType = default) => Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(-1f, "WORLD", damageType, 0), gameObject); - [Obsolete("Didnt work properly in Scopophobia we will fix this")] public void ChangeRoleAtPosition(RoleType role) { //TODO: Fix this shit - Hub.characterClassManager.NetworkCurClass = role; - Hub.playerStats.SetHPAmount(Hub.characterClassManager.Classes.SafeGet(Role).maxHP); + Hub.characterClassManager.SetClassIDAdv(role, true); } public bool CheckPermission(string permission) diff --git a/Synapse/Events/Classes/PickupItemEvent.cs b/Synapse/Events/Classes/PickupItemEvent.cs new file mode 100644 index 0000000..68f4e3c --- /dev/null +++ b/Synapse/Events/Classes/PickupItemEvent.cs @@ -0,0 +1,13 @@ +using Synapse.Api; + +namespace Synapse.Events.Classes +{ + public class PickupItemEvent + { + public Player Player { get; internal set; } + + public Pickup Pickup { get; internal set; } + + public bool Allow { get; set; } + } +} diff --git a/Synapse/Events/Patches/PickUpItemPatch.cs b/Synapse/Events/Patches/PickUpItemPatch.cs new file mode 100644 index 0000000..337acd4 --- /dev/null +++ b/Synapse/Events/Patches/PickUpItemPatch.cs @@ -0,0 +1,43 @@ +using System; +using Harmony; +using Mirror; +using Searching; +using Synapse.Api; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(SearchCoordinator), nameof(SearchCoordinator.ContinuePickupServer))] + static class PickUpItemPatch + { + public static bool Prefix(SearchCoordinator __instance) + { + try + { + if (__instance.Completor.ValidateUpdate()) + { + if (NetworkTime.time >= __instance.SessionPipe.Session.FinishTime) + { + bool allow = true; + + Events.InvokePickupItemEvent(__instance.GetPlayer(),__instance.Completor.TargetPickup, ref allow); + + if (allow) + { + __instance.Completor.Complete(); + return false; + } + } + } + + __instance.SessionPipe.Invalidate(); + + return false; + } + catch (Exception e) + { + Log.Error($"PickupItem Event Error: {e}"); + return false; + } + } + } +} diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 435e060..e131f54 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -376,5 +376,23 @@ internal static void InvokeUseItemEvent(Player player, out bool allow) allow = ev.Allow; } + + public delegate void OnPickupItem(ref PickupItemEvent ev); + public static event OnPickupItem PickupItemEvent; + internal static void InvokePickupItemEvent(Player player, Pickup pickup, ref bool allow) + { + if (PickupItemEvent == null) return; + + var ev = new PickupItemEvent + { + Allow = allow, + Pickup = pickup, + Player = player + }; + + PickupItemEvent.Invoke(ref ev); + + allow = ev.Allow; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 2c63a86..de85abe 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -71,12 +71,13 @@ + + - From 281b51945f36564a2e0aaad8823f8604b19b238b Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 09:39:49 +0200 Subject: [PATCH 145/199] added default permission --- Synapse/Permissions/PermissionReader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Synapse/Permissions/PermissionReader.cs b/Synapse/Permissions/PermissionReader.cs index e386bf2..0abb2f0 100644 --- a/Synapse/Permissions/PermissionReader.cs +++ b/Synapse/Permissions/PermissionReader.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; +using System.Text; using Synapse.Api; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; @@ -21,7 +23,7 @@ public static class PermissionReader internal static void Init() { if (!File.Exists(PermissionPath)) - File.Create(PermissionPath).Close(); + File.WriteAllText(PermissionPath, "groups:\n user:\n default: true\n permissions:\n - plugin.permission\n northwood:\n northwood: true\n permissions:\n - plugin.permission\n owner:\n permissions:\n - .*"); ReloadPermission(); } From a7114f24c9a627701d1dc9c1b4e1ee3eb4c977ea Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 09:58:06 +0200 Subject: [PATCH 146/199] added ReloadPluginConfigs Event --- Synapse/Events/EventHandler.cs | 18 +++++++++++++++--- Synapse/Plugin.cs | 7 ++++++- Synapse/PluginManager.cs | 13 +++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 7bb1fc2..1434d47 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -58,17 +58,29 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) { case "RELOADPERMISSION": { - if (!ev.Player.CheckPermission("sy.reload")) + if (!ev.Player.CheckPermission("sy.reload.permission")) { - ev.Sender.RaMessage("You have no Permission for Reload", false, + ev.Sender.RaMessage("You have no Permission for Reload Permissions", false, RaCategory.AdminTools); return; } PermissionReader.ReloadPermission(); - ev.Sender.RaMessage("Permissions Reloaded!", true, RaCategory.AdminTools); + ev.Sender.RaMessage("Permissions Reloaded!", true, RaCategory.ServerConfigs); return; } + + case "RELOADCONFIGS": + if (!ev.Player.CheckPermission("sy.reload.configs")) + { + ev.Sender.RaMessage("You have no Permission for Reload Configs", false, + RaCategory.AdminTools); + return; + } + + PluginManager.OnConfigReload(); + ev.Sender.RaMessage("Configs Reloaded!", true, RaCategory.ServerConfigs); + return; } } diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 3766b83..ba6e08b 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; namespace Synapse { @@ -10,6 +11,10 @@ public abstract class Plugin // ReSharper disable once NotAccessedField.Global public static YamlConfig Config; + internal delegate void OnConfigReload(); + private event OnConfigReload ConfigReloadEvent; + public void InvokeReload() => ConfigReloadEvent?.Invoke(); + // ReSharper disable once UnusedAutoPropertyAccessor.Global public Translation Translation { get; internal set; } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 55831b7..33b5f81 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -164,6 +164,19 @@ private static void OnEnable() } } + internal static void OnConfigReload() + { + foreach (var plugin in Plugins) + try + { + plugin.InvokeReload(); + } + catch (Exception e) + { + Log.Error($"Plugin {plugin.GetName} threw an exception while reloading {e}"); + } + } + private static void HarmonyPatch() { try From c69c1f01628f12fa7e9afb27aa8d98dd61f70ce6 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 10:00:13 +0200 Subject: [PATCH 147/199] changed Invoke to Internal --- Synapse/Plugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index ba6e08b..f1aa502 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -13,7 +13,7 @@ public abstract class Plugin internal delegate void OnConfigReload(); private event OnConfigReload ConfigReloadEvent; - public void InvokeReload() => ConfigReloadEvent?.Invoke(); + internal void InvokeReload() => ConfigReloadEvent?.Invoke(); // ReSharper disable once UnusedAutoPropertyAccessor.Global public Translation Translation { get; internal set; } From 5d04e72cf30f99a386b80615fb9c8542ac964d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 10:01:22 +0200 Subject: [PATCH 148/199] Add Inventory to Player Object --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index ee63ffa..84249d3 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -190,6 +190,8 @@ public Player Cuffer public bool IsDead => Team == Team.RIP; + public Inventory Inventory => Hub.inventory; + //Methods public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); From 1b4c973251fc08678234322cf441e3cd8206de4f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 10:12:01 +0200 Subject: [PATCH 149/199] added Components to Player --- Synapse/Api/Player.cs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index e190d16..ad17389 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -3,6 +3,8 @@ using System.Linq; using Hints; using Mirror; +using RemoteAdmin; +using Searching; using Synapse.Api.Enums; using Synapse.Permissions; using UnityEngine; @@ -21,8 +23,36 @@ public class Player : MonoBehaviour public CharacterClassManager ClassManager => Hub.characterClassManager; + public Inventory Inventory => Hub.inventory; + + public PlayerStats PlayerStats => Hub.playerStats; + + public ServerRoles ServerRoles => Hub.serverRoles; + + public QueryProcessor QueryProcessor => Hub.queryProcessor; + + public PlayerMovementSync MovementSync => Hub.playerMovementSync; + + public NicknameSync NicknameSync => Hub.nicknameSync; + + public SpectatorManager SpectatorManager => Hub.spectatorManager; + + public AnimationController AnimationController => Hub.animationController; + + public FallDamage FallDamage => Hub.falldamage; + + public Handcuffs Handcuffs => Hub.handcuffs; + + public PlayerInteract PlayerInteract => Hub.playerInteract; + public PlayerEffectsController EffectsController => Hub.playerEffectsController; + public FootstepSync FootstepSync => Hub.footstepSync; + + public SearchCoordinator SearchCoordinator => Hub.searchCoordinator; + + public HintDisplay HintDisplay => Hub.hints; + public string NickName { get => Hub.nicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } @@ -190,8 +220,6 @@ public Player Cuffer public bool IsDead => Team == Team.RIP; - public Inventory Inventory => Hub.inventory; - //Methods public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); From d685977dc3d14164e5bf594cbfe58df7980294e5 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 10:17:40 +0200 Subject: [PATCH 150/199] added GetPlayer for Playable Scp classes --- Synapse/Api/PlayerExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 55a15dd..43c590b 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -76,6 +76,8 @@ public static IEnumerable GetAllPlayers() public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent(); + public static Player GetPlayer(this PlayableScps.PlayableScp scp) => scp.Hub.GetPlayer(); + public static Player GetPlayer(this GameObject gameObject) => gameObject.GetComponent(); public static Player GetPlayer(int id) => GetAllPlayers().FirstOrDefault(p => p.PlayerId == id); From 3a00ed87a5dfa9d6cf5b9bacbad45b7dbed665d0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 10:32:09 +0200 Subject: [PATCH 151/199] added more to Map api --- Synapse/Api/Map.cs | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index d6b33a8..2e92a97 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -11,6 +11,27 @@ namespace Synapse.Api [SuppressMessage("ReSharper", "UnusedMember.Global")] public static class Map { + public static AlphaWarheadController WarheadController => Player.Server.GetComponent(); + + public static bool RoundLock { get => RoundSummary.RoundLock; set => RoundSummary.RoundLock = value; } + + public static bool LobbyLock { get => GameCore.RoundStart.LobbyLock; set => GameCore.RoundStart.LobbyLock = value; } + + public static bool FriendlyFire + { + get => ServerConsole.FriendlyFire; + set + { + ServerConsole.FriendlyFire = value; + foreach (var player in PlayerExtensions.GetAllPlayers()) + player.FriendlyFire = value; + } + } + + public static List Lifts => Object.FindObjectsOfType().ToList(); + + private static Broadcast BroadcastComponent => Player.Server.GetComponent(); + // Variables private static List _rooms = new List(); @@ -30,11 +51,13 @@ public static List Rooms /// Gets The Status of is the NukeDetonated public static bool IsNukeDetonated => - PlayerManager.localPlayer.GetComponent().detonated; + WarheadController.detonated; /// Gets The Status of is the NukeInProgress public static bool IsNukeInProgress => - PlayerManager.localPlayer.GetComponent().inProgress; + WarheadController.inProgress; + + public static int ActivatedGenerators => Generator079.mainGenerator.totalVoltage; // Methods /// Gives you the Position of the Door @@ -141,18 +164,10 @@ public static void StartNuke() } /// Stops the AlphaWarhead - public static void StopNuke() - { - var alpha = PlayerManager.localPlayer.GetComponent(); - alpha.CancelDetonation(); - } + public static void StopNuke() => WarheadController.CancelDetonation(); /// Detonate the AlphaWarhead instantly - public static void DetonateNuke() - { - var alpha = PlayerManager.localPlayer.GetComponent(); - alpha.Detonate(); - } + public static void DetonateNuke() => WarheadController.Detonate(); /// Name of the group you want to check /// Permission you want to check @@ -168,5 +183,11 @@ public static bool IsGroupAllowed(string group, string permission) return false; } } + + public static void Broadcast(string message, ushort duration) => BroadcastComponent.RpcAddElement(message, duration, new global::Broadcast.BroadcastFlags()); + + public static void ClearBroadcasts() => BroadcastComponent.RpcClearElements(); + + public static void TurnOffAllLights(float duration, bool onlyHeavy = false) => Generator079.generators[0].RpcCustomOverchargeForOurBeautifulModCreators(duration, onlyHeavy); } } \ No newline at end of file From 69ab8093a9ea31c85819c260df6512ae3408f49f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 11:02:30 +0200 Subject: [PATCH 152/199] fixed PlaerReloadEvent --- Synapse/Api/Player.cs | 1 + Synapse/Events/Classes/PlayerReloadEvent.cs | 2 -- Synapse/Events/Patches/PlayerReloadPatch.cs | 5 +---- Synapse/Events/PlayerEvents.cs | 4 +--- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index ad17389..5f1abc1 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -228,6 +228,7 @@ public Player Cuffer public void Kill(DamageTypes.DamageType damageType = default) => Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(-1f, "WORLD", damageType, 0), gameObject); + [Obsolete("Does not work properly")] public void ChangeRoleAtPosition(RoleType role) { //TODO: Fix this shit diff --git a/Synapse/Events/Classes/PlayerReloadEvent.cs b/Synapse/Events/Classes/PlayerReloadEvent.cs index 52d0f48..add36a2 100644 --- a/Synapse/Events/Classes/PlayerReloadEvent.cs +++ b/Synapse/Events/Classes/PlayerReloadEvent.cs @@ -9,7 +9,5 @@ public class PlayerReloadEvent public bool Allow { get; set; } public Inventory.SyncItemInfo InventorySlot { get; internal set; } - - public WeaponManager.Weapon Weapon { get; set; } } } diff --git a/Synapse/Events/Patches/PlayerReloadPatch.cs b/Synapse/Events/Patches/PlayerReloadPatch.cs index 7d984fd..1b738d3 100644 --- a/Synapse/Events/Patches/PlayerReloadPatch.cs +++ b/Synapse/Events/Patches/PlayerReloadPatch.cs @@ -15,7 +15,6 @@ public static bool Prefix(WeaponManager __instance) var allow = true; var itemIndex = __instance.hub.inventory.GetItemIndex(); - var weapon = __instance.weapons[__instance._reloadingWeapon]; var inventoryslot = __instance.hub.inventory.items[itemIndex]; var player = __instance.hub.GetPlayer(); @@ -23,9 +22,7 @@ public static bool Prefix(WeaponManager __instance) if (__instance.curWeapon < 0 || __instance.hub.inventory.curItem != __instance.weapons[__instance.curWeapon].inventoryID) return false; if (__instance.hub.inventory.items[itemIndex].durability >= __instance.weapons[__instance.curWeapon].maxAmmo) return false; - Events.InvokePlayerReloadEvent(player, ref allow, ref weapon, inventoryslot); - - __instance.weapons[__instance._reloadingWeapon] = weapon; + Events.InvokePlayerReloadEvent(player, ref allow, inventoryslot); return allow; } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index e131f54..f793b5f 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -206,7 +206,7 @@ internal static void InvokeSyncDataEvent(Player player, ref bool allow, ref Vect public delegate void OnPlayerReload(ref PlayerReloadEvent ev); public static event OnPlayerReload PlayerReloadEvent; - internal static void InvokePlayerReloadEvent(Player player,ref bool allow,ref WeaponManager.Weapon weapon,Inventory.SyncItemInfo syncItem) + internal static void InvokePlayerReloadEvent(Player player, ref bool allow, Inventory.SyncItemInfo syncItem) { if (PlayerReloadEvent == null) return; @@ -215,13 +215,11 @@ internal static void InvokePlayerReloadEvent(Player player,ref bool allow,ref We Player = player, Allow = allow, InventorySlot = syncItem, - Weapon = weapon }; PlayerReloadEvent.Invoke(ref ev); allow = ev.Allow; - weapon = ev.Weapon; } //FemurEnterEvent From 3f8c5fbac0fe7d77b413cebbad4b9c7f981838e5 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 11:17:50 +0200 Subject: [PATCH 153/199] code optimisation --- Synapse/Api/Player.cs | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 5f1abc1..d316dd9 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; +using CustomPlayerEffects; using Hints; using Mirror; using RemoteAdmin; @@ -53,21 +54,21 @@ public class Player : MonoBehaviour public HintDisplay HintDisplay => Hub.hints; - public string NickName { get => Hub.nicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } + public string NickName { get => NicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } - public int PlayerId { get => Hub.queryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } + public int PlayerId { get => QueryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } public string UserId { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } public string CustomUserId { get => ClassManager.UserId2; set => ClassManager.UserId2 = value; } - public string IpAddress => Hub.queryProcessor._ipAddress; + public string IpAddress => QueryProcessor._ipAddress; - public bool NoClip { get => Hub.serverRoles.NoclipReady; set => Hub.serverRoles.NoclipReady = value; } + public bool NoClip { get => ServerRoles.NoclipReady; set => Hub.serverRoles.NoclipReady = value; } - public bool OverWatch { get => Hub.serverRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } + public bool OverWatch { get => ServerRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } - public bool Bypass { get => Hub.serverRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } + public bool Bypass { get => ServerRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } public bool GodMode { get => ClassManager.GodMode; set => ClassManager.GodMode = value; } @@ -90,19 +91,19 @@ public Vector3 Scale } } - public Vector3 Position { get => Hub.playerMovementSync.GetRealPosition(); set => Hub.playerMovementSync.OverridePosition(value,RotationFloat); } + public Vector3 Position { get => MovementSync.GetRealPosition(); set => Hub.playerMovementSync.OverridePosition(value,RotationFloat); } public Vector3 RotationVector { get => ClassManager._plyCam.transform.forward; set => ClassManager._plyCam.transform.forward = value; } - public Vector2 Rotation { get => Hub.playerMovementSync.RotationSync; set => Hub.playerMovementSync.RotationSync = value; } + public Vector2 Rotation { get => MovementSync.RotationSync; set => Hub.playerMovementSync.RotationSync = value; } - public float Health { get => Hub.playerStats.Health; set => Hub.playerStats.Health = value; } + public float Health { get => PlayerStats.Health; set => Hub.playerStats.Health = value; } - public int MaxHealth { get => Hub.playerStats.maxHP; set => Hub.playerStats.maxHP = value; } + public int MaxHealth { get => PlayerStats.maxHP; set => Hub.playerStats.maxHP = value; } - public float ArtificialHealth { get => Hub.playerStats.unsyncedArtificialHealth; set => Hub.playerStats.unsyncedArtificialHealth = value; } + public float ArtificialHealth { get => PlayerStats.unsyncedArtificialHealth; set => Hub.playerStats.unsyncedArtificialHealth = value; } - public int MaxArtificialHealth { get => Hub.playerStats.maxArtificialHealth; set => Hub.playerStats.maxArtificialHealth = value; } + public int MaxArtificialHealth { get => PlayerStats.maxArtificialHealth; set => Hub.playerStats.maxArtificialHealth = value; } public RoleType Role { @@ -110,7 +111,7 @@ public RoleType Role set => Hub.characterClassManager.SetPlayersClass(value,gameObject); } - public Team Team { get => Hub.characterClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } + public Team Team { get => ClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } public Team Side { @@ -162,7 +163,7 @@ public Room CurRoom public NetworkConnection Connection => Hub.scp079PlayerScript.connectionToClient; - public Inventory.SyncListItemInfo Items { get => Hub.inventory.items; set => Hub.inventory.items = value; } + public Inventory.SyncListItemInfo Items { get => Inventory.items; set => Inventory.items = value; } /// /// The Person Who has cuffed the Player @@ -170,20 +171,20 @@ public Room CurRoom /// Set Cuffer to null and he will be disarmed public Player Cuffer { - get => PlayerExtensions.GetPlayer(Hub.handcuffs.CufferId); + get => PlayerExtensions.GetPlayer(Handcuffs.CufferId); set { - var handcuff = value.Hub.handcuffs; + var handcuff = value.Handcuffs; if (handcuff == null) return; if (value == null) { - handcuff.NetworkCufferId = -1; + Handcuffs.NetworkCufferId = -1; return; } - handcuff.NetworkCufferId = value.PlayerId; + Handcuffs.NetworkCufferId = value.PlayerId; } } @@ -193,7 +194,7 @@ public Player Cuffer public uint Ammo9 { get => Hub.ammoBox.amount[2]; set => Hub.ammoBox.amount[2] = value; } - public UserGroup Rank { get => Hub.serverRoles.Group; set => Hub.serverRoles.SetGroup(value, false); } + public UserGroup Rank { get => ServerRoles.Group; set => ServerRoles.SetGroup(value, false); } public string GroupName => ServerStatic.PermissionsHandler._members[UserId]; From 311edae448941252f764ff80772b4c8bcc40f0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 11:47:31 +0200 Subject: [PATCH 154/199] PlayerSetClassEvent for Item and Class Changes --- Synapse/Events/Classes/PlayerSetClassEvent.cs | 12 +++ Synapse/Events/Patches/PlayerSetClassPatch.cs | 91 +++++++++++++++++++ Synapse/Events/PlayerEvents.cs | 22 ++++- Synapse/Synapse.csproj | 2 + 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 Synapse/Events/Classes/PlayerSetClassEvent.cs create mode 100644 Synapse/Events/Patches/PlayerSetClassPatch.cs diff --git a/Synapse/Events/Classes/PlayerSetClassEvent.cs b/Synapse/Events/Classes/PlayerSetClassEvent.cs new file mode 100644 index 0000000..c10a9f4 --- /dev/null +++ b/Synapse/Events/Classes/PlayerSetClassEvent.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using Synapse.Api; + +namespace Synapse.Events.Classes +{ + public class PlayerSetClassEvent + { + public Player Player { get; internal set; } + public RoleType Role { get; set; } + public List Items { get; set; } + } +} \ No newline at end of file diff --git a/Synapse/Events/Patches/PlayerSetClassPatch.cs b/Synapse/Events/Patches/PlayerSetClassPatch.cs new file mode 100644 index 0000000..6cf769d --- /dev/null +++ b/Synapse/Events/Patches/PlayerSetClassPatch.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using System.Linq; +using Harmony; +using Mirror; +using Synapse.Api; +using UnityEngine; + +namespace Synapse.Events.Patches +{ + [HarmonyPatch(typeof(CharacterClassManager), nameof(CharacterClassManager.SetPlayersClass))] + public class PlayerSetClassPatch + { + public static bool Prefix(CharacterClassManager __instance, RoleType classid, GameObject ply, + bool lite = false, bool escape = false) + { + if (!NetworkServer.active) return false; + if (!ply.GetPlayer().ClassManager.IsVerified) return false; + + var inventory = + lite ? new List(0) : __instance.Classes.SafeGet(classid).startItems.ToList(); + Events.InvokePlayerSetClassEvent(ply.GetPlayer(), ref classid, ref inventory); + ply.GetPlayer().ClassManager.SetClassIDAdv(classid, lite, escape); + ply.GetPlayer().Health = __instance.Classes.SafeGet(classid).maxHP; + + if (lite) return false; + var inv = ply.GetPlayer().Inventory; + var list = ListPool.Rent(); + + if (escape && __instance.KeepItemsAfterEscaping) + { + list.AddRange(inv.items); + } + + inv.items.Clear(); + foreach (var id in inventory) + { + inv.AddNewItem(id); + } + + if (escape && __instance.KeepItemsAfterEscaping) + { + foreach (var syncItemInfo in list) + { + if (__instance.PutItemsInInvAfterEscaping) + { + var itemById = inv.GetItemByID(syncItemInfo.id); + var flag = false; + var categories = __instance._search.categories; + var i = 0; + + while (i < categories.Length) + { + var invCat = categories[i]; + if (invCat.itemType == itemById.itemCategory && itemById.itemCategory != ItemCategory.None) + { + var num = inv.items.Count(syncItemInfo2 => inv.GetItemByID(syncItemInfo2.id).itemCategory == itemById.itemCategory); + + if (num >= invCat.maxItems) + { + flag = true; + } + + break; + } + i++; + } + + if (inv.items.Count >= 8 || flag) + { + inv.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance._pms.RealModelPosition, + Quaternion.Euler(__instance._pms.Rotations.x, __instance._pms.Rotations.y, 0f), + syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther); + } + else + { + inv.AddNewItem(syncItemInfo.id, syncItemInfo.durability, syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther); + } + } + else + { + inv.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance._pms.RealModelPosition, + Quaternion.Euler(__instance._pms.Rotations.x, __instance._pms.Rotations.y, 0f), + syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther); + } + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index f793b5f..bf99a70 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Assets._Scripts.Dissonance; using Synapse.Api; using Synapse.Events.Classes; @@ -392,5 +393,24 @@ internal static void InvokePickupItemEvent(Player player, Pickup pickup, ref boo allow = ev.Allow; } + + public delegate void OnSetPlayerClass(ref PlayerSetClassEvent ev); + + public static event OnSetPlayerClass PlayerSetClassEvent; + + internal static void InvokePlayerSetClassEvent(Player player, ref RoleType type, ref List items) + { + var ev = new PlayerSetClassEvent() + { + Items = items, + Player = player, + Role = type + }; + + PlayerSetClassEvent?.Invoke(ref ev); + + items = ev.Items; + type = ev.Role; + } } } \ No newline at end of file diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index de85abe..b6663b3 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -73,10 +73,12 @@ + + From 703cfc6fa56f697ce79b72d4c855de7e0fa52a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 11:47:55 +0200 Subject: [PATCH 155/199] Update for independent DoorInteraction --- Synapse/Events/Patches/DoorInteractPatch.cs | 56 ++++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/Synapse/Events/Patches/DoorInteractPatch.cs b/Synapse/Events/Patches/DoorInteractPatch.cs index 6c809ef..78653d4 100644 --- a/Synapse/Events/Patches/DoorInteractPatch.cs +++ b/Synapse/Events/Patches/DoorInteractPatch.cs @@ -1,4 +1,6 @@ using System; +using System.Linq; +using System.Runtime.CompilerServices; using Harmony; using Synapse.Api; using UnityEngine; @@ -10,20 +12,60 @@ public class DoorInteractPatch { public static bool Prefix(PlayerInteract __instance, GameObject doorId) { + var allowTheAccess = true; + Door door = null; try { - var allowed = true; - var door = doorId.GetComponent(); - var player = __instance.GetPlayer(); + if (!__instance._playerInteractRateLimit.CanExecute() || + (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract) || doorId == null || + __instance._ccm.CurClass == RoleType.None || __instance._ccm.CurClass == RoleType.Spectator || + !doorId.TryGetComponent(out door) || !((door.buttons.Count == 0) + ? __instance.ChckDis(doorId.transform.position) + : door.buttons.Any(item => __instance.ChckDis(item.transform.position)))) return false; + + __instance.OnInteract(); + + if (__instance._sr.BypassMode) allowTheAccess = true; + else if (door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) && + __instance._ccm.CurRole.team == Team.SCP) allowTheAccess = true; + else + { + try + { + if (door.PermissionLevels == 0) + { + allowTheAccess = !door.locked; + } + else if (!door.RequireAllPermissions) + { + var itemPerms = __instance._inv.GetItemByID(__instance._inv.curItem).permissions; + allowTheAccess = itemPerms.Any(p => + door.backwardsCompatPermissions.TryGetValue(p, out var flag) && + door.PermissionLevels.HasPermission(flag)); + } + else allowTheAccess = false; + } + catch + { + allowTheAccess = false; + } + } + + Events.InvokeDoorInteraction(__instance.gameObject.GetPlayer(), door, ref allowTheAccess); + + if(allowTheAccess) door.ChangeState(__instance._sr.BypassMode); + else __instance.RpcDenied(doorId); - Events.InvokeDoorInteraction(player, door, ref allowed); - - return allowed; + return false; } catch (Exception e) { Log.Error($"DoorInteraction Error: {e}"); - return true; + + if(allowTheAccess && door != null) + door.ChangeState(__instance._sr.BypassMode); + else __instance.RpcDenied(doorId); + return false; } } } From 488d854ec4ca7468dcc818275f19f16e96e760bc Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 13:02:17 +0200 Subject: [PATCH 156/199] small fixes --- Synapse/Configs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index ec30422..535ff1b 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -16,8 +16,8 @@ internal static void ReloadConfig() { if (_config == null) _config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); - RequiredForFemur = _config.GetInt("synapse.femur",1); - RemoteKeyCard = _config.GetBool("synapse.remote.keyCard", true); + RequiredForFemur = _config.GetInt("synapse_femur",1); + RemoteKeyCard = _config.GetBool("synapse_remote_keycard", true); } } } From 5526dc868c9b1ad1e2f651facba852b0e5bacef0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 15:44:18 +0200 Subject: [PATCH 157/199] Changed SpeakEventEvent?? to PlayerSpeakEvent --- .../Classes/{SpeakEventEvent.cs => PlayerSpeakEvent.cs} | 2 +- Synapse/Events/PlayerEvents.cs | 4 ++-- Synapse/Synapse.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename Synapse/Events/Classes/{SpeakEventEvent.cs => PlayerSpeakEvent.cs} (92%) diff --git a/Synapse/Events/Classes/SpeakEventEvent.cs b/Synapse/Events/Classes/PlayerSpeakEvent.cs similarity index 92% rename from Synapse/Events/Classes/SpeakEventEvent.cs rename to Synapse/Events/Classes/PlayerSpeakEvent.cs index ab79c50..688e91b 100644 --- a/Synapse/Events/Classes/SpeakEventEvent.cs +++ b/Synapse/Events/Classes/PlayerSpeakEvent.cs @@ -6,7 +6,7 @@ namespace Synapse.Events.Classes { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] - public class SpeakEventEvent : EventArgs + public class PlayerSpeakEvent : EventArgs { public Player Player { get; internal set; } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index bf99a70..558c643 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -30,7 +30,7 @@ internal static void InvokePlayerJoinEvent(Player player, ref string nick) } /// A Event which is activated when a user press any voice HotKey - public delegate void OnSpeak(ref SpeakEventEvent ev); + public delegate void OnSpeak(ref PlayerSpeakEvent ev); public static event OnSpeak SpeakEvent; internal static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool intercom, ref bool radio, @@ -38,7 +38,7 @@ internal static void InvokeSpeakEvent(DissonanceUserSetup dissonance, ref bool i { if (SpeakEvent == null) return; - var ev = new SpeakEventEvent + var ev = new PlayerSpeakEvent { IntercomTalk = intercom, RadioTalk = radio, diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index b6663b3..345302e 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -116,7 +116,7 @@ - + From 0baaad700a2370b918cc2f4f267afd83508a7286 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 16:57:20 +0200 Subject: [PATCH 158/199] yes i forgot to reload Synapse Configs when every other Configs get reloaded --- Synapse/Plugin.cs | 6 +++--- Synapse/PluginManager.cs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index f1aa502..4696788 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -11,9 +11,9 @@ public abstract class Plugin // ReSharper disable once NotAccessedField.Global public static YamlConfig Config; - internal delegate void OnConfigReload(); - private event OnConfigReload ConfigReloadEvent; - internal void InvokeReload() => ConfigReloadEvent?.Invoke(); + public delegate void OnConfigReload(); + public event OnConfigReload ConfigReloadEvent; + internal void InvokeConfigReloadEvent() => ConfigReloadEvent.Invoke(); // ReSharper disable once UnusedAutoPropertyAccessor.Global public Translation Translation { get; internal set; } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 33b5f81..963725f 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -169,7 +169,8 @@ internal static void OnConfigReload() foreach (var plugin in Plugins) try { - plugin.InvokeReload(); + Configs.ReloadConfig(); + plugin.InvokeConfigReloadEvent(); } catch (Exception e) { From eab1874ef392c7512bd61ce700eb188bb9d7cc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 16:58:04 +0200 Subject: [PATCH 159/199] Remove not needed Element --- Synapse/Events/Classes/PlayerBanEvent.cs | 2 -- Synapse/Events/Patches/PlayerBanPatch.cs | 2 +- Synapse/Events/PlayerEvents.cs | 5 ++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Synapse/Events/Classes/PlayerBanEvent.cs b/Synapse/Events/Classes/PlayerBanEvent.cs index 4fb00e3..d98f7cc 100644 --- a/Synapse/Events/Classes/PlayerBanEvent.cs +++ b/Synapse/Events/Classes/PlayerBanEvent.cs @@ -11,8 +11,6 @@ public class PlayerBanEvent // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global public bool Allowed { get; set; } = true; - public string UserId { get; internal set; } - public int Duration { get; internal set; } public Player Issuer { get; internal set; } diff --git a/Synapse/Events/Patches/PlayerBanPatch.cs b/Synapse/Events/Patches/PlayerBanPatch.cs index 62909f7..10f3fb2 100644 --- a/Synapse/Events/Patches/PlayerBanPatch.cs +++ b/Synapse/Events/Patches/PlayerBanPatch.cs @@ -17,7 +17,7 @@ public static bool Prefix(GameObject user, int duration, string reason, string i var player = user.GetPlayer(); var banIssuer = PlayerExtensions.GetPlayer(issuer); var allow = true; - Events.InvokePlayerBanEvent(player, player.UserId, duration, ref allow, reason, banIssuer); + Events.InvokePlayerBanEvent(player, duration, ref allow, reason, banIssuer); return isGlobalBan && ConfigFile.ServerConfig.GetBool("gban_ban_ip") || allow; } diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 558c643..3258da7 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -79,7 +79,7 @@ internal static void InvokePlayerLeaveEvent(Player player) public delegate void OnPlayerBanEvent(ref PlayerBanEvent ev); public static event OnPlayerBanEvent PlayerBanEvent; - internal static void InvokePlayerBanEvent(Player player, string userId, int duration, ref bool allow, + internal static void InvokePlayerBanEvent(Player player, int duration, ref bool allow, string reason, Player issuer) { if (PlayerBanEvent == null) return; @@ -89,8 +89,7 @@ internal static void InvokePlayerBanEvent(Player player, string userId, int dura Issuer = issuer, Duration = duration, Reason = reason, - BannedPlayer = player, - UserId = userId + BannedPlayer = player }; PlayerBanEvent.Invoke(ref ev); From 5a06485c582ee11465eee3bb52c811376ed98aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 17:19:12 +0200 Subject: [PATCH 160/199] Fixed Missing Todos --- Synapse/Events/Patches/DropItemPatch.cs | 2 -- .../Patches/PocketDimensionEnterPatch.cs | 31 ++++++++++++++++--- .../Events/Patches/PreAuthenticationPatch.cs | 4 ++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Synapse/Events/Patches/DropItemPatch.cs b/Synapse/Events/Patches/DropItemPatch.cs index 6e8239b..cd1d35a 100644 --- a/Synapse/Events/Patches/DropItemPatch.cs +++ b/Synapse/Events/Patches/DropItemPatch.cs @@ -30,8 +30,6 @@ public static bool Prefix(Inventory __instance, int itemInventoryIndex) __instance.items.RemoveAt(itemInventoryIndex); - //TODO: InvokeItemDroped - return false; } catch (Exception e) diff --git a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs index 239757a..978ad21 100644 --- a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs +++ b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Runtime.CompilerServices; using CustomPlayerEffects; using Harmony; @@ -36,15 +37,37 @@ public static bool Prefix(Scp106PlayerScript __instance, GameObject ply, int t) } else { - //TODO: Implement SCP079 Shit + foreach (var scp079PlayerScript in Scp079PlayerScript.instances) + { + var otherRoom = ply.GetComponent().GetOtherRoom(); + var filter = new[] + { + Scp079Interactable.InteractableType.Door, + Scp079Interactable.InteractableType.Light, + Scp079Interactable.InteractableType.Lockdown, + Scp079Interactable.InteractableType.Tesla, + Scp079Interactable.InteractableType.ElevatorUse + }; + var flag = false; + foreach (var zoneAndRoom in from scp079Interaction in scp079PlayerScript.ReturnRecentHistory(12f, + filter) from zoneAndRoom in scp079Interaction.interactable + .currentZonesAndRooms where zoneAndRoom.currentZone == otherRoom.currentZone && + zoneAndRoom.currentRoom == otherRoom.currentRoom select zoneAndRoom) + { + flag = true; + } + + if (flag) + { + scp079PlayerScript.RpcGainExp(ExpGainType.PocketAssist, player.ClassManager.CurClass); + } + } } var canEnter = true; Events.InvokePocketDimensionEnterEvent(player, ref canEnter); if (!canEnter) return false; - - //TODO: Implement Damage Event - + __instance.hub.playerStats.HurtPlayer( new PlayerStats.HitInfo(40f, $"{__instance.GetComponent().MyNick} ({__instance.hub.characterClassManager.UserId})", diff --git a/Synapse/Events/Patches/PreAuthenticationPatch.cs b/Synapse/Events/Patches/PreAuthenticationPatch.cs index 83c38fa..970ab2e 100644 --- a/Synapse/Events/Patches/PreAuthenticationPatch.cs +++ b/Synapse/Events/Patches/PreAuthenticationPatch.cs @@ -34,7 +34,9 @@ public static void Postfix(CustomLiteNetLib4MirrorTransport __instance, Connecti request.RejectForce(data); } - //TODO: Explain this code to other contrib. + /// + /// This transpiler removes the instruction to accept an incoming connection. :) + /// private static IEnumerable Transpiler(IEnumerable instructions) { var codes = new List(instructions); From 2adf231d4d340d8e5dd43635339289f8d1392f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 17:37:43 +0200 Subject: [PATCH 161/199] Code Fixes --- Synapse/Api/Map.cs | 2 +- Synapse/Api/Player.cs | 1 - Synapse/Api/PlayerExtensions.cs | 3 +- Synapse/Events/EventHandler.cs | 14 +++---- Synapse/Events/Patches/CheckRoundEndPatch.cs | 4 -- Synapse/Events/Patches/DoorInteractPatch.cs | 1 - Synapse/Events/Patches/FemurEnterPatch.cs | 33 +++++++--------- Synapse/Events/Patches/GeneratorPatches.cs | 41 +++++++++----------- Synapse/Events/Patches/PlayerEscapePatch.cs | 2 +- Synapse/Events/Patches/TeamRespawnPatch.cs | 13 +++---- Synapse/Events/PlayerEvents.cs | 4 +- Synapse/Permissions/PermissionReader.cs | 2 - Synapse/Plugin.cs | 3 +- 13 files changed, 51 insertions(+), 72 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 2e92a97..9877367 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -184,7 +184,7 @@ public static bool IsGroupAllowed(string group, string permission) } } - public static void Broadcast(string message, ushort duration) => BroadcastComponent.RpcAddElement(message, duration, new global::Broadcast.BroadcastFlags()); + public static void Broadcast(string message, ushort duration) => BroadcastComponent.RpcAddElement(message, duration, new Broadcast.BroadcastFlags()); public static void ClearBroadcasts() => BroadcastComponent.RpcClearElements(); diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index d316dd9..b71bc1f 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using CustomPlayerEffects; using Hints; using Mirror; using RemoteAdmin; diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index 43c590b..b62138e 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 1434d47..03717ab 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using MEC; using Synapse.Api; using Synapse.Api.Enums; @@ -34,13 +35,12 @@ private static void OnDoorInteract(ref DoorInteractEvent ev) if (!Configs.RemoteKeyCard) return; if (ev.Allow) return; - foreach (var item in ev.Player.Items) - { - if (!ev.Player.Hub.inventory.GetItemByID(item.id).permissions - .Contains(ev.Door.permissionLevel)) continue; //update to backwardsCompatPermissions when necessary - ev.Allow = true; - return; - } + if (!ev.Player.Items.Any()) return; + var itemPerms = ev.Player.Inventory.GetItemByID(ev.Player.Inventory.curItem).permissions; + var door = ev.Door; + ev.Allow = itemPerms.Any(p => + door.backwardsCompatPermissions.TryGetValue(p, out var flag) && + door.PermissionLevels.HasPermission(flag)); } private static void OnSyncData(ref SyncDataEvent ev) diff --git a/Synapse/Events/Patches/CheckRoundEndPatch.cs b/Synapse/Events/Patches/CheckRoundEndPatch.cs index 8850d9a..707687f 100644 --- a/Synapse/Events/Patches/CheckRoundEndPatch.cs +++ b/Synapse/Events/Patches/CheckRoundEndPatch.cs @@ -1,15 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; -using System.Runtime.CompilerServices; -using System.Runtime.Remoting.Messaging; using GameCore; using Harmony; using UnityEngine; -using Console = System.Console; namespace Synapse.Events.Patches { diff --git a/Synapse/Events/Patches/DoorInteractPatch.cs b/Synapse/Events/Patches/DoorInteractPatch.cs index 78653d4..d408c13 100644 --- a/Synapse/Events/Patches/DoorInteractPatch.cs +++ b/Synapse/Events/Patches/DoorInteractPatch.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Runtime.CompilerServices; using Harmony; using Synapse.Api; using UnityEngine; diff --git a/Synapse/Events/Patches/FemurEnterPatch.cs b/Synapse/Events/Patches/FemurEnterPatch.cs index 7dfa368..ab9e314 100644 --- a/Synapse/Events/Patches/FemurEnterPatch.cs +++ b/Synapse/Events/Patches/FemurEnterPatch.cs @@ -9,7 +9,7 @@ namespace Synapse.Events.Patches [HarmonyPatch(typeof(CharacterClassManager), nameof(CharacterClassManager.AllowContain))] public class FemurEnterPatch { - public static int femurBrokePeople; + public static int FemurBrokePeople; public static bool Prefix(CharacterClassManager __instance) { @@ -18,27 +18,24 @@ public static bool Prefix(CharacterClassManager __instance) if (!NetworkServer.active) return false; if (!NonFacilityCompatibility.currentSceneSettings.enableStandardGamplayItems) return false; - foreach (GameObject gameObject in PlayerManager.players) + foreach (var gameObject in PlayerManager.players) { - if (Vector3.Distance(gameObject.transform.position, __instance._lureSpj.transform.position) < 1.97f) - { - CharacterClassManager component = gameObject.GetComponent(); - PlayerStats component2 = gameObject.GetComponent(); - if (component.CurClass != RoleType.Spectator && !component.GodMode) - { - var allow = component.CurRole.team != Team.SCP; + if (!(Vector3.Distance(gameObject.transform.position, __instance._lureSpj.transform.position) < + 1.97f)) continue; + var component = gameObject.GetComponent(); + var component2 = gameObject.GetComponent(); + if (component.CurClass == RoleType.Spectator || component.GodMode) continue; + var allow = component.CurRole.team != Team.SCP; - var CloseFemur = femurBrokePeople + 1 >= Configs.RequiredForFemur; - var player = __instance.GetPlayer(); + var closeFemur = FemurBrokePeople + 1 >= Configs.RequiredForFemur; + var player = __instance.GetPlayer(); - Events.InvokeFemurEnterEvent(player, ref allow, ref CloseFemur); + Events.InvokeFemurEnterEvent(player, ref allow, ref closeFemur); - if (!allow) return false; - component2.HurtPlayer(new PlayerStats.HitInfo(10000f, "WORLD", DamageTypes.Lure, 0), gameObject); - femurBrokePeople++; - if (CloseFemur) __instance._lureSpj.SetState(true); - } - } + if (!allow) return false; + component2.HurtPlayer(new PlayerStats.HitInfo(10000f, "WORLD", DamageTypes.Lure, 0), gameObject); + FemurBrokePeople++; + if (closeFemur) __instance._lureSpj.SetState(true); } return false; diff --git a/Synapse/Events/Patches/GeneratorPatches.cs b/Synapse/Events/Patches/GeneratorPatches.cs index da329ab..4e4f23c 100644 --- a/Synapse/Events/Patches/GeneratorPatches.cs +++ b/Synapse/Events/Patches/GeneratorPatches.cs @@ -16,7 +16,7 @@ public static bool Prefix(Generator079 __instance, GameObject person, string com if (player == null) { - Log.Error("GeneratorEventError: a gameobject which is not a Player used a Generator?"); + Log.Error("GeneratorEventError: a GameObject which is not a Player used a Generator?"); return false; } @@ -30,31 +30,26 @@ public static bool Prefix(Generator079 __instance, GameObject person, string com var enumerator = component.items.GetEnumerator(); while (enumerator.MoveNext()) { - Inventory.SyncItemInfo syncItemInfo = enumerator.Current; - if (syncItemInfo.id == ItemType.WeaponManagerTablet) - { - bool allow = player.Team != Team.SCP; - Events.InvokeGeneratorInserted(player, __instance, ref allow); - if (allow) - { - component.items.Remove(syncItemInfo); - __instance.NetworkisTabletConnected = true; - } - return false; - } + var syncItemInfo = enumerator.Current; + if (syncItemInfo.id != ItemType.WeaponManagerTablet) continue; + var allow = player.Team != Team.SCP; + Events.InvokeGeneratorInserted(player, __instance, ref allow); + if (!allow) return false; + component.items.Remove(syncItemInfo); + __instance.NetworkisTabletConnected = true; + return false; } } - if (command.StartsWith("EPS_CANCEL")) + if (!command.StartsWith("EPS_CANCEL")) return true; { if (!__instance.isTabletConnected) return false; - bool allow = true; + var allow = true; Events.InvokeGeneratorEjected(player, __instance, ref allow); return allow; } - return true; - } + } catch (Exception e) { Log.Error($"GeneratorTablet Event Error: {e}"); @@ -70,7 +65,7 @@ public static bool Prefix(Generator079 __instance, GameObject person) { var player = person.GetPlayer(); - Inventory component = person.GetComponent(); + var component = person.GetComponent(); if (component == null || __instance.doorAnimationCooldown > 0f || __instance.deniedCooldown > 0f) return false; //Check if the Generator can be open or must be unlocked @@ -99,15 +94,15 @@ public static bool Prefix(Generator079 __instance, GameObject person) } //Unlock The Generator - bool flag = player.Bypass; - bool flag2 = player.Team != Team.SCP; + var flag = player.Bypass; + var flag2 = player.Team != Team.SCP; if (flag2 && component.curItem > ItemType.KeycardJanitor) { - string[] permissions = component.GetItemByID(component.curItem).permissions; + var permissions = component.GetItemByID(component.curItem).permissions; - for (int i = 0; i < permissions.Length; i++) - if (permissions[i] == "ARMORY_LVL_2") + foreach (var t in permissions) + if (t == "ARMORY_LVL_2") flag = true; } diff --git a/Synapse/Events/Patches/PlayerEscapePatch.cs b/Synapse/Events/Patches/PlayerEscapePatch.cs index 3fcd710..f499689 100644 --- a/Synapse/Events/Patches/PlayerEscapePatch.cs +++ b/Synapse/Events/Patches/PlayerEscapePatch.cs @@ -6,7 +6,7 @@ // ReSharper disable SwitchStatementMissingSomeEnumCasesNoDefault -namespace Synapse.Events.Classes +namespace Synapse.Events.Patches { [HarmonyPatch(typeof(CharacterClassManager), nameof(CharacterClassManager.CallCmdRegisterEscape))] public static class PlayerEscapePatch diff --git a/Synapse/Events/Patches/TeamRespawnPatch.cs b/Synapse/Events/Patches/TeamRespawnPatch.cs index 9ca6ef2..81bcce0 100644 --- a/Synapse/Events/Patches/TeamRespawnPatch.cs +++ b/Synapse/Events/Patches/TeamRespawnPatch.cs @@ -45,20 +45,17 @@ public static bool Prefix(MTFRespawn __instance) //Event var allow = true; - var respawnlist = new List(); - var usetickets = true; + var useTickets = true; - foreach (GameObject player in list) - respawnlist.Add(player.GetPlayer()); + var respawnList = list.Select(player => player.GetPlayer()).ToList(); - Events.InvokeTeamRespawnEvent(ref respawnlist,ref __instance.nextWaveIsCI,ref allow,ref usetickets); + Events.InvokeTeamRespawnEvent(ref respawnList,ref __instance.nextWaveIsCI,ref allow,ref useTickets); if (!allow) return false; list.Clear(); - foreach (Player hub in respawnlist) - list.Add(hub.gameObject); + list.AddRange(respawnList.Select(hub => hub.gameObject)); - if (usetickets) __instance.NextWaveRespawnTickets -= num2 - list.Count; + if (useTickets) __instance.NextWaveRespawnTickets -= num2 - list.Count; if (ConfigFile.ServerConfig.GetBool("use_crypto_rng")) list.ShuffleListSecure(); diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs index 3258da7..44e0c52 100644 --- a/Synapse/Events/PlayerEvents.cs +++ b/Synapse/Events/PlayerEvents.cs @@ -214,7 +214,7 @@ internal static void InvokePlayerReloadEvent(Player player, ref bool allow, Inve { Player = player, Allow = allow, - InventorySlot = syncItem, + InventorySlot = syncItem }; PlayerReloadEvent.Invoke(ref ev); @@ -399,7 +399,7 @@ internal static void InvokePickupItemEvent(Player player, Pickup pickup, ref boo internal static void InvokePlayerSetClassEvent(Player player, ref RoleType type, ref List items) { - var ev = new PlayerSetClassEvent() + var ev = new PlayerSetClassEvent { Items = items, Player = player, diff --git a/Synapse/Permissions/PermissionReader.cs b/Synapse/Permissions/PermissionReader.cs index 0abb2f0..7238bc9 100644 --- a/Synapse/Permissions/PermissionReader.cs +++ b/Synapse/Permissions/PermissionReader.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; -using System.Text; using Synapse.Api; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 4696788..df324c3 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; namespace Synapse { From d4dae840165c301f9c7cab3f8a8e0ba442dcea06 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 19:21:41 +0200 Subject: [PATCH 162/199] small fixes --- Synapse/Api/Player.cs | 3 +-- Synapse/Events/EventHandler.cs | 4 ++-- Synapse/Plugin.cs | 7 ++++++- Synapse/PluginManager.cs | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index d316dd9..4b7b4e8 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using CustomPlayerEffects; using Hints; using Mirror; using RemoteAdmin; @@ -238,7 +237,7 @@ public void ChangeRoleAtPosition(RoleType role) public bool CheckPermission(string permission) { - if (Hub == PlayerManager.localPlayer) return true; + if (this == Server) return true; try { return PermissionReader.CheckPermission(this, permission); diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandler.cs index 1434d47..7e2c279 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandler.cs @@ -57,7 +57,7 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) switch (args[0].ToUpper()) { case "RELOADPERMISSION": - { + ev.Allow = false; if (!ev.Player.CheckPermission("sy.reload.permission")) { ev.Sender.RaMessage("You have no Permission for Reload Permissions", false, @@ -68,9 +68,9 @@ private static void OnRemoteCommand(ref RemoteCommandEvent ev) PermissionReader.ReloadPermission(); ev.Sender.RaMessage("Permissions Reloaded!", true, RaCategory.ServerConfigs); return; - } case "RELOADCONFIGS": + ev.Allow = false; if (!ev.Player.CheckPermission("sy.reload.configs")) { ev.Sender.RaMessage("You have no Permission for Reload Configs", false, diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 4696788..470ba60 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -13,7 +13,12 @@ public abstract class Plugin public delegate void OnConfigReload(); public event OnConfigReload ConfigReloadEvent; - internal void InvokeConfigReloadEvent() => ConfigReloadEvent.Invoke(); + internal void InvokeConfigReloadEvent() + { + if (ConfigReloadEvent == null) return; + + ConfigReloadEvent.Invoke(); + } // ReSharper disable once UnusedAutoPropertyAccessor.Global public Translation Translation { get; internal set; } diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 963725f..2973416 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -166,10 +166,11 @@ private static void OnEnable() internal static void OnConfigReload() { + Configs.ReloadConfig(); + foreach (var plugin in Plugins) try { - Configs.ReloadConfig(); plugin.InvokeConfigReloadEvent(); } catch (Exception e) From cb4890921033696bd2015f736239611ab28cebe2 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 23 Jun 2020 19:37:30 +0200 Subject: [PATCH 163/199] roomname changed to ridname --- Synapse/Api/Map.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 9877367..6752238 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -126,14 +126,14 @@ public static Vector3 GetDoorPos(string doorName) } /// Gives you the Position of the cubes you can see when you write "showrids" in the console! - /// + /// /// - public static Vector3 GetRidPos(string room) + public static Vector3 GetRidPos(string ridname) { var position = new Vector3(53f, 1020f, -44f); var array = GameObject.FindGameObjectsWithTag("RoomID"); foreach (var gameObject2 in array) - if (gameObject2.GetComponent().id == room) + if (gameObject2.GetComponent().id == ridname) position = gameObject2.transform.position; return position; } From 6aec50950bce498f4570374b301790741ee5436e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:24:04 +0200 Subject: [PATCH 164/199] Create README --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2054b7e --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# **Synapse** +### **The new SCP: Secret Laboratory mod / plugin loader** +Synapse is a new found project created by two german Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. + +##**Features & Configs** + +Synapse itself has a ton of features some of these include: + - A complete self written permission system + - A remote keycard system out of the box + - A feature rich translation system + - and many many more... + + For a full feature list click the [Features](https://github.com/moelrobi/Synapse/wiki/Features) link to get to the wiki. + +## **Installation** +The installation of Synapse is very easy. + +Download the newest release from the [Releases](https://github.com/moelrobi/Synapse/releases) page. +Then follow the instructions under the Wiki: [Hosting Guides](https://github.com/moelrobi/Synapse/wiki#hosting-guides) + +##**Developers** + +Developing for Synapse is just as easy as the Installation. +Please check our [example plugin](https://github.com/GrafDimenzio/Example-Plugin) and our [Wiki](https://github.com/GrafDimenzio/Example-Plugin) for a full API documentation. + +##**Support & Credits** +In need of Support please join our [Discord](https://discord.gg/wSBHXwy)! + +First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing Game. Please support them and the game via thier patron. + +We also need to thank the [Harmony](https://github.com/pardeike/Harmony) Guys for developing a Runtime .NET Patcher. + + +####**Created by Dimenzio and SirRoob** \ No newline at end of file From e97b4ffd6e96731b88b3429b6c80880099f49fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:25:54 +0200 Subject: [PATCH 165/199] Change to one line --- Synapse/Plugin.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Synapse/Plugin.cs b/Synapse/Plugin.cs index 9df14a0..f4918c4 100644 --- a/Synapse/Plugin.cs +++ b/Synapse/Plugin.cs @@ -12,12 +12,7 @@ public abstract class Plugin public delegate void OnConfigReload(); public event OnConfigReload ConfigReloadEvent; - internal void InvokeConfigReloadEvent() - { - if (ConfigReloadEvent == null) return; - - ConfigReloadEvent.Invoke(); - } + internal void InvokeConfigReloadEvent() => ConfigReloadEvent?.Invoke(); // ReSharper disable once UnusedAutoPropertyAccessor.Global public Translation Translation { get; internal set; } From 4d714f8fc554b8e29997b90c67a3f19c58ab7245 Mon Sep 17 00:00:00 2001 From: GrafDimenzio <66207264+GrafDimenzio@users.noreply.github.com> Date: Tue, 23 Jun 2020 20:26:13 +0200 Subject: [PATCH 166/199] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2054b7e..7c79bb4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # **Synapse** ### **The new SCP: Secret Laboratory mod / plugin loader** -Synapse is a new found project created by two german Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. +Synapse is a new found project created by two german Officcial Community Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. ##**Features & Configs** @@ -31,4 +31,4 @@ First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) an We also need to thank the [Harmony](https://github.com/pardeike/Harmony) Guys for developing a Runtime .NET Patcher. -####**Created by Dimenzio and SirRoob** \ No newline at end of file +####**Created by Dimenzio and SirRoob** From eee3e8d528c30a314bc99ad5355ce3152f955617 Mon Sep 17 00:00:00 2001 From: GrafDimenzio <66207264+GrafDimenzio@users.noreply.github.com> Date: Tue, 23 Jun 2020 20:26:56 +0200 Subject: [PATCH 167/199] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c79bb4..8e207b1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # **Synapse** ### **The new SCP: Secret Laboratory mod / plugin loader** -Synapse is a new found project created by two german Officcial Community Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. +Synapse is a new found project created by two german Official Community Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. ##**Features & Configs** From 476ed59cb859208d675aef1ee6a0e8f8006819ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:27:43 +0200 Subject: [PATCH 168/199] Update Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2054b7e..0362444 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # **Synapse** ### **The new SCP: Secret Laboratory mod / plugin loader** -Synapse is a new found project created by two german Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. +Synapse is a new found project created by two german Server-Hosters. We used Harmony to create a framework which makes us easier to implement new functions, game updates and overall a new experience a player. ##**Features & Configs** @@ -28,7 +28,7 @@ In need of Support please join our [Discord](https://discord.gg/wSBHXwy)! First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing Game. Please support them and the game via thier patron. -We also need to thank the [Harmony](https://github.com/pardeike/Harmony) Guys for developing a Runtime .NET Patcher. +We also need to thank the [Harmony](https://github.com/pardeike/Harmony) guys for developing a Runtime .NET Patcher. ####**Created by Dimenzio and SirRoob** \ No newline at end of file From 75be4de19e8fdc61e6969953054759bfe140cbae Mon Sep 17 00:00:00 2001 From: GrafDimenzio <66207264+GrafDimenzio@users.noreply.github.com> Date: Tue, 23 Jun 2020 20:27:45 +0200 Subject: [PATCH 169/199] fixed Features & Configs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e207b1..6a417e5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ### **The new SCP: Secret Laboratory mod / plugin loader** Synapse is a new found project created by two german Official Community Server-Hosters. We used Harmony to create a Framework which makes us easier to implement new functions, game updates and overall a new experience a player. -##**Features & Configs** +## **Features & Configs** Synapse itself has a ton of features some of these include: - A complete self written permission system From e216941310b61a9af036cdedb3710dcb1d02963a Mon Sep 17 00:00:00 2001 From: GrafDimenzio <66207264+GrafDimenzio@users.noreply.github.com> Date: Tue, 23 Jun 2020 20:28:55 +0200 Subject: [PATCH 170/199] added spaces --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6a417e5..fc38560 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ The installation of Synapse is very easy. Download the newest release from the [Releases](https://github.com/moelrobi/Synapse/releases) page. Then follow the instructions under the Wiki: [Hosting Guides](https://github.com/moelrobi/Synapse/wiki#hosting-guides) -##**Developers** +## **Developers** Developing for Synapse is just as easy as the Installation. Please check our [example plugin](https://github.com/GrafDimenzio/Example-Plugin) and our [Wiki](https://github.com/GrafDimenzio/Example-Plugin) for a full API documentation. -##**Support & Credits** +## **Support & Credits** In need of Support please join our [Discord](https://discord.gg/wSBHXwy)! First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing Game. Please support them and the game via thier patron. @@ -31,4 +31,4 @@ First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) an We also need to thank the [Harmony](https://github.com/pardeike/Harmony) Guys for developing a Runtime .NET Patcher. -####**Created by Dimenzio and SirRoob** +#### **Created by Dimenzio and SirRoob** From bc8301e6e812619d395289bf564fd7acc9ba55f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:30:17 +0200 Subject: [PATCH 171/199] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa6053d..5fb187a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Please check our [example plugin](https://github.com/GrafDimenzio/Example-Plugin ## **Support & Credits** In need of Support please join our [Discord](https://discord.gg/wSBHXwy)! -First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing Game. Please support them and the game via thier patron. +First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing game. Please support them and the game via thier patron. We also need to thank the [Harmony](https://github.com/pardeike/Harmony) guys for developing a Runtime .NET Patcher. From c3f892256839609de6f24bb37e5d1b9cf8014411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:32:08 +0200 Subject: [PATCH 172/199] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fb187a..70b48ee 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Then follow the instructions under the Wiki: [Hosting Guides](https://github.com ## **Developers** Developing for Synapse is just as easy as the Installation. -Please check our [example plugin](https://github.com/GrafDimenzio/Example-Plugin) and our [Wiki](https://github.com/GrafDimenzio/Example-Plugin) for a full API documentation. +Please check our [example plugin](https://github.com/GrafDimenzio/Example-Plugin) and our [Wiki](https://github.com/moelrobi/Synapse/wiki#developer-guides) for a full API documentation. ## **Support & Credits** In need of Support please join our [Discord](https://discord.gg/wSBHXwy)! From af3c348386199724284a55ac56cb4f70c9823c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:37:31 +0200 Subject: [PATCH 173/199] Set the default config for remote keycard to false. --- Synapse/Configs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index 535ff1b..ef27ba5 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -17,7 +17,7 @@ internal static void ReloadConfig() if (_config == null) _config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); RequiredForFemur = _config.GetInt("synapse_femur",1); - RemoteKeyCard = _config.GetBool("synapse_remote_keycard", true); + RemoteKeyCard = _config.GetBool("synapse_remote_keycard", false); } } } From c9eb06aa9fde234405a68af78c468b78802d7f37 Mon Sep 17 00:00:00 2001 From: snoks <66261217+git-snoks@users.noreply.github.com> Date: Tue, 23 Jun 2020 20:41:01 +0200 Subject: [PATCH 174/199] Grammer yes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70b48ee..a8d8f3a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Please check our [example plugin](https://github.com/GrafDimenzio/Example-Plugin ## **Support & Credits** In need of Support please join our [Discord](https://discord.gg/wSBHXwy)! -First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing game. Please support them and the game via thier patron. +First of all we need to thank [SCP: Secret Laboratory](https://scpslgame.com) and Northwood Studios for creating this amazing game. Please support them and the game via their patron. We also need to thank the [Harmony](https://github.com/pardeike/Harmony) guys for developing a Runtime .NET Patcher. From 516eea44633de6a7ebac6f7763168e2275576470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:55:46 +0200 Subject: [PATCH 175/199] Add example Instuctions on how to use the SynapseModLoaderPatcher --- SynapseModLoaderPatcher/Program.cs | 5 +++++ SynapseModLoaderPatcher/README.md | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 SynapseModLoaderPatcher/README.md diff --git a/SynapseModLoaderPatcher/Program.cs b/SynapseModLoaderPatcher/Program.cs index ee72f20..21cce5a 100644 --- a/SynapseModLoaderPatcher/Program.cs +++ b/SynapseModLoaderPatcher/Program.cs @@ -15,6 +15,11 @@ namespace SynapseModLoaderPatcher // ReSharper disable once ClassNeverInstantiated.Global internal class Program { + /// + /// This Program is used to compile the Assembly-CSharp. + /// + /// For Instruction on how to use this Program please check the readme of this Project. + /// public static void Main(string[] args) { if (args.Length != 1) diff --git a/SynapseModLoaderPatcher/README.md b/SynapseModLoaderPatcher/README.md new file mode 100644 index 0000000..c0fb27d --- /dev/null +++ b/SynapseModLoaderPatcher/README.md @@ -0,0 +1,3 @@ +This Project is to patch a new Assembly-CSharp for a new SCP:SL version. + +For a more detailed description please check the [Wiki]() for infos how to self-compile Synapse. \ No newline at end of file From bd5b53b04645a008c4248c39a6c4af04f40cf4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:56:18 +0200 Subject: [PATCH 176/199] Add the Link --- SynapseModLoaderPatcher/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SynapseModLoaderPatcher/README.md b/SynapseModLoaderPatcher/README.md index c0fb27d..79c58fa 100644 --- a/SynapseModLoaderPatcher/README.md +++ b/SynapseModLoaderPatcher/README.md @@ -1,3 +1,3 @@ This Project is to patch a new Assembly-CSharp for a new SCP:SL version. -For a more detailed description please check the [Wiki]() for infos how to self-compile Synapse. \ No newline at end of file +For a more detailed description please check the [Wiki](https://github.com/moelrobi/Synapse/wiki/Synapse-ModLoader-Patcher) for infos how to self-compile Synapse. \ No newline at end of file From 4f4578299f1412216a469be1c7f639d9ea92471d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 20:59:13 +0200 Subject: [PATCH 177/199] Short Summary on the ModLoader --- SynapseModLoader/ModLoader.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SynapseModLoader/ModLoader.cs b/SynapseModLoader/ModLoader.cs index 926d94c..1c1427b 100644 --- a/SynapseModLoader/ModLoader.cs +++ b/SynapseModLoader/ModLoader.cs @@ -6,6 +6,11 @@ namespace SynapseModLoader { // ReSharper disable once UnusedType.Global + + /// + /// This Class is injected directly into the Assembly-CSharp and calls the MainLoader of Synapse. + /// The Injection and Call happens not directly at Boot Time but when the ServerConsole gets constructed. + /// public class ModLoader { private static byte[] ReadFile(string path) From 034af5d5bcbf5bbf47388cf8a8db19b91becfc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Tue, 23 Jun 2020 22:15:20 +0200 Subject: [PATCH 178/199] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8d8f3a..e15dfd0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # **Synapse** -### **The new SCP: Secret Laboratory mod / plugin loader** +### **The new SCP: Secret Laboratory Plugin loader** Synapse is a new found project created by two german official community Server-Hosters. We used Harmony to create a framework which makes us easier to implement new functions, game updates and overall a new experience a player. ## **Features & Configs** From 423bf959c7fd07c27271310950a3eac1a03c4e19 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Wed, 24 Jun 2020 08:46:49 +0200 Subject: [PATCH 179/199] added default color to SendConsoleMessage --- Synapse/Api/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 4b7b4e8..4ae743b 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -266,7 +266,7 @@ public void InstantBroadcast(ushort time, string message) GetComponent().TargetAddElement(Connection, message, time, new Broadcast.BroadcastFlags()); } - public void SendConsoleMessage(string message, string color) => ClassManager.TargetConsolePrint(Connection, message, color); + public void SendConsoleMessage(string message, string color = "red") => ClassManager.TargetConsolePrint(Connection, message, color); public void HideTag() => ClassManager.CallCmdRequestHideTag(); From 20ebd6bc11b1a8f4aaa7802e2647654b586fad02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Wed, 24 Jun 2020 20:53:42 +0200 Subject: [PATCH 180/199] Re-Add Jail API --- Synapse/Api/Jail.cs | 63 +++++++++++++++++++++++ Synapse/Api/Player.cs | 2 + Synapse/Events/Patches/ComponentsPatch.cs | 5 +- Synapse/Synapse.csproj | 1 + 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Synapse/Api/Jail.cs diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs new file mode 100644 index 0000000..5d74748 --- /dev/null +++ b/Synapse/Api/Jail.cs @@ -0,0 +1,63 @@ +using System; +using UnityEngine; + +namespace Synapse.Api +{ + public class Jail : MonoBehaviour + { + public bool IsJailed { get; private set; } + + public Player Player + { + get => this.GetPlayer(); + } + + public Player Admin { get; set; } + + public RoleType Role { get; set; } + + public Vector3 Position { get; set; } + + public Inventory.SyncListItemInfo Items { get; set; } + + public float Health { get; set; } + + + public void Awake() + { + IsJailed = false; + Role = RoleType.ClassD; + Position = Role.GetRandomSpawnPoint(); + } + + public void DoJail(Player admin) + { + if (IsJailed) return; + + var player = this.GetPlayer(); + + Admin = admin; + Role = player.Role; + Position = player.Position; + if (Items != null) Items = player.Items; + Health = player.Health; + + player.Role = RoleType.Tutorial; + + IsJailed = true; + } + + public void UnJail() + { + if (!IsJailed) return; + + var player = this.GetPlayer(); + player.Role = Role; + player.Position = Position; + player.Health = Health; + player.Items = Items; + + IsJailed = false; + } + } +} \ No newline at end of file diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 4b7b4e8..02e2b3a 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -220,6 +220,8 @@ public Player Cuffer public bool IsDead => Team == Team.RIP; + public Jail Jail => GetComponent(); + //Methods public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); diff --git a/Synapse/Events/Patches/ComponentsPatch.cs b/Synapse/Events/Patches/ComponentsPatch.cs index 4e4d78a..adf92ed 100644 --- a/Synapse/Events/Patches/ComponentsPatch.cs +++ b/Synapse/Events/Patches/ComponentsPatch.cs @@ -9,8 +9,9 @@ public static class ComponentsPatch { public static void Prefix(ReferenceHub __instance) { - if (__instance.GetComponent() == null) - __instance.gameObject.AddComponent(); + if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); + + if (__instance.GetComponent() == null) __instance.gameObject.AddComponent(); try { diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 345302e..283c753 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -65,6 +65,7 @@ + From e43c636d256dda6d683034d2933ba6b963596aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Wed, 24 Jun 2020 20:55:01 +0200 Subject: [PATCH 181/199] Dependency change for ModLoaderPatcher --- SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj b/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj index 516c1f9..a7c6dc1 100644 --- a/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj +++ b/SynapseModLoaderPatcher/SynapseModLoaderPatcher.csproj @@ -32,9 +32,6 @@ 4 - - ..\..\Synaps Verweise\Assembly-CSharp-Synapse_publizied.dll - ..\packages\dnlib.3.3.2\lib\net45\dnlib.dll True From 09f78e63f8895566d19ea4833468f18b7f244455 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Wed, 24 Jun 2020 21:33:48 +0200 Subject: [PATCH 182/199] added SpawnItem --- Synapse/Api/Map.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 6752238..3d18ca0 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -163,6 +163,12 @@ public static void StartNuke() alpha.StartDetonation(); } + /// + /// Spawns a Item on the Map + /// + public static Pickup SpawnItem(ItemType itemType, float durability, Vector3 position, Quaternion rotation = default, int sight = 0, int barrel = 0, int other = 0) + => Player.Server.Inventory.SetPickup(itemType, durability, position, rotation, sight, barrel, other); + /// Stops the AlphaWarhead public static void StopNuke() => WarheadController.CancelDetonation(); From 02a9f13d20427ad3448d96537dd66ddcb6f0128f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Wed, 24 Jun 2020 21:45:48 +0200 Subject: [PATCH 183/199] Changed Player.Role a little --- Synapse/Api/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index f009c7e..34f4f33 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -106,7 +106,7 @@ public Vector3 Scale public RoleType Role { - get => Hub.characterClassManager.CurClass; + get => Hub.characterClassManager.NetworkCurClass; set => Hub.characterClassManager.SetPlayersClass(value,gameObject); } From bd082067907652c40069eb768c3729bff0859717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=B6ller?= Date: Wed, 24 Jun 2020 21:52:23 +0200 Subject: [PATCH 184/199] Bugfix: SetClassIDAdv --- Synapse/Api/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 34f4f33..91a5f72 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -106,8 +106,8 @@ public Vector3 Scale public RoleType Role { - get => Hub.characterClassManager.NetworkCurClass; - set => Hub.characterClassManager.SetPlayersClass(value,gameObject); + get => Hub.characterClassManager.CurClass; + set => Hub.characterClassManager.SetClassIDAdv(value, false); } public Team Team { get => ClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } From bff11d3b22b8236224f27187350c5a139871d094 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 25 Jun 2020 10:57:21 +0200 Subject: [PATCH 185/199] added Map.StartDecontamination() --- Synapse/Api/Map.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 3d18ca0..0a8f46d 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -1,4 +1,5 @@ -using Synapse.Permissions; +using LightContainmentZoneDecontamination; +using Synapse.Permissions; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -155,6 +156,12 @@ public static Vector3 GetRandomSpawnPoint(this RoleType type) return Object.FindObjectOfType().GetRandomPosition(type).transform.position; } + /// + /// Starts the Decontamination + /// + public static void StartDecontamination() => DecontaminationController.Singleton.FinishDecontamination(); + + /// Starts the AlphaWarhead public static void StartNuke() { From f5c0e7805240f0203b5c5e68c36f153f4bde601c Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 25 Jun 2020 11:03:56 +0200 Subject: [PATCH 186/199] added Map.CassieMessage --- Synapse/Api/Map.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 0a8f46d..f4fac6a 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -156,6 +156,14 @@ public static Vector3 GetRandomSpawnPoint(this RoleType type) return Object.FindObjectOfType().GetRandomPosition(type).transform.position; } + /// + /// Sends a Cassie Message + /// + /// + /// + /// + public static void CassieMessage(string msg, bool makeHold, bool makeNoise) => Player.Server.GetComponent().RpcPlayCustomAnnouncement(msg, makeHold, makeNoise); + /// /// Starts the Decontamination /// From 933f31c01a7049aa5e1812da54d7bee55a6b5079 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 2 Jul 2020 21:18:49 +0200 Subject: [PATCH 187/199] update to current bet version --- Synapse/Api/Map.cs | 4 +++- Synapse/Api/Player.cs | 2 +- Synapse/Events/Patches/CheckRoundEndPatch.cs | 12 ++++++------ Synapse/Events/Patches/GeneratorPatches.cs | 8 ++++---- Synapse/Events/Patches/PlayerReloadPatch.cs | 12 ++++++------ Synapse/Events/Patches/PocketDimensionEnterPatch.cs | 2 +- Synapse/Events/Patches/RoundEndPatch.cs | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index f4fac6a..f33d285 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -18,6 +18,7 @@ public static class Map public static bool LobbyLock { get => GameCore.RoundStart.LobbyLock; set => GameCore.RoundStart.LobbyLock = value; } + /* TODO: Fix this FriendlyFire public static bool FriendlyFire { get => ServerConsole.FriendlyFire; @@ -28,6 +29,7 @@ public static bool FriendlyFire player.FriendlyFire = value; } } + */ public static List Lifts => Object.FindObjectsOfType().ToList(); @@ -209,6 +211,6 @@ public static bool IsGroupAllowed(string group, string permission) public static void ClearBroadcasts() => BroadcastComponent.RpcClearElements(); - public static void TurnOffAllLights(float duration, bool onlyHeavy = false) => Generator079.generators[0].RpcCustomOverchargeForOurBeautifulModCreators(duration, onlyHeavy); + public static void TurnOffAllLights(float duration, bool onlyHeavy = false) => Generator079.Generators[0].RpcCustomOverchargeForOurBeautifulModCreators(duration, onlyHeavy); } } \ No newline at end of file diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 91a5f72..5c4ba8f 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -205,7 +205,7 @@ public Player Cuffer public bool IsIntercomMuted { get => ClassManager.NetworkIntercomMuted; set => ClassManager.NetworkIntercomMuted = value; } - public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } + //TODO: Find a way to make this possible again public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } public Camera079 Camera { get => Hub.scp079PlayerScript.currentCamera; set => Hub.scp079PlayerScript?.RpcSwitchCamera(value.cameraId, false); } diff --git a/Synapse/Events/Patches/CheckRoundEndPatch.cs b/Synapse/Events/Patches/CheckRoundEndPatch.cs index 707687f..d4f32b7 100644 --- a/Synapse/Events/Patches/CheckRoundEndPatch.cs +++ b/Synapse/Events/Patches/CheckRoundEndPatch.cs @@ -40,7 +40,7 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) while (roundSummary != null) { while (RoundSummary.RoundLock || !RoundSummary.RoundInProgress() || - roundSummary.keepRoundOnOne && PlayerManager.players.Count < 2) yield return 0.0f; + roundSummary._keepRoundOnOne && PlayerManager.players.Count < 2) yield return 0.0f; var newList = new RoundSummary.SumInfo_ClassList(); @@ -106,18 +106,18 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) continue; } - if (forceEnd) roundSummary.roundEnded = true; + if (forceEnd) roundSummary._roundEnded = true; if(!allow) continue; if (newList.class_ds == 0 && mtfSum == 0) { - roundSummary.roundEnded = true; + roundSummary._roundEnded = true; } else if (mtfSum == 0 && PlayerManager.localPlayer.GetComponent().MtfRespawnTickets == 0) { - roundSummary.roundEnded = true; + roundSummary._roundEnded = true; } else @@ -129,11 +129,11 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) if (chaosSum > 0) checkVar++; if (scpSum > 0) checkVar++; - if (checkVar <= 1) roundSummary.roundEnded = true; + if (checkVar <= 1) roundSummary._roundEnded = true; } - if (!roundSummary.roundEnded) continue; + if (!roundSummary._roundEnded) continue; var leadingTeam = RoundSummary.LeadingTeam.Draw; if (mtfSum > 0) diff --git a/Synapse/Events/Patches/GeneratorPatches.cs b/Synapse/Events/Patches/GeneratorPatches.cs index 4e4f23c..9b10f71 100644 --- a/Synapse/Events/Patches/GeneratorPatches.cs +++ b/Synapse/Events/Patches/GeneratorPatches.cs @@ -24,7 +24,7 @@ public static bool Prefix(Generator079 __instance, GameObject person, string com if (command.StartsWith("EPS_TABLET")) { - if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance.localTime <= 0f || Generator079.mainGenerator.forcedOvercharge) return false; + if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge) return false; var component = person.GetComponent(); var enumerator = component.items.GetEnumerator(); @@ -66,7 +66,7 @@ public static bool Prefix(Generator079 __instance, GameObject person) var player = person.GetPlayer(); var component = person.GetComponent(); - if (component == null || __instance.doorAnimationCooldown > 0f || __instance.deniedCooldown > 0f) return false; + if (component == null || __instance._doorAnimationCooldown > 0f || __instance._deniedCooldown > 0f) return false; //Check if the Generator can be open or must be unlocked if (__instance.isDoorUnlocked) @@ -87,7 +87,7 @@ public static bool Prefix(Generator079 __instance, GameObject person) return false; } - __instance.doorAnimationCooldown = 1.5f; + __instance._doorAnimationCooldown = 1.5f; __instance.NetworkisDoorOpen = !__instance.isDoorOpen; __instance.RpcDoSound(__instance.isDoorOpen); return false; @@ -111,7 +111,7 @@ public static bool Prefix(Generator079 __instance, GameObject person) if (flag) { __instance.NetworkisDoorUnlocked = true; - __instance.doorAnimationCooldown = 0.5f; + __instance._doorAnimationCooldown = 0.5f; return false; } __instance.RpcDenied(); diff --git a/Synapse/Events/Patches/PlayerReloadPatch.cs b/Synapse/Events/Patches/PlayerReloadPatch.cs index 1b738d3..78f32fa 100644 --- a/Synapse/Events/Patches/PlayerReloadPatch.cs +++ b/Synapse/Events/Patches/PlayerReloadPatch.cs @@ -14,13 +14,13 @@ public static bool Prefix(WeaponManager __instance) if (!__instance._iawRateLimit.CanExecute(true)) return false; var allow = true; - var itemIndex = __instance.hub.inventory.GetItemIndex(); - var inventoryslot = __instance.hub.inventory.items[itemIndex]; - var player = __instance.hub.GetPlayer(); + var itemIndex = __instance._hub.inventory.GetItemIndex(); + var inventoryslot = __instance._hub.inventory.items[itemIndex]; + var player = __instance._hub.GetPlayer(); - if (itemIndex < 0 || itemIndex >= __instance.hub.inventory.items.Count) return false; - if (__instance.curWeapon < 0 || __instance.hub.inventory.curItem != __instance.weapons[__instance.curWeapon].inventoryID) return false; - if (__instance.hub.inventory.items[itemIndex].durability >= __instance.weapons[__instance.curWeapon].maxAmmo) return false; + if (itemIndex < 0 || itemIndex >= __instance._hub.inventory.items.Count) return false; + if (__instance.curWeapon < 0 || __instance._hub.inventory.curItem != __instance.weapons[__instance.curWeapon].inventoryID) return false; + if (__instance._hub.inventory.items[itemIndex].durability >= __instance.weapons[__instance.curWeapon].maxAmmo) return false; Events.InvokePlayerReloadEvent(player, ref allow, inventoryslot); diff --git a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs index 978ad21..8de2b70 100644 --- a/Synapse/Events/Patches/PocketDimensionEnterPatch.cs +++ b/Synapse/Events/Patches/PocketDimensionEnterPatch.cs @@ -27,7 +27,7 @@ public static bool Prefix(Scp106PlayerScript __instance, GameObject ply, int t) Vector3.Distance(__instance.hub.playerMovementSync.RealModelPosition, ply.transform.position) >= 3f || !charClassManager.IsHuman()) return false; - if (Scp106PlayerScript.blastDoor.isClosed) + if (Scp106PlayerScript._blastDoor.isClosed) { __instance.hub.characterClassManager.RpcPlaceBlood(ply.transform.position, 1, 2f); __instance.hub.playerStats.HurtPlayer( diff --git a/Synapse/Events/Patches/RoundEndPatch.cs b/Synapse/Events/Patches/RoundEndPatch.cs index 3c983c3..c75c0d9 100644 --- a/Synapse/Events/Patches/RoundEndPatch.cs +++ b/Synapse/Events/Patches/RoundEndPatch.cs @@ -10,7 +10,7 @@ public static void Postfix(RoundSummary __instance) { try { - if (__instance.roundEnded) + if (__instance._roundEnded) Events.InvokeRoundEndEvent(); } catch (Exception e) From 34da621fb44e6c81875a3df9156fb816f042a04d Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 3 Jul 2020 13:13:53 +0200 Subject: [PATCH 188/199] my try to fix this --- Synapse/Api/Jail.cs | 14 +++++++++++--- Synapse/Api/Map.cs | 13 +------------ Synapse/Api/Player.cs | 2 +- .../Events/{EventHandler.cs => EventHandlers.cs} | 4 ++-- Synapse/PluginManager.cs | 4 ++-- Synapse/Synapse.csproj | 2 +- 6 files changed, 18 insertions(+), 21 deletions(-) rename Synapse/Events/{EventHandler.cs => EventHandlers.cs} (98%) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index 5d74748..8a795f8 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEngine; namespace Synapse.Api @@ -18,7 +19,7 @@ public Player Player public Vector3 Position { get; set; } - public Inventory.SyncListItemInfo Items { get; set; } + public List Items { get; set; } public float Health { get; set; } @@ -39,7 +40,12 @@ public void DoJail(Player admin) Admin = admin; Role = player.Role; Position = player.Position; - if (Items != null) Items = player.Items; + + Items.Clear(); + foreach (var item in player.Items) + Items.Add(item); + player.ClearInventory(); + Health = player.Health; player.Role = RoleType.Tutorial; @@ -55,7 +61,9 @@ public void UnJail() player.Role = Role; player.Position = Position; player.Health = Health; - player.Items = Items; + + foreach (var item in Items) + player.Inventory.items.Add(item); IsJailed = false; } diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index f33d285..b5db9fa 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -18,18 +18,7 @@ public static class Map public static bool LobbyLock { get => GameCore.RoundStart.LobbyLock; set => GameCore.RoundStart.LobbyLock = value; } - /* TODO: Fix this FriendlyFire - public static bool FriendlyFire - { - get => ServerConsole.FriendlyFire; - set - { - ServerConsole.FriendlyFire = value; - foreach (var player in PlayerExtensions.GetAllPlayers()) - player.FriendlyFire = value; - } - } - */ + public static bool FriendlyFire { get => ServerConsole.FriendlyFire; set => ServerConsole.FriendlyFire = value; } public static List Lifts => Object.FindObjectsOfType().ToList(); diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 5c4ba8f..a516f2e 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -205,7 +205,7 @@ public Player Cuffer public bool IsIntercomMuted { get => ClassManager.NetworkIntercomMuted; set => ClassManager.NetworkIntercomMuted = value; } - //TODO: Find a way to make this possible again public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } + //TODO: Find a way to make this possible again: public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } public Camera079 Camera { get => Hub.scp079PlayerScript.currentCamera; set => Hub.scp079PlayerScript?.RpcSwitchCamera(value.cameraId, false); } diff --git a/Synapse/Events/EventHandler.cs b/Synapse/Events/EventHandlers.cs similarity index 98% rename from Synapse/Events/EventHandler.cs rename to Synapse/Events/EventHandlers.cs index bfc7bb2..4a4fc30 100644 --- a/Synapse/Events/EventHandler.cs +++ b/Synapse/Events/EventHandlers.cs @@ -10,7 +10,7 @@ namespace Synapse.Events { // ReSharper disable once UnusedType.Global - internal class EventHandler + internal class EventHandlers { // Variables private bool _roundInProgress; @@ -19,7 +19,7 @@ internal class EventHandler private int _roundTime; // Constructor - public EventHandler() + public EventHandlers() { Events.SyncDataEvent += OnSyncData; Events.RemoteCommandEvent += OnRemoteCommand; diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 2973416..35d2e97 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -26,7 +26,7 @@ public static class PluginManager private static string ServerConfigFile { get; set; } // ReSharper disable once NotAccessedField.Local - private static Events.EventHandler _eventHandler; + private static Events.EventHandlers _eventHandler; // Methods internal static IEnumerator StartSynapse() @@ -81,7 +81,7 @@ private static void LoadSynapse() { Configs.ReloadConfig(); HarmonyPatch(); - _eventHandler = new Events.EventHandler(); + _eventHandler = new Events.EventHandlers(); ServerConsole.ReloadServerName(); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 283c753..eeb12e6 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -95,7 +95,7 @@ - + From f263767f71e1a95143df816db68cbfc2cc862a79 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 3 Jul 2020 13:18:55 +0200 Subject: [PATCH 189/199] fix my mistake --- Synapse/Api/Jail.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index 8a795f8..0abed93 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; namespace Synapse.Api @@ -41,10 +40,9 @@ public void DoJail(Player admin) Role = player.Role; Position = player.Position; - Items.Clear(); + Items = new List(); foreach (var item in player.Items) Items.Add(item); - player.ClearInventory(); Health = player.Health; From e8280697fd1f8262a4b6c9a302ba1d4bc23e483b Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 3 Jul 2020 13:22:55 +0200 Subject: [PATCH 190/199] fixed Player.Role --- Synapse/Api/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index a516f2e..6f0a8e6 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -107,7 +107,7 @@ public Vector3 Scale public RoleType Role { get => Hub.characterClassManager.CurClass; - set => Hub.characterClassManager.SetClassIDAdv(value, false); + set => Hub.characterClassManager.SetPlayersClass(value,gameObject); } public Team Team { get => ClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } From b6026037351702e52d60791adeb3244525263b3a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 3 Jul 2020 13:42:59 +0200 Subject: [PATCH 191/199] added Delay --- Synapse/Api/Jail.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index 0abed93..850d9f0 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using MEC; +using System.Collections.Generic; using UnityEngine; namespace Synapse.Api @@ -57,7 +58,7 @@ public void UnJail() var player = this.GetPlayer(); player.Role = Role; - player.Position = Position; + Timing.CallDelayed(2f, () => player.Position = Position); player.Health = Health; foreach (var item in Items) From 8d8cfd4f103dd439622d04d6433f67c69405a4da Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 3 Jul 2020 13:51:22 +0200 Subject: [PATCH 192/199] fixed Delay now should Jail work --- Synapse/Api/Jail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index 850d9f0..30f0fe0 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -58,7 +58,7 @@ public void UnJail() var player = this.GetPlayer(); player.Role = Role; - Timing.CallDelayed(2f, () => player.Position = Position); + Timing.CallDelayed(0.2f, () => player.Position = Position); player.Health = Health; foreach (var item in Items) From e872e56a50eb13c6972aad3baaa3d66c79a295c0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 3 Jul 2020 15:30:58 +0200 Subject: [PATCH 193/199] added JoinBroadcast and JoinTextHint --- Synapse/Api/Jail.cs | 1 - Synapse/Configs.cs | 4 ++++ Synapse/Events/EventHandlers.cs | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index 30f0fe0..e45987a 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -23,7 +23,6 @@ public Player Player public float Health { get; set; } - public void Awake() { IsJailed = false; diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index ef27ba5..cce5429 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -10,6 +10,8 @@ internal static class Configs // Configs internal static int RequiredForFemur; internal static bool RemoteKeyCard; + internal static string JoinBroadcast; + internal static string JoinTextHint; // Methods internal static void ReloadConfig() @@ -18,6 +20,8 @@ internal static void ReloadConfig() RequiredForFemur = _config.GetInt("synapse_femur",1); RemoteKeyCard = _config.GetBool("synapse_remote_keycard", false); + JoinBroadcast = _config.GetString("synapse_join_broadcast", ""); + JoinTextHint = _config.GetString("synapse_join_texthint", ""); } } } diff --git a/Synapse/Events/EventHandlers.cs b/Synapse/Events/EventHandlers.cs index 4a4fc30..f657844 100644 --- a/Synapse/Events/EventHandlers.cs +++ b/Synapse/Events/EventHandlers.cs @@ -27,9 +27,16 @@ public EventHandlers() Events.RoundEndEvent += OnRoundEnd; Events.RoundRestartEvent += OnRoundRestart; Events.DoorInteractEvent += OnDoorInteract; + Events.PlayerJoinEvent += OnPlayerJoin; } // Methods + private void OnPlayerJoin(ref PlayerJoinEvent ev) + { + ev.Player.Broadcast(5,Configs.JoinBroadcast); + ev.Player.GiveTextHint(Configs.JoinTextHint); + } + private static void OnDoorInteract(ref DoorInteractEvent ev) { if (!Configs.RemoteKeyCard) return; From c53b8db387c28443caf0f5178bf1213b6b890645 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 4 Jul 2020 08:39:00 +0200 Subject: [PATCH 194/199] Documented Api --- Synapse/Api/Jail.cs | 35 +++++- Synapse/Api/Map.cs | 76 +++++++++--- Synapse/Api/Player.cs | 198 +++++++++++++++++++++++++++++++- Synapse/Api/PlayerExtensions.cs | 24 +++- Synapse/Api/Room.cs | 12 ++ 5 files changed, 324 insertions(+), 21 deletions(-) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index e45987a..9f5c1aa 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -8,21 +8,43 @@ public class Jail : MonoBehaviour { public bool IsJailed { get; private set; } + /// + /// The Player which is Jailed + /// public Player Player { get => this.GetPlayer(); } + /// + /// The Admins which Jailed the Player + /// public Player Admin { get; set; } + /// + /// The Role the Player will get after he gets Unjailed + /// public RoleType Role { get; set; } - + + + /// + /// The Position the Player will get after he gets Unjailed + /// public Vector3 Position { get; set; } - + + /// + /// The Items the Player will get after he gets Unjailed + /// public List Items { get; set; } - + + /// + /// The Health the Player will get after he gets Unjailed + /// public float Health { get; set; } + /// + /// Used by Unity for you its Usseles + /// public void Awake() { IsJailed = false; @@ -30,6 +52,10 @@ public void Awake() Position = Role.GetRandomSpawnPoint(); } + /// + /// Jail the Player + /// + /// The Person who jails the Player public void DoJail(Player admin) { if (IsJailed) return; @@ -51,6 +77,9 @@ public void DoJail(Player admin) IsJailed = true; } + /// + /// Unjail the Player + /// public void UnJail() { if (!IsJailed) return; diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index b5db9fa..9c1f79c 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -12,22 +12,38 @@ namespace Synapse.Api [SuppressMessage("ReSharper", "UnusedMember.Global")] public static class Map { + /// + /// Gives you the WarheadController. + /// public static AlphaWarheadController WarheadController => Player.Server.GetComponent(); + /// + /// Activates/Deactivates the RoundLock (if the Round can end) + /// public static bool RoundLock { get => RoundSummary.RoundLock; set => RoundSummary.RoundLock = value; } + /// + /// Activates/Deactivates the LobbyLock (if the Lobby can continue counting down) + /// public static bool LobbyLock { get => GameCore.RoundStart.LobbyLock; set => GameCore.RoundStart.LobbyLock = value; } + /// + /// Activates/Deactivates the FriendlyFire on the server + /// public static bool FriendlyFire { get => ServerConsole.FriendlyFire; set => ServerConsole.FriendlyFire = value; } + /// + /// Gives you a list of all lifts + /// public static List Lifts => Object.FindObjectsOfType().ToList(); private static Broadcast BroadcastComponent => Player.Server.GetComponent(); - // Variables private static List _rooms = new List(); - /// Gives You a List with all Rooms on the Server + /// + /// Gives you a list of all rooms + /// public static List Rooms { get @@ -41,18 +57,25 @@ public static List Rooms } } - /// Gets The Status of is the NukeDetonated + /// + /// Is the nuke detonated? + /// public static bool IsNukeDetonated => WarheadController.detonated; - /// Gets The Status of is the NukeInProgress + /// + /// Is the nuke in progress? + /// public static bool IsNukeInProgress => WarheadController.inProgress; + /// + /// How many generators are activated? + /// public static int ActivatedGenerators => Generator079.mainGenerator.totalVoltage; // Methods - /// Gives you the Position of the Door + /// Gives the position of the door with that name /// Name of the Door you want /// public static Vector3 GetDoorPos(string doorName) @@ -117,7 +140,9 @@ public static Vector3 GetDoorPos(string doorName) return vector; } - /// Gives you the Position of the cubes you can see when you write "showrids" in the console! + /// + /// Gives you the position of the cubes you can see when you write "showrids" in the console + /// /// /// public static Vector3 GetRidPos(string ridname) @@ -130,8 +155,10 @@ public static Vector3 GetRidPos(string ridname) return position; } + /// + /// Gives the position of the room with that name + /// /// The name of the Room you want - /// Gives you the Position of the Room public static Vector3 GetRoomPos(string name) { return Rooms?.FirstOrDefault(room => @@ -139,7 +166,9 @@ public static Vector3 GetRoomPos(string name) new Vector3(0f, 0f, 0f); } - /// Gives you the Spawn Position of a Role + /// + /// Gives you a random spawnpoint of the Role + /// /// The Role you want to get s spawn position /// public static Vector3 GetRandomSpawnPoint(this RoleType type) @@ -156,12 +185,14 @@ public static Vector3 GetRandomSpawnPoint(this RoleType type) public static void CassieMessage(string msg, bool makeHold, bool makeNoise) => Player.Server.GetComponent().RpcPlayCustomAnnouncement(msg, makeHold, makeNoise); /// - /// Starts the Decontamination + /// Starts the Decontamination /// public static void StartDecontamination() => DecontaminationController.Singleton.FinishDecontamination(); - /// Starts the AlphaWarhead + /// + /// Starts the nuke + /// public static void StartNuke() { var alpha = PlayerManager.localPlayer.GetComponent(); @@ -175,15 +206,21 @@ public static void StartNuke() public static Pickup SpawnItem(ItemType itemType, float durability, Vector3 position, Quaternion rotation = default, int sight = 0, int barrel = 0, int other = 0) => Player.Server.Inventory.SetPickup(itemType, durability, position, rotation, sight, barrel, other); - /// Stops the AlphaWarhead + /// + /// Stops the nuke + /// public static void StopNuke() => WarheadController.CancelDetonation(); - /// Detonate the AlphaWarhead instantly + /// + /// Detonates the nuke + /// public static void DetonateNuke() => WarheadController.Detonate(); + /// + /// Has the group the permission? + /// /// Name of the group you want to check /// Permission you want to check - /// Have the Group the permissions? public static bool IsGroupAllowed(string group, string permission) { try @@ -196,10 +233,23 @@ public static bool IsGroupAllowed(string group, string permission) } } + /// + /// Gives all players a broadcast + /// + /// + /// public static void Broadcast(string message, ushort duration) => BroadcastComponent.RpcAddElement(message, duration, new Broadcast.BroadcastFlags()); + /// + /// Clear all broadcasts from all players + /// public static void ClearBroadcasts() => BroadcastComponent.RpcClearElements(); + /// + /// Deactivates the lights + /// + /// + /// public static void TurnOffAllLights(float duration, bool onlyHeavy = false) => Generator079.Generators[0].RpcCustomOverchargeForOurBeautifulModCreators(duration, onlyHeavy); } } \ No newline at end of file diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 6f0a8e6..5bd51e1 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -53,24 +53,57 @@ public class Player : MonoBehaviour public HintDisplay HintDisplay => Hub.hints; + /// + /// The name of the player + /// public string NickName { get => NicknameSync.Network_myNickSync; set => Hub.nicknameSync.Network_myNickSync = value; } + /// + /// The PlayerId of the player (The Id you can see in RemoteAdmin) + /// public int PlayerId { get => QueryProcessor.NetworkPlayerId; set => Hub.queryProcessor.NetworkPlayerId = value; } + /// + /// The UserId of the player (@steam, @discord, etc.) + /// public string UserId { get => Hub.characterClassManager.UserId; set => Hub.characterClassManager.UserId = value; } + /// + /// A possible second id. + /// public string CustomUserId { get => ClassManager.UserId2; set => ClassManager.UserId2 = value; } + /// + /// The Ip address of the player + /// public string IpAddress => QueryProcessor._ipAddress; + /// + /// Get / Set the user into noclip + /// public bool NoClip { get => ServerRoles.NoclipReady; set => Hub.serverRoles.NoclipReady = value; } + /// + /// Get / Set the Overwatch Status + /// public bool OverWatch { get => ServerRoles.OverwatchEnabled; set => Hub.serverRoles.OverwatchEnabled = value; } + + /// + /// Get / Set the Players Bypassmode. + /// public bool Bypass { get => ServerRoles.BypassMode; set => Hub.serverRoles.BypassMode = value; } + + /// + /// Get / Set the Players GodMode + /// public bool GodMode { get => ClassManager.GodMode; set => ClassManager.GodMode = value; } + + /// + /// Modify the size of the Player + /// public Vector3 Scale { get => Hub.transform.localScale; @@ -90,28 +123,58 @@ public Vector3 Scale } } + /// + /// The position of the player + /// public Vector3 Position { get => MovementSync.GetRealPosition(); set => Hub.playerMovementSync.OverridePosition(value,RotationFloat); } + /// + /// The rotation vector of the player + /// public Vector3 RotationVector { get => ClassManager._plyCam.transform.forward; set => ClassManager._plyCam.transform.forward = value; } + /// + /// The rotation of the player + /// public Vector2 Rotation { get => MovementSync.RotationSync; set => Hub.playerMovementSync.RotationSync = value; } + /// + /// The health of the player + /// public float Health { get => PlayerStats.Health; set => Hub.playerStats.Health = value; } + /// + /// The maximum health a player can get + /// public int MaxHealth { get => PlayerStats.maxHP; set => Hub.playerStats.maxHP = value; } + /// + /// The extra health of the Player (AP) + /// public float ArtificialHealth { get => PlayerStats.unsyncedArtificialHealth; set => Hub.playerStats.unsyncedArtificialHealth = value; } + /// + /// The maximum ArtificialHealth a player can get + /// public int MaxArtificialHealth { get => PlayerStats.maxArtificialHealth; set => Hub.playerStats.maxArtificialHealth = value; } + /// + /// The RoleType of the player + /// public RoleType Role { get => Hub.characterClassManager.CurClass; set => Hub.characterClassManager.SetPlayersClass(value,gameObject); } + /// + /// The team of the player + /// public Team Team { get => ClassManager.CurRole.team; set => Hub.characterClassManager.CurRole.team = value; } + /// + /// The "Side" the player is on (ClassDs are on TeamChaos, Scientists are on Team MTF) + /// public Team Side { get @@ -131,6 +194,9 @@ public Team Side } } + /// + /// The Room where the player currently is + /// public Room CurRoom { get @@ -160,14 +226,20 @@ public Room CurRoom set => Position = value.Position; } + /// + /// The NetworkConnection of the player (often used by vanilla methods) + /// public NetworkConnection Connection => Hub.scp079PlayerScript.connectionToClient; + /// + /// All items the player has + /// public Inventory.SyncListItemInfo Items { get => Inventory.items; set => Inventory.items = value; } /// - /// The Person Who has cuffed the Player + /// The person who cuffed the player /// - /// Set Cuffer to null and he will be disarmed + /// maybe be null, if set to null, uncuffed public Player Cuffer { get => PlayerExtensions.GetPlayer(Handcuffs.CufferId); @@ -185,49 +257,109 @@ public Player Cuffer Handcuffs.NetworkCufferId = value.PlayerId; } - } + } + /// + /// How much Ammo5 has the player + /// public uint Ammo5 { get => Hub.ammoBox.amount[0]; set => Hub.ammoBox.amount[0] = value; } + /// + /// How much Ammo7 has the player + /// public uint Ammo7 { get => Hub.ammoBox.amount[1]; set => Hub.ammoBox.amount[1] = value; } + /// + /// How much Ammo9 has the player + /// public uint Ammo9 { get => Hub.ammoBox.amount[2]; set => Hub.ammoBox.amount[2] = value; } + /// + /// The UserGroup the player is in + /// public UserGroup Rank { get => ServerRoles.Group; set => ServerRoles.SetGroup(value, false); } + /// + /// The name of the group the user has + /// public string GroupName => ServerStatic.PermissionsHandler._members[UserId]; + /// + /// The color of the rank + /// + /// Note: This will not change the permissions public string RankColor { get => Rank.BadgeColor; set => Hub.serverRoles.SetColor(value); } + /// + /// The name which is shown + /// + /// Note: This will not change the permissions public string RankName { get => Rank.BadgeText; set => Hub.serverRoles.SetText(value); } + /// + /// Is the player muted + /// public bool IsMuted { get => ClassManager.NetworkMuted; set => ClassManager.NetworkMuted = value; } + /// + /// Is the player muted in the intercom + /// public bool IsIntercomMuted { get => ClassManager.NetworkIntercomMuted; set => ClassManager.NetworkIntercomMuted = value; } //TODO: Find a way to make this possible again: public bool FriendlyFire { get => Hub.weaponManager.NetworkfriendlyFire; set => Hub.weaponManager.NetworkfriendlyFire = value; } + /// + /// The current camera the player uses (Scp079 only, if not null) + /// public Camera079 Camera { get => Hub.scp079PlayerScript.currentCamera; set => Hub.scp079PlayerScript?.RpcSwitchCamera(value.cameraId, false); } - + /// + /// The rotation float of the player + /// public float RotationFloat => Hub.transform.rotation.eulerAngles.y; + /// + /// Is the player cuffed? + /// public bool IsCuffed => Cuffer != null; + /// + /// Is the player reloading right now? + /// public bool IsReloading => Hub.weaponManager.IsReloading(); + /// + /// Is the player currently scoping + /// public bool IsZooming => Hub.weaponManager.ZoomInProgress(); + /// + /// Is the player dead + /// public bool IsDead => Team == Team.RIP; public Jail Jail => GetComponent(); //Methods + /// + /// Kicks the player + /// + /// public void Kick(string message) => ServerConsole.Disconnect(gameObject, message); + /// + /// Bans the player + /// + /// + /// + /// public void Ban(int duration, string reason, string issuer = "Plugin") => Server.GetComponent().BanUser(gameObject, duration, reason, issuer); + /// + /// Kills a player + /// + /// public void Kill(DamageTypes.DamageType damageType = default) => Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(-1f, "WORLD", damageType, 0), gameObject); [Obsolete("Does not work properly")] @@ -237,6 +369,11 @@ public void ChangeRoleAtPosition(RoleType role) Hub.characterClassManager.SetClassIDAdv(role, true); } + /// + /// Checks if the user has permission + /// + /// + /// public bool CheckPermission(string permission) { if (this == Server) return true; @@ -250,6 +387,11 @@ public bool CheckPermission(string permission) } } + /// + /// Gives the player a text hint on his screen + /// + /// + /// public void GiveTextHint(string message, float duration = 5f) { Hub.hints.Show(new TextHint(message, new HintParameter[] @@ -258,28 +400,73 @@ public void GiveTextHint(string message, float duration = 5f) }, HintEffectPresets.FadeInAndOut(duration), duration)); } + /// + /// Clear all Broadcast the Player has currently + /// public void ClearBroadcasts() => GetComponent().TargetClearElements(Connection); + /// + /// Sends a broadcast to the player + /// + /// + /// public void Broadcast(ushort time,string message) => GetComponent().TargetAddElement(Connection, message, time, new Broadcast.BroadcastFlags()); + /// + /// Clear all previous broadcasts and send the broadcast instant to the player + /// + /// + /// public void InstantBroadcast(ushort time, string message) { ClearBroadcasts(); GetComponent().TargetAddElement(Connection, message, time, new Broadcast.BroadcastFlags()); } + /// + /// Send a message in the console of the player + /// + /// + /// public void SendConsoleMessage(string message, string color = "red") => ClassManager.TargetConsolePrint(Connection, message, color); + /// + /// Hides for normal player the RankName the player has + /// public void HideTag() => ClassManager.CallCmdRequestHideTag(); + /// + /// Shows everyone the RankName the player has + /// + /// public void ShowTag(bool global = false) => ClassManager.CallCmdRequestShowTag(global); + /// + /// Gives the player a item + /// + /// + /// + /// + /// + /// public void GiveItem(ItemType itemType, float duration = float.NegativeInfinity, int sight = 0, int barrel = 0, int other = 0) => Hub.inventory.AddNewItem(itemType, duration, sight, barrel, other); + /// + /// Clears the players Inventory + /// public void ClearInventory() => Hub.inventory.Clear(); + /// + /// Gives the player an effect + /// + /// + /// + /// public void GiveEffect(Effect effect,byte intensity = 1,float duration = -1f) => EffectsController.ChangeByString(effect.ToString().ToLower(), intensity, duration); + /// + /// Allow the player to open the RemoteAdmin-Interface + /// public void RaLogin() { Hub.serverRoles.RemoteAdmin = true; @@ -288,6 +475,9 @@ public void RaLogin() Hub.serverRoles.TargetOpenRemoteAdmin(Connection, false); } + /// + /// Denies the access to the RemoteAdmin-Interface + /// public void RaLogout() { Hub.serverRoles.RemoteAdmin = false; diff --git a/Synapse/Api/PlayerExtensions.cs b/Synapse/Api/PlayerExtensions.cs index b62138e..332c4d1 100644 --- a/Synapse/Api/PlayerExtensions.cs +++ b/Synapse/Api/PlayerExtensions.cs @@ -25,7 +25,7 @@ public static MethodInfo SendSpawnMessage } } - /// Gives a User a Message im Remote Admin + /// Gives a player a message in the RemoteAdmin /// The User who you send the Message /// The Message you want to send /// True = green the command is right you have permission and execute it successfully @@ -64,6 +64,9 @@ public static void RaMessage(this CommandSender sender, string message, bool suc sender.RaReply($"{Assembly.GetCallingAssembly().GetName().Name}#" + message, success, true, category); } + /// + /// Gives all players on the server + /// public static IEnumerable GetAllPlayers() { return (from gameObject in PlayerManager.players @@ -71,16 +74,35 @@ public static IEnumerable GetAllPlayers() select gameObject.GetPlayer()).ToList(); } + /// + /// Gives all players on the server with this Role + /// + /// public static IEnumerable GetAllPlayers(this RoleType role) => GetAllPlayers().Where(x => x.Role == role); + /// + /// Gives you the player object + /// public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent(); + /// + /// Gives you the player object + /// public static Player GetPlayer(this PlayableScps.PlayableScp scp) => scp.Hub.GetPlayer(); + /// + /// Gives you the player object + /// public static Player GetPlayer(this GameObject gameObject) => gameObject.GetComponent(); + /// + /// Gives you the player object + /// public static Player GetPlayer(int id) => GetAllPlayers().FirstOrDefault(p => p.PlayerId == id); + /// + /// Gives you the player object + /// public static Player GetPlayer(string arg) { if (short.TryParse(arg, out var playerId)) diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index bfff62d..0fcec88 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -6,13 +6,25 @@ namespace Synapse.Api public class Room { private ZoneType _zone = ZoneType.Unspecified; + /// + /// The name of the room + /// public string Name { get; set; } // ReSharper disable once UnusedAutoPropertyAccessor.Global + /// + /// The transform of the room + /// public Transform Transform { get; set; } + /// + /// The position of the room + /// public Vector3 Position { get; set; } // ReSharper disable once UnusedMember.Global + /// + /// The ZoneType in which the room is + /// public ZoneType Zone { get From 7533e42a029e7c826269cf00dc3d99892ef51d15 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 4 Jul 2020 09:24:35 +0200 Subject: [PATCH 195/199] added JoinMessage Duration --- Synapse/Configs.cs | 2 ++ Synapse/Events/EventHandlers.cs | 4 ++-- Synapse/PluginManager.cs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index cce5429..06348b4 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -12,6 +12,7 @@ internal static class Configs internal static bool RemoteKeyCard; internal static string JoinBroadcast; internal static string JoinTextHint; + internal static ushort JoinMessageDuration; // Methods internal static void ReloadConfig() @@ -22,6 +23,7 @@ internal static void ReloadConfig() RemoteKeyCard = _config.GetBool("synapse_remote_keycard", false); JoinBroadcast = _config.GetString("synapse_join_broadcast", ""); JoinTextHint = _config.GetString("synapse_join_texthint", ""); + JoinMessageDuration = _config.GetUShort("synapse_join_duration",5); } } } diff --git a/Synapse/Events/EventHandlers.cs b/Synapse/Events/EventHandlers.cs index f657844..84a48e7 100644 --- a/Synapse/Events/EventHandlers.cs +++ b/Synapse/Events/EventHandlers.cs @@ -33,8 +33,8 @@ public EventHandlers() // Methods private void OnPlayerJoin(ref PlayerJoinEvent ev) { - ev.Player.Broadcast(5,Configs.JoinBroadcast); - ev.Player.GiveTextHint(Configs.JoinTextHint); + ev.Player.Broadcast(Configs.JoinMessageDuration,Configs.JoinBroadcast); + ev.Player.GiveTextHint(Configs.JoinTextHint, Configs.JoinMessageDuration); } private static void OnDoorInteract(ref DoorInteractEvent ev) diff --git a/Synapse/PluginManager.cs b/Synapse/PluginManager.cs index 35d2e97..d8d90b6 100644 --- a/Synapse/PluginManager.cs +++ b/Synapse/PluginManager.cs @@ -166,6 +166,7 @@ private static void OnEnable() internal static void OnConfigReload() { + Plugin.Config = new YamlConfig(ServerConfigFile); Configs.ReloadConfig(); foreach (var plugin in Plugins) From cddcbfa511e3e63f2cf400737e1ffca280658c1d Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 4 Jul 2020 09:37:46 +0200 Subject: [PATCH 196/199] fixed reload bug for server-config.yml --- Synapse/Configs.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Synapse/Configs.cs b/Synapse/Configs.cs index 06348b4..e67e117 100644 --- a/Synapse/Configs.cs +++ b/Synapse/Configs.cs @@ -4,9 +4,6 @@ namespace Synapse { internal static class Configs { - // Variables - private static YamlConfig _config; - // Configs internal static int RequiredForFemur; internal static bool RemoteKeyCard; @@ -17,13 +14,11 @@ internal static class Configs // Methods internal static void ReloadConfig() { - if (_config == null) _config = new YamlConfig(Path.Combine(PluginManager.ServerConfigDirectory, "server-config.yml")); - - RequiredForFemur = _config.GetInt("synapse_femur",1); - RemoteKeyCard = _config.GetBool("synapse_remote_keycard", false); - JoinBroadcast = _config.GetString("synapse_join_broadcast", ""); - JoinTextHint = _config.GetString("synapse_join_texthint", ""); - JoinMessageDuration = _config.GetUShort("synapse_join_duration",5); + RequiredForFemur = Plugin.Config.GetInt("synapse_femur",1); + RemoteKeyCard = Plugin.Config.GetBool("synapse_remote_keycard", false); + JoinBroadcast = Plugin.Config.GetString("synapse_join_broadcast", ""); + JoinTextHint = Plugin.Config.GetString("synapse_join_texthint", ""); + JoinMessageDuration = Plugin.Config.GetUShort("synapse_join_duration",5); } } } From ed94b5a33f6ac1f982311f259ca4af1497c4f5a0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 4 Jul 2020 10:16:19 +0200 Subject: [PATCH 197/199] Document IsJailed --- Synapse/Api/Jail.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Synapse/Api/Jail.cs b/Synapse/Api/Jail.cs index 9f5c1aa..c85d81f 100644 --- a/Synapse/Api/Jail.cs +++ b/Synapse/Api/Jail.cs @@ -6,6 +6,9 @@ namespace Synapse.Api { public class Jail : MonoBehaviour { + /// + /// Is the Player currently in Jail? + /// public bool IsJailed { get; private set; } /// From 83ab41e1eb127788bd5d30d0d575ae0fa2b4103c Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 4 Jul 2020 10:42:11 +0200 Subject: [PATCH 198/199] added CommandSender and SendRAConsoleMessage to Player --- Synapse/Api/Player.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 5bd51e1..1fc987c 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -53,6 +53,18 @@ public class Player : MonoBehaviour public HintDisplay HintDisplay => Hub.hints; + /// + /// The CommandSender objects og the Player + /// + public CommandSender CommandSender + { + get + { + if (this == Server) return ServerConsole._scs; + else return QueryProcessor._sender; + } + } + /// /// The name of the player /// @@ -430,6 +442,14 @@ public void InstantBroadcast(ushort time, string message) /// public void SendConsoleMessage(string message, string color = "red") => ClassManager.TargetConsolePrint(Connection, message, color); + /// + /// Send a message in the Text based Remote Admin of the Player + /// + /// + /// + /// + public void SendRAConsoleMessage(string message, bool success = true, RaCategory type = RaCategory.None) => CommandSender.RaMessage(message, success, type); + /// /// Hides for normal player the RankName the player has /// From a0dba45d7407b56cc8aec242f4f0d56eca4606f3 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 5 Jul 2020 10:19:24 +0200 Subject: [PATCH 199/199] Changed version to 1.0-beta --- Synapse/Api/Player.cs | 4 ++-- Synapse/Events/Patches/ServerNamePatch.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 1fc987c..19f0e9d 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -54,7 +54,7 @@ public class Player : MonoBehaviour public HintDisplay HintDisplay => Hub.hints; /// - /// The CommandSender objects og the Player + /// The CommandSender objects of the Player /// public CommandSender CommandSender { @@ -443,7 +443,7 @@ public void InstantBroadcast(ushort time, string message) public void SendConsoleMessage(string message, string color = "red") => ClassManager.TargetConsolePrint(Connection, message, color); /// - /// Send a message in the Text based Remote Admin of the Player + /// Sends a message in the Text based Remote Admin of the Player /// /// /// diff --git a/Synapse/Events/Patches/ServerNamePatch.cs b/Synapse/Events/Patches/ServerNamePatch.cs index 56502b2..8308a8b 100644 --- a/Synapse/Events/Patches/ServerNamePatch.cs +++ b/Synapse/Events/Patches/ServerNamePatch.cs @@ -8,7 +8,7 @@ public static class ServerNamePatch public static void Postfix() { ServerConsole._serverName = ServerConsole._serverName.Replace("SM119.0.0", ""); - ServerConsole._serverName += " SMSynapse-ModLoader v.0.1-Alpha"; + ServerConsole._serverName += " SMSynapse-ModLoader v.1.0-beta"; } } } \ No newline at end of file