-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
add dead pixel and detach seatruck segment try (in vain) to reduce ermfish fps impact
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections.Generic; | ||
using SCHIZO.Commands.Base; | ||
using SCHIZO.Commands.Context; | ||
using SCHIZO.Resources; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.SwarmControl.Redeems.Annoying; | ||
#nullable enable | ||
|
||
[Redeem( | ||
Name = "redeem_deadpixel", | ||
DisplayName = "Dead Pixel", | ||
Description = "The whole screen is your canvas... Lasts 5 minutes" | ||
)] | ||
internal class DeadPixelRedeem : Command, IParameters | ||
{ | ||
public static float Duration = 300f; | ||
public IReadOnlyList<Parameter> Parameters => []; | ||
|
||
protected override object? ExecuteCore(CommandExecutionContext ctx) | ||
{ | ||
Vector2 coords = new(Random.Range(0, 1920), Random.Range(0, 1080)); | ||
GameObject instance = GameObject.Instantiate(Assets.Mod_SwarmControl_DeadPixel); | ||
instance.EnsureComponent<DeadPixel>().duration = Duration; | ||
instance.transform.SetParent(uGUI.main.screenCanvas.transform, false); | ||
instance.transform.localPosition = new Vector2(coords.x-960, coords.y-540); | ||
return $"Your pixel is at {coords}"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using SCHIZO.Commands.Base; | ||
using SCHIZO.Commands.Context; | ||
using SCHIZO.Commands.Output; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.SwarmControl.Redeems.Annoying; | ||
|
||
#nullable enable | ||
[Redeem( | ||
Name = "redeem_detach", | ||
DisplayName = "Bad Glue", | ||
Description = "Whoever designed the Sea Truck module connector should be fired..." | ||
)] | ||
internal class DetachBackSeatruckModule : Command, IParameters | ||
{ | ||
public IReadOnlyList<Parameter> Parameters => []; | ||
|
||
protected override object? ExecuteCore(CommandExecutionContext ctx) | ||
{ | ||
if (!Player.main) return CommonResults.Error("Requires a loaded game."); | ||
|
||
SeaTruckUpgrades cabin = GameObject.FindObjectOfType<SeaTruckUpgrades>(); | ||
Check failure on line 23 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
Check failure on line 23 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
Check failure on line 23 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
|
||
if (!cabin) return CommonResults.Error("Sea Truck not found."); | ||
|
||
SeaTruckSegment cabinSegment = cabin.GetComponent<SeaTruckSegment>(); | ||
Check failure on line 26 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
Check failure on line 26 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
Check failure on line 26 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
|
||
SeaTruckSegment rearSegment = cabinSegment; | ||
Check failure on line 27 in SCHIZO/SwarmControl/Redeems/Annoying/DetachBackSeatruckModule.cs GitHub Actions / build (Subnautica)
|
||
while (rearSegment.rearConnection && rearSegment.rearConnection.connection) | ||
rearSegment = rearSegment.rearConnection.connection.truckSegment; | ||
|
||
if (rearSegment == cabinSegment) | ||
return CommonResults.Error("Sea Truck not connected to any modules."); | ||
|
||
rearSegment.Detach(); | ||
|
||
return CommonResults.OK(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,46 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using SCHIZO.Commands.Base; | ||
using SCHIZO.Commands.Context; | ||
using SCHIZO.Commands.Input; | ||
using SCHIZO.Commands.Output; | ||
using SCHIZO.Twitch; | ||
using SwarmControl.Models.Game.Messages; | ||
using UnityEngine; | ||
using UWE; | ||
|
||
namespace SCHIZO.SwarmControl.Redeems.PayAttentionToMeStreamer; | ||
|
||
#nullable enable | ||
[Redeem( | ||
Name = "redeem_addsignal", | ||
DisplayName = "Add Beacon", | ||
Description = "Adds a beacon ping to the map." | ||
DisplayName = "Add Signal", | ||
Description = "Adds a signal marker to the world. After redeeming, your next Twitch chat message will name the beacon." | ||
)] | ||
internal class AddSignalRedeem() : ProxyCommand<MethodCommand>("addsignal") | ||
internal class AddSignalRedeem : Command, IParameters | ||
{ | ||
public override IReadOnlyList<Parameter> Parameters { get; } = [ | ||
new Parameter(new("coords", "Coordinates", "Beacon coordinates"), typeof(Vector3), false), | ||
new Parameter(new("name", "Name", "Beacon name"), typeof(string), false) | ||
public IReadOnlyList<Parameter> Parameters { get; } = [ | ||
new Parameter(new("coords", "Coordinates", "Beacon coordinates"), typeof(Vector3), false) | ||
]; | ||
|
||
protected override Dictionary<string, object?>? GetTargetArgs(Dictionary<string, object?>? proxyArgs) | ||
protected override object? ExecuteCore(CommandExecutionContext ctx) | ||
{ | ||
if (proxyArgs is null) return []; | ||
|
||
NamedArgs args = new(proxyArgs); | ||
Dictionary<string, object?> targetArgs = []; | ||
if (!args.TryGetValue("coords", out Vector3 coords) || !args.TryGetValue("name", out string? name)) | ||
return targetArgs; | ||
RedeemMessage? model = (ctx.Input as RemoteInput)?.Model; | ||
TwitchUser? user = model?.User; | ||
if (user is null) | ||
return CommonResults.Error("Could not get user"); | ||
if (!ctx.Input.GetNamedArguments().TryGetValue("coords", out Vector3 coords)) | ||
return CommonResults.Error("Invalid coordinates"); | ||
CoroutineHost.StartCoroutine(Coro(user, coords)); | ||
return "Success - the next message you send in Twitch chat will be used to name the beacon."; | ||
} | ||
|
||
return new() | ||
{ | ||
{ "x", coords.x }, | ||
{ "y", coords.y }, | ||
{ "z", coords.z }, | ||
{ "signalName", name } | ||
}; | ||
private IEnumerator Coro(TwitchUser user, Vector3 coords) | ||
{ | ||
string? message = null; | ||
TwitchIntegration.AddNextMessageCallback(user, (msg) => message = msg ?? "(unnamed)"); | ||
yield return new WaitUntil(() => message is { }); | ||
CustomSignalManager.AddSignal(coords.x, coords.y, coords.z, | ||
$"[{user.DisplayName}]\n{message}"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,42 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using SCHIZO.Commands; | ||
using SCHIZO.Commands.Base; | ||
using SCHIZO.Commands.Context; | ||
using SCHIZO.Commands.Input; | ||
using SwarmControl.Models.Game; | ||
using SCHIZO.Commands.Output; | ||
using SwarmControl.Models.Game.Messages; | ||
using UnityEngine; | ||
using UWE; | ||
|
||
namespace SCHIZO.SwarmControl.Redeems.PayAttentionToMeStreamer; | ||
|
||
#nullable enable | ||
[Redeem( | ||
Name = "redeem_hint", | ||
DisplayName = "Send Hint", | ||
Description = "Display a message in the center of the screen", | ||
DisplayName = "Send Message", | ||
Description = "Your next Twitch chat message will be displayed in-game", | ||
Announce = false // the message itself is the announcement | ||
)] | ||
internal class Hint() : ProxyCommand<MethodCommand>("hint") | ||
internal class Hint : Command, IParameters | ||
{ | ||
public override IReadOnlyList<Parameter> Parameters => [ | ||
new TextParameter(new NamedModel("message", "Message", "The message to display")) { | ||
MinLength = 1 | ||
} | ||
]; | ||
public IReadOnlyList<Parameter> Parameters => []; | ||
|
||
protected override JsonContext GetContextForTarget(JsonContext proxyCtx) | ||
protected override object? ExecuteCore(CommandExecutionContext ctx) | ||
{ | ||
RemoteInput input = proxyCtx.JsonInput; | ||
input.Model.Announce = false; | ||
string submitter = input.Model.GetDisplayName(); | ||
NamedArgs args = input.GetNamedArguments(); | ||
args.TryGetValue("message", out string? message); | ||
if (string.IsNullOrWhiteSpace(message)) | ||
message = "(no message)"; | ||
args["message"] = $"{submitter}: {message}"; | ||
return base.GetContextForTarget(proxyCtx); | ||
RedeemMessage? model = (ctx.Input as RemoteInput)?.Model; | ||
TwitchUser? user = model?.User; | ||
if (user is null) | ||
return CommonResults.Error("Could not get user"); | ||
CoroutineHost.StartCoroutine(Coro(user)); | ||
return "Success - the next message you send in Twitch chat will be displayed in-game."; | ||
} | ||
|
||
protected override Dictionary<string, object?> GetTargetArgs(Dictionary<string, object?>? proxyArgs) | ||
private IEnumerator Coro(TwitchUser user) | ||
{ | ||
if (proxyArgs is null) return []; | ||
|
||
return new Dictionary<string, object?> | ||
{ | ||
{ "message", proxyArgs["message"] } | ||
}; | ||
string? message = null; | ||
Twitch.TwitchIntegration.AddNextMessageCallback(user, (msg) => message = msg ?? "(no message)"); | ||
yield return new WaitUntil(() => message is { }); | ||
DevCommands.Hint($"{user.DisplayName}: {message}"); | ||
} | ||
} |