From 8889df545bcacac040fc9b35a3ac0b7d2fa639fa Mon Sep 17 00:00:00 2001 From: Dolly Date: Thu, 26 Oct 2023 21:07:47 +0900 Subject: [PATCH] Update to 10.26b --- .gitignore | 1 - .../ScriptComponents/ModAbilityButton.cs | 46 +++++++++++++++++- .../Modules/ScriptComponents/Timer.cs | 16 ++++++ NebulaPluginNova/Nebula.cs | 4 +- .../Addons/DefaultLanguage/addon.meta | 6 +++ NebulaPluginNova/Resources/Lang.dat | 1 + .../Resources/MouseActionIcon.png | Bin 0 -> 1582 bytes NebulaPluginNova/Roles/Crewmate/Phosphorus.cs | 5 +- NebulaPluginNova/Roles/Impostor/Raider.cs | 1 + NebulaPluginNova/Roles/Impostor/Sniper.cs | 1 + NebulaPluginNova/Roles/Neutral/Paparazzo.cs | 10 ++++ 11 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 NebulaPluginNova/Resources/Addons/DefaultLanguage/addon.meta create mode 100644 NebulaPluginNova/Resources/MouseActionIcon.png diff --git a/.gitignore b/.gitignore index 80ae215d..b952eead 100644 --- a/.gitignore +++ b/.gitignore @@ -76,7 +76,6 @@ StyleCopReport.xml *_p.c *_h.h *.ilk -*.meta *.obj *.iobj *.pch diff --git a/NebulaPluginNova/Modules/ScriptComponents/ModAbilityButton.cs b/NebulaPluginNova/Modules/ScriptComponents/ModAbilityButton.cs index 4fbacc43..b069650f 100644 --- a/NebulaPluginNova/Modules/ScriptComponents/ModAbilityButton.cs +++ b/NebulaPluginNova/Modules/ScriptComponents/ModAbilityButton.cs @@ -1,4 +1,6 @@ using AmongUs.GameOptions; +using Epic.OnlineServices.Lobby; +using UnityEngine; namespace Nebula.Modules.ScriptComponents; @@ -56,6 +58,16 @@ public override void OnReleased() if (VanillaButton) UnityEngine.Object.Destroy(VanillaButton.gameObject); } + private bool CheckMouseClick() + { + if (Input.GetKeyDown(KeyCode.Mouse0)) + { + var dis = (Vector2)Input.mousePosition - new Vector2(Screen.width, Screen.height) * 0.5f; + return dis.magnitude < 280f; + } + return false; + } + public override void Update() { //表示・非表示切替 @@ -77,8 +89,9 @@ public override void Update() VanillaButton.cooldownTimerText.text = timerText; VanillaButton.cooldownTimerText.color = EffectActive ? Color.green : Color.white; - if (keyCode?.KeyDownInGame ?? false) DoClick(); + if ((keyCode?.KeyDownInGame ?? false) || (canUseByMouseClick && CheckMouseClick())) DoClick(); if (subKeyCode?.KeyDownInGame ?? false) DoSubClick(); + } public override void OnMeetingStart() @@ -224,6 +237,14 @@ public ModAbilityButton SubKeyBind(VirtualInput keyCode) return this; } + + private bool canUseByMouseClick = false; + public ModAbilityButton SetCanUseByMouseClick(bool onlyLook = false) + { + if(!onlyLook)canUseByMouseClick = true; + ButtonEffect.SetMouseActionIcon(VanillaButton.gameObject, true); + return this; + } } public static class ButtonEffect @@ -322,6 +343,8 @@ static public SpriteRenderer AddOverlay(this ActionButton button, Sprite sprite, static ISpriteLoader keyBindBackgroundSprite = SpriteLoader.FromResource("Nebula.Resources.KeyBindBackground.png", 100f); + static ISpriteLoader mouseActionSprite = SpriteLoader.FromResource("Nebula.Resources.MouseActionIcon.png", 100f); + static public GameObject? AddKeyGuide(GameObject button, KeyCode key, Vector2 pos,bool removeExistingGuide) { if(removeExistingGuide)button.gameObject.ForEachChild((Il2CppSystem.Action)(obj => { if (obj.name == "HotKeyGuide") GameObject.Destroy(obj); })); @@ -362,4 +385,25 @@ static public SpriteRenderer AddOverlay(this ActionButton button, Sprite sprite, { return AddKeyGuide(button, key, new Vector2(0.28f, 0.28f), true); } + + static public GameObject? SetMouseActionIcon(GameObject button,bool show) + { + if (!show) + { + button.gameObject.ForEachChild((Il2CppSystem.Action)(obj => { if (obj.name == "MouseAction") GameObject.Destroy(obj); })); + return null; + } + else + { + GameObject obj = new GameObject(); + obj.name = "MouseAction"; + obj.transform.SetParent(button.transform); + obj.layer = button.layer; + SpriteRenderer renderer = obj.AddComponent(); + renderer.transform.localPosition = new Vector3(0.48f, -0.29f) + new Vector3(0f, 0f, -10f); + renderer.sprite = mouseActionSprite.GetSprite(); + return obj; + } + + } } \ No newline at end of file diff --git a/NebulaPluginNova/Modules/ScriptComponents/Timer.cs b/NebulaPluginNova/Modules/ScriptComponents/Timer.cs index 0cb615a0..f6dadbca 100644 --- a/NebulaPluginNova/Modules/ScriptComponents/Timer.cs +++ b/NebulaPluginNova/Modules/ScriptComponents/Timer.cs @@ -6,6 +6,19 @@ namespace Nebula.Modules.ScriptComponents; + +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.IsKillTimerEnabled), MethodType.Getter)] +class PlayerIsKillTimerEnabledPatch +{ + public static void Postfix(PlayerControl __instance, ref bool __result) + { + if(Minigame.Instance && Minigame.Instance.TryCast()) + { + __result = false; + } + } +} + public class Timer : INebulaScriptComponent { private Func? predicate = null; @@ -102,8 +115,11 @@ public Timer SetAsAbilityCoolDown() return SetPredicate(() => { if (PlayerControl.LocalPlayer.CanMove) return true; + if (PlayerControl.LocalPlayer.inMovingPlat || PlayerControl.LocalPlayer.onLadder) return true; + if (Minigame.Instance && ((bool)Minigame.Instance.MyNormTask + || Minigame.Instance.TryCast() != null || Minigame.Instance.TryCast() != null || Minigame.Instance.TryCast() != null || Minigame.Instance.TryCast() != null diff --git a/NebulaPluginNova/Nebula.cs b/NebulaPluginNova/Nebula.cs index f1900926..5b3514c0 100644 --- a/NebulaPluginNova/Nebula.cs +++ b/NebulaPluginNova/Nebula.cs @@ -60,10 +60,10 @@ public class NebulaPlugin : BasePlugin public const bool IsSnapshot = false; //public const string VisualVersion = "v2.0"; - public const string VisualVersion = "Snapshot 23.10.26a"; + public const string VisualVersion = "Snapshot 23.10.26b"; public const int PluginEpoch = 101; - public const int PluginBuildNum = 1029; + public const int PluginBuildNum = 1030; static public HttpClient HttpClient { diff --git a/NebulaPluginNova/Resources/Addons/DefaultLanguage/addon.meta b/NebulaPluginNova/Resources/Addons/DefaultLanguage/addon.meta new file mode 100644 index 00000000..9fd92087 --- /dev/null +++ b/NebulaPluginNova/Resources/Addons/DefaultLanguage/addon.meta @@ -0,0 +1,6 @@ +{ + "Name" : "Default Language Pack", + "Author" : "Dolly", + "Description" : "It is Built-in Addon that supports localization.", + "Version" : "" +} \ No newline at end of file diff --git a/NebulaPluginNova/Resources/Lang.dat b/NebulaPluginNova/Resources/Lang.dat index 7fdd4ef3..0e074717 100644 --- a/NebulaPluginNova/Resources/Lang.dat +++ b/NebulaPluginNova/Resources/Lang.dat @@ -272,6 +272,7 @@ "options.role.phosphorus.placeCoolDown" : "Place Cool Down" "options.role.phosphorus.lampCoolDown" : "Lamp Cool Down" "options.role.phosphorus.lampDuration" : "Lamp Duration" +"options.role.phosphorus.lampStrength" : "Lamp Strength" "role.provocateur.name" : "Provocateur" "role.provocateur.short" : "P" diff --git a/NebulaPluginNova/Resources/MouseActionIcon.png b/NebulaPluginNova/Resources/MouseActionIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..1ddae76e6f6e16a8f1a246f980b0eb3d8b0a4a4b GIT binary patch literal 1582 zcmV+}2GRM6P)m?u;H70Q_2gjHig&M3h zO;ePJHi}eLp+qz(?Jfxhd?&IK`Sff6qqM&Xs5eZwb5#+a7it#>U+PG)_vs&%4ek(`3WOhiLn3 zyC2vVtBI_h6;LXq1s+rErllIM=i0>^s)XBHlI;2M56TAF{r~`xXcgNZ-v!_UzC2d~ z7jPX{>4s0aWp&~6!V_C2=soiRXM4|FJ8#=l$B}3it!?cFA`ixDBJCA`fuXckigBQr zN*kydwH>=bSk^Ge-lu;!b;@p8&vS79Z`kzU1Ef+(T3XxK^Rs6~DU|@$R~RJX)v-jp`dDjoR8sFKk+W26 z?;kN_*{zLo=%v3%bJJ3(tBpz`RxLXoe^lP;>XNRW9_d`OO2=v<{qfppOId<}p>z^> zc_3-%!QsjXlQ|flfOP62k8E5|YBAvy!_`wi+~6)I0cxNVv{lh@rIl0`SeXoX=`7}>drf_oiUtN;uQrH=wHymsUj8NYn_x&Q#v zG|So-`p*j}P-a=z~zxyfw7DHPIxGb>8^;C6DW&=VHCFs6JV9nGgNO_Orw4}8+N|`wqVa6*QaI#)zgR4`ojCrFL_U|NsrgoA zlzyGL$qB|r(})PJ)^vBhs}COdtsWe>Ai#5mVf<-4n{(y_lpq(wA%C}0YH3gRyNgcz z>z~Rg6jVMx$)!sv$z(>=$jBv*zWz6P=BeGJl0zCe4eT}yQC$p~XrYjMzw!B_% zvliK|wO*@TH){I>M59%zrlyA8GaukMMT$ko1^R*S8HVxvU~)7Mb1WTafhZAKsI~3@ z?g83?I { if (focus) { action.Invoke(); GameObject.Destroy(button); } }); + } + public void Update() { if (focus) @@ -285,6 +291,7 @@ public override bool CheckWins(CustomEndCondition endCondition, ref ulong extraW return null; } }; + public override void OnActivated() { NebulaGameManager.Instance?.CriteriaManager.AddCriteria(PaparazzoCriteria); @@ -308,6 +315,7 @@ public override void OnActivated() shotButton.CoolDownTimer = Bind(new Timer(0f, MyRole.ShotCoolDownOption.GetFloat()).SetAsAbilityCoolDown().Start()); shotButton.SetLabelType(ModAbilityButton.LabelType.Standard); shotButton.SetLabel("shot"); + shotButton.SetCanUseByMouseClick(true); } } @@ -323,6 +331,8 @@ public override void LocalUpdate() var pos = MyPlayer.MyControl.transform.localPosition; pos.z = -10f; shot.transform.localPosition = pos; + + shot.SetUpButton(() => shotButton.DoClick()); } if (MyFinder != null && (MeetingHud.Instance || ExileController.Instance || MyPlayer.IsDead))