Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ContentAPI/API/Components/CustomKeybind.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ContentAPI.API.Monobehavior
namespace ContentAPI.API.Components
{
using System.Linq;
using UnityEngine;
Expand Down
3 changes: 2 additions & 1 deletion ContentAPI/API/Features/Modal.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace ContentAPI.API.Features
{
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Modal wrapper base class.
Expand Down Expand Up @@ -29,7 +30,7 @@ public void Show()
{
if (Options.Count == 0)
{
ContentPlugin.Log.LogInfo("No options present going in safe mode.");
Debug.Log("No options present going in safe mode.");
global::Modal.ShowError(Title, Body);
return;
}
Expand Down
12 changes: 12 additions & 0 deletions ContentAPI/ContentBepinLoad.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace ContentAPI
{
using BepInEx;

using static ContentPlugin;

/// <summary>
/// Handles loading the API through BepInEx.
/// </summary>
[BepInPlugin(ContentGuid, ContentName, ContentVersion)]
public class ContentBepinLoad : BaseUnityPlugin;
}
61 changes: 19 additions & 42 deletions ContentAPI/ContentPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,72 +1,49 @@
namespace ContentAPI
{
using BepInEx;
using BepInEx.Logging;
using ContentAPI.API.Monobehavior;
using HarmonyLib;
using ContentAPI.API.Components;
using UnityEngine;
using UnityEngine.SceneManagement;

/// <summary>
/// Base class handling loading the plugin.
/// </summary>
[BepInPlugin(ContentGuid, ContentName, ContentVersion)]
[ContentWarningPlugin(ContentGuid, ContentVersion, ContentVanillaCompatible)]
public class ContentPlugin : BaseUnityPlugin
public static class ContentPlugin
{
/// <summary>
/// The guid of the ContentAPI.
/// </summary>
public const string ContentGuid = "Circus.ContentAPI";
private const string ContentName = "ContentAPI";
private const string ContentVersion = "0.0.3";
private const bool ContentVanillaCompatible = true;

static ContentPlugin()
{
new GameObject("ContentAPI").AddComponent<ContentPlugin>();
}

/// <summary>
/// Gets the instance of the plugin.
/// Gets the name to be used.
/// </summary>
public static ContentPlugin Instance { get; private set; }
public const string ContentName = "ContentAPI";

/// <summary>
/// Gets the plugin Logger.
/// Gets the version of the API.
/// </summary>
internal static ManualLogSource Log { get; private set; }
public const string ContentVersion = "0.0.3";

/// <summary>
/// Gets the Harmony.
/// Gets whether or not its compatible with vanilla.
/// </summary>
internal static Harmony Harmony { get; private set; }
public const bool ContentVanillaCompatible = true;

private void Awake()
static ContentPlugin()
{
if (Instance != null)
return;

Instance = this;
Log = Logger;
Harmony = new(ContentGuid);
Harmony.PatchAll();

new GameObject("ContentAPI_CustomKeybindings").AddComponent<CustomKeybind>();

Logger.LogInfo($"Plugin {ContentGuid}@{ContentVersion} is loaded!");
DontDestroyOnLoad(gameObject);
CreateObjects();
}

private void Update()
/// <summary>
/// Gets the <see cref="GameObject"/> used by the API.
/// </summary>
public static GameObject GameObject { get; private set; }

private static void CreateObjects()
{
if (Input.GetKeyDown(KeyCode.F2))
{
foreach (API.Features.Player player in API.Features.Player.List)
{
Log.LogInfo(player.SteamID.ToString());
}
}
GameObject = new("ContentAPI");
GameObject.AddComponent<CustomKeybind>();
Object.DontDestroyOnLoad(GameObject);
}
}
}
2 changes: 1 addition & 1 deletion ContentAPI/Example/InputShowcase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class InputShowcase : Input
/// <inheritdoc/>
public override void ProcessInput()
{
ContentPlugin.Log.LogInfo("YOOO! The player clicked Backspace.");
Debug.Log("YOOO! The player clicked Backspace.");
}
}
}
9 changes: 5 additions & 4 deletions ContentAPI/Example/ModalShowcase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace ContentAPI.Example
{
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Showcase how a modal works.
Expand Down Expand Up @@ -28,19 +29,19 @@ public ModalShowcase()
/// <inheritdoc/>
protected override void OnClosed()
{
ContentPlugin.Log.LogInfo("Cookie closed.");
Debug.Log("Cookie closed.");
base.OnClosed();
}

/// <inheritdoc/>
protected override void HandleButtonClick(int buttonNumber)
{
if (buttonNumber == 1)
ContentPlugin.Log.LogInfo("No cookie :(");
Debug.Log("No cookie :(");
else if (buttonNumber == 2)
ContentPlugin.Log.LogInfo("Cookie :)");
Debug.Log("Cookie :)");
else if (buttonNumber == 3)
ContentPlugin.Log.LogInfo("Wut bugged cookie??????");
Debug.Log("Wut bugged cookie??????");

base.HandleButtonClick(buttonNumber);
}
Expand Down