-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buff docs by 15% fix forced sends not sending when disabled update credits add (optional) auth for immersion to match swarm control export redeems to clipboard auto-destroy spawns from redeems
- Loading branch information
Showing
18 changed files
with
215 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Basic cruddy "send stuff to LLM" mod. | ||
|
||
### Setup | ||
|
||
Set up a web server at your chosen URL that will accept POST requests on the following endpoints: | ||
- `/mute` - mute/unmute (to reduce blabbering during cutscenes) | ||
- accepts `True` and `False` in POST body | ||
- `/priority` and `/non-priority` - send messages (general context/react stuff) | ||
- accepts the message as a raw string in POST body (e.g. `Something happened`, note no quotation marks) | ||
|
||
Then, go in game and run the following commands in the console (`SHIFT + Enter` to open): | ||
- `immersion set player Your Name` | ||
- `immersion set url http://yoururl:12345` | ||
- If your API uses auth, run `immersion set apikey yoursecretapikey` | ||
- `immersion set pronouns you/your` | ||
|
||
The default configuration is [defined here](./Globals.cs#L11). | ||
|
||
### Console commands | ||
Available console commands are: | ||
- `immersion set <option> <value>` - set config value | ||
- Available options are `player`, `url`, `apikey`, and `pronouns` | ||
- For `pronouns`, there are several [predefined sets of pronouns](./Formatting/PronounSet.cs#L27) | ||
- Otherwise, the command output will guide you to the correct formatting | ||
- `immersion trackers` - list available trackers | ||
- `immersion <enable|disable> [tracker...]` - toggle one or more trackers | ||
- If no trackers are specified (i.e. `immersion enable`) all trackers will be affected | ||
- For a list of available trackers, run `immersion trackers` | ||
- `immersion <prio|noprio>` - force low prio | ||
- While active, all high-priority messages will be routed to the `non-priority` endpoint. | ||
- `noprio` activates this effect and `prio` deactivates it. | ||
- `immersion <react|send> <message>` - manually send with high (for `react`) or low (for `send`) priority. | ||
- Affected by `noprio`. | ||
- `immersion <mute|unmute>` - manual mute/unmute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Items.Components; | ||
internal class DestroyAtTime : MonoBehaviour | ||
{ | ||
public float time = float.PositiveInfinity; | ||
private void Update() | ||
{ | ||
if (Time.time > time) | ||
Destroy(gameObject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using HarmonyLib; | ||
using SCHIZO.Helpers; | ||
using SCHIZO.Items.Components; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Patches; | ||
|
||
[HarmonyPatch] | ||
internal static class AutoDestroyManualSpawns | ||
{ | ||
private static readonly MethodInfo NotifyCraftEnd = AccessTools.Method(typeof(CrafterLogic), nameof(CrafterLogic.NotifyCraftEnd)); | ||
private static readonly MethodInfo UnityEngineDebugLogFormat = AccessTools.Method(typeof(Debug), nameof(Debug.LogFormat), [typeof(string), typeof(object[])]); | ||
|
||
[HarmonyTargetMethod] | ||
private static MethodBase TargetMethod() => AccessTools.EnumeratorMoveNext(AccessTools.Method(typeof(SpawnConsoleCommand), nameof(SpawnConsoleCommand.SpawnAsync))); | ||
|
||
[HarmonyTranspiler] | ||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) | ||
{ | ||
CodeMatcher matcher = new(instructions, generator); | ||
LocalBuilder lifetimeLocal = generator.DeclareLocal(typeof(float)); | ||
|
||
matcher.MatchForward(false, new CodeMatch(ci => ci.Calls(UnityEngineDebugLogFormat))); | ||
if (!matcher.IsValid) | ||
{ | ||
LOGGER.LogWarning("Could not patch SpawnConsoleCommand.SpawnAsync to auto destroy manual spawns (UnityEngine.Debug.LogFormat call not found)"); | ||
return instructions; | ||
} | ||
// i know it's kind of lazy to insert our instructions in the middle of a method call | ||
// unfortunately there's a loop right afterwards so the alternative is even less elegant | ||
//matcher.Advance(1); | ||
// get lifetime from args | ||
// float lifetime = GetLifetime(this); | ||
matcher.Insert( | ||
new(OpCodes.Ldarg_0), | ||
new(OpCodes.Call, AccessTools.Method(typeof(AutoDestroyManualSpawns), nameof(GetLifetime))), | ||
new(OpCodes.Stloc, lifetimeLocal) | ||
); | ||
|
||
// match: | ||
// CrafterLogic.NotifyCraftEnd(gameObject, this.<techType>5__2); | ||
matcher.MatchForward(false, | ||
new(OpCodes.Dup), | ||
new(OpCodes.Ldarg_0), | ||
new(OpCodes.Ldfld), | ||
new(ci => ci.Calls(NotifyCraftEnd)) | ||
); | ||
if (!matcher.IsValid) | ||
{ | ||
LOGGER.LogWarning("Could not patch SpawnConsoleCommand.SpawnAsync to auto destroy manual spawns (CrafterLogic.NotifyCraftEnd call not found)"); | ||
return instructions; | ||
} | ||
matcher.Insert( | ||
new(OpCodes.Dup), | ||
lifetimeLocal.LoadInstruction(), | ||
CodeInstruction.Call((GameObject go, float lifetime) => AddManualSpawnTag(go, lifetime)) | ||
); | ||
|
||
return matcher.InstructionEnumeration(); | ||
} | ||
|
||
private static void AddManualSpawnTag(GameObject obj, float lifetime) | ||
{ | ||
if (lifetime is <= 0 or float.PositiveInfinity) return; | ||
|
||
float dieAt = Time.time + lifetime; | ||
LOGGER.LogDebug($"{obj.name} ({obj.GetInstanceID()}) is fated to die in {lifetime}s (at {dieAt})"); | ||
DestroyAtTime destroy = obj.EnsureComponent<DestroyAtTime>(); | ||
destroy.time = dieAt; | ||
|
||
// prevent unload/load since it would remove our manually-added component | ||
Component.Destroy(obj.GetComponent<LargeWorldEntity>()); | ||
} | ||
|
||
private static float GetLifetime(object iEnumerator) | ||
{ | ||
Hashtable args = GetArgs(iEnumerator); | ||
if (args.Count >= 4 && float.TryParse((string) args[3], out float lifetime)) | ||
{ | ||
return lifetime; | ||
} | ||
return float.PositiveInfinity; | ||
} | ||
|
||
private static Hashtable GetArgs(object iEnumerator) | ||
{ | ||
NotificationCenter.Notification x = (NotificationCenter.Notification) AccessTools.Field(iEnumerator.GetType(), "n").GetValue(iEnumerator); | ||
return x.data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Game client portion of the [Swarm Control](https://github.com/VedalAI/swarm-control) Twitch extension. | ||
|
||
Intended for Below Zero, nothing is guaranteed to work in base Subnautica (it's low prio, PRs welcome) | ||
|
||
### Setup | ||
After setting up the [server](https://github.com/VedalAI/swarm-control), launch the game (with the mod) and do the following: | ||
- Open the console with `SHIFT + Enter` | ||
- Use the `sc_url` command to set the base URL for the server. e.g. `sc_url https://subnautica.example.com/` | ||
- Set the private API key with `sc_apikey` - e.g. `sc_apikey totallysecretkey` | ||
- Go into `Options` -> `Mods` and click `Connect Swarm Control` | ||
- After the game connects and you load a save, any redeems you have configured should become available! | ||
|
||
Running `sc_export` in the console will save the config json (without the `version` field) to your clipboard. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.