Skip to content

Commit

Permalink
Update to 10.26b
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolly committed Oct 26, 2023
1 parent 7e5910e commit 8889df5
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ StyleCopReport.xml
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
Expand Down
46 changes: 45 additions & 1 deletion NebulaPluginNova/Modules/ScriptComponents/ModAbilityButton.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AmongUs.GameOptions;
using Epic.OnlineServices.Lobby;
using UnityEngine;

namespace Nebula.Modules.ScriptComponents;

Expand Down Expand Up @@ -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()
{
//表示・非表示切替
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<GameObject>)(obj => { if (obj.name == "HotKeyGuide") GameObject.Destroy(obj); }));
Expand Down Expand Up @@ -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<GameObject>)(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<SpriteRenderer>();
renderer.transform.localPosition = new Vector3(0.48f, -0.29f) + new Vector3(0f, 0f, -10f);
renderer.sprite = mouseActionSprite.GetSprite();
return obj;
}

}
}
16 changes: 16 additions & 0 deletions NebulaPluginNova/Modules/ScriptComponents/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SwitchMinigame>())
{
__result = false;
}
}
}

public class Timer : INebulaScriptComponent
{
private Func<bool>? predicate = null;
Expand Down Expand Up @@ -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<SwitchMinigame>() != null
|| Minigame.Instance.TryCast<IDoorMinigame>() != null
|| Minigame.Instance.TryCast<VitalsMinigame>() != null
|| Minigame.Instance.TryCast<MultistageMinigame>() != null
Expand Down
4 changes: 2 additions & 2 deletions NebulaPluginNova/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 6 additions & 0 deletions NebulaPluginNova/Resources/Addons/DefaultLanguage/addon.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Name" : "Default Language Pack",
"Author" : "Dolly",
"Description" : "It is Built-in Addon that supports localization.",
"Version" : ""
}
1 change: 1 addition & 0 deletions NebulaPluginNova/Resources/Lang.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Binary file added NebulaPluginNova/Resources/MouseActionIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion NebulaPluginNova/Roles/Crewmate/Phosphorus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class Phosphorus : ConfigurableStandardRole
private NebulaConfiguration PlaceCoolDownOption = null!;
private NebulaConfiguration LampCoolDownOption = null!;
private NebulaConfiguration LampDurationOption = null!;

private NebulaConfiguration LampStrengthOption = null!;

protected override void LoadOptions()
{
base.LoadOptions();
Expand All @@ -34,6 +35,7 @@ protected override void LoadOptions()
PlaceCoolDownOption = new NebulaConfiguration(RoleConfig, "placeCoolDown", null, 5f, 60f, 5f, 15f, 15f) { Decorator = NebulaConfiguration.SecDecorator };
LampCoolDownOption = new NebulaConfiguration(RoleConfig, "lampCoolDown", null, 5f, 60f, 5f, 30f, 30f) { Decorator = NebulaConfiguration.SecDecorator };
LampDurationOption = new NebulaConfiguration(RoleConfig, "lampDuration", null, 7.5f, 30f, 2.5f, 15f, 15f) { Decorator = NebulaConfiguration.SecDecorator };
LampStrengthOption = new NebulaConfiguration(RoleConfig, "lampStrength", null, 0.25f, 5f, 0.25f, 1f, 1f) { Decorator = NebulaConfiguration.OddsDecorator };
}

private static IDividedSpriteLoader lanternSprite = XOnlyDividedSpriteLoader.FromResource("Nebula.Resources.Lantern.png", 100f, 4);
Expand Down Expand Up @@ -146,6 +148,7 @@ public override void OnMeetingStart()
if (lantern != null)
{
SpriteRenderer lightRenderer = AmongUsUtil.GenerateCustomLight(lantern.Position);
lightRenderer.transform.localScale *= MyRole.LampStrengthOption.GetFloat();
IEnumerator CoLight()
{
Expand Down
1 change: 1 addition & 0 deletions NebulaPluginNova/Roles/Impostor/Raider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public override void OnActivated()
killButton.CoolDownTimer = Bind(new Timer(MyRole.ThrowCoolDownOption.KillCoolDown).SetAsKillCoolDown().Start());
killButton.SetLabelType(ModAbilityButton.LabelType.Standard);
killButton.SetLabel("throw");
killButton.SetCanUseByMouseClick();
}
}

Expand Down
1 change: 1 addition & 0 deletions NebulaPluginNova/Roles/Impostor/Sniper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public override void OnActivated()
killButton.CoolDownTimer = Bind(new Timer(MyRole.SnipeCoolDownOption.KillCoolDown).SetAsKillCoolDown().Start());
killButton.SetLabelType(ModAbilityButton.LabelType.Standard);
killButton.SetLabel("snipe");
killButton.SetCanUseByMouseClick();
}
}

Expand Down
10 changes: 10 additions & 0 deletions NebulaPluginNova/Roles/Neutral/Paparazzo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public void Awake()
focus = true;
}

public void SetUpButton(Action action)
{
var button = gameObject.SetUpButton();
button.OnClick.AddListener(() => { if (focus) { action.Invoke(); GameObject.Destroy(button); } });
}

public void Update()
{
if (focus)
Expand Down Expand Up @@ -285,6 +291,7 @@ public override bool CheckWins(CustomEndCondition endCondition, ref ulong extraW
return null;
}
};

public override void OnActivated()
{
NebulaGameManager.Instance?.CriteriaManager.AddCriteria(PaparazzoCriteria);
Expand All @@ -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);
}

}
Expand All @@ -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))
Expand Down

0 comments on commit 8889df5

Please sign in to comment.