JilloSlug/src/story/Pebbles.cs

32 lines
1.2 KiB
C#

using System;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using SlugBase;
using SlugBase.Features;
using static SlugBase.Features.FeatureTypes;
namespace JilloSlug.Story;
internal static class Pebbles {
public static readonly PlayerFeature<string[]> PebblesLines = PlayerStrings("jillo/pebbles_lines");
public static void AddHooks() {
On.SSOracleBehavior.PebblesConversation.AddEvents += PebblesConversation_AddEvents;
}
private static void PebblesConversation_AddEvents(On.SSOracleBehavior.PebblesConversation.orig_AddEvents orig, SSOracleBehavior.PebblesConversation self) {
if (PebblesLines.TryGet(self.convBehav.player, out var lines)) {
foreach (string line in lines) {
if (line.StartsWith("!wait ")) {
int wait = int.Parse(line.Split(' ')[1]);
self.events.Add(new SSOracleBehavior.PebblesConversation.PauseAndWaitForStillEvent(self, self.convBehav, wait));
} else {
self.events.Add(new Conversation.TextEvent(self, 0, self.Translate(line), 0));
}
}
return;
}
orig(self);
}
}