mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Initial commit
This commit is contained in:
1 parent
1f3e21ce19
commit
bc188191de
15 files changed
+227
-86
No files matched your search
@@ -0,0 +1,27 @@
|
||||
using MiraAPI.Example.Extension.GameOver;
|
||||
using MiraAPI.Example.Extension.Roles;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Extension.Buttons;
|
||||
|
||||
public class NeutralKillerButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Win Game";
|
||||
|
||||
public override float Cooldown => 0f;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
CustomGameOver.Trigger<NeutralKillerGameOver>([PlayerControl.LocalPlayer.Data]);
|
||||
}
|
||||
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return role is NeutralKillerRole;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using BepInEx;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
using Reactor;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.Attributes;
|
||||
|
||||
namespace MiraAPI.Example.Extension;
|
||||
|
||||
[BepInAutoPlugin("mira.example.extension", "MiraExampleExtensionMod")]
|
||||
[BepInProcess("Among Us.exe")]
|
||||
[BepInDependency(ReactorPlugin.Id)]
|
||||
[BepInDependency(MiraApiPlugin.Id)]
|
||||
[BepInDependency(ExamplePlugin.Id)]
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
public partial class ExampleExtensionPlugin : BasePlugin, IMiraExtension
|
||||
{
|
||||
public Harmony Harmony { get; } = new(Id);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
Harmony.PatchAll();
|
||||
}
|
||||
|
||||
public Type GetBasePluginType()
|
||||
{
|
||||
return typeof(ExamplePlugin);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using MiraAPI.Example.Extension.Roles;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Extension.GameOver;
|
||||
|
||||
public class NeutralKillerGameOver : CustomGameOver
|
||||
{
|
||||
public override bool VerifyCondition(PlayerControl playerControl, NetworkedPlayerInfo[] winners)
|
||||
{
|
||||
return winners is [{ Role: NeutralKillerRole }];
|
||||
}
|
||||
|
||||
public override void AfterEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
endGameManager.WinText.text = "Outcast Killer Wins!";
|
||||
endGameManager.WinText.color = Color.magenta;
|
||||
endGameManager.BackgroundBar.material.SetColor(ShaderID.Color, Color.magenta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0</Version>
|
||||
<Description>Example extension for Mira API</Description>
|
||||
<Authors>Angxl, XtraCube</Authors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MiraAPI\MiraAPI.csproj" />
|
||||
<ProjectReference Include="..\MiraAPI.Example\MiraAPI.Example.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\AmongUs.props" />
|
||||
</Project>
|
||||
@@ -0,0 +1,16 @@
|
||||
using MiraAPI.Example.Extension.Options;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
|
||||
namespace MiraAPI.Example.Extension.Modifiers;
|
||||
|
||||
public class ExtensionModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "Extension Modifier";
|
||||
|
||||
public override string GetDescription() => "This is from the extension mod!";
|
||||
|
||||
public override int GetAssignmentChance() => (int)OptionGroupSingleton<ExtensionModifierOptions>.Instance.ModifierChance;
|
||||
|
||||
public override int GetAmountPerGame() => (int)OptionGroupSingleton<ExtensionModifierOptions>.Instance.ModifierLimit;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
|
||||
namespace MiraAPI.Example.Extension.Options;
|
||||
|
||||
public class ExtendedFreezerOptions : AbstractOptionGroup<FreezerRole>
|
||||
{
|
||||
public override string GroupName => "Extended Freezer Role Options";
|
||||
|
||||
[ModdedNumberOption("Freeze Uses", 1, 5)]
|
||||
public float FreezeUses { get; set; } = 1;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using MiraAPI.Example.Extension.Modifiers;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.GameOptions.Attributes;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.Example.Extension.Options;
|
||||
|
||||
public class ExtensionModifierOptions : AbstractOptionGroup<ExtensionModifier>
|
||||
{
|
||||
public override string GroupName => "Extension Modifier Options";
|
||||
|
||||
[ModdedNumberOption("Modifier Chance", 0, 100, 10, MiraNumberSuffixes.Percent)]
|
||||
public float ModifierChance { get; set; } = 100f;
|
||||
|
||||
[ModdedNumberOption("Modifier Limit", 0, 10)]
|
||||
public float ModifierLimit { get; set; } = 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Example.Buttons.Freezer;
|
||||
using MiraAPI.Example.Extension.Options;
|
||||
using MiraAPI.GameOptions;
|
||||
|
||||
namespace MiraAPI.Example.Extension.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(FreezeButton), nameof(FreezeButton.MaxUses), MethodType.Getter)]
|
||||
public static class FreezeButtonPatch
|
||||
{
|
||||
public static void Postfix(ref int __result)
|
||||
{
|
||||
__result = (int)OptionGroupSingleton<ExtendedFreezerOptions>.Instance.FreezeUses;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using MiraAPI.Example.Extension.GameOver;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Roles;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Extension.Roles;
|
||||
|
||||
public class NeutralKillerRole : ImpostorRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Outcast Killer";
|
||||
|
||||
public string RoleDescription => "Outcast who can kill.";
|
||||
|
||||
public string RoleLongDescription => this.RoleDescription;
|
||||
|
||||
public Color RoleColor => Color.magenta;
|
||||
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Custom;
|
||||
|
||||
public CustomRoleConfiguration Configuration => new(this)
|
||||
{
|
||||
UseVanillaKillButton = true,
|
||||
CanGetKilled = true,
|
||||
CanUseVent = true,
|
||||
};
|
||||
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
||||
|
||||
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
|
||||
Color.gray,
|
||||
"OUTCAST",
|
||||
"You are an Outcast. You do not have a team.");
|
||||
|
||||
public override void SpawnTaskHeader(PlayerControl playerControl)
|
||||
{
|
||||
// remove existing task header.
|
||||
}
|
||||
|
||||
public override bool DidWin(GameOverReason gameOverReason)
|
||||
{
|
||||
return gameOverReason == CustomGameOver.GameOverReason<NeutralKillerGameOver>();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user