diff --git a/Assets/Resources/Prefabs/Static/GlobalController.prefab b/Assets/Resources/Prefabs/Static/GlobalController.prefab index 9fea240061..a5ba31315f 100644 --- a/Assets/Resources/Prefabs/Static/GlobalController.prefab +++ b/Assets/Resources/Prefabs/Static/GlobalController.prefab @@ -373,6 +373,7 @@ MonoBehaviour: loader: {fileID: 4106952048028765773} translationKey: ui.options.controls.player.sprintfireball hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 4415235828989290865} --- !u!114 &4106952048028765773 MonoBehaviour: @@ -2594,6 +2595,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &450293994584279393 GameObject: m_ObjectHideFlags: 0 @@ -3208,6 +3210,7 @@ MonoBehaviour: loader: {fileID: 1572332216229407554} translationKey: ui.options.general.usenicknamecolor hideOnWebGL: 1 + requireReconnect: 1 toggle: {fileID: 5498601322469563358} --- !u!114 &1572332216229407554 MonoBehaviour: @@ -4569,6 +4572,7 @@ MonoBehaviour: loader: {fileID: 3946802595166957417} translationKey: ui.options.general.language hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: [] leftButton: {fileID: 7410339893995999180} @@ -7139,6 +7143,7 @@ MonoBehaviour: loader: {fileID: 8085566484365423440} translationKey: ui.options.audio.sfxvolume hideOnWebGL: 0 + requireReconnect: 0 slider: {fileID: 6987087655746581023} --- !u!114 &8085566484365423440 MonoBehaviour: @@ -7793,6 +7798,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 slider: {fileID: 3860544532418367598} --- !u!1 &1612769417556316985 GameObject: @@ -8126,6 +8132,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &1706591211145739144 GameObject: m_ObjectHideFlags: 0 @@ -8621,6 +8628,7 @@ MonoBehaviour: loader: {fileID: 4100463863979494654} translationKey: ui.options.general.filter hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 1249766320593447571} --- !u!114 &4100463863979494654 MonoBehaviour: @@ -12214,6 +12222,7 @@ MonoBehaviour: loader: {fileID: 8578619449753810612} translationKey: ui.options.graphics.colorblind hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 7055432996009240227} --- !u!114 &8578619449753810612 MonoBehaviour: @@ -12578,6 +12587,7 @@ MonoBehaviour: loader: {fileID: 3080994205510645947} translationKey: ui.options.graphic.ndsborder hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: - ui.generic.none @@ -15503,6 +15513,7 @@ MonoBehaviour: loader: {fileID: 4874636553619239975} translationKey: ui.options.audio.specialpowerupmusic hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: - None @@ -15785,6 +15796,7 @@ MonoBehaviour: loader: {fileID: 3258124353341044133} translationKey: ui.options.general.disablenatpunchthrough hideOnWebGL: 1 + requireReconnect: 0 toggle: {fileID: 2877012976476073891} --- !u!114 &3258124353341044133 MonoBehaviour: @@ -16990,6 +17002,7 @@ MonoBehaviour: loader: {fileID: 3109658290078881478} translationKey: ui.options.graphics.nametags hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 6333737616381551296} --- !u!114 &3109658290078881478 MonoBehaviour: @@ -18612,6 +18625,7 @@ MonoBehaviour: loader: {fileID: 6228130765146996256} translationKey: ui.options.graphics.outlines hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 5634080094010737286} --- !u!114 &6228130765146996256 MonoBehaviour: @@ -19100,6 +19114,7 @@ MonoBehaviour: loader: {fileID: 5299115518252778836} translationKey: ui.options.graphics.ndsaspect hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 2109658561299059253} --- !u!114 &5299115518252778836 MonoBehaviour: @@ -20307,6 +20322,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &4030309687177511095 GameObject: m_ObjectHideFlags: 0 @@ -21232,6 +21248,7 @@ MonoBehaviour: loader: {fileID: 7484567522761811551} translationKey: ui.options.audio.musicvolume hideOnWebGL: 0 + requireReconnect: 0 slider: {fileID: 1000726170360123287} --- !u!114 &7484567522761811551 MonoBehaviour: @@ -23254,6 +23271,7 @@ MonoBehaviour: loader: {fileID: 7376213027954581934} translationKey: ui.options.graphics.ndspixelperfect hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 3135476301697766250} --- !u!114 &7376213027954581934 MonoBehaviour: @@ -25649,6 +25667,7 @@ MonoBehaviour: loader: {fileID: 6602884925576800488} translationKey: ui.options.controls.player.rumble hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: - ui.generic.none @@ -26070,6 +26089,7 @@ MonoBehaviour: loader: {fileID: 8134013611042343623} translationKey: ui.options.general.scoreboard hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 6144179526056008828} --- !u!114 &8134013611042343623 MonoBehaviour: @@ -26217,6 +26237,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: - Example Option #1 @@ -26362,6 +26383,7 @@ MonoBehaviour: loader: {fileID: 4325302529494723555} translationKey: ui.options.audio.mutemusic hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 7189109949806830117} --- !u!114 &4325302529494723555 MonoBehaviour: @@ -26846,6 +26868,7 @@ MonoBehaviour: loader: {fileID: 932358162206055826} translationKey: ui.options.audio.directionalaudio hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 1146890752544744863} --- !u!114 &932358162206055826 MonoBehaviour: @@ -27935,6 +27958,7 @@ MonoBehaviour: loader: {fileID: 1818113054297424985} translationKey: ui.options.audio.mastervolume hideOnWebGL: 0 + requireReconnect: 0 slider: {fileID: 5728337758400529624} --- !u!114 &1818113054297424985 MonoBehaviour: @@ -30702,6 +30726,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 564158829353813385} --- !u!1 &6200578200987653295 GameObject: @@ -31427,6 +31452,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &6364731373147859471 GameObject: m_ObjectHideFlags: 0 @@ -31900,6 +31926,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 action: m_Name: Action m_Type: 0 @@ -32337,6 +32364,7 @@ MonoBehaviour: loader: {fileID: 1145943068350904329} translationKey: ui.options.controls.player.autosprint hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 2073441564213733866} --- !u!114 &1145943068350904329 MonoBehaviour: @@ -32409,6 +32437,7 @@ MonoBehaviour: loader: {fileID: 2237231657595372107} translationKey: ui.options.graphics.ndsresolution hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 3083316540106571746} --- !u!114 &2237231657595372107 MonoBehaviour: @@ -32518,7 +32547,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 23.75 + m_fontSize: 0 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -33664,6 +33693,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &6858180508840204657 GameObject: m_ObjectHideFlags: 0 @@ -33884,6 +33914,7 @@ MonoBehaviour: loader: {fileID: 3540664288043984378} translationKey: ui.options.audio.specialpowerupmusic.localonly hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 6536488187605093126} --- !u!114 &3540664288043984378 MonoBehaviour: @@ -34030,6 +34061,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &6931819943234914722 GameObject: m_ObjectHideFlags: 0 @@ -34875,6 +34907,7 @@ MonoBehaviour: loader: {fileID: 7098611919111807654} translationKey: ui.options.graphics.windowmode hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: - Windowed @@ -35744,6 +35777,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &7276809741208318974 GameObject: m_ObjectHideFlags: 0 @@ -37423,6 +37457,7 @@ MonoBehaviour: loader: {fileID: 57704536503830520} translationKey: ui.options.audio.mutesfx hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 7084307702370645175} --- !u!114 &57704536503830520 MonoBehaviour: @@ -41940,6 +41975,7 @@ MonoBehaviour: loader: {fileID: 2390399773882146463} translationKey: ui.options.controls.player.propellerjump hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 1032388464164283321} --- !u!114 &2390399773882146463 MonoBehaviour: @@ -42969,6 +43005,7 @@ MonoBehaviour: loader: {fileID: 2989453527913275262} translationKey: ui.options.graphics.vsync hideOnWebGL: 0 + requireReconnect: 0 toggle: {fileID: 1360917658475361938} --- !u!114 &2989453527913275262 MonoBehaviour: @@ -44054,6 +44091,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 slider: {fileID: 4900420335262708530} valueLabel: {fileID: 7275605491149319844} numberMultiplier: 0 @@ -44199,6 +44237,7 @@ MonoBehaviour: loader: {fileID: 2731578900809585502} translationKey: ui.options.graphics.maxframerate hideOnWebGL: 0 + requireReconnect: 0 slider: {fileID: 4562510881309958844} valueLabel: {fileID: 593734359055409212} numberMultiplier: 5 @@ -45053,6 +45092,7 @@ MonoBehaviour: loader: {fileID: 0} translationKey: hideOnWebGL: 0 + requireReconnect: 0 --- !u!1 &9120245329450423663 GameObject: m_ObjectHideFlags: 0 @@ -45576,6 +45616,7 @@ MonoBehaviour: loader: {fileID: 5592080312414666002} translationKey: ui.options.graphics.fullscreenresolution hideOnWebGL: 0 + requireReconnect: 0 value: 0 options: [] leftButton: {fileID: 6803919461541835449} diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index e1ad7067b3..4be8e3aaa4 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -2343,10 +2343,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 24} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -484} + m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &66575388 MonoBehaviour: @@ -2395,7 +2395,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14 m_fontSizeBase: 13.6 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -2481,9 +2481,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -110} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &75133766 @@ -2633,9 +2633,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -136} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &75580657 @@ -2784,9 +2784,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -188} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &77529301 @@ -2934,10 +2934,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 30} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -19} + m_SizeDelta: {x: 260, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &80074248 MonoBehaviour: @@ -2987,7 +2987,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 18 m_fontSizeBase: 13.6 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -3661,7 +3661,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14.6 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -3975,9 +3975,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -15} m_SizeDelta: {x: 260, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &153817299 @@ -5599,7 +5599,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 16.1 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -6885,9 +6885,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -32} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &256353508 @@ -14263,9 +14263,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -255} m_SizeDelta: {x: 260, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &402645375 @@ -14635,7 +14635,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 18 m_fontSizeBase: 18 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -15707,10 +15707,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 34} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -98} + m_SizeDelta: {x: 260, y: 34} m_Pivot: {x: 0.5, y: 1} --- !u!114 &438218786 MonoBehaviour: @@ -15759,7 +15759,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14 m_fontSizeBase: 21.8 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -16500,7 +16500,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 36.3 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -17139,10 +17139,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 24} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -36} + m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &485322299 MonoBehaviour: @@ -17191,7 +17191,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14 m_fontSizeBase: 13.6 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -23635,10 +23635,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 34} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -62} + m_SizeDelta: {x: 260, y: 34} m_Pivot: {x: 0.5, y: 1} --- !u!114 &574816556 MonoBehaviour: @@ -23687,7 +23687,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14 m_fontSizeBase: 13.6 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -24877,10 +24877,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 24} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -134} + m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &644584041 MonoBehaviour: @@ -24929,7 +24929,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14 m_fontSizeBase: 13.6 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -26781,10 +26781,10 @@ RectTransform: m_Father: {fileID: 823064026} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: -321} + m_SizeDelta: {x: 260, y: 322} m_Pivot: {x: 0, y: 0.5} --- !u!114 &698007183 MonoBehaviour: @@ -28312,9 +28312,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -84} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &745954561 @@ -36986,9 +36986,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -214} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &899502179 @@ -39674,7 +39674,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 14 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -44107,9 +44107,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -298} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1259822364 @@ -46578,8 +46578,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 47220571} m_HandleRect: {fileID: 47220570} m_Direction: 2 - m_Value: 0 - m_Size: 1 + m_Value: 1 + m_Size: 0.6737094 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -46709,7 +46709,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0 + m_fontSize: 18 m_fontSizeBase: 18 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -49851,9 +49851,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -58} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1488925096 @@ -75289,9 +75289,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -284} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1585506762 @@ -82555,7 +82555,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1141870934} m_HandleRect: {fileID: 1141870933} m_Direction: 2 - m_Value: 0 + m_Value: 1 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: @@ -89400,9 +89400,9 @@ RectTransform: m_Father: {fileID: 698007182} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -162} m_SizeDelta: {x: 260, y: 24} m_Pivot: {x: 0.5, y: 1} --- !u!114 &2007433170 diff --git a/Assets/Scripts/BackgroundLoop.cs b/Assets/Scripts/BackgroundLoop.cs index f3b5148789..e86e504d7d 100644 --- a/Assets/Scripts/BackgroundLoop.cs +++ b/Assets/Scripts/BackgroundLoop.cs @@ -4,7 +4,6 @@ using NSMB.Extensions; using NSMB.Game; using NSMB.Utils; -using Fusion; public class BackgroundLoop : MonoBehaviour { @@ -36,8 +35,9 @@ public void Start() { truePositions[i] = children[i].transform.position; } - foreach (GameObject obj in children) + foreach (GameObject obj in children) { LoadChildObjects(obj); + } lastPosition = transform.position; } @@ -82,15 +82,19 @@ private void LoadChildObjects(GameObject obj) { c.name = obj.name + i; } Destroy(clone); - if (obj.GetComponent() is LegacyAnimateSpriteRenderer anim) + if (obj.GetComponent() is LegacyAnimateSpriteRenderer anim) { Destroy(anim); - if (obj.GetComponent() is SpriteRenderer sRenderer) + } + + if (obj.GetComponent() is SpriteRenderer sRenderer) { Destroy(sRenderer); + } } private void RepositionChildObjects(GameObject obj) { - if (!obj) + if (!obj) { return; + } Transform parent = obj.transform; if (parent.childCount > 1) { diff --git a/Assets/Scripts/BuildInfo.cs b/Assets/Scripts/BuildInfo.cs index 29f17fcdfd..e70283bc50 100644 --- a/Assets/Scripts/BuildInfo.cs +++ b/Assets/Scripts/BuildInfo.cs @@ -1 +1 @@ -public static class BuildInfo{public static string BUILD_TIME = "1/4/2024 10:13:15 PM";} +public static class BuildInfo{public static string BUILD_TIME = "1/8/2024 5:02:13 AM";} diff --git a/Assets/Scripts/Entity/BasicEntity.cs b/Assets/Scripts/Entity/BasicEntity.cs index 3ea1c1f7cf..ca560f9df6 100644 --- a/Assets/Scripts/Entity/BasicEntity.cs +++ b/Assets/Scripts/Entity/BasicEntity.cs @@ -36,8 +36,8 @@ public abstract class BasicEntity : NetworkBehaviour, IBlockBumpable { protected ChangeDetector changeDetector; public virtual void OnValidate() { - SetIfNull(ref body); - SetIfNull(ref sfx); + this.SetIfNull(ref body); + this.SetIfNull(ref sfx); } public override void Spawned() { @@ -58,6 +58,11 @@ public override void Spawned() { } public override void Render() { + changeDetector ??= GetChangeDetector(ChangeDetector.Source.SimulationState); + if (changeDetector == null) { + return; + } + NetworkBehaviourBuffer oldBuffer = default; NetworkBehaviourBuffer newBuffer = default; HandleRenderChanges(true, ref oldBuffer, ref newBuffer); @@ -245,16 +250,5 @@ protected virtual void HandleRenderChanges(bool fillBuffer, ref NetworkBehaviour } } } - - //---Utils - protected void SetIfNull(ref T var, bool children = false) where T : Component { - if (!var) { - if (children) { - var = GetComponentInChildren(); - } else { - var = GetComponent(); - } - } - } } } diff --git a/Assets/Scripts/Entity/Enemy/Boo.cs b/Assets/Scripts/Entity/Enemy/Boo.cs index b0aa5dc430..c1d771dced 100644 --- a/Assets/Scripts/Entity/Enemy/Boo.cs +++ b/Assets/Scripts/Entity/Enemy/Boo.cs @@ -137,8 +137,8 @@ private PlayerController GetNearestPlayer(float maxDistance) { public override void InteractWithPlayer(PlayerController player, PhysicsDataStruct.IContactStruct contact = null) { bool fromRight = Utils.WrappedDirectionSign(body.Position, CurrentTarget.body.Position + targetingOffset) == -1; - if (player.State == Enums.PowerupState.MegaMushroom || player.IsStarmanInvincible) { - SpecialKill(!fromRight, false, player.State == Enums.PowerupState.MegaMushroom, player.StarCombo++); + if (player.State == Enums.PowerupState.MegaMushroom || player.IsStarmanInvincible || player.IsInShell) { + SpecialKill(!fromRight, false, !player.IsStarmanInvincible, player.StarCombo++); return; } diff --git a/Assets/Scripts/Entity/Enemy/HoldableEntity.cs b/Assets/Scripts/Entity/Enemy/HoldableEntity.cs index 5e9ada0392..088f3cbdcf 100644 --- a/Assets/Scripts/Entity/Enemy/HoldableEntity.cs +++ b/Assets/Scripts/Entity/Enemy/HoldableEntity.cs @@ -76,10 +76,10 @@ public virtual void Throw(bool toRight, bool crouching) { } ThrowInvincibility = TickTimer.CreateFromSeconds(Runner, crouching ? 0.6f : 0.35f); + CurrentKickSpeed = throwSpeed + 1.5f * (Mathf.Abs(Holder.body.Velocity.x) / Holder.RunningMaxSpeed); PreviousHolder = Holder; Holder = null; FacingRight = toRight; - CurrentKickSpeed = throwSpeed; body.Velocity = new((crouching && canPlace ? 2f : CurrentKickSpeed) * (FacingRight ? 1 : -1), 0); } diff --git a/Assets/Scripts/Entity/Enemy/KillableEntity.cs b/Assets/Scripts/Entity/Enemy/KillableEntity.cs index 2cdeb28186..a4a61c4436 100644 --- a/Assets/Scripts/Entity/Enemy/KillableEntity.cs +++ b/Assets/Scripts/Entity/Enemy/KillableEntity.cs @@ -101,10 +101,10 @@ public override Vector2 FrozenOffset { public override void OnValidate() { base.OnValidate(); - SetIfNull(ref hitbox); - SetIfNull(ref animator, true); - SetIfNull(ref sRenderer, true); - SetIfNull(ref legacyAnimation, true); + this.SetIfNull(ref hitbox); + this.SetIfNull(ref animator, UnityExtensions.GetComponentType.Children); + this.SetIfNull(ref sRenderer, UnityExtensions.GetComponentType.Children); + this.SetIfNull(ref legacyAnimation, UnityExtensions.GetComponentType.Children); } public virtual void Start() { diff --git a/Assets/Scripts/Entity/Enemy/PiranhaPlant.cs b/Assets/Scripts/Entity/Enemy/PiranhaPlant.cs index 4fa2a441c6..2596e7899e 100644 --- a/Assets/Scripts/Entity/Enemy/PiranhaPlant.cs +++ b/Assets/Scripts/Entity/Enemy/PiranhaPlant.cs @@ -139,7 +139,10 @@ public override void RespawnEntity() { public override void Kill() { IsDead = true; - Runner.Spawn(PrefabList.Instance.Obj_LooseCoin, transform.position + Vector3.up); + + if (Runner.IsServer) { + Runner.Spawn(PrefabList.Instance.Obj_LooseCoin, transform.position + Vector3.up); + } } public override void SpecialKill(bool right, bool groundpound, bool mega, int combo) { diff --git a/Assets/Scripts/Entity/Fireball.cs b/Assets/Scripts/Entity/Fireball.cs index 0d781e7d98..143fbb3606 100644 --- a/Assets/Scripts/Entity/Fireball.cs +++ b/Assets/Scripts/Entity/Fireball.cs @@ -8,9 +8,6 @@ using NSMB.Utils; namespace NSMB.Entities { - - //[OrderBefore(typeof(FrozenCube))] - //[OrderAfter(typeof(PlayerController), typeof(NetworkPhysicsSimulation2D))] public class Fireball : BasicEntity, IPlayerInteractable, IFireballInteractable { //---Static Variables diff --git a/Assets/Scripts/Entity/Player/PlayerController.cs b/Assets/Scripts/Entity/Player/PlayerController.cs index 8dfc1d566d..7de0a88c82 100644 --- a/Assets/Scripts/Entity/Player/PlayerController.cs +++ b/Assets/Scripts/Entity/Player/PlayerController.cs @@ -519,9 +519,7 @@ public override void FixedUpdateNetwork() { HandleMovement(heldButtons, pressedButtons); } - //HandleBlockSnapping(); CheckForEntityCollision(); - PreviousTickIsOnGround = IsOnGround; } @@ -1183,7 +1181,6 @@ public override void Freeze(FrozenCube cube) { IsFrozen = true; FrozenCube = cube; FrozenCube.AutoBreakTimer = TickTimer.CreateFromSeconds(Runner, 1.75f); - animator.enabled = false; body.Freeze = true; IsInKnockback = false; IsSkidding = false; @@ -1209,12 +1206,11 @@ public override void Unfreeze(UnfreezeReason reason) { } IsFrozen = false; - animator.enabled = true; body.Freeze = false; int knockbackStars = reason switch { UnfreezeReason.Timer => 0, - UnfreezeReason.Groundpounded => 2, + UnfreezeReason.Groundpounded => 3, _ => 1 }; @@ -1225,7 +1221,7 @@ public override void Unfreeze(UnfreezeReason reason) { } if (knockbackStars > 0) { - DoKnockback(FacingRight, knockbackStars, true, null); + DoKnockback(FacingRight, knockbackStars, knockbackStars <= 1, null); } else { DamageInvincibilityTimer = TickTimer.CreateFromSeconds(Runner, 1f); } @@ -1287,7 +1283,6 @@ public void SpawnItem(NetworkPrefabRef prefab) { } private void SpawnStars(int amount, bool deathplane) { - if (!Runner.IsServer) { return; } @@ -1656,7 +1651,7 @@ private bool InteractWithTile(Vector2Int tilePos, InteractionDirection direction #region -- KNOCKBACK -- public void DoKnockback(bool fromRight, int starsToDrop, bool weak, NetworkObject attacker) { - if ((weak && IsWeakKnockback && IsInKnockback) || (IsInKnockback && !IsWeakKnockback)) { + if (IsInKnockback && ((IsWeakKnockback && weak) || !IsWeakKnockback)) { return; } @@ -1682,10 +1677,12 @@ public void DoKnockback(bool fromRight, int starsToDrop, bool weak, NetworkObjec KnockbackWasOriginallyFacingRight = FacingRight; KnockbackTick = Runner.Tick; - //Vector2Int tileLoc = Utils.Utils.WorldToTilemapPosition(body.Position); - //TileBase tile = Utils.Utils.GetTileAtTileLocation(tileLoc + (fromRight ? Vector2Int.left : Vector2Int.right)); - //if (!weak && tile) - // fromRight = !fromRight; + // Don't go into walls + Vector2Int tileLoc = Utils.Utils.WorldToTilemapPosition(body.Position); + TileBase tile = Utils.Utils.GetTileAtTileLocation(tileLoc + (fromRight ? Vector2Int.left : Vector2Int.right)); + if (!weak && tile) { + fromRight = !fromRight; + } body.Velocity = new Vector2( (fromRight ? -1 : 1) * @@ -1695,7 +1692,7 @@ public void DoKnockback(bool fromRight, int starsToDrop, bool weak, NetworkObjec (State == Enums.PowerupState.MiniMushroom ? 2.5f : 1f) * (weak ? 0.5f : 1f), - // don't go upwards if we got hit by a fireball + // Don't go upwards if we got hit by a fireball (attacker && attacker.TryGetComponent(out Fireball _)) ? 0 : 4.5f ); @@ -1727,6 +1724,8 @@ private void ResetKnockback() { DamageInvincibilityTimer = TickTimer.CreateFromSeconds(Runner, 1f); //DoEntityBounce = false; IsInKnockback = false; + IsWeakKnockback = false; + IsForwardsKnockback = false; body.Velocity = new(0, body.Velocity.y); FacingRight = KnockbackWasOriginallyFacingRight; } @@ -2620,6 +2619,10 @@ private void HandleMovement(NetworkButtons heldButtons, NetworkButtons pressedBu return; } + if (State == Enums.PowerupState.MegaMushroom) { + HandleMegaTiles(true); + } + // Don't do anything if we're stuck in a block if (HandleStuckInBlock()) { return; @@ -2862,7 +2865,6 @@ private void HandleMovement(NetworkButtons heldButtons, NetworkButtons pressedBu HandleFacingDirection(left, right); - if (State == Enums.PowerupState.MegaMushroom) { HandleMegaTiles(true); if (Runner.IsForward && IsOnGround && JumpState == PlayerJumpState.SingleJump) { diff --git a/Assets/Scripts/Entity/Powerups/Powerup.cs b/Assets/Scripts/Entity/Powerups/Powerup.cs index 51c54fc11e..8dfec48464 100644 --- a/Assets/Scripts/Entity/Powerups/Powerup.cs +++ b/Assets/Scripts/Entity/Powerups/Powerup.cs @@ -49,9 +49,9 @@ public class Powerup : CollectableEntity, IBlockBumpable { public override void OnValidate() { base.OnValidate(); - SetIfNull(ref sRenderer, true); - SetIfNull(ref hitbox); - SetIfNull(ref childAnimator, true); + this.SetIfNull(ref sRenderer, UnityExtensions.GetComponentType.Children); + this.SetIfNull(ref hitbox); + this.SetIfNull(ref childAnimator, UnityExtensions.GetComponentType.Children); } public void Awake() { diff --git a/Assets/Scripts/Entity/World Elements/Coin.cs b/Assets/Scripts/Entity/World Elements/Coin.cs index c6cd7febec..729eaae774 100644 --- a/Assets/Scripts/Entity/World Elements/Coin.cs +++ b/Assets/Scripts/Entity/World Elements/Coin.cs @@ -3,6 +3,7 @@ using Fusion; using NSMB.Entities.Enemies; using NSMB.Entities.Player; +using NSMB.Extensions; using NSMB.Tiles; namespace NSMB.Entities.Collectable { @@ -12,15 +13,16 @@ public abstract class Coin : CollectableEntity { [SerializeField] protected SpriteRenderer sRenderer; public override void OnValidate() { - if (!sRenderer) sRenderer = GetComponentInChildren(); + this.SetIfNull(ref sRenderer, UnityExtensions.GetComponentType.Children); } public static void GivePlayerCoin(PlayerController player, Vector3 position) { byte newCoins = (byte) (player.Coins + 1); bool item = newCoins >= SessionData.Instance.CoinRequirement; - if (player.Object.HasStateAuthority) + if (player.Object.HasStateAuthority) { player.Rpc_SpawnCoinEffects(position, newCoins, item); + } if (item) { player.SpawnItem(NetworkPrefabRef.Empty); @@ -32,8 +34,9 @@ public static void GivePlayerCoin(PlayerController player, Vector3 position) { //---IPlayerInteractable overrides public override void InteractWithPlayer(PlayerController player, PhysicsDataStruct.IContactStruct contact = null) { - if (Collector) + if (Collector) { return; + } Collector = player; GivePlayerCoin(player, transform.position); @@ -41,17 +44,20 @@ public override void InteractWithPlayer(PlayerController player, PhysicsDataStru //---IBlockBumpable overrides public override void BlockBump(BasicEntity bumper, Vector2Int tile, InteractionDirection direction) { - if (direction == InteractionDirection.Down) + if (direction == InteractionDirection.Down) { return; + } PlayerController target = null; - if (bumper is PlayerController player) + if (bumper is PlayerController player) { target = player; - else if (bumper is Koopa koopa) + } else if (bumper is Koopa koopa) { target = koopa.PreviousHolder; + } - if (!target) + if (!target) { return; + } InteractWithPlayer(target); } diff --git a/Assets/Scripts/Entity/World Elements/FrozenCube.cs b/Assets/Scripts/Entity/World Elements/FrozenCube.cs index f545715507..0e529f5c86 100644 --- a/Assets/Scripts/Entity/World Elements/FrozenCube.cs +++ b/Assets/Scripts/Entity/World Elements/FrozenCube.cs @@ -82,7 +82,7 @@ public override void Render() { } if (FrozenEntity && FrozenEntity.IsCarryable) { - Transform target = FrozenEntity.transform.transform; + Transform target = FrozenEntity.transform; Vector2 newPos = (Vector2) transform.position + EntityPositionOffset; Utils.Utils.WrapWorldLocation(ref newPos); target.position = new(newPos.x, newPos.y, target.position.z); @@ -98,6 +98,7 @@ public override void FixedUpdateNetwork() { base.FixedUpdateNetwork(); if (!Object || IsDead) { + gameObject.layer = Layers.LayerHitsNothing; return; } @@ -174,7 +175,6 @@ public override void FixedUpdateNetwork() { } private bool HandleTile() { - if ((FastSlide && (body.Data.HitLeft || body.Data.HitRight)) || (flying && Fallen && body.Data.OnGround && !Holder) || ((Holder || body.Data.OnGround) && body.Data.HitRoof)) { diff --git a/Assets/Scripts/Entity/World Elements/LooseCoin.cs b/Assets/Scripts/Entity/World Elements/LooseCoin.cs index 366005c0a3..75656f1c8f 100644 --- a/Assets/Scripts/Entity/World Elements/LooseCoin.cs +++ b/Assets/Scripts/Entity/World Elements/LooseCoin.cs @@ -22,8 +22,8 @@ public class LooseCoin : Coin { public override void OnValidate() { base.OnValidate(); - SetIfNull(ref spriteAnimation, true); - SetIfNull(ref hitbox); + this.SetIfNull(ref spriteAnimation, UnityExtensions.GetComponentType.Children); + this.SetIfNull(ref hitbox); } public override void Spawned() { diff --git a/Assets/Scripts/Networking/Fusion/NetworkHandler.cs b/Assets/Scripts/Networking/Fusion/NetworkHandler.cs index 5e0b8d1bd6..9586020713 100644 --- a/Assets/Scripts/Networking/Fusion/NetworkHandler.cs +++ b/Assets/Scripts/Networking/Fusion/NetworkHandler.cs @@ -418,10 +418,12 @@ public static async Task ConnectToRegion(string region = "") { connecting++; // Exit if we're already in a room - if ((Runner.SessionInfo.IsValid || Runner.LobbyInfo.IsValid) && !Runner.IsShutdown) { + if (Runner && (Runner.SessionInfo.IsValid || Runner.LobbyInfo.IsValid) && !Runner.IsShutdown) { await Runner.Shutdown(); } else { - DestroyImmediate(Runner); + if (Runner) { + DestroyImmediate(Runner); + } Instance.runner = Instance.gameObject.AddComponent(); } @@ -601,6 +603,7 @@ public static async Task JoinRoom(string roomId) { }); if (!result.Ok) { Debug.Log($"[Network] Failed to join game: {result.ShutdownReason}"); + connecting = 0; // Automatically go back to the lobby. await ConnectToRegion(originalRegion); } diff --git a/Assets/Scripts/UI/Menu/Chat/MainMenuChat.cs b/Assets/Scripts/UI/Menu/Chat/MainMenuChat.cs index 672768fbd0..0063d6fde9 100644 --- a/Assets/Scripts/UI/Menu/Chat/MainMenuChat.cs +++ b/Assets/Scripts/UI/Menu/Chat/MainMenuChat.cs @@ -44,8 +44,8 @@ public void SetTypingIndicator(PlayerRef player) { return; } - PlayerData data; - if ((data = player.GetPlayerData(NetworkHandler.Runner)) && data.IsMuted) { + PlayerData data = player.GetPlayerData(NetworkHandler.Runner); + if (data && data.IsMuted) { return; } diff --git a/Assets/Scripts/UI/Menu/MainMenuManager.cs b/Assets/Scripts/UI/Menu/MainMenuManager.cs index 11d70e1b40..07804327fa 100644 --- a/Assets/Scripts/UI/Menu/MainMenuManager.cs +++ b/Assets/Scripts/UI/Menu/MainMenuManager.cs @@ -632,7 +632,7 @@ private IEnumerator FinishQuitting() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else - Application.Quit(); + Application.Quit(); #endif } @@ -720,8 +720,6 @@ private void OnLanguageChanged(TranslationManager tm) { characterDropdown.SetValueWithoutNotify(selectedCharacter); characterDropdown.RefreshShownValue(); - //TODO: RTL FONT - if (SessionData.Instance && SessionData.Instance.Object) { UpdateRoomHeader(); OnCountdownTick((int) (SessionData.Instance.GameStartTimer.RemainingRenderTime(NetworkHandler.Runner) ?? -1)); @@ -740,7 +738,7 @@ public void OnCountdownTick(int time) { } } else { UpdateStartGameButton(); - hostControlsGroup.interactable = data && data.IsRoomOwner; + hostControlsGroup.interactable = Runner.IsServer || (data && data.IsRoomOwner); if (fadeMusicCoroutine != null) { StopCoroutine(fadeMusicCoroutine); fadeMusicCoroutine = null; diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/FullscreenModeLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/FullscreenModeLoader.cs index b10724674a..92ec2e7fa3 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/FullscreenModeLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/FullscreenModeLoader.cs @@ -12,7 +12,8 @@ public class FullscreenModeLoader : PauseOptionLoader { "ui.options.graphics.windowmode.fullscreen", "ui.options.graphics.windowmode.borderless", "ui.options.graphics.windowmode.maximized", - "ui.options.graphics.windowmode.windowed" }; + "ui.options.graphics.windowmode.windowed" + }; //---Private Variables private FullScreenMode[] validModes; @@ -27,18 +28,19 @@ public void OnDisable() { } public override void LoadOptions(PauseOption option) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } this.option = option; spo.options.Clear(); validModes ??= Application.platform switch { - RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsEditor => new[] { FullScreenMode.Windowed, FullScreenMode.FullScreenWindow, FullScreenMode.ExclusiveFullScreen }, - RuntimePlatform.OSXPlayer or RuntimePlatform.OSXEditor => new[] { FullScreenMode.Windowed, FullScreenMode.FullScreenWindow, FullScreenMode.MaximizedWindow }, - RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxEditor => new[] { FullScreenMode.Windowed, FullScreenMode.FullScreenWindow }, - _ => new[] { FullScreenMode.FullScreenWindow }, - }; + RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsEditor => new[] { FullScreenMode.Windowed, FullScreenMode.FullScreenWindow, FullScreenMode.ExclusiveFullScreen }, + RuntimePlatform.OSXPlayer or RuntimePlatform.OSXEditor => new[] { FullScreenMode.Windowed, FullScreenMode.FullScreenWindow, FullScreenMode.MaximizedWindow }, + RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxEditor => new[] { FullScreenMode.Windowed, FullScreenMode.FullScreenWindow }, + _ => new[] { FullScreenMode.FullScreenWindow }, + }; spo.options.AddRange(validModes.Select(fsm => FullscreenDisplayKeys[(int) fsm]).Select(GlobalController.Instance.translationManager.GetTranslation)); @@ -47,8 +49,9 @@ public override void LoadOptions(PauseOption option) { } public override void OnValueChanged(PauseOption option, object newValue) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } int value = spo.value; FullScreenMode newMode = validModes[value]; @@ -58,11 +61,14 @@ public override void OnValueChanged(PauseOption option, object newValue) { } else { Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, newMode); } + + option.manager.RequireReconnect |= option.requireReconnect; } private void OnLanguageChanged(TranslationManager tm) { - if (option) + if (option) { LoadOptions(option); + } } } } diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/LanguageLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/LanguageLoader.cs index 4cf5d8a58a..196296a339 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/LanguageLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/LanguageLoader.cs @@ -12,8 +12,9 @@ public class LanguageLoader : PauseOptionLoader { private LocaleData[] locales; public override void LoadOptions(PauseOption option) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } spo.options.Clear(); locales = GlobalController.Instance.translationManager.GetLocaleData(); @@ -27,10 +28,12 @@ public override void LoadOptions(PauseOption option) { } public override void OnValueChanged(PauseOption option, object newValue) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } GlobalController.Instance.translationManager.ChangeLanguage(locales[spo.value].Locale); + option.manager.RequireReconnect |= option.requireReconnect; } } } diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/MaxFpsLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/MaxFpsLoader.cs index 3b4bac6178..31454cdb7c 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/MaxFpsLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/MaxFpsLoader.cs @@ -5,22 +5,26 @@ namespace NSMB.UI.Pause.Loaders { public class MaxFpsLoader : PauseOptionLoader { public override void LoadOptions(PauseOption option) { - if (option is not SliderPauseOption spo) + if (option is not SliderPauseOption spo) { return; + } int value = Settings.Instance.GraphicsMaxFps <= 0 ? (int) spo.slider.maxValue : (Settings.Instance.GraphicsMaxFps / 5); spo.slider.SetValueWithoutNotify(value); } public override void OnValueChanged(PauseOption option, object newValue) { - if (option is not SliderPauseOption spo) + if (option is not SliderPauseOption spo) { return; + } int value = Mathf.RoundToInt((float) newValue); - if (value == (int) spo.slider.maxValue) + if (value == (int) spo.slider.maxValue) { value = 0; + } Settings.Instance.GraphicsMaxFps = value * 5; + option.manager.RequireReconnect |= option.requireReconnect; } } } diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/ResolutionOptionLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/ResolutionOptionLoader.cs index a373047bdf..1d79556148 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/ResolutionOptionLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/ResolutionOptionLoader.cs @@ -11,8 +11,9 @@ public class ResolutionOptionLoader : PauseOptionLoader { private List resolutions; public override void LoadOptions(PauseOption option) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } spo.options.Clear(); @@ -40,15 +41,17 @@ public override void LoadOptions(PauseOption option) { } public override void OnValueChanged(PauseOption option, object newValue) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } if (Screen.fullScreenMode != FullScreenMode.Windowed) { var res = resolutions[spo.value]; Screen.SetResolution(res.width, res.height, Screen.fullScreenMode); } - } + option.manager.RequireReconnect |= option.requireReconnect; + } public class ResolutionComparer : IEqualityComparer { public bool Equals(Resolution x, Resolution y) { @@ -60,7 +63,7 @@ public int GetHashCode(Resolution obj) { } } - private static Dictionary ValidAspectRatios = new() { + private readonly static Dictionary ValidAspectRatios = new() { { 5f/4f, "5:4" }, { 4f/3f, "4:3" }, { 3f/2f, "3:2" }, @@ -90,7 +93,7 @@ private static string GetClosestAspectRatio(int width, int height) { } private static int GreatestCommonDenominator(int a, int b) { - return (b == 0) ? a : GreatestCommonDenominator(b, a%b); + return (b == 0) ? a : GreatestCommonDenominator(b, a % b); } } } diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/SimpleLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/SimpleLoader.cs index 755e0f618f..590b8db4b7 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/SimpleLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/SimpleLoader.cs @@ -14,11 +14,13 @@ public abstract class SimpleLoader : PauseOptionLoader where O : PauseOpti private PropertyInfo property; public override void LoadOptions(PauseOption option) { - if (option is not O optionType) + if (option is not O optionType) { return; + } - if (string.IsNullOrEmpty(fieldName)) + if (string.IsNullOrEmpty(fieldName)) { return; + } V value; field = Settings.Instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public); @@ -40,13 +42,16 @@ public override void LoadOptions(PauseOption option) { public abstract V GetValue(O pauseOption); public override void OnValueChanged(PauseOption option, object newValue) { - if (option is not O optionType) + if (option is not O optionType) { return; + } V value = GetValue(optionType); field?.SetValue(Settings.Instance, value); property?.SetValue(Settings.Instance, value); + + option.manager.RequireReconnect |= option.requireReconnect; } } } diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/SimpleOptionsLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/SimpleOptionsLoader.cs index c386fa66de..cafc5356b0 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/SimpleOptionsLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/SimpleOptionsLoader.cs @@ -10,11 +10,11 @@ public class SimpleOptionsLoader : SimpleLoader { private readonly List options = new(); public override void LoadOptions(PauseOption option) { - ScrollablePauseOption spo = (ScrollablePauseOption) option; - if (options.Count == 0) + if (options.Count == 0) { options.AddRange(spo.options); + } spo.options.Clear(); spo.options.AddRange(options.Select(GlobalController.Instance.translationManager.GetTranslation)); diff --git a/Assets/Scripts/UI/Menu/Options/Loaders/SpecialPowerupMusicLoader.cs b/Assets/Scripts/UI/Menu/Options/Loaders/SpecialPowerupMusicLoader.cs index e4fd7fc13e..25a395670e 100644 --- a/Assets/Scripts/UI/Menu/Options/Loaders/SpecialPowerupMusicLoader.cs +++ b/Assets/Scripts/UI/Menu/Options/Loaders/SpecialPowerupMusicLoader.cs @@ -24,8 +24,9 @@ public void OnDisable() { } public override void LoadOptions(PauseOption option) { - if (option is not ScrollablePauseOption spo) + if (option is not ScrollablePauseOption spo) { return; + } this.option = option; spo.options.Clear(); @@ -37,11 +38,13 @@ public override void LoadOptions(PauseOption option) { public override void OnValueChanged(PauseOption option, object newValue) { Settings.Instance.audioSpecialPowerupMusic = (Enums.SpecialPowerupMusic) newValue; + option.manager.RequireReconnect |= option.requireReconnect; } private void OnLanguageChanged(TranslationManager tm) { - if (option) + if (option) { LoadOptions(option); + } } } } diff --git a/Assets/Scripts/UI/Menu/Options/PauseOption.cs b/Assets/Scripts/UI/Menu/Options/PauseOption.cs index d1ef9dcaa1..787e5f7fe6 100644 --- a/Assets/Scripts/UI/Menu/Options/PauseOption.cs +++ b/Assets/Scripts/UI/Menu/Options/PauseOption.cs @@ -1,6 +1,7 @@ using UnityEngine; using TMPro; +using NSMB.Extensions; using NSMB.Translation; using NSMB.UI.Pause.Loaders; @@ -18,18 +19,18 @@ public class PauseOption : MonoBehaviour { #endif //---Serialized Variables - [SerializeField] private PauseOptionMenuManager manager; + [SerializeField] internal PauseOptionMenuManager manager; [SerializeField] internal TMP_Text label; [SerializeField] protected PauseOptionLoader loader; [SerializeField] public string translationKey; - [SerializeField] internal bool hideOnWebGL; + [SerializeField] internal bool hideOnWebGL, requireReconnect; //---Properties public bool IsSelected { get; private set; } public virtual void OnValidate() { - if (!manager) manager = GetComponentInParent(); - if (!loader) loader = GetComponent(); + this.SetIfNull(ref manager, UnityExtensions.GetComponentType.Parent); + this.SetIfNull(ref loader); } public virtual void Awake() { @@ -37,8 +38,9 @@ public virtual void Awake() { } public virtual void OnEnable() { - if (loader) + if (loader) { loader.LoadOptions(this); + } TranslationManager.OnLanguageChanged += OnLanguageChanged; OnLanguageChanged(GlobalController.Instance.translationManager); @@ -49,21 +51,20 @@ public virtual void OnDisable() { } private void OnLanguageChanged(TranslationManager tm) { - if (IsSelected) + if (IsSelected) { Selected(); - else + } else { Deselected(); + } } public virtual void Selected() { label.text = "» " + GetTranslatedString(); - //label.isRightToLeftText = GlobalController.Instance.translationManager.RightToLeft; IsSelected = true; } public virtual void Deselected() { label.text = GetTranslatedString(); - //label.isRightToLeftText = GlobalController.Instance.translationManager.RightToLeft; IsSelected = false; } diff --git a/Assets/Scripts/UI/Menu/Options/PauseOptionMenuManager.cs b/Assets/Scripts/UI/Menu/Options/PauseOptionMenuManager.cs index 020591a2f0..56130353a7 100644 --- a/Assets/Scripts/UI/Menu/Options/PauseOptionMenuManager.cs +++ b/Assets/Scripts/UI/Menu/Options/PauseOptionMenuManager.cs @@ -41,6 +41,7 @@ private bool Back { backButton.sprite = _back ? backSelectedSprite : backDeselectedSprite; } } + public bool RequireReconnect { get; set; } protected override void Awake() { base.Awake(); @@ -76,14 +77,21 @@ protected override void OnDisable() { EventSystem.current.SetSelectedGameObject(previouslySelected); } OnOptionsOpenedToggled?.Invoke(false); + + if (RequireReconnect && NetworkHandler.Runner.LobbyInfo.IsValid) { + _ = NetworkHandler.ConnectToSameRegion(); + } + RequireReconnect = false; } public void Update() { - if (!Application.isPlaying) + if (!Application.isPlaying) { return; + } - if (!EnableInput) + if (!EnableInput) { return; + } Vector2 direction = ControlSystem.controls.UI.Navigate.ReadValue(); direction = direction.normalized; @@ -109,25 +117,30 @@ public void Update() { func = SelectedTab.OnRightPress; } - if (func(true)) + if (func(true)) { return; + } } - if (!SelectedOption) + if (!SelectedOption) { return; + } - if (left) + if (left) { SelectedOption.OnLeftHeld(); - else if (right) + } else if (right) { SelectedOption.OnRightHeld(); + } } private void OnCancel(InputAction.CallbackContext context) { - if (!EnableInput) + if (!EnableInput) { return; + } - if (SelectedTab && SelectedTab.OnCancel()) + if (SelectedTab && SelectedTab.OnCancel()) { return; + } if (Back) { CloseMenu(); @@ -141,19 +154,22 @@ private void OnCancel(InputAction.CallbackContext context) { } private void OnSubmit(InputAction.CallbackContext context) { - if (!EnableInput) + if (!EnableInput) { return; + } - if (SelectedTab && SelectedTab.OnSubmit()) + if (SelectedTab && SelectedTab.OnSubmit()) { return; + } if (Back) { CloseMenu(); return; } - if (!SelectedOption) + if (!SelectedOption) { return; + } SelectedOption.OnClick(); } @@ -165,11 +181,13 @@ private void OnNavigate(InputAction.CallbackContext context) { return; } - if (!EnableInput) + if (!EnableInput) { return; + } - if (inputted) + if (inputted) { return; + } Vector2 direction = context.ReadValue(); direction = direction.normalized; @@ -194,22 +212,25 @@ private void OnNavigate(InputAction.CallbackContext context) { func = SelectedTab.OnRightPress; } - if (func(false)) + if (func(false)) { return; + } } if (Back && (down || right)) { Back = false; if (right) { - if (currentTabIndex != 0) + if (currentTabIndex != 0) { SetTab(0, false); - else + } else { SelectedTab.Highlighted(); + } } if (down) { SetCurrentOption(0); - if (currentOptionIndex == -1) + if (currentOptionIndex == -1) { SelectedTab.Highlighted(); + } } GlobalController.Instance.PlaySound(Enums.Sounds.UI_Cursor); return; @@ -223,11 +244,11 @@ private void OnNavigate(InputAction.CallbackContext context) { } else if (currentOption) { // Give this input to the option - if (left) + if (left) { currentOption.OnLeftPress(); - else + } else { currentOption.OnRightPress(); - + } } else { // Move between tabs if (left && currentTabIndex == 0) { @@ -246,8 +267,9 @@ private void OnNavigate(InputAction.CallbackContext context) { public void OpenMenu() { gameObject.SetActive(true); - foreach (PauseOptionTab tab in tabs) + foreach (PauseOptionTab tab in tabs) { tab.Deselected(); + } currentTabIndex = -1; currentOptionIndex = -1; @@ -258,11 +280,13 @@ public void OpenMenu() { } public void CloseMenu() { - if (SelectedTab) + if (SelectedTab) { SelectedTab.Deselected(); + } - if (SelectedOption) + if (SelectedOption) { SelectedOption.Deselected(); + } EnableInput = false; gameObject.SetActive(false); @@ -270,11 +294,13 @@ public void CloseMenu() { } public void SetCurrentOption(int index, bool center = false) { - if (currentOptionIndex == index || index >= SelectedTab.options.Count || index < -1) + if (currentOptionIndex == index || index >= SelectedTab.options.Count || index < -1) { return; + } - if (SelectedOption) + if (SelectedOption) { SelectedOption.Deselected(); + } int direction = index - currentOptionIndex; int original = currentOptionIndex; @@ -284,11 +310,13 @@ public void SetCurrentOption(int index, bool center = false) { currentOptionIndex += direction; } - if (currentOptionIndex >= SelectedTab.options.Count) + if (currentOptionIndex >= SelectedTab.options.Count) { currentOptionIndex = original; + } - if (currentOptionIndex < -1) + if (currentOptionIndex < -1) { currentOptionIndex = -1; + } if (SelectedTab) { if (currentOptionIndex == -1) { @@ -327,19 +355,23 @@ public void SetCurrentOption(PauseOption option) { public void SetTab(int index, bool sound = true) { SetCurrentOption(-1); - if (currentTabIndex == index) + if (currentTabIndex == index) { return; + } - if (SelectedTab) + if (SelectedTab) { SelectedTab.Deselected(); + } currentTabIndex = index; - if (SelectedTab) + if (SelectedTab) { SelectedTab.Selected(); + } - if (sound) + if (sound) { GlobalController.Instance.PlaySound(Enums.Sounds.UI_Cursor); + } Canvas.ForceUpdateCanvases(); scroll.verticalNormalizedPosition = 1; diff --git a/Assets/Scripts/UI/Menu/Options/TogglePauseOption.cs b/Assets/Scripts/UI/Menu/Options/TogglePauseOption.cs index 67fe3607cf..623dd88d94 100644 --- a/Assets/Scripts/UI/Menu/Options/TogglePauseOption.cs +++ b/Assets/Scripts/UI/Menu/Options/TogglePauseOption.cs @@ -1,6 +1,8 @@ using UnityEngine; using UnityEngine.UI; +using NSMB.Extensions; + namespace NSMB.UI.Pause.Options { public class TogglePauseOption : PauseOption { @@ -9,7 +11,7 @@ public class TogglePauseOption : PauseOption { public override void OnValidate() { base.OnValidate(); - if (!toggle) toggle = GetComponentInChildren(); + this.SetIfNull(ref toggle, UnityExtensions.GetComponentType.Children); } public override void Awake() { @@ -23,8 +25,9 @@ public override void OnClick() { } public void OnToggleValueChanged(bool value) { - if (loader) + if (loader) { loader.OnValueChanged(this, value); + } Settings.Instance.SaveSettings(); } diff --git a/Assets/Scripts/UI/Menu/PlayerListHandler.cs b/Assets/Scripts/UI/Menu/PlayerListHandler.cs index 1da7ef90b5..6a24a7a338 100644 --- a/Assets/Scripts/UI/Menu/PlayerListHandler.cs +++ b/Assets/Scripts/UI/Menu/PlayerListHandler.cs @@ -109,7 +109,11 @@ public void UpdatePlayerEntry(PlayerRef player, bool updateChat = true) { } public void ReorderEntries() { - foreach (PlayerRef player in Runner.ActivePlayers.OrderByDescending(pr => pr.GetPlayerData(NetworkHandler.Runner).JoinTick)) { + var playerList = Runner.ActivePlayers + .Where(pr => pr.GetPlayerData(NetworkHandler.Runner)) + .OrderByDescending(pr => pr.GetPlayerData(NetworkHandler.Runner).JoinTick); + + foreach (PlayerRef player in playerList) { if (!playerListEntries.ContainsKey(player)) { continue; diff --git a/Assets/Scripts/UI/Scoreboard/ScoreboardUpdater.cs b/Assets/Scripts/UI/Scoreboard/ScoreboardUpdater.cs index bc99782ddb..a22b96baaf 100644 --- a/Assets/Scripts/UI/Scoreboard/ScoreboardUpdater.cs +++ b/Assets/Scripts/UI/Scoreboard/ScoreboardUpdater.cs @@ -52,11 +52,13 @@ public void UpdateSpectatorCount() { int count = 0; foreach (var player in NetworkHandler.Runner.ActivePlayers) { PlayerData data = player.GetPlayerData(NetworkHandler.Runner); - if (!data) + if (!data) { continue; + } - if (data.IsCurrentlySpectating) + if (data.IsCurrentlySpectating) { count++; + } } spectatorText.text = (count == 0) ? "" : ""; } @@ -84,16 +86,18 @@ private void PlayAnimation(bool enabled) { } public void OnDeathToggle() { - if (manuallyToggled) + if (manuallyToggled) { return; + } PlayAnimation(true); autoToggled = true; } public void OnRespawnToggle() { - if (manuallyToggled) + if (manuallyToggled) { return; + } PlayAnimation(false); autoToggled = false; @@ -109,7 +113,10 @@ public void RepositionEntries() { public void CreateEntries() { NetworkRunner runner = NetworkHandler.Runner; - List actualPlayers = runner.ActivePlayers.Select(pr => pr.GetPlayerData(runner)).Where(pd => !pd.IsCurrentlySpectating).ToList(); + List actualPlayers = runner.ActivePlayers + .Select(pr => pr.GetPlayerData(runner)) + .Where(pd => pd && !pd.IsCurrentlySpectating) + .ToList(); foreach (PlayerData player in actualPlayers) { @@ -139,8 +146,9 @@ private void OnAllPlayersLoaded() { CreateEntries(); UpdateSpectatorCount(); - if (Settings.Instance.generalScoreboardAlways) + if (Settings.Instance.generalScoreboardAlways) { SetEnabled(); + } } private void OnPlayerListChanged(NetworkRunner runner, PlayerRef player) { diff --git a/Assets/Scripts/Utils/Extensions/UnityExtensions.cs b/Assets/Scripts/Utils/Extensions/UnityExtensions.cs index 7f9f6bdd64..b6a5fd7c8b 100644 --- a/Assets/Scripts/Utils/Extensions/UnityExtensions.cs +++ b/Assets/Scripts/Utils/Extensions/UnityExtensions.cs @@ -5,20 +5,20 @@ namespace NSMB.Extensions { public static class UnityExtensions { - private static readonly Vector3[] corners = new Vector3[4]; + private static readonly Vector3[] CornerBuffer = new Vector3[4]; public static Bounds TransformBoundsTo(this RectTransform source, Transform target) { // Based on code in ScrollRect's internal GetBounds and InternalGetBounds methods var bounds = new Bounds(); if (source != null) { - source.GetWorldCorners(corners); + source.GetWorldCorners(CornerBuffer); var vMin = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); var vMax = new Vector3(float.MinValue, float.MinValue, float.MinValue); var matrix = target.worldToLocalMatrix; for (int j = 0; j < 4; j++) { - Vector3 v = matrix.MultiplyPoint3x4(corners[j]); + Vector3 v = matrix.MultiplyPoint3x4(CornerBuffer[j]); vMin = Vector3.Min(v, vMin); vMax = Vector3.Max(v, vMax); } @@ -51,15 +51,16 @@ public static float ScrollToCenter(this ScrollRect scrollRect, RectTransform tar var elementBounds = target.TransformBoundsTo(view); var offset = viewRect.center.y - elementBounds.center.y; - if (onlyOffscreen && (elementBounds.center.y + elementBounds.extents.y) < 0 && (elementBounds.center.y - elementBounds.extents.y) > -viewRect.height) + if (onlyOffscreen && (elementBounds.center.y + elementBounds.extents.y) < 0 && (elementBounds.center.y - elementBounds.extents.y) > -viewRect.height) { return scrollRect.verticalNormalizedPosition; + } // Normalize and apply the calculated offset var scrollPos = scrollRect.verticalNormalizedPosition - scrollRect.NormalizeScrollDistance(1, offset); return Mathf.Clamp(scrollPos, 0f, 1f); } - //Missing multiply and divide operators for vector3 + // Missing component-wise multiply and divide operators for vector3 public static Vector3 Multiply(this Vector3 a, Vector3 b) { return new(a.x * b.x, a.y * b.y, a.z * b.z); } @@ -101,13 +102,31 @@ public static bool ContainsLayer(this LayerMask mask, string layerName) { } public static void SetLossyScale(this Transform transform, Vector3 lossyScale) { - if (transform.parent) + if (transform.parent) { lossyScale = lossyScale.Divide(transform.parent.lossyScale); + } - if (lossyScale.z == 0 || !float.IsFinite(lossyScale.z)) + if (lossyScale.z == 0 || !float.IsFinite(lossyScale.z)) { lossyScale.z = 1; + } transform.localScale = lossyScale; } + + public static void SetIfNull(this Component component, ref T var, GetComponentType children = GetComponentType.Self) where T : Component { + if (component && !var) { + var = children switch { + GetComponentType.Children => component.GetComponentInChildren(), + GetComponentType.Parent => component.GetComponentInParent(), + _ => component.GetComponent(), + }; + } + } + + public enum GetComponentType { + Self, + Parent, + Children + } } } diff --git a/Assets/Scripts/Utils/Utils.cs b/Assets/Scripts/Utils/Utils.cs index 647ac0a886..5b403aaa18 100644 --- a/Assets/Scripts/Utils/Utils.cs +++ b/Assets/Scripts/Utils/Utils.cs @@ -543,9 +543,13 @@ public static Color GetPlayerColor(NetworkRunner runner, PlayerData player, floa // Then id based color int result = -1; int count = 0; - foreach (PlayerRef pl in runner.ActivePlayers.OrderBy(pr => pr.GetPlayerData(runner).JoinTick)) { + var players = runner.ActivePlayers + .Select(pr => pr.GetPlayerData(runner)) + .Where(pd => pd) + .OrderBy(pd => pd.JoinTick); + + foreach (PlayerData playerData in players) { // Skip spectators in color calculations - PlayerData playerData = pl.GetPlayerData(runner); if (playerData.IsManualSpectator || playerData.IsCurrentlySpectating) { continue; }