mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using MiraAPI.Example.Modifiers;
|
|
using MiraAPI.Hud;
|
|
using MiraAPI.Keybinds;
|
|
using MiraAPI.Modifiers;
|
|
using MiraAPI.Utilities.Assets;
|
|
using UnityEngine;
|
|
|
|
namespace MiraAPI.Example.Buttons;
|
|
|
|
public class MeetingButton : CustomActionButton
|
|
{
|
|
public override string Name => "button.callMeeting";
|
|
public override float Cooldown => 15;
|
|
public override int MaxUses => 3;
|
|
|
|
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
|
public override MiraKeybind? Keybind => MiraGlobalKeybinds.ModifierPrimaryAbility;
|
|
|
|
public override bool Enabled(RoleBehaviour? role)
|
|
{
|
|
return PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.HasModifier<CaptainModifier>();
|
|
}
|
|
|
|
protected override void OnClick()
|
|
{
|
|
var bt = ShipStatus.Instance.EmergencyButton;
|
|
|
|
PlayerControl.LocalPlayer.NetTransform.Halt();
|
|
var minigame = Object.Instantiate(bt.MinigamePrefab, Camera.main!.transform, false);
|
|
|
|
var taskAdderGame = minigame.TryCast<TaskAdderGame>();
|
|
if (taskAdderGame)
|
|
{
|
|
taskAdderGame!.SafePositionWorld = bt.SafePositionLocal + (Vector2)bt.transform.position;
|
|
}
|
|
|
|
minigame.transform.localPosition = new Vector3(0f, 0f, -50f);
|
|
minigame.Begin(null);
|
|
|
|
if (UsesLeft == 0 && PlayerControl.LocalPlayer.HasModifier<CaptainModifier>())
|
|
{
|
|
PlayerControl.LocalPlayer.RpcRemoveModifier<CaptainModifier>();
|
|
}
|
|
}
|
|
}
|