Decompiled source of CrowdControl CultOfTheLamb v1.4.0
BepInEx/plugins/ConnectorLib.JSON.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Warp World, Inc.")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("© 2026 Warp World, Inc.")] [assembly: AssemblyFileVersion("5.0.9785.29449")] [assembly: AssemblyInformationalVersion("5.0.9785.29449+90c600e1db2ff53dd548283d7fc60b5af3e3ec86")] [assembly: AssemblyProduct("ConnectorLib.JSON")] [assembly: AssemblyTitle("ConnectorLib.JSON")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("5.0.9785.29449")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class ParamCollectionAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] internal sealed class ScopedRefAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ConnectorLib.JSON { public class CamelCaseStringEnumConverter : JsonConverter<Enum> { public override void WriteJson(JsonWriter writer, Enum? value, JsonSerializer serializer) { if (value == null) { serializer.Serialize(writer, (object)null); } else { serializer.Serialize(writer, (object)value.ToCamelCase()); } } public override Enum ReadJson(JsonReader reader, Type objectType, Enum? existingValue, bool hasExistingValue, JsonSerializer serializer) { return ReadJToken(JToken.ReadFrom(reader), objectType); } public static Enum ReadJToken(JToken reader, Type objectType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 JTokenType type = reader.Type; if ((int)type != 6) { if ((int)type == 8) { string text = Extensions.Value<string>((IEnumerable<JToken>)reader); if (text == null) { throw new SerializationException("The value was null."); } if (Enum.TryParse(objectType, text, ignoreCase: true, out object result)) { return (Enum)result; } throw new SerializationException("The value was not recognized."); } throw new SerializationException("The value was not a string or number."); } int? num = Extensions.Value<int>((IEnumerable<JToken>)reader); if (!num.HasValue) { throw new SerializationException("The value was null."); } return (Enum)Enum.ToObject(objectType, num.Value); } } [Serializable] public class DataRequest : SimpleJSONRequest { public string key; public DataRequest(string key) { this.key = key; type = RequestType.DataRequest; } } [Serializable] public class DataResponse : SimpleJSONResponse { public string key; public JToken? value; public EffectStatus status; public long timeRemaining; public string? message; [JsonConstructor] public DataResponse(string key, EffectStatus status, object? value = null, long timeRemaining = 0L, string? message = null) { this.key = key; this.value = value.IfNotNull((Func<object, JToken?>)JToken.FromObject); this.status = status; this.timeRemaining = timeRemaining; this.message = message; type = ResponseType.DataResponse; } public static DataResponse SuccessIfDefined(string key, object? value, string failMessage = "") { if (value == null) { return Retry(key, 0L, failMessage); } if (value is string input && input.IsNullOrWhiteSpace()) { return Retry(key, 0L, failMessage); } return Success(key, value); } public static DataResponse Success(string key, object? value) { return new DataResponse(key, EffectStatus.Success, value, 0L); } public static DataResponse Success(string key, object? value, string? message) { return new DataResponse(key, EffectStatus.Success, value, 0L, message); } public static DataResponse Failure(string key) { return new DataResponse(key, EffectStatus.Failure, null, 0L); } public static DataResponse Failure(string key, string? message) { return new DataResponse(key, EffectStatus.Failure, null, 0L, message); } public static DataResponse Failure(string key, object? value, string? message = null) { return new DataResponse(key, EffectStatus.Failure, value, 0L, message); } public static DataResponse Retry(string key, long delay = 0L, string? message = null) { return new DataResponse(key, EffectStatus.Retry, null, delay, message); } } [Serializable] public class EffectRequest : SimpleJSONRequest { [Serializable] public class Target { public string? service; public string? id; public string? name; public string? avatar; } public string? code; public string? message; public JToken? parameters; public uint? quantity; public JArray? targets; public long? duration; public string? viewer; public JArray? viewers; public long? cost; public Dictionary<string, object?>? arguments; public Guid? requestID; [JsonConverter(typeof(IEffectSourceDetails.Converter))] public IEffectSourceDetails? sourceDetails; public EffectRequest() { type = RequestType.EffectStart; } } [Serializable] public class EffectResponse : SimpleJSONResponse { private class MetadataConverter : JsonConverter<Dictionary<string, DataResponse>?> { public override void WriteJson(JsonWriter writer, Dictionary<string, DataResponse>? value, JsonSerializer serializer) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown if (value == null) { serializer.Serialize(writer, (object)null); return; } JObject val = new JObject(); foreach (KeyValuePair<string, DataResponse> item in value) { JObject val2 = JObject.FromObject((object)item.Value); val2.Remove("key"); val[item.Key] = (JToken)(object)val2; } serializer.Serialize(writer, (object)val); } public override Dictionary<string, DataResponse>? ReadJson(JsonReader reader, Type objectType, Dictionary<string, DataResponse>? existingValue, bool hasExistingValue, JsonSerializer serializer) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown JObject val = (JObject)serializer.Deserialize(reader); if (val == null) { return null; } Dictionary<string, DataResponse> dictionary = new Dictionary<string, DataResponse>(); foreach (JProperty item in val.Properties()) { JObject val2 = (JObject)item.Value; val2["key"] = JToken.op_Implicit(item.Name); dictionary.Add(item.Name, ((JToken)val2).ToObject<DataResponse>()); } return dictionary; } } public EffectStatus status; public string? message; public StandardErrors messageID; public long timeRemaining; [JsonConverter(typeof(MetadataConverter))] public Dictionary<string, DataResponse>? metadata; public EffectResponse() { } public EffectResponse(uint id, EffectStatus status) : this(id, status, 0L) { } public EffectResponse(uint id, EffectStatus status, StandardErrors messageID, string? message = null) : this(id, status, 0L, messageID, message) { } public EffectResponse(uint id, EffectStatus status, string? message) : this(id, status, 0L, message) { } public EffectResponse(uint id, EffectStatus status, TimeSpan timeRemaining) : this(id, status, checked((long)timeRemaining.TotalMilliseconds)) { } public EffectResponse(uint id, EffectStatus status, TimeSpan timeRemaining, StandardErrors messageID) : this(id, status, checked((long)timeRemaining.TotalMilliseconds), messageID) { } public EffectResponse(uint id, EffectStatus status, TimeSpan timeRemaining, string? message) : this(id, status, checked((long)timeRemaining.TotalMilliseconds), message) { } public EffectResponse(uint id, EffectStatus status, long timeRemaining, string? message = null) { base.id = id; this.status = status; this.timeRemaining = timeRemaining; this.message = message; type = ResponseType.EffectRequest; } [JsonConstructor] public EffectResponse(uint id, EffectStatus status, long timeRemaining, StandardErrors messageID, string? message = null) { base.id = id; this.status = status; this.timeRemaining = timeRemaining; this.messageID = messageID; this.message = message; type = ResponseType.EffectRequest; } public static EffectResponse Success(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Success, message); } public static EffectResponse Success(uint id, long delay, string? message = null) { return new EffectResponse(id, EffectStatus.Success, delay, message); } public static EffectResponse Success(uint id, TimeSpan delay, string? message = null) { return new EffectResponse(id, EffectStatus.Success, delay, message); } public static EffectResponse Failure(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Failure, message); } public static EffectResponse Failure(uint id, StandardErrors error, string? message = null) { return new EffectResponse(id, EffectStatus.Failure, error, message); } public static EffectResponse Unavailable(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Unavailable, message); } public static EffectResponse Unavailable(uint id, StandardErrors error) { return new EffectResponse(id, EffectStatus.Unavailable, error); } public static EffectResponse Retry(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Retry, 0L, message); } public static EffectResponse Retry(uint id, long delay, string? message = null) { return new EffectResponse(id, EffectStatus.Retry, delay, message); } public static EffectResponse Retry(uint id, TimeSpan delay, string? message = null) { return new EffectResponse(id, EffectStatus.Retry, delay, message); } public static EffectResponse Retry(uint id, StandardErrors error) { return new EffectResponse(id, EffectStatus.Retry, 0L, error); } public static EffectResponse Retry(uint id, long delay, StandardErrors error) { return new EffectResponse(id, EffectStatus.Retry, delay, error); } public static EffectResponse Retry(uint id, TimeSpan delay, StandardErrors error) { return new EffectResponse(id, EffectStatus.Retry, delay, error); } public static EffectResponse Paused(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Paused, 0L, message); } public static EffectResponse Paused(uint id, long timeRemaining, string? message = null) { return new EffectResponse(id, EffectStatus.Paused, timeRemaining, message); } public static EffectResponse Paused(uint id, TimeSpan timeRemaining, string? message = null) { return new EffectResponse(id, EffectStatus.Paused, timeRemaining, message); } public static EffectResponse Paused(uint id, StandardErrors error) { return new EffectResponse(id, EffectStatus.Paused, 0L, error); } public static EffectResponse Paused(uint id, long timeRemaining, StandardErrors error) { return new EffectResponse(id, EffectStatus.Paused, timeRemaining, error); } public static EffectResponse Paused(uint id, TimeSpan timeRemaining, StandardErrors error) { return new EffectResponse(id, EffectStatus.Paused, timeRemaining, error); } public static EffectResponse Resumed(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Resumed, 0L, message); } public static EffectResponse Resumed(uint id, long timeRemaining, string? message = null) { return new EffectResponse(id, EffectStatus.Resumed, timeRemaining, message); } public static EffectResponse Resumed(uint id, TimeSpan timeRemaining, string? message = null) { return new EffectResponse(id, EffectStatus.Resumed, timeRemaining, message); } public static EffectResponse Resumed(uint id, StandardErrors error) { return new EffectResponse(id, EffectStatus.Resumed, 0L, error); } public static EffectResponse Resumed(uint id, long timeRemaining, StandardErrors error) { return new EffectResponse(id, EffectStatus.Resumed, timeRemaining, error); } public static EffectResponse Resumed(uint id, TimeSpan timeRemaining, StandardErrors error) { return new EffectResponse(id, EffectStatus.Resumed, timeRemaining, error); } public static EffectResponse Finished(uint id, string? message = null) { return new EffectResponse(id, EffectStatus.Finished, 0L, message); } public static EffectResponse Finished(uint id, StandardErrors error) { return new EffectResponse(id, EffectStatus.Finished, 0L, error); } } public interface IEffectSourceDetails { public class Converter : JsonConverter<IEffectSourceDetails?> { public static readonly Converter Instance = new Converter(); public override IEffectSourceDetails? ReadJson(JsonReader reader, Type objectType, IEffectSourceDetails? existingValue, bool hasExistingValue, JsonSerializer serializer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)reader.TokenType == 11) { return null; } JObject val = JObject.Load(reader); JToken obj = val["type"]; return ((obj != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj) : null) switch { "twitch-channel-reward" => ((JToken)val).ToObject<TwitchChannelRewardSourceDetails>(), "stream-labs-donation" => ((JToken)val).ToObject<StreamLabsDonationSourceDetails>(), "event-hype-train" => ((JToken)val).ToObject<HypeTrainSourceDetails>(), "tiktok-gift" => ((JToken)val).ToObject<TikTokGiftSourceDetails>(), "tiktok-like" => ((JToken)val).ToObject<TikTokLikeSourceDetails>(), "tiktok-follow" => ((JToken)val).ToObject<TikTokFollowSourceDetails>(), "tiktok-share" => ((JToken)val).ToObject<TikTokShareSourceDetails>(), "pulsoid-trigger" => ((JToken)val).ToObject<PulsoidTriggerSourceDetails>(), "crowd-control-test" => ((JToken)val).ToObject<CrowdControlTestSourceDetails>(), "crowd-control-chaos-mode" => ((JToken)val).ToObject<CrowdControlChaosModeSourceDetails>(), "crowd-control-retry" => ((JToken)val).ToObject<CrowdControlRetrySourceDetails>(), _ => null, }; } public override void WriteJson(JsonWriter writer, IEffectSourceDetails? value, JsonSerializer serializer) { serializer.Serialize(writer, (object)((value == null) ? null : JObject.FromObject((object)value))); } } [JsonProperty("type")] string Type { get; } } public class TwitchChannelRewardSourceDetails : IEffectSourceDetails { [JsonProperty("type")] public string Type => "twitch-channel-reward"; [JsonProperty("rewardID")] public string RewardID { get; set; } [JsonProperty("redemptionID")] public string RedemptionID { get; set; } [JsonProperty("twitchID")] public string TwitchID { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("cost")] public int Cost { get; set; } } public class StreamLabsDonationSourceDetails : IEffectSourceDetails { [JsonProperty("type")] public string Type => "stream-labs-donation"; [JsonProperty("donationID")] public string DonationID { get; set; } [JsonProperty("cost")] public string Cost { get; set; } [JsonProperty("currency")] public string Currency { get; set; } [JsonProperty("name")] public string? Name { get; set; } [JsonProperty("message")] public string? Message { get; set; } } public class HypeTrainSourceDetails : IEffectSourceDetails { public class Contribution { [JsonProperty("user_id")] public string UserID { get; set; } [JsonProperty("user_login")] public string UserLogin { get; set; } [JsonProperty("user_name")] public string UserName { get; set; } [JsonProperty("type")] public string Type { get; set; } [JsonProperty("total")] public int Total { get; set; } } [JsonProperty("type")] public string Type => "event-hype-train"; [JsonProperty("total")] public int Total { get; set; } [JsonProperty("progress")] public int Progress { get; set; } [JsonProperty("goal")] public int Goal { get; set; } [JsonProperty("top_contributions")] public List<Contribution> TopContributions { get; set; } [JsonProperty("last_contribution")] public Contribution LastContribution { get; set; } [JsonProperty("level")] public int Level { get; set; } } public abstract class TikTokSourceDetails : IEffectSourceDetails { [JsonProperty("type")] public abstract string Type { get; } [JsonProperty("cost")] public int Cost { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("userID")] public string UserID { get; set; } } public class TikTokGiftSourceDetails : TikTokSourceDetails { [JsonProperty("type")] public override string Type => "tiktok-gift"; [JsonProperty("giftID")] public int GiftID { get; set; } [JsonProperty("giftName")] public string GiftName { get; set; } [JsonProperty("transactionID")] public string? TransactionID { get; set; } } public class TikTokLikeSourceDetails : TikTokSourceDetails { [JsonProperty("type")] public override string Type => "tiktok-like"; } public class TikTokFollowSourceDetails : TikTokSourceDetails { [JsonProperty("type")] public override string Type => "tiktok-follow"; } public class TikTokShareSourceDetails : TikTokSourceDetails { [JsonProperty("type")] public override string Type => "tiktok-share"; } public class PulsoidTriggerSourceDetails : IEffectSourceDetails { [JsonProperty("type")] public string Type => "pulsoid-trigger"; [JsonProperty("heartRate")] public int HeartRate { get; set; } [JsonProperty("uuid")] public Guid Uuid { get; set; } [JsonProperty("triggerType")] public string TriggerType { get; set; } [JsonProperty("targetHeartRate")] public int TargetHeartRate { get; set; } [JsonProperty("holdTime")] public int HoldTime { get; set; } [JsonProperty("cooldown")] public int Cooldown { get; set; } } public class CrowdControlTestSourceDetails : IEffectSourceDetails { [JsonProperty("type")] public string Type => "crowd-control-test"; } public class CrowdControlChaosModeSourceDetails : IEffectSourceDetails { [JsonProperty("type")] public string Type => "crowd-control-chaos-mode"; } public class CrowdControlRetrySourceDetails : IEffectSourceDetails { [JsonProperty("type")] public string Type => "crowd-control-retry"; } [JsonConverter(typeof(CamelCaseStringEnumConverter))] public enum EffectStatus { Success = 0, Failure = 1, Unavailable = 2, Retry = 3, Queue = 4, Running = 5, Paused = 6, Resumed = 7, Finished = 8, Wait = 9, RemoteScheduled = 10, Visible = 128, NotVisible = 129, Selectable = 130, NotSelectable = 131, Reserved0 = 160, NotReady = 255 } [Serializable] public class EffectUpdate : SimpleJSONResponse { [JsonConverter(typeof(CamelCaseStringEnumConverter))] public enum IdentifierType { Effect, Group, Category } [Obsolete("This field is deprecated. Please use the ids field instead.")] [JsonProperty(/*Could not decode attribute arguments.*/)] public string? code; [JsonProperty(/*Could not decode attribute arguments.*/)] public string[]? ids; public IdentifierType idType; public EffectStatus status; public string? message; public EffectUpdate() { } public EffectUpdate(string id, EffectStatus status, string? message = null) { ids = new string[1] { id }; idType = IdentifierType.Effect; this.status = status; this.message = message; type = ResponseType.EffectStatus; } public EffectUpdate(string id, IdentifierType idType, EffectStatus status, string? message = null) { ids = new string[1] { id }; this.idType = idType; this.status = status; this.message = message; type = ResponseType.EffectStatus; } public EffectUpdate(string[] ids, EffectStatus status, string? message = null) { this.ids = ids; idType = IdentifierType.Effect; this.status = status; this.message = message; type = ResponseType.EffectStatus; } public EffectUpdate(string[] ids, IdentifierType idType, EffectStatus status, string? message = null) { this.ids = ids; this.idType = idType; this.status = status; this.message = message; type = ResponseType.EffectStatus; } public EffectUpdate(IEnumerable<string> ids, EffectStatus status, string? message = null) { this.ids = ids.ToArray(); idType = IdentifierType.Effect; this.status = status; this.message = message; type = ResponseType.EffectStatus; } public EffectUpdate(IEnumerable<string> ids, IdentifierType idType, EffectStatus status, string? message = null) { this.ids = ids.ToArray(); this.idType = idType; this.status = status; this.message = message; type = ResponseType.EffectStatus; } } [Serializable] public class EmptyRequest : SimpleJSONRequest { } [Serializable] public class EmptyResponse : SimpleJSONResponse { } internal static class EnumEx { internal static string ToCamelCase(this Enum value) { return value.ToString("G").ToCamelCase(); } } [JsonConverter(typeof(CamelCaseStringEnumConverter))] public enum GameState { Unknown = 0, Error = -1, Unmodded = -2, BadGameSettings = -3, WrongVersion = -4, NotFocused = -5, Loading = -6, InLevel = 1, [Obsolete("Use InLevel instead. This state is redundant and does not provide any additional information about the game state.")] Ready = 1, TitleScreen = -17, Credits = -18, Menu = -13, Paused = -7, WrongMode = -8, SafeArea = -9, StartingArea = -19, Dialogue = -20, Cutscene = -11, BadPlayerState = -12, InputLocked = -21, Map = -14, UntimedArea = -10, InCombat = -15, NotInCombat = -16, PipelineBusy = -128, NotReady = int.MinValue } [Serializable] public class GameUpdate : SimpleJSONResponse { public GameState state; public string? message; public GameUpdate(GameState state, string? message = null) { this.state = state; this.message = message; type = ResponseType.GameUpdate; } } [Serializable] public class GenericEventRequest : SimpleJSONRequest { [JsonProperty(PropertyName = "internal")] public bool @internal; public string eventType; public Dictionary<string, object?>? data; public GenericEventRequest(string eventType) { type = RequestType.GenericEvent; this.eventType = eventType; } [JsonConstructor] public GenericEventRequest(string eventType, IEnumerable<KeyValuePair<string, object?>>? data) : this(eventType) { this.data = ((data != null) ? data.ToDictionary() : null); } [JsonConstructor] public GenericEventRequest(string eventType, IEnumerable<KeyValuePair<string, object?>>? data, bool @internal) : this(eventType, data) { this.@internal = @internal; } } [Serializable] public class GenericEventResponse : SimpleJSONResponse { [JsonProperty(PropertyName = "internal")] public bool @internal; public string eventType; public Dictionary<string, object?>? data; public GenericEventResponse(string eventType) { type = ResponseType.GenericEvent; this.eventType = eventType; } public GenericEventResponse(string eventType, IEnumerable<KeyValuePair<string, object>>? data, bool @internal = false) : this(eventType) { this.data = ((data != null) ? data.ToDictionary() : null); this.@internal = @internal; } [JsonConstructor] public GenericEventResponse(string eventType, Dictionary<string, object>? data, [JsonProperty(PropertyName = "internal")] bool @internal) : this(eventType, data) { this.@internal = @internal; } } internal class HexColorConverter : JsonConverter<ParameterColorValue> { private static readonly Dictionary<char, byte> CHAR_LOOKUP = new Dictionary<char, byte> { { '0', 0 }, { '1', 1 }, { '2', 2 }, { '3', 3 }, { '4', 4 }, { '5', 5 }, { '6', 6 }, { '7', 7 }, { '8', 8 }, { '9', 9 }, { 'A', 10 }, { 'B', 11 }, { 'C', 12 }, { 'D', 13 }, { 'E', 14 }, { 'F', 15 } }; public override void WriteJson(JsonWriter writer, ParameterColorValue value, JsonSerializer serializer) { serializer.Serialize(writer, (object)string.Format("#{0}{1:X2}{2:X2}{3:X2}", (value.A != byte.MaxValue) ? value.A.ToString("X2") : string.Empty, value.R, value.G, value.B)); } public override ParameterColorValue ReadJson(JsonReader reader, Type objectType, ParameterColorValue existingValue, bool hasExistingValue, JsonSerializer serializer) { if (TryParse(serializer.Deserialize<string>(reader), out var color)) { return color; } throw new SerializationException("Unrecognized color code."); } public static bool TryParse(string? value, out ParameterColorValue color) { if (value == null) { color = default(ParameterColorValue); return false; } value = value.TrimStart('#'); switch (value.Length) { case 6: { string[] array2 = value.Chop(2); byte result2; byte red3 = (byte)(byte.TryParse(array2[0], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result2) ? result2 : 0); byte green3 = (byte)(byte.TryParse(array2[1], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result2) ? result2 : 0); byte blue3 = (byte)(byte.TryParse(array2[2], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result2) ? result2 : 0); color = ParameterColorValue.FromArgb(red3, green3, blue3); return true; } case 8: { string[] array = value.Chop(2); byte result; byte alpha2 = (byte)(byte.TryParse(array[0], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result) ? result : 0); byte red2 = (byte)(byte.TryParse(array[1], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result) ? result : 0); byte green2 = (byte)(byte.TryParse(array[2], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result) ? result : 0); byte blue2 = (byte)(byte.TryParse(array[3], NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out result) ? result : 0); color = ParameterColorValue.FromArgb(alpha2, red2, green2, blue2); return true; } case 3: { byte value3; byte red4 = (byte)(CHAR_LOOKUP.TryGetValue(value[0], out value3) ? checked((byte)(value3 * 16)) : 0); byte green4 = (byte)(CHAR_LOOKUP.TryGetValue(value[1], out value3) ? checked((byte)(value3 * 16)) : 0); byte blue4 = (byte)(CHAR_LOOKUP.TryGetValue(value[2], out value3) ? checked((byte)(value3 * 16)) : 0); color = ParameterColorValue.FromArgb(red4, green4, blue4); return true; } case 4: { byte value2; byte alpha = (byte)(CHAR_LOOKUP.TryGetValue(value[0], out value2) ? checked((byte)(value2 * 16)) : 0); byte red = (byte)(CHAR_LOOKUP.TryGetValue(value[1], out value2) ? checked((byte)(value2 * 16)) : 0); byte green = (byte)(CHAR_LOOKUP.TryGetValue(value[2], out value2) ? checked((byte)(value2 * 16)) : 0); byte blue = (byte)(CHAR_LOOKUP.TryGetValue(value[3], out value2) ? checked((byte)(value2 * 16)) : 0); color = ParameterColorValue.FromArgb(alpha, red, green, blue); return true; } default: color = default(ParameterColorValue); return false; } } } internal static class IEnumerableEx { internal static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> values) where TKey : notnull { Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>(); foreach (KeyValuePair<TKey, TValue> value in values) { dictionary.Add(value.Key, value.Value); } return dictionary; } } public interface IParameterValue { string ID { get; } string Name { get; } ParameterBase.ParameterType Type { get; } object? Value { get; } } [Serializable] public class LoginRequest : SimpleJSONRequest { public string? login; public string? password; } [Serializable] public class MessageRequest : SimpleJSONRequest { public string? message; } [Serializable] public class MessageResponse : SimpleJSONResponse { public string? message; } internal static class ObjectEx { internal static T2? IfNotNull<T1, T2>(this T1? value, Func<T1, T2?> selector) where T2 : class { if (value == null) { return null; } return selector(value); } } public abstract class ParameterBase { [JsonConverter(typeof(ParameterTypeConverter))] public enum ParameterType { Options, HexColor } private class ParameterTypeConverter : JsonConverter<ParameterType> { public override void WriteJson(JsonWriter writer, ParameterType value, JsonSerializer serializer) { writer.WriteValue(value switch { ParameterType.Options => "options", ParameterType.HexColor => "hex-color", _ => throw new SerializationException("Unknown parameter type."), }); } public override ParameterType ReadJson(JsonReader reader, Type objectType, ParameterType existingValue, bool hasExistingValue, JsonSerializer serializer) { switch (reader.Value?.ToString().ToLowerInvariant()) { case "options": return ParameterType.Options; case "hexcolor": case "hex-color": return ParameterType.HexColor; default: throw new SerializationException("Unknown parameter type."); } } } [JsonIgnore] public readonly string ID; [JsonProperty(PropertyName = "title")] public readonly string Name; [JsonProperty(PropertyName = "type")] public readonly ParameterType Type; protected ParameterBase(string name, string id, ParameterType type) { ID = id; Name = name; Type = type; } } public class ParameterColor : ParameterBase, IParameterValue { [JsonProperty(PropertyName = "value")] [JsonConverter(typeof(HexColorConverter))] public ParameterColorValue Value; [JsonIgnore] string IParameterValue.ID => ID; [JsonIgnore] string IParameterValue.Name => Name; [JsonIgnore] ParameterType IParameterValue.Type => Type; [JsonIgnore] object? IParameterValue.Value => Value; [JsonConstructor] public ParameterColor(string name, string id, ParameterColorValue value) : base(name, id, ParameterType.HexColor) { Value = value; } [JsonConstructor] public ParameterColor(string name, string id, string value) : base(name, id, ParameterType.HexColor) { if (!HexColorConverter.TryParse(value, out Value)) { throw new ArgumentException("Unknown color code.", "value"); } } } [Serializable] [DebuggerDisplay("{NameAndARGBValue}")] [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public readonly struct ParameterColorValue : IEquatable<ParameterColorValue> { public static readonly ParameterColorValue Empty; private const short StateARGBValueValid = 2; private const short StateValueMask = 2; private const short StateNameValid = 8; private const long NotDefinedValue = 0L; internal const int ARGBAlphaShift = 24; internal const int ARGBRedShift = 16; internal const int ARGBGreenShift = 8; internal const int ARGBBlueShift = 0; internal const uint ARGBAlphaMask = 4278190080u; internal const uint ARGBRedMask = 16711680u; internal const uint ARGBGreenMask = 65280u; internal const uint ARGBBlueMask = 255u; private readonly long value; private readonly short state; public byte R => (byte)(Value >> 16); public byte G => (byte)(Value >> 8); public byte B => (byte)Value; public byte A => (byte)(Value >> 24); public bool IsEmpty => state == 0; private long Value { get { if ((state & 2) != 0) { return value; } return 0L; } } private ParameterColorValue(long value, short state) { this.value = value; this.state = state; } private static ParameterColorValue FromArgb(uint argb) { return new ParameterColorValue(argb, 2); } public static ParameterColorValue FromArgb(int argb) { return FromArgb((uint)argb); } public static ParameterColorValue FromArgb(byte alpha, byte red, byte green, byte blue) { return FromArgb((uint)((alpha << 24) | (red << 16) | (green << 8) | blue)); } public static ParameterColorValue FromArgb(int alpha, ParameterColorValue baseColor) { return FromArgb(checked(((uint)alpha << 24) | ((uint)baseColor.Value & 0xFFFFFF))); } public static ParameterColorValue FromArgb(byte red, byte green, byte blue) { return FromArgb(byte.MaxValue, red, green, blue); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void GetRgbValues(out byte r, out byte g, out byte b) { checked { uint num = (uint)Value; r = (byte)((num & 0xFF0000) >> 16); g = (byte)((num & 0xFF00) >> 8); b = (byte)(num & 0xFF); } } public float GetBrightness() { GetRgbValues(out var r, out var g, out var b); int num = Math.Min(Math.Min(r, g), b); return (float)checked(Math.Max(Math.Max(r, g), b) + num) / 510f; } public float GetHue() { GetRgbValues(out var r, out var g, out var b); if (r == g && g == b) { return 0f; } int num = Math.Min(Math.Min(r, g), b); int num2 = Math.Max(Math.Max(r, g), b); checked { float num3 = num2 - num; float num4 = ((r == num2) ? ((float)(g - b) / num3) : ((g != num2) ? ((float)(r - g) / num3 + 4f) : ((float)(b - r) / num3 + 2f))); num4 *= 60f; if (num4 < 0f) { num4 += 360f; } return num4; } } public float GetSaturation() { GetRgbValues(out var r, out var g, out var b); if (r == g && g == b) { return 0f; } int num = Math.Min(Math.Min(r, g), b); int num2 = Math.Max(Math.Max(r, g), b); checked { int num3 = num2 + num; if (num3 > 255) { num3 = 510 - num2 - num; } return (float)(num2 - num) / (float)num3; } } public int ToArgb() { return (int)Value; } public override string ToString() { if ((state & 2) != 0) { return "ParameterColorValue [A=" + A + ", R=" + R + ", G=" + G + ", B=" + B + "]"; } return "ParameterColorValue [Empty]"; } public static bool operator ==(ParameterColorValue left, ParameterColorValue right) { if (left.value == right.value) { return left.state == right.state; } return false; } public static bool operator !=(ParameterColorValue left, ParameterColorValue right) { return !(left == right); } public override bool Equals(object? obj) { if (obj is ParameterColorValue other) { return Equals(other); } return false; } public bool Equals(ParameterColorValue other) { return this == other; } public override int GetHashCode() { return (value.GetHashCode() * 397) ^ state.GetHashCode(); } } public class ParameterValue<TValue> : ParameterBase, IParameterValue { [JsonProperty(PropertyName = "value")] public TValue? Value; [JsonIgnore] string IParameterValue.ID => ID; [JsonIgnore] string IParameterValue.Name => Name; [JsonIgnore] ParameterType IParameterValue.Type => Type; [JsonIgnore] object? IParameterValue.Value => Value; [JsonConstructor] public ParameterValue(string name, string id, TValue? value) : base(name, id, ParameterType.Options) { Value = value; } public override string ToString() { return Name; } } [Serializable] public class PlayerInfo : SimpleJSONRequest { public JObject? player; public PlayerInfo() { type = RequestType.PlayerInfo; } } [Serializable] [JsonConverter(typeof(Converter))] public class RequestParameters : IReadOnlyList<string>, IEnumerable<string>, IEnumerable, IReadOnlyCollection<string>, IReadOnlyDictionary<string, IParameterValue>, IEnumerable<KeyValuePair<string, IParameterValue>>, IReadOnlyCollection<KeyValuePair<string, IParameterValue>> { private class Converter : JsonConverter<RequestParameters> { public override void WriteJson(JsonWriter writer, RequestParameters? value, JsonSerializer serializer) { serializer.Serialize(writer, (object)value?._parameters); } public override RequestParameters? ReadJson(JsonReader reader, Type objectType, RequestParameters? existingValue, bool hasExistingValue, JsonSerializer serializer) { JObject obj = JObject.Load(reader); List<IParameterValue> list = new List<IParameterValue>(); foreach (KeyValuePair<string, JToken> item in obj) { string key = item.Key; string name = Extensions.Value<string>((IEnumerable<JToken>)item.Value[(object)"name"]); switch (Extensions.Value<ParameterBase.ParameterType>((IEnumerable<JToken>)item.Value[(object)"type"])) { case ParameterBase.ParameterType.Options: { string value = Extensions.Value<string>((IEnumerable<JToken>)item.Value[(object)"value"]); list.Add(new ParameterValue<string>(name, key, value)); break; } case ParameterBase.ParameterType.HexColor: { if (HexColorConverter.TryParse(Extensions.Value<string>((IEnumerable<JToken>)item.Value[(object)"value"]), out var color)) { list.Add(new ParameterColor(name, key, color)); } break; } default: throw new SerializationException(); } } return new RequestParameters(list); } } private readonly Dictionary<string, IParameterValue> _parameters; private readonly List<string> _parameter_list; int IReadOnlyCollection<string>.Count => _parameters.Count; int IReadOnlyCollection<KeyValuePair<string, IParameterValue>>.Count => _parameters.Count; public string this[int index] => _parameter_list[index]; public IParameterValue this[string key] => _parameters[key]; public IEnumerable<string> Keys => _parameters.Keys; public IEnumerable<IParameterValue> Values => _parameters.Values; public int Count => _parameters.Count; private RequestParameters() { _parameters = new Dictionary<string, IParameterValue>(); _parameter_list = new List<string>(); } public RequestParameters(IEnumerable<IParameterValue> parameters) { parameters = parameters.ToArray(); _parameters = parameters.ToDictionary((IParameterValue d) => d.ID); _parameter_list = parameters.Select((IParameterValue v) => v.Value.ToString()).ToList(); } public RequestParameters(IEnumerable<KeyValuePair<string, IParameterValue>> parameters) { _parameters = parameters.ToDictionary(); _parameter_list = _parameters.Values.Select((IParameterValue p) => p.Value.ToString()).ToList(); } IEnumerator<KeyValuePair<string, IParameterValue>> IEnumerable<KeyValuePair<string, IParameterValue>>.GetEnumerator() { return _parameters.GetEnumerator(); } IEnumerator<string> IEnumerable<string>.GetEnumerator() { return _parameters.Values.Select((IParameterValue v) => v.Value?.ToString()).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<string>)this).GetEnumerator(); } public bool ContainsKey(string key) { return _parameters.ContainsKey(key); } public bool TryGetValue(string key, out IParameterValue value) { return _parameters.TryGetValue(key, out value); } public IEnumerable<string> Where(Func<string, bool> predicate) { return Enumerable.Where(this, predicate); } public IEnumerable<TResult> Select<TResult>(Func<string, TResult> selector) { return Enumerable.Select(this, selector); } public IEnumerable<TResult> SelectMany<TResult>(Func<string, IEnumerable<TResult>> selector) { return Enumerable.SelectMany(this, selector); } public IEnumerable<TResult> SelectMany<TResult>(Func<string, int, IEnumerable<TResult>> selector) { return Enumerable.SelectMany(this, selector); } public string First() { return this.First<string>(); } public string First(Func<string, bool> predicate) { return Enumerable.First(this, predicate); } public string? FirstOrDefault() { return this.FirstOrDefault<string>(); } public string FirstOrDefault(string defaultValue) { return this.FirstOrDefault<string>() ?? defaultValue; } public string? FirstOrDefault(Func<string, bool> predicate) { return Enumerable.FirstOrDefault(this, predicate); } public string FirstOrDefault(Func<string, bool> predicate, string defaultValue) { return Enumerable.FirstOrDefault(this, predicate) ?? defaultValue; } public bool Any() { return this.Any<string>(); } public bool Any(Func<string, bool> predicate) { return Enumerable.Any(this, predicate); } } public enum RequestType : byte { EffectTest = 0, EffectStart = 1, EffectStop = 2, [Obsolete("Use EffectTest instead.")] Test = 0, [Obsolete("Use EffectStart instead.")] Start = 1, [Obsolete("Use EffectStop instead.")] Stop = 2, GenericEvent = 16, DataRequest = 32, RpcResponse = 208, PlayerInfo = 224, Login = 240, Version = 252, GameUpdate = 253, KeepAlive = byte.MaxValue } [JsonConverter(typeof(CamelCaseStringEnumConverter))] public enum ResponseType : byte { EffectRequest = 0, EffectStatus = 1, GenericEvent = 16, LoadEvent = 24, SaveEvent = 25, DataResponse = 32, RpcRequest = 208, Login = 240, LoginSuccess = 241, Version = 252, GameUpdate = 253, Disconnect = 254, KeepAlive = byte.MaxValue } [Serializable] public class RpcRequest : SimpleJSONResponse { public string? method; public object?[]? args; public RpcTarget? target; public RpcRequest() { type = ResponseType.RpcRequest; } } [Serializable] public class RpcResponse : SimpleJSONRequest { public object? value; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool exception; public RpcResponse() { type = RequestType.RpcResponse; } } [Flags] [JsonConverter(typeof(CamelCaseStringEnumConverter))] public enum RpcTarget { Game = 1, Pack = 2, Native = 4, Client = 8, Server = 0x10 } public abstract class SimpleJSONMessage { public static readonly JsonSerializerSettings JSON_SERIALIZER_SETTINGS = new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1, MissingMemberHandling = (MissingMemberHandling)0, Formatting = (Formatting)0 }; public static readonly JsonSerializer JSON_SERIALIZER = new JsonSerializer { NullValueHandling = JSON_SERIALIZER_SETTINGS.NullValueHandling, MissingMemberHandling = JSON_SERIALIZER_SETTINGS.MissingMemberHandling, Formatting = JSON_SERIALIZER_SETTINGS.Formatting }; private static int _next_id = 0; public static uint NextID { get { uint result; while ((result = (uint)Interlocked.Increment(ref _next_id)) == 0) { } return result; } } public abstract uint ID { get; } public abstract bool IsKeepAlive { get; } public string Serialize() { return JsonConvert.SerializeObject((object)this, JSON_SERIALIZER_SETTINGS); } } [Serializable] public class SimpleJSONRequest : SimpleJSONMessage { public uint id = SimpleJSONMessage.NextID; public RequestType type; [JsonIgnore] public override uint ID => id; [JsonIgnore] public override bool IsKeepAlive => type == RequestType.KeepAlive; public static bool TryParse(string json, [MaybeNullWhen(false)] out SimpleJSONRequest request) { return TryParse(JObject.Parse(json), out request); } public static bool TryParse(JObject j, [MaybeNullWhen(false)] out SimpleJSONRequest request) { try { JToken value = j.GetValue("type"); switch ((value != null) ? ((RequestType)(object)CamelCaseStringEnumConverter.ReadJToken(value, typeof(RequestType))) : RequestType.EffectTest) { case RequestType.EffectTest: case RequestType.EffectStart: request = ((JToken)j).ToObject<EffectRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.EffectStop: request = ((JToken)j).ToObject<EffectRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.DataRequest: request = ((JToken)j).ToObject<DataRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.RpcResponse: request = ((JToken)j).ToObject<RpcResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.PlayerInfo: request = ((JToken)j).ToObject<PlayerInfo>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.Login: request = ((JToken)j).ToObject<MessageRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.Version: request = ((JToken)j).ToObject<EmptyRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.GameUpdate: request = ((JToken)j).ToObject<EmptyRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case RequestType.KeepAlive: request = ((JToken)j).ToObject<EmptyRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; } } catch { } request = null; return false; } } [Serializable] public class SimpleJSONResponse : SimpleJSONMessage { public uint id; public ResponseType type; [JsonIgnore] public override uint ID => id; [JsonIgnore] public override bool IsKeepAlive => type == ResponseType.KeepAlive; [JsonIgnore] public static SimpleJSONResponse KeepAlive { get; } = new EmptyResponse { type = ResponseType.KeepAlive }; public static bool TryParse(string json, [MaybeNullWhen(false)] out SimpleJSONResponse response) { return TryParse(JObject.Parse(json), out response); } public static bool TryParse(JObject j, [MaybeNullWhen(false)] out SimpleJSONResponse response) { try { JToken value = j.GetValue("type"); ResponseType responseType = ((value != null) ? ((ResponseType)(object)CamelCaseStringEnumConverter.ReadJToken(value, typeof(ResponseType))) : ResponseType.EffectRequest); switch (responseType) { case ResponseType.EffectStatus: if (responseType != ResponseType.EffectStatus) { break; } response = ((JToken)j).ToObject<EffectUpdate>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.EffectRequest: response = ((JToken)j).ToObject<EffectResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.RpcRequest: response = ((JToken)j).ToObject<RpcRequest>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.GenericEvent: response = ((JToken)j).ToObject<GenericEventResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.DataResponse: response = ((JToken)j).ToObject<DataResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.Login: response = ((JToken)j).ToObject<EmptyResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.LoginSuccess: response = ((JToken)j).ToObject<EmptyResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.Version: response = ((JToken)j).ToObject<VersionResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.GameUpdate: response = ((JToken)j).ToObject<GameUpdate>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.Disconnect: response = ((JToken)j).ToObject<MessageResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; case ResponseType.KeepAlive: response = ((JToken)j).ToObject<EmptyResponse>(SimpleJSONMessage.JSON_SERIALIZER); return true; } } catch { } response = null; return false; } } [JsonConverter(typeof(CamelCaseStringEnumConverter))] public enum StandardErrors { Unknown = 0, ExceptionThrown = 1, BadRequest = 4096, EffectUnknown = 4097, [Obsolete("Use EffectUnknown instead.")] UnknownEffect = 4097, EffectDisabled = 4098, AlreadyFailed = 4099, CannotParseNumber = 4112, UnknownSelection = 4113, ConnectorError = 8192, ConnectorReadFailure = 8193, ConnectorWriteFailure = 8194, ConnectorNotConnected = 8195, ConnectorNotSupported = 8196, NoResponse = 8448, SettingsError = 12288, CooldownPerEffect = 12545, CooldownGlobal = 12546, RetryMaxTime = 12291, RetryMaxAttempts = 12292, NoSession = 20480, SessionEnding = 20481, BadGameState = 16384, GameObjectNotFound = 16640, PlayerNotFound = 16641, CharacterNotFound = 16642, EnemyNotFound = 16643, ObjectNotFound = 16644, PrerequisiteNotFound = 16645, ObjectStateError = 16896, AlreadyInState = 16897, AlreadyAcquired = 16898, AlreadyFinished = 16899, NoEmptyContainers = 16912, PartyFull = 16913, InvalidArea = 16928, InvalidTarget = 16929, NoValidTargets = 16930, SpawnNotAllowedHere = 16932, RangeError = 17152, AlreadyMinimum = 17153, AlreadyMaximum = 17154, EffectNotImplemented = 24576, PackResourceMissing = 24577, EmulatorNotSupported = 28672, EmulatorInvalidSetting = 28673, ConflictingEffectRunning = 32768, UnqueueablePending = 32769 } internal static class StringEx { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsNullOrWhiteSpace(this string? input) { return string.IsNullOrWhiteSpace(input); } internal static string ToCamelCase(this string input) { bool flag = false; string text = ""; checked { for (int i = 0; i < input.Length; i++) { if (char.IsUpper(input[i])) { if (flag) { text += input.Substring(i); break; } text += char.ToLower(input[i]); } else { flag = true; text = ((i <= 1 || !char.IsUpper(input[i - 1]) || !char.IsUpper(input[i - 2])) ? (text + input[i]) : (text.Substring(0, text.Length - 1) + char.ToUpper(input[i - 1]) + input[i])); } } return text; } } internal unsafe static string[] Chop(this string value, int chopLength) { int length = value.Length; char* ptr = stackalloc char[chopLength]; string[] array = new string[length]; for (int i = 0; i < length; i = checked(i + chopLength)) { int j; for (j = 0; j < chopLength; j = checked(j + 1)) { int num = checked(i + j); if (num >= length) { break; } *(char*)((byte*)ptr + checked(unchecked((nint)j) * (nint)2)) = value[num]; } array[i / chopLength] = new string(ptr, 0, j); } return array; } } public static class TypeEx { public static bool IsAssignableTo(this Type? type, Type? targetType) { if ((object)type != null && (object)targetType != null) { return targetType.IsAssignableFrom(type); } return false; } } [Serializable] [JsonConverter(typeof(Converter))] public class VersionNumber : IEquatable<VersionNumber>, IComparable<VersionNumber> { private class Converter : JsonConverter<VersionNumber> { public override void WriteJson(JsonWriter writer, VersionNumber? value, JsonSerializer serializer) { if (value == null) { writer.WriteNull(); } else { writer.WriteValue((string)value); } } public override VersionNumber? ReadJson(JsonReader reader, Type objectType, VersionNumber? existingValue, bool hasExistingValue, JsonSerializer serializer) { object value = reader.Value; if (value == null) { return null; } if (!(value is string value2)) { return null; } return new VersionNumber(value2); } } public static readonly VersionNumber Zero = new VersionNumber(new Span<uint>(new uint[1])); public static readonly VersionNumber One = new VersionNumber(new Span<uint>(new uint[1] { 1u })); private readonly uint[] _version; public VersionNumber(string value) { _version = (from v in value.Split('.') select uint.TryParse(Sanitize(v), out var result) ? result : 0u).ToArray(); } public VersionNumber(IEnumerable<uint> values) { _version = values.ToArray(); } public VersionNumber(VersionNumber version) { _version = version._version.ToArray(); } public VersionNumber([ParamCollection] scoped Span<uint> values) { _version = values.ToArray(); } public static implicit operator VersionNumber(string value) { return new VersionNumber(value); } public static implicit operator VersionNumber(uint value) { return new VersionNumber(new Span<uint>(new uint[1] { value })); } public static implicit operator VersionNumber(uint[] values) { return new VersionNumber((Span<uint>)values); } public static implicit operator VersionNumber(Span<uint> values) { return new VersionNumber(values); } public static implicit operator VersionNumber(List<uint> values) { return new VersionNumber((IEnumerable<uint>)values); } public static implicit operator string(VersionNumber value) { return value.ToString(); } public static implicit operator uint[](VersionNumber value) { return value._version.ToArray(); } public static bool operator ==(VersionNumber? a, VersionNumber? b) { return Equals(a, b); } public static bool operator !=(VersionNumber? a, VersionNumber? b) { return !Equals(a, b); } public static bool operator <(VersionNumber? a, VersionNumber? b) { return CompareTo(a, b) < 0; } public static bool operator >(VersionNumber? a, VersionNumber? b) { return CompareTo(a, b) > 0; } public static bool operator <=(VersionNumber? a, VersionNumber? b) { return CompareTo(a, b) <= 0; } public static bool operator >=(VersionNumber? a, VersionNumber? b) { return CompareTo(a, b) >= 0; } public override string ToString() { return string.Join('.', _version.Select((uint v) => v.ToString("D"))); } public static bool Equals(VersionNumber? a, VersionNumber? b) { return a?.Equals(b) ?? ((object)b == null); } public override bool Equals(object? obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (TypeEx.IsAssignableTo(obj.GetType(), typeof(VersionNumber))) { return false; } return Equals((VersionNumber)obj); } public override int GetHashCode() { return _version.GetHashCode(); } public bool Equals(VersionNumber? other) { if ((object)other == null) { return false; } if ((object)this == other) { return true; } int num = _version.Length; if (num != other._version.Length) { return false; } for (int i = 0; i < num; i = checked(i + 1)) { if (_version[i] != other._version[i]) { return false; } } return true; } public static int CompareTo(VersionNumber? a, VersionNumber? b) { if ((object)a == null) { if ((object)b != null) { return -1; } return 0; } return a.CompareTo(b); } public int CompareTo(VersionNumber? other) { if ((object)other == null) { return 1; } int num = _version.Length; int num2 = other._version.Length; int num3 = Math.Min(num, num2); checked { int i; for (i = 0; i < num3; i++) { uint num4 = _version[i]; uint num5 = other._version[i]; if (num4 != num5) { if (num4 > num5) { return 1; } return -1; } } if (num == num2) { return 0; } if (num > num2) { for (; i < num; i++) { if (_version[i] != 0) { return 1; } } return 0; } for (; i < num2; i++) { if (other._version[i] != 0) { return -1; } } return 0; } } public static VersionNumber GetAssemblyVersion(IEnumerable<Assembly> assemblies) { VersionNumber versionNumber = Zero; foreach (Assembly assembly in assemblies) { VersionNumber versionNumber2; try { versionNumber2 = GetAssemblyVersion(assembly); } catch { versionNumber2 = Zero; } if (versionNumber2 > versionNumber) { versionNumber = versionNumber2; } } return versionNumber; } public static VersionNumber GetAssemblyVersion(Assembly assembly) { string text = null; object[] customAttributes = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), inherit: false); if (customAttributes != null && customAttributes.Length > 0) { text = ((AssemblyInformationalVersionAttribute)customAttributes[0]).InformationalVersion; } if (text == null || text.Length == 0) { text = GetFileVersionInfo(assembly).ProductVersion?.Trim(); } if (text == null || text.Length == 0) { text = Zero; } return text; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static string Sanitize(string value) { for (int i = 0; i < value.Length; i = checked(i + 1)) { if (!char.IsDigit(value[i])) { return value.Substring(0, i); } } return value; } private static FileVersionInfo GetFileVersionInfo(Assembly assembly) { return FileVersionInfo.GetVersionInfo(assembly.Location); } } [Serializable] public class VersionResponse : SimpleJSONResponse { public VersionNumber version; [JsonConstructor] public VersionResponse(VersionNumber version) { this.version = version; type = ResponseType.Version; } public VersionResponse(uint id, VersionNumber version) { base.id = id; this.version = version; type = ResponseType.Version; } } }
BepInEx/plugins/CrowdControl.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ConnectorLib.JSON; using CrowdControl.Delegates.Effects; using CrowdControl.Delegates.Metadata; using CrowdControl.UI; using HarmonyLib; using Lamb.UI; using Lamb.UI.MainMenu; using MMBiomeGeneration; using MMRoomGeneration; using MMTools; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Spine; using Spine.Unity; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Crowd Control for Cult of the Lamb")] [assembly: AssemblyDescription("Crowd Control integration for Cult of the Lamb (BepInEx 5)")] [assembly: AssemblyCompany("Warp World, Inc.")] [assembly: AssemblyProduct("Crowd Control for Cult of the Lamb")] [assembly: AssemblyCopyright("© Warp World, Inc.")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class ParamCollectionAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CrowdControl { [BepInPlugin("WarpWorld.CrowdControl", "Crowd Control for Cult of the Lamb", "1.4.0.0")] public class CrowdControlMod : BaseUnityPlugin { public const string MOD_GUID = "WarpWorld.CrowdControl"; public const string MOD_NAME = "Crowd Control for Cult of the Lamb"; public const string MOD_VERSION = "1.4.0.0"; private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl"); private const double MANUAL_RECONNECT_COOLDOWN_SECONDS = 5.0; private DateTime m_nextManualReconnectAllowedUtc = DateTime.MinValue; private bool m_hotkeysDisabled; private bool m_clientPresent; private float m_nextClientCheck; private const float CLIENT_CHECK_INTERVAL = 2f; private string? _modVersion; public static bool ForceSpecialPoops; public static TarotCard? tarotCard; public static TarotCard? tarotCard2; public static EnemyOnboarding? eo; public static float DeltaTime => Time.unscaledDeltaTime; public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger; internal static CrowdControlMod Instance { get; private set; } public GameStateManager GameStateManager { get; private set; } public EffectLoader EffectLoader { get; private set; } public bool ClientConnected => Client.Connected; public NetworkClient Client { get; private set; } public Scheduler Scheduler { get; private set; } public string Version { get { try { if (!string.IsNullOrEmpty(_modVersion)) { return _modVersion; } string text = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ccver")); if (string.IsNullOrEmpty(text)) { _modVersion = "1.4.0.0"; } else { _modVersion = text; } return _modVersion; } catch (Exception arg) { Logger.LogInfo((object)$"Error retrieving mod version: {arg}"); return "0"; } } } private void Awake() { Instance = this; Logger.LogInfo((object)"Loaded WarpWorld.CrowdControl. Patching."); harmony.PatchAll(); ModSettings.Initialize(((BaseUnityPlugin)this).Config); Logger.LogInfo((object)"Initializing Crowd Control"); try { GameStateManager = new GameStateManager(this); Client = new NetworkClient(this); EffectLoader = new EffectLoader(this, Client); Scheduler = new Scheduler(this, Client); } catch (Exception arg) { Logger.LogError((object)$"Crowd Control Init Error: {arg}"); } Logger.LogInfo((object)"Crowd Control Initialized"); } private void OnApplicationQuit() { try { Client?.Stop(); Client?.Dispose(); } catch { } } private void OnDestroy() { try { Client?.Stop(); Client?.Dispose(); } catch { } } private void Update() { if (GameStateManager != null) { GameStateManager.InvalidateStateCache(); GameStateManager.UpdateGameState(); Scheduler?.Tick(); } UpdateClientPresence(); HandleHotkeys(); } private void HandleHotkeys() { if (m_hotkeysDisabled) { return; } try { HandleOverlayToggleHotkey(); HandleManualReconnectHotkey(); } catch (Exception ex) { m_hotkeysDisabled = true; Logger.LogWarning((object)("F8/F9 hotkeys disabled - Unity input is unavailable: " + ex.Message)); } } private void UpdateClientPresence() { float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < m_nextClientCheck) { return; } m_nextClientCheck = realtimeSinceStartup + 2f; try { m_clientPresent = Client?.CrowdControlClientFound ?? false; } catch { m_clientPresent = false; } } private void OnGUI() { try { Overlay.Draw(ClientConnected, m_clientPresent); } catch { } } private void HandleOverlayToggleHotkey() { if (Input.GetKeyDown((KeyCode)289)) { bool flag = Overlay.Toggle(); Logger.LogInfo((object)("F8 pressed - overlay " + (flag ? "shown" : "hidden") + ".")); if (flag) { Overlay.Show("Crowd Control display on (F8)", force: true); } } } private void HandleManualReconnectHotkey() { if (!Input.GetKeyDown((KeyCode)290)) { return; } DateTime utcNow = DateTime.UtcNow; if (!(utcNow < m_nextManualReconnectAllowedUtc)) { m_nextManualReconnectAllowedUtc = utcNow.AddSeconds(5.0); Logger.LogInfo((object)"F9 pressed - manual Crowd Control reconnect requested."); NetworkClient client = Client; if (client != null && client.RequestReconnect()) { Overlay.Show("Reconnecting to Crowd Control...", force: true); Logger.LogInfo((object)"Manual Crowd Control reconnect queued."); } else { Overlay.Show("Crowd Control client not found.", force: true); Logger.LogInfo((object)"Manual Crowd Control reconnect skipped because the Crowd Control client was not found."); } } } public void ShowGameUiMessage(string message) { Overlay.Show(message); } private void OnApplicationFocus(bool hasFocus) { try { GameStateManager?.InvalidateStateCache(); GameStateManager?.UpdateGameState(); } catch { } } private void OnApplicationPause(bool isPaused) { try { GameStateManager?.InvalidateStateCache(); GameStateManager?.UpdateGameState(); } catch { } } public IEnumerator CentrePlayer() { float Progress = 0f; Vector3 StartPosition = ((Component)PlayerFarming.Instance.state).transform.position; while (true) { float num; Progress = (num = Progress + Time.deltaTime * 2f); if (num < 0.5f) { ((Component)PlayerFarming.Instance.state).transform.position = Vector3.Lerp(StartPosition, ((Component)this).transform.position + Vector3.down, Mathf.SmoothStep(0f, 1f, Progress)); yield return null; continue; } break; } } private IEnumerator DelayEffectsRoutine(TarotCard? card, float delay) { yield return (object)new WaitForSeconds(0.2f + delay); if (card != null) { TrinketManager.AddTrinket(card, PlayerFarming.Instance); } } public IEnumerator BackToIdleRoutine(TarotCard? card, float delay) { LetterBox.Hide(true); HUD_Manager.Instance.Show(0, false); AudioManager.Instance.PlayOneShot("event:/tarot/tarot_card_close", ((Component)this).gameObject); GameManager.GetInstance().CameraResetTargetZoom(); CameraFollowTarget.Instance.DisablePlayerLook = false; PlayerFarming.Instance.state.CURRENT_STATE = (State)0; yield return null; PlayerFarming.Instance.simpleSpineAnimator.Animate("cards/cards-stop-seperate", 0, false); PlayerFarming.Instance.simpleSpineAnimator.AddAnimate("idle", 0, true, 0f); ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)GameManager.GetInstance()).StartCoroutine(DelayEffectsRoutine(card, delay)); } public IEnumerator GiveTarot() { HUD_Manager.Instance.Hide(false, 0, false); GameManager.GetInstance().CameraSetTargetZoom(4f); LetterBox.Show(false); PlayerFarming.Instance.state.CURRENT_STATE = (State)49; PlayerFarming.Instance.state.facingAngle = -90f; CameraFollowTarget.Instance.DisablePlayerLook = true; ((MonoBehaviour)this).StartCoroutine(CentrePlayer()); AudioManager.Instance.PlayOneShot("event:/tarot/tarot_card_pull", ((Component)this).gameObject); PlayerFarming.Instance.simpleSpineAnimator.Animate("cards/cards-start", 0, false); PlayerFarming.Instance.simpleSpineAnimator.AddAnimate("cards/cards-loop", 0, true, 0f); yield return (object)new WaitForSeconds(0.1f); GameManager.GetInstance().CameraSetTargetZoom(6f); TarotCard card1 = tarotCard; TarotCard card2 = tarotCard2; if (card1 != null && card2 != null) { UITarotChoiceOverlayController tarotChoiceOverlayInstance = MonoSingleton<UIManager>.Instance.ShowTarotChoice(card1, card2); UITarotChoiceOverlayController obj = tarotChoiceOverlayInstance; obj.OnTarotCardSelected = (Action<TarotCard>)Delegate.Combine(obj.OnTarotCardSelected, (Action<TarotCard>)delegate(TarotCard val) { ((MonoBehaviour)this).StartCoroutine(BackToIdleRoutine(val, 0f)); PlayerFarming.Instance.RunTrinkets.Add(val); }); UITarotChoiceOverlayController obj2 = tarotChoiceOverlayInstance; ((UIMenuBase)obj2).OnHidden = (Action)Delegate.Combine(((UIMenuBase)obj2).OnHidden, (Action)delegate { tarotChoiceOverlayInstance = null; }); yield break; } if (card1 != null || card2 != null) { if (card1 != null) { UITrinketCards.Play(card1, (Action)delegate { ((MonoBehaviour)this).StartCoroutine(BackToIdleRoutine(card1, 0f)); }, 1f); } else if (card2 != null) { UITrinketCards.Play(card2, (Action)delegate { ((MonoBehaviour)this).StartCoroutine(BackToIdleRoutine(card2, 0f)); }, 1f); } yield break; } int i = -1; checked { while (true) { int num = i + 1; i = num; if (num > 25) { break; } AudioManager.Instance.PlayOneShot("event:/chests/chest_item_spawn", ((Component)this).gameObject); CameraManager.shakeCamera(Random.Range(0.4f, 0.6f), true); PickUp obj3 = InventoryItem.Spawn((ITEM_TYPE)20, 1, ((Component)this).transform.position + Vector3.back, 0f, (Action<PickUp>)null); obj3.SetInitialSpeedAndDiraction(4f + Random.Range(-0.5f, 1f), (float)(270 + Random.Range(-90, 90))); obj3.MagnetDistance = 3f; obj3.CanStopFollowingPlayer = false; yield return (object)new WaitForSeconds(0.01f); } yield return (object)new WaitForSeconds(1f); ((MonoBehaviour)this).StartCoroutine(BackToIdleRoutine(null, 0f)); } } } public class DelimitedStreamReader(NetworkStream stream) : IDisposable { private readonly MemoryStream _memory_stream = new MemoryStream(); private const int MAX_MESSAGE_SIZE = 1048576; ~DelimitedStreamReader() { Dispose(disposing: false); } public void Dispose() { Dispose(disposing: true); } protected virtual void Dispose(bool disposing) { if (!disposing) { return; } try { _memory_stream.Dispose(); } catch { } } public string ReadUntilNullTerminator() { int num; while ((num = stream.ReadByte()) != -1 && num != 0) { if (_memory_stream.Length >= 1048576) { _memory_stream.SetLength(0L); throw new InvalidDataException("Message exceeded the maximum allowed size without a null terminator. Dropping the connection."); } _memory_stream.WriteByte(checked((byte)num)); } if (num == -1) { throw new EndOfStreamException("Reached end of stream without finding a null terminator."); } string result = Encoding.UTF8.GetString(_memory_stream.ToArray()); _memory_stream.SetLength(0L); return result; } } public static class EffectReasons { public const string GamePaused = "The game is paused."; public const string PlayerBusy = "The Lamb is busy right now."; public const string Cutscene = "A cutscene is playing."; public const string GameNotReady = "The game isn't ready for effects right now."; public const string NotFocused = "The game window isn't focused."; public const string MainMenu = "The game is on the main menu."; public const string Loading = "The game is loading."; public const string MenuOpen = "A menu is open."; public const string NotInDungeon = "The Lamb must be on a crusade."; public const string NotAtBase = "The Lamb must be at the cult base."; public const string PlayerNotFound = "The Lamb couldn't be found."; public const string HealthTooLow = "The Lamb doesn't have enough health left."; public const string AlreadyFullHealth = "The Lamb is already at full health."; public const string NoSpiritHearts = "The Lamb has no spirit hearts to take."; public const string NoBlueHearts = "The Lamb has no blue hearts to take."; public const string NoBlackHearts = "The Lamb has no black hearts to take."; public const string NoExtraHearts = "The Lamb has no extra hearts to take."; public const string CannotPoison = "The Lamb can't be poisoned right now."; public const string NotPoisoned = "The Lamb isn't poisoned."; public const string CannotFreeze = "The Lamb can't be frozen right now."; public const string NotFrozen = "The Lamb isn't frozen."; public const string CannotElectrify = "The Lamb can't be electrified right now."; public const string NotElectrified = "The Lamb isn't electrified."; public const string CannotCharm = "The Lamb can't be charmed right now."; public const string NotCharmed = "The Lamb isn't charmed."; public const string NoWeapon = "The Lamb has no weapon equipped."; public const string WeaponMaxLevel = "The weapon is already at max level."; public const string WeaponMinLevel = "The weapon is already at the lowest level."; public const string WeaponUnavailable = "That weapon isn't available."; public const string CursesLocked = "Curses haven't been unlocked yet."; public const string NoCurse = "The Lamb has no curse equipped."; public const string CurseMaxLevel = "The curse is already at max level."; public const string CurseMinLevel = "The curse is already at the lowest level."; public const string FervourFull = "Fervour is already full."; public const string FervourEmpty = "Fervour is already empty."; public const string NotEnoughItem = "Not enough {0} to take."; public const string TeleportDisabled = "Teleporting is disabled here."; public const string NoRoomInDirection = "There's no room in that direction."; public const string AlreadyAtStart = "The Lamb is already in the starting room."; public const string NoEnemiesToKill = "No enemies to kill."; public const string NoEnemies = "No enemies in the room."; public const string BossFight = "Not available during a boss fight."; public const string NoBoss = "There's no boss to kill."; public const string CannotSpawnHere = "Enemies can't be spawned in this room."; public const string NoRelic = "The Lamb has no relic."; public const string RelicCantCharge = "This relic doesn't charge."; public const string RelicCharged = "The relic is already charged."; public const string RelicEmpty = "The relic has no charge to drain."; public const string NoTarotToDraw = "No tarot cards are left to draw."; public const string NoTarotToTake = "The Lamb has no tarot cards to take."; public const string NoFollowers = "The cult has no followers."; public const string NoDeadFollowers = "No followers to revive."; public const string NoFollowerToKill = "No follower can be killed right now."; public const string NoFollowerToMakeIll = "No follower can be made ill right now."; public const string NoIllFollowers = "No followers are ill."; public const string NoFollowerToMakeDissenter = "No follower can be made a dissenter right now."; public const string NoDissenters = "No followers are dissenting."; public const string FollowersMaxLevel = "All followers are already max level."; public const string FollowersMinLevel = "All followers are already level 1."; public const string FaithHigh = "Cult faith is already near max."; public const string FaithEmpty = "Cult faith is already at zero."; public const string MissingSpecies = "No follower species was chosen."; public const string UnknownSpecies = "Unknown follower species: {0}"; public const string NoBuildingsToBreak = "No buildings can be broken."; public const string NoBrokenBuildings = "No buildings need repairing."; public const string NoBuildingsInProgress = "No buildings are under construction."; public const string NoRitualCooldowns = "Rituals and sermons are already off cooldown."; } public static class EffectRequestEx { public const string DEFAULT_VIEWER_NAME = "the crowd"; public const int MAX_VIEWER_NAME_LENGTH = 32; public static string GetViewerDisplayName(this EffectRequest request, string fallback = "the crowd") { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 string text = request.viewer; if (string.IsNullOrWhiteSpace(text) && request.viewers != null) { foreach (JToken viewer in request.viewers) { JToken obj = ((viewer is JObject) ? viewer : null); string text2 = ((obj != null) ? obj.Value<string>((object)"name") : null); if (text2 == null) { string text3 = (((int)viewer.Type != 8) ? null : Extensions.Value<string>((IEnumerable<JToken>)viewer)); text2 = text3; } text = text2; if (!string.IsNullOrWhiteSpace(text)) { break; } } } string text4 = SanitizeDisplayName(text); if (text4.Length <= 0) { return fallback; } return text4; } public static string SanitizeDisplayName(string? name) { if (string.IsNullOrWhiteSpace(name)) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(Math.Min(name.Length, 32)); bool flag = true; foreach (char c in name) { if (char.IsControl(c) || char.IsSurrogate(c) || ((c == '<' || c == '>') ? true : false)) { continue; } if (char.IsWhiteSpace(c)) { if (flag) { continue; } stringBuilder.Append(' '); flag = true; } else { stringBuilder.Append(c); flag = false; } if (stringBuilder.Length >= 32) { break; } } return stringBuilder.ToString().TrimEnd(); } } public class GameStateManager(CrowdControlMod mod) { public const bool CARE_ABOUT_FOCUS = false; private string? m_reasonDetail; private string? m_reasonMessage; private GameState? m_cachedState; private volatile bool m_stateResendRequested; private GameState? _last_game_state; private GameState? m_loggedState; private string? m_loggedDetail; public string NotReadyReason { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) _ = CurrentState; return m_reasonMessage ?? "The game isn't ready for effects right now."; } } public GameState CurrentState { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) GameState valueOrDefault = m_cachedState.GetValueOrDefault(); if (!m_cachedState.HasValue) { valueOrDefault = GetGameState(); m_cachedState = valueOrDefault; return valueOrDefault; } return valueOrDefault; } } public bool IsReady(string code = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)CurrentState == 1; } private static bool IsPlayerStateReady(State state) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if ((int)state <= 27) { if ((int)state <= 15) { if ((int)state <= 7 || (int)state == 15) { goto IL_0047; } } else if (state - 21 <= 2 || (int)state == 27) { goto IL_0047; } } else if ((int)state <= 54) { if ((int)state == 46 || state - 53 <= 1) { goto IL_0047; } } else if ((int)state == 59 || state - 65 <= 1 || (int)state == 70) { goto IL_0047; } return false; IL_0047: return true; } private GameState State(GameState state, string detail, string message) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) m_reasonDetail = detail; m_reasonMessage = message; return state; } public GameState GetGameState() { //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)UIManager.GetActiveMenu<MainMenu>() != (Object)null) { return State((GameState)(-8), "main menu open", "The game is on the main menu."); } if (MMTransition.IsPlaying) { return State((GameState)(-6), "scene transition playing (MMTransition.IsPlaying)", "The game is loading."); } PlayerFarming instance = PlayerFarming.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.playerController == (Object)null) { return State((GameState)(-6), "no player instance yet", "The game is loading."); } if (Time.timeScale == 0f) { UIManager instance2 = MonoSingleton<UIManager>.Instance; UIMenuBase val = ((instance2 != null) ? instance2.CurrentMenu : null); string text = (((Object)(object)val != (Object)null) ? ("menu '" + ((object)val).GetType().Name + "' open") : "no menu open"); return State((GameState)(-7), "Time.timeScale is 0 (" + text + ")", "The game is paused."); } if (GameManager.InMenu) { return State((GameState)(-7), "GameManager.InMenu is set", "The game is paused."); } if (LetterBox.IsPlaying) { return State((GameState)(-11), "letterbox cutscene playing (LetterBox.IsPlaying)", "A cutscene is playing."); } if (MMConversation.isPlaying) { return State((GameState)(-11), "conversation playing (MMConversation.isPlaying)", "A cutscene is playing."); } StateMachine field = instance.playerController.GetField<StateMachine>("state"); if ((Object)(object)field == (Object)null) { return State((GameState)(-12), "player has no state machine", "The Lamb is busy right now."); } if (!IsPlayerStateReady(field.CURRENT_STATE)) { return State((GameState)(-12), $"player state is {field.CURRENT_STATE}", "The Lamb is busy right now."); } return State((GameState)1, $"player state is {field.CURRENT_STATE}, location {PlayerFarming.Location}", string.Empty); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)$"Game state check failed: {ex}"); return State((GameState)(-1), "state check threw " + ex.GetType().Name, "The game isn't ready for effects right now."); } } public void InvalidateStateCache() { m_cachedState = null; } public void RequestStateResend() { m_stateResendRequested = true; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool UpdateGameState(bool force = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return UpdateGameState(CurrentState, force); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool UpdateGameState(GameState newState, bool force) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return UpdateGameState(newState, null, force); } private void LogStateChange(GameState newState) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) string text = (((GameState?)newState == m_cachedState) ? (m_reasonDetail ?? "no detail") : "no detail"); if ((GameState?)newState != m_loggedState || ((int)newState != 1 && !(text == m_loggedDetail))) { CrowdControlMod.Instance.Logger.LogInfo((object)(((int)newState == 1) ? $"Game state: {newState} - effects can run ({text})" : $"Game state: {newState} - effects are held ({text})")); m_loggedState = newState; m_loggedDetail = text; } } public bool UpdateGameState(GameState newState, string? message = null, bool force = false) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (m_stateResendRequested) { m_stateResendRequested = false; force = true; } LogStateChange(newState); if (force || _last_game_state != (GameState?)newState) { _last_game_state = newState; return mod.Client.Send((SimpleJSONResponse?)new GameUpdate(newState, message)); } return true; } } public static class EnemySpawnHelper { public static bool CanSpawnInCurrentRoom() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 if ((Object)(object)BiomeGenerator.Instance == (Object)null || BiomeGenerator.Instance.CurrentRoom == null) { return false; } if (BiomeGenerator.Instance.CurrentRoom.IsBoss || (int)PlayerFarming.Location == 51) { return false; } if (BiomeGenerator.Instance.CurrentRoom.Completed) { return false; } return true; } public static bool HasSpawnSource() { GameObject prefab; return TryPickEnemyPrefab(out prefab); } public static Transform GetSpawnParent() { if ((Object)(object)Interaction_Chest.Instance != (Object)null) { return ((Component)Interaction_Chest.Instance).transform.parent; } BiomeGenerator instance = BiomeGenerator.Instance; object obj; if (instance == null) { obj = null; } else { BiomeRoom currentRoom = instance.CurrentRoom; obj = ((currentRoom != null) ? currentRoom.generateRoom : null); } if ((Object)obj != (Object)null) { return ((Component)BiomeGenerator.Instance.CurrentRoom.generateRoom).transform; } return ((Component)PlayerFarming.Instance).transform.parent; } public static bool TryPickEnemyPrefab(out GameObject prefab) { List<GameObject> list = new List<GameObject>(); HashSet<GameObject> seenObjects = new HashSet<GameObject>(); HashSet<string> seenTypes = new HashSet<string>(); CollectScenePrefabLists(list, seenObjects); CollectRoomEnemies(list, seenObjects, seenTypes); CollectLiveEnemyPrefabs(list, seenObjects, seenTypes); if (list.Count == 0) { prefab = null; return false; } prefab = list[Random.Range(0, list.Count)]; return (Object)(object)prefab != (Object)null; } public static void SpawnRandomEnemy() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 if (!CanSpawnInCurrentRoom() || !TryPickEnemyPrefab(out GameObject prefab)) { CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { instance.Logger.LogInfo((object)"SpawnEnemy: no prefab source in this room."); } return; } EnemySpawner.Preload(); EnsurePoolRegistered(prefab); Vector3 randomPositionInIsland = BiomeGenerator.GetRandomPositionInIsland(); Transform spawnParent = GetSpawnParent(); GameObject val = EnemySpawner.Create(randomPositionInIsland, spawnParent, prefab); if (!((Object)(object)val == (Object)null)) { ResetFlashState(val); UnitObject val2 = default(UnitObject); if (val.TryGetComponent<UnitObject>(ref val2)) { val2.CanHaveModifier = false; val2.RemoveModifier(); } DropLootOnDeath val3 = default(DropLootOnDeath); if (val.TryGetComponent<DropLootOnDeath>(ref val3) && (int)val3.LootToDrop == 30) { val3.GiveXP = false; } Health val4 = default(Health); if (val.TryGetComponent<Health>(ref val4) && (Object)(object)Interaction_Chest.Instance != (Object)null) { Interaction_Chest.Instance.AddEnemy(val4); } } } private static void EnsurePoolRegistered(GameObject prefab) { Health val = default(Health); if (!((Object)(object)prefab == (Object)null) && !((Object)(object)ObjectPool.instance == (Object)null) && !ObjectPool.instance.pooledObjects.ContainsKey(prefab) && (!prefab.activeInHierarchy || !prefab.TryGetComponent<Health>(ref val) || !(val.HP > 0f) || !((Behaviour)val).enabled)) { ObjectPoolExtensions.CreatePool(prefab, 2, true); } } private static void ResetFlashState(GameObject root) { SimpleSpineFlash[] componentsInChildren = root.GetComponentsInChildren<SimpleSpineFlash>(true); foreach (SimpleSpineFlash val in componentsInChildren) { ((MonoBehaviour)val).StopAllCoroutines(); AccessTools.Field(typeof(SimpleSpineFlash), "cFlashFillRoutine")?.SetValue(val, null); AccessTools.Field(typeof(SimpleSpineFlash), "fadeRoutine")?.SetValue(val, null); AccessTools.Field(typeof(SimpleSpineFlash), "FlashingRed")?.SetValue(val, false); } } private static string NormalizeEnemyTypeName(string name) { if (name.EndsWith("(Clone)")) { name = name.Substring(0, checked(name.Length - "(Clone)".Length)).TrimEnd(); } return name; } private static void AddCandidate(List<GameObject> candidates, HashSet<GameObject> seenObjects, GameObject? prefab) { if (!((Object)(object)prefab == (Object)null) && seenObjects.Add(prefab)) { candidates.Add(prefab); } } private static void AddCandidateByType(List<GameObject> candidates, HashSet<GameObject> seenObjects, HashSet<string> seenTypes, GameObject prefab) { if (!((Object)(object)prefab == (Object)null)) { string item = NormalizeEnemyTypeName(((Object)prefab).name); if (seenTypes.Add(item) || !seenObjects.Contains(prefab)) { AddCandidate(candidates, seenObjects, prefab); } } } private static bool IsRoomEnemy(UnitObject unit) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if ((Object)(object)unit != (Object)null && (Object)(object)unit.health != (Object)null && (int)unit.health.team == 2 && !unit.IsBoss) { return (Object)(object)((Component)unit).GetComponent<Follower>() == (Object)null; } return false; } private static void CollectScenePrefabLists(List<GameObject> candidates, HashSet<GameObject> seenObjects) { EnemyScout[] array = Object.FindObjectsOfType<EnemyScout>(); foreach (EnemyScout val in array) { if (val.EnemiesToSpawn == null) { continue; } foreach (GameObject item in val.EnemiesToSpawn) { AddCandidate(candidates, seenObjects, item); } } EnemyGuardian1[] array2 = Object.FindObjectsOfType<EnemyGuardian1>(); foreach (EnemyGuardian1 val2 in array2) { if (val2.Enemies != null) { GameObject[] enemies = val2.Enemies; foreach (GameObject prefab in enemies) { AddCandidate(candidates, seenObjects, prefab); } } } EnemyGuardian2[] array3 = Object.FindObjectsOfType<EnemyGuardian2>(); foreach (EnemyGuardian2 val3 in array3) { if (val3.EnemyToSpawn != null) { GameObject[] enemies = val3.EnemyToSpawn; foreach (GameObject prefab2 in enemies) { AddCandidate(candidates, seenObjects, prefab2); } } } EnemyMiniGuardian1[] array4 = Object.FindObjectsOfType<EnemyMiniGuardian1>(); foreach (EnemyMiniGuardian1 val4 in array4) { if (val4.Enemies != null) { GameObject[] enemies = val4.Enemies; foreach (GameObject prefab3 in enemies) { AddCandidate(candidates, seenObjects, prefab3); } } } } private static void CollectRoomEnemies(List<GameObject> candidates, HashSet<GameObject> seenObjects, HashSet<string> seenTypes) { BiomeGenerator instance = BiomeGenerator.Instance; object obj; if (instance == null) { obj = null; } else { BiomeRoom currentRoom = instance.CurrentRoom; obj = ((currentRoom != null) ? currentRoom.generateRoom : null); } GenerateRoom val = (GenerateRoom)obj; if ((Object)(object)val == (Object)null) { return; } UnitObject[] componentsInChildren = ((Component)val).GetComponentsInChildren<UnitObject>(true); foreach (UnitObject val2 in componentsInChildren) { if (IsRoomEnemy(val2) && !((Component)val2).gameObject.activeInHierarchy) { AddCandidateByType(candidates, seenObjects, seenTypes, ((Component)val2).gameObject); } } componentsInChildren = ((Component)val).GetComponentsInChildren<UnitObject>(true); foreach (UnitObject val3 in componentsInChildren) { if (IsRoomEnemy(val3) && ((Component)val3).gameObject.activeInHierarchy) { AddCandidateByType(candidates, seenObjects, seenTypes, ((Component)val3).gameObject); } } } private static void CollectLiveEnemyPrefabs(List<GameObject> candidates, HashSet<GameObject> seenObjects, HashSet<string> seenTypes) { Follower val = default(Follower); UnitObject val2 = default(UnitObject); foreach (Health item in new List<Health>(Health.team2)) { if (!((Object)(object)item == (Object)null) && !(item.HP <= 0f) && ((Behaviour)item).enabled && !((Component)item).TryGetComponent<Follower>(ref val) && (!((Component)item).TryGetComponent<UnitObject>(ref val2) || !val2.IsBoss)) { GameObject prefab = ((Component)item).gameObject; if ((Object)(object)ObjectPool.instance != (Object)null && ObjectPool.instance.spawnedObjects.TryGetValue(((Component)item).gameObject, out var value) && (Object)(object)value != (Object)null) { prefab = value; } AddCandidateByType(candidates, seenObjects, seenTypes, prefab); } } } } public static class GameEffects { public static Random rng = new Random(); public static bool isDungeon() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected I4, but got Unknown FollowerLocation location = PlayerFarming.Location; switch (location - 7) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 24: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 46: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 60: case 61: case 62: case 63: case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 74: case 77: case 79: case 80: case 86: case 88: case 89: case 90: return true; default: return false; } } private static int GetCurrentWeaponLevel() { int num = PlayerFarming.Instance.currentWeaponLevel; if (num <= 0) { num = DataManager.Instance.CurrentRunWeaponLevel; } if (num <= 0) { num = 1; } return num; } private static EquipmentType ResolveWeaponVariant(int baseType, int bonus) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) int num = checked(baseType + bonus); if (Enum.IsDefined(typeof(EquipmentType), num)) { EquipmentType val = (EquipmentType)num; if ((Object)(object)EquipmentManager.GetWeaponData(val) != (Object)null) { return val; } } if (Enum.IsDefined(typeof(EquipmentType), baseType)) { EquipmentType val2 = (EquipmentType)baseType; if ((Object)(object)EquipmentManager.GetWeaponData(val2) != (Object)null) { return val2; } } return (EquipmentType)9999; } private static EffectResponse Success(EffectRequest req) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new EffectResponse(((SimpleJSONMessage)req).ID, (EffectStatus)0); } private static EffectResponse Retry(EffectRequest req, string reason) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown return new EffectResponse(((SimpleJSONMessage)req).ID, (EffectStatus)3, reason); } private static EffectResponse Fail(EffectRequest req, string reason) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown return new EffectResponse(((SimpleJSONMessage)req).ID, (EffectStatus)1, reason); } private static EffectResponse Apply(EffectRequest req, Action action) { try { action(); } catch (EffectFailedException ex) { CrowdControlMod.Instance.Logger.LogInfo((object)("Effect '" + req.code + "' failed: " + ex.Message)); return Fail(req, ex.Message); } return Success(req); } private static int CodeValue(EffectRequest req) { return int.Parse(req.code.Split('_')[1]); } private static bool TryGetPlayerHealth(out GameObject player, out Health health) { player = GameObject.FindWithTag("Player"); health = (((Object)(object)player != (Object)null) ? player.GetComponent<Health>() : null); if ((Object)(object)player != (Object)null) { return (Object)(object)health != (Object)null; } return false; } private static bool InBossFight() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location == 51) { return true; } BiomeGenerator instance = BiomeGenerator.Instance; if ((Object)(object)instance != (Object)null && instance.CurrentRoom != null) { return instance.CurrentRoom.IsBoss; } return false; } internal static bool HasLivingEnemy() { foreach (Health item in new List<Health>(Health.team2)) { if ((Object)(object)item != (Object)null && item.HP > 0f) { return true; } } return false; } private static FollowerBrain? FindBrain(FollowerInfo info) { foreach (FollowerBrain allBrain in FollowerBrain.AllBrains) { if (allBrain != null && allBrain.Info != null && allBrain.Info.ID == info.ID) { return allBrain; } } return null; } public static EffectResponse Money100(EffectRequest req) { if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.HP + health.SpiritHearts < 2f) { return Retry(req, "The Lamb doesn't have enough health left."); } return Apply(req, delegate { //IL_0028: Unknown result type (might be due to invalid IL or missing references) HUD_Manager.Instance.Show(0, false); health.DealDamage(1f, player, player.transform.position, false, (AttackTypes)0, false, (AttackFlags)0); }); } public static EffectResponse Poison(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.IsAilemented || health.IsImmuneToAllStasis || health.PoisonImmune || (health.isPlayer && TrinketManager.IsPoisonImmune(PlayerFarming.Instance)) || !health.CanBePoisoned) { return Retry(req, "The Lamb can't be poisoned right now."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.AddPoison(player, 6f); }); } public static EffectResponse RemPoison(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject _, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if ((int)getProperty(health, "poisonCounter") == -1) { return Retry(req, "The Lamb isn't poisoned."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.ClearPoison(); }); } public static EffectResponse Ice(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject _, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.IsAilemented || health.IsImmuneToAllStasis || health.IceImmune || !health.CanBeIced) { return Retry(req, "The Lamb can't be frozen right now."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.AddIce(-1f); }); } public static EffectResponse RemIce(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject _, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if ((int)getProperty(health, "iceCounter") == -1) { return Retry(req, "The Lamb isn't frozen."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.ClearIce(); }); } public static EffectResponse Electric(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.IsAilemented || health.IsImmuneToAllStasis || health.ElectrifiedImmune || !health.CanBeElectrified) { return Retry(req, "The Lamb can't be electrified right now."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.AddElectrified(player); }); } public static EffectResponse RemElectric(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject _, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if ((int)getProperty(health, "electrifiedCounter") == -1) { return Retry(req, "The Lamb isn't electrified."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.ClearElectrified(); }); } public static EffectResponse Charm(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject _, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.IsAilemented || health.IsImmuneToAllStasis || health.CharmImmune || !health.CanBeCharmed) { return Retry(req, "The Lamb can't be charmed right now."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.AddCharm(); }); } public static EffectResponse RemCharm(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject _, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if ((int)getProperty(health, "charmCounter") == -1) { return Retry(req, "The Lamb isn't charmed."); } return Apply(req, delegate { HUD_Manager.Instance.Show(0, false); health.ClearCharm(); }); } public static EffectResponse Kill(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } return Apply(req, delegate { //IL_0028: Unknown result type (might be due to invalid IL or missing references) HUD_Manager.Instance.Show(0, false); health.DealDamage(9999f, player, player.transform.position, false, (AttackTypes)0, false, (AttackFlags)0); }); } public static EffectResponse Damage(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.HP + health.SpiritHearts + health.BlueHearts + health.BlackHearts < 2f) { return Retry(req, "The Lamb doesn't have enough health left."); } return Apply(req, delegate { //IL_0028: Unknown result type (might be due to invalid IL or missing references) HUD_Manager.Instance.Show(0, false); health.DealDamage(1f, player, player.transform.position, false, (AttackTypes)0, false, (AttackFlags)0); }); } public static EffectResponse Damage4(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.HP + health.SpiritHearts + health.BlueHearts + health.BlackHearts < 5f) { return Retry(req, "The Lamb doesn't have enough health left."); } return Apply(req, delegate { //IL_0028: Unknown result type (might be due to invalid IL or missing references) HUD_Manager.Instance.Show(0, false); health.DealDamage(4f, player, player.transform.position, false, (AttackTypes)0, false, (AttackFlags)0); }); } public static EffectResponse DamageAll(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!TryGetPlayerHealth(out GameObject player, out Health health)) { return Retry(req, "The Lamb couldn't be found."); } if (health.HP + health.SpiritHearts + health.BlueHearts + health.BlackHearts < 2f) { return Retry(req, "The Lamb doesn't have enough health left."); } return Apply(req, delegate { //IL_0068: Unknown result type (might be due to invalid IL or missing references) HUD_Manager.Instance.Show(0, false); health.BlackHearts = 0f; health.BlueHearts = 0f; health.SpiritHearts = 0f; health.HP = 2f; health.DealDamage(1f, player, player.transform.position, false, (AttackTypes)0, false, (AttackFlags)0); }); } public static EffectResponse Fervour(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!DataManager.Instance.EnabledSpells) { return Retry(req, "Curses haven't been unlocked yet."); } int num = CodeValue(req); checked { num = (int)(PlayerFarming.Instance.playerSpells.faithAmmo.Total * (float)num / 100f); if (num > 0) { if (PlayerFarming.Instance.playerSpells.faithAmmo.Ammo >= PlayerFarming.Instance.playerSpells.faithAmmo.Total) { return Retry(req, "Fervour is already full."); } } else if (PlayerFarming.Instance.playerSpells.faithAmmo.Ammo == 0f) { return Retry(req, "Fervour is already empty."); } return Apply(req, delegate { if ((float)num + PlayerFarming.Instance.playerSpells.faithAmmo.Ammo < 0f) { num = (int)(0f - PlayerFarming.Instance.playerSpells.faithAmmo.Ammo); } if ((float)num + PlayerFarming.Instance.playerSpells.faithAmmo.Ammo > PlayerFarming.Instance.playerSpells.faithAmmo.Total) { num = (int)(PlayerFarming.Instance.playerSpells.faithAmmo.Total - PlayerFarming.Instance.playerSpells.faithAmmo.Ammo); } PlayerFarming.Instance.playerSpells.faithAmmo.UseAmmo((float)(-num), false); }); } } public static EffectResponse Coins(EffectRequest req) { return GiveOrTakeItem(req, (ITEM_TYPE)20, "coins"); } public static EffectResponse Wood(EffectRequest req) { return GiveOrTakeItem(req, (ITEM_TYPE)1, "wood"); } public static EffectResponse Stone(EffectRequest req) { return GiveOrTakeItem(req, (ITEM_TYPE)2, "stone"); } public static EffectResponse Bone(EffectRequest req) { return GiveOrTakeItem(req, (ITEM_TYPE)9, "bones"); } public static EffectResponse Meat(EffectRequest req) { return GiveOrTakeItem(req, (ITEM_TYPE)6, "meat"); } public static EffectResponse Berries(EffectRequest req) { return GiveOrTakeItem(req, (ITEM_TYPE)21, "berries"); } private static EffectResponse GiveOrTakeItem(EffectRequest req, ITEM_TYPE type, string itemName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) int num = CodeValue(req); checked { if (num < 0) { InventoryItem itemByType = Inventory.GetItemByType(type); if (itemByType == null || itemByType.quantity < -num) { return Retry(req, $"Not enough {itemName} to take."); } return Apply(req, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Inventory.ChangeItemQuantity(type, num, 0); }); } GameObject player = GameObject.FindWithTag("Player"); if ((Object)(object)player == (Object)null) { return Retry(req, "The Lamb couldn't be found."); } return Apply(req, delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < num; i++) { InventoryItem.Spawn(type, 1, player.transform.position + Vector3.back, 0f, (Action<PickUp>)null).SetInitialSpeedAndDiraction(3f + Random.Range(-0.5f, 1f), (float)(270 + Random.Range(-90, 90))); } }); } } public static EffectResponse TeleLeft(EffectRequest req) { return TeleportBy(req, -1, 0); } public static EffectResponse TeleUp(EffectRequest req) { return TeleportBy(req, 0, -1); } public static EffectResponse TeleRight(EffectRequest req) { return TeleportBy(req, 1, 0); } public static EffectResponse TeleDown(EffectRequest req) { return TeleportBy(req, 0, 1); } private static EffectResponse TeleportBy(EffectRequest req, int dx, int dy) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (ActivateMiniMap.DisableTeleporting || (Object)(object)BiomeGenerator.Instance == (Object)null || BiomeGenerator.Instance.CurrentRoom == null) { return Retry(req, "Teleporting is disabled here."); } BiomeRoom currentRoom = BiomeGenerator.Instance.CurrentRoom; if (checked(BiomeRoom.GetRoom(currentRoom.x + dx, currentRoom.y + dy)) == null) { return Retry(req, "There's no room in that direction."); } return Apply(req, delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) BiomeGenerator.ChangeRoom(new Vector2Int(dx, dy)); RoomManager.Instance.PlaceAndPositionPlayer(true); }); } public static EffectResponse TeleStart(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (ActivateMiniMap.DisableTeleporting || (Object)(object)BiomeGenerator.Instance == (Object)null || BiomeGenerator.Instance.CurrentRoom == null) { return Retry(req, "Teleporting is disabled here."); } BiomeRoom currentRoom = BiomeGenerator.Instance.CurrentRoom; int sx = (int)getProperty(BiomeGenerator.Instance, "StartX"); int sy = (int)getProperty(BiomeGenerator.Instance, "StartY"); if (currentRoom.x == sx && currentRoom.y == sy) { return Retry(req, "The Lamb is already in the starting room."); } return Apply(req, delegate { BiomeGenerator.ChangeRoom(sx, sy); RoomManager.Instance.PlaceAndPositionPlayer(true); }); } public static EffectResponse TeleBase(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } return Apply(req, delegate { GameManager.ToShip("Base Biome 1", 2f, (Effect)0); }); } public static EffectResponse CastBlast(EffectRequest req) { return CastSpell(req, delegate(GameObject player) { PlayerFarming.Instance.playerSpells.Spell_EnemyBlast(false, player, 1f); }); } public static EffectResponse CastFireball(EffectRequest req) { return CastSpell(req, delegate(GameObject player) { PlayerFarming.Instance.playerSpells.Spell_Fireball((EquipmentType)800, 0f, false, false, player, 1f, true); }); } public static EffectResponse CastSlash(EffectRequest req) { return CastSpell(req, delegate(GameObject player) { PlayerFarming.Instance.playerSpells.Spell_MegaSlash(false, player, 1f); }); } public static EffectResponse CastProjectile(EffectRequest req) { return CastSpell(req, delegate(GameObject player) { PlayerFarming.Instance.playerSpells.Spell_ProjectileAOE(false, player, 1f); }); } public static EffectResponse CastTentacle(EffectRequest req) { return CastSpell(req, delegate(GameObject player) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) EquipmentType currentCurse = PlayerFarming.Instance.currentCurse; PlayerFarming.Instance.playerSpells.SetSpell((EquipmentType)500, DataManager.Instance.CurrentRunCurseLevel); PlayerFarming.Instance.playerSpells.Spell_Tentacle(0f, false, player, 1f); PlayerFarming.Instance.playerSpells.SetSpell(currentCurse, DataManager.Instance.CurrentRunCurseLevel); }); } private static EffectResponse CastSpell(EffectRequest req, Action<GameObject> cast) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!DataManager.Instance.EnabledSpells) { return Retry(req, "Curses haven't been unlocked yet."); } return Apply(req, delegate { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown GameObject obj = GameObject.FindWithTag("Player"); StateMachine val = (StateMachine)getProperty(PlayerFarming.Instance.playerSpells, "state"); PlayerFarming.Instance.playerSpells.AimAngle = val.LookAngle; cast(obj); }); } public static EffectResponse ForcePoopAndPuke(EffectRequest req) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Fail(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers.Count == 0) { return Fail(req, "The cult has no followers."); } return Apply(req, delegate { CrowdControlMod.ForceSpecialPoops = true; try { FollowerManager.MakeAllFollowersPoopOrVomit(); } finally { CrowdControlMod.ForceSpecialPoops = false; } }); } public static EffectResponse GiveTarot(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } CrowdControlMod.tarotCard = TarotCards.DrawRandomCard(PlayerFarming.Instance, true); CrowdControlMod.tarotCard2 = TarotCards.DrawRandomCard(PlayerFarming.Instance, true); if (CrowdControlMod.tarotCard == null && CrowdControlMod.tarotCard2 == null) { return Retry(req, "No tarot cards are left to draw."); } return Apply(req, delegate { ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CrowdControlMod.Instance.GiveTarot()); }); } public static EffectResponse RemoveTarot(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (PlayerFarming.Instance.RunTrinkets.Count == 0) { return Retry(req, "The Lamb has no tarot cards to take."); } return Apply(req, delegate { TrinketManager.RemoveRandomTrinket(PlayerFarming.Instance); }); } public static EffectResponse SpawnEnemy(EffectRequest req) { return SpawnEnemies(req, 1); } public static EffectResponse SpawnEnemiesPack(EffectRequest req) { return SpawnEnemies(req, 3); } private static EffectResponse SpawnEnemies(EffectRequest req, int count) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (!EnemySpawnHelper.CanSpawnInCurrentRoom() || !EnemySpawnHelper.HasSpawnSource()) { return Retry(req, "Enemies can't be spawned in this room."); } return Apply(req, delegate { for (int i = 0; i < count; i = checked(i + 1)) { EnemySpawnHelper.SpawnRandomEnemy(); } }); } public static EffectResponse SpawnHelper(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } FollowerInfo follower = DataManager.Instance.Followers[Random.Range(0, DataManager.Instance.Followers.Count)]; return Apply(req, delegate { BiomeGenerator.Instance.SpawnDemon(Random.Range(0, 7), follower.ID, -1, false, (GameObject)null, (Action<Demon>)null); }); } public static EffectResponse KillEnemy(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (InBossFight()) { return Retry(req, "Not available during a boss fight."); } List<Health> list = new List<Health>(); foreach (Health item in new List<Health>(Health.team2)) { if ((Object)(object)item != (Object)null && item.HP > 0f && ((Behaviour)item).enabled) { list.Add(item); } } if (list.Count == 0) { return Retry(req, "No enemies to kill."); } Health target = list[Random.Range(0, list.Count)]; return Apply(req, delegate { //IL_002d: Unknown result type (might be due to invalid IL or missing references) target.invincible = false; ((Behaviour)target).enabled = true; target.DealDamage(float.PositiveInfinity, ((Component)PlayerFarming.Instance).gameObject, Vector3.zero, false, (AttackTypes)2, true, (AttackFlags)2048); }); } public static EffectResponse BreakStructure(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } List<StructureBrain> list = new List<StructureBrain>(); foreach (StructureBrain item in StructureManager.StructuresAtLocation((FollowerLocation)1)) { if (item != null && StructureManager.IsCollapsible(item.Data.Type) && !item.Data.IsCollapsed) { list.Add(item); } } if (list.Count == 0) { return Retry(req, "No buildings can be broken."); } StructureBrain target = list[Random.Range(0, list.Count)]; return Apply(req, delegate { target.Collapse(true, true, false); }); } public static EffectResponse RepairStructure(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } List<StructureBrain> list = new List<StructureBrain>(); foreach (StructureBrain item in StructureManager.StructuresAtLocation((FollowerLocation)1)) { if (item != null && item.Data.IsCollapsed) { list.Add(item); } } if (list.Count == 0) { return Retry(req, "No buildings need repairing."); } StructureBrain target = list[Random.Range(0, list.Count)]; return Apply(req, delegate { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 target.Repaired(); if ((int)target.Data.Type == 250 || (int)target.Data.Type == 251 || (int)target.Data.Type == 41) { ((Structures_Bed)target).Rebuild(); } }); } public static EffectResponse Build(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } List<Structures_BuildSite> targets = new List<Structures_BuildSite>(); List<Structures_BuildSiteProject> targets2 = new List<Structures_BuildSiteProject>(); foreach (Structures_BuildSite item in StructureManager.GetAllStructuresOfType<Structures_BuildSite>()) { if (item.BuildProgress < (float)StructuresData.BuildDurationGameMinutes(((StructureBrain)item).Data.ToBuildType)) { targets.Add(item); } } foreach (Structures_BuildSiteProject item2 in StructureManager.GetAllStructuresOfType<Structures_BuildSiteProject>()) { if (item2.BuildProgress < (float)StructuresData.BuildDurationGameMinutes(((StructureBrain)item2).Data.ToBuildType)) { targets2.Add(item2); } } checked { if (targets.Count + targets2.Count == 0) { return Retry(req, "No buildings are under construction."); } return Apply(req, delegate { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num = Random.Range(0, targets.Count + targets2.Count); if (num >= targets.Count) { num -= targets.Count; targets2[num].BuildProgress = StructuresData.BuildDurationGameMinutes(((StructureBrain)targets2[num]).Data.ToBuildType); } else { targets[num].BuildProgress = StructuresData.BuildDurationGameMinutes(((StructureBrain)targets[num]).Data.ToBuildType); } }); } } public static EffectResponse Cooldowns(EffectRequest req) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } bool flag = false; checked { for (int i = 0; i < DataManager.Instance.LastUsedSermonRitualDayIndex.Length; i++) { if (DataManager.Instance.LastUsedSermonRitualDayIndex[i] != -1) { flag = true; } } if (!flag) { return Retry(req, "Rituals and sermons are already off cooldown."); } return Apply(req, delegate { for (int j = 0; j < DataManager.Instance.LastUsedSermonRitualDayIndex.Length; j++) { DataManager.Instance.LastUsedSermonRitualDayIndex[j] = -1; } }); } } public static EffectResponse BuildAll(EffectRequest req) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } bool flag = false; foreach (Structures_BuildSite item in StructureManager.GetAllStructuresOfType<Structures_BuildSite>()) { if (item.BuildProgress < (float)StructuresData.BuildDurationGameMinutes(((StructureBrain)item).Data.ToBuildType)) { flag = true; } } foreach (Structures_BuildSiteProject item2 in StructureManager.GetAllStructuresOfType<Structures_BuildSiteProject>()) { if (item2.BuildProgress < (float)StructuresData.BuildDurationGameMinutes(((StructureBrain)item2).Data.ToBuildType)) { flag = true; } } if (!flag) { return Retry(req, "No buildings are under construction."); } return Apply(req, delegate { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) foreach (Structures_BuildSite item3 in StructureManager.GetAllStructuresOfType<Structures_BuildSite>()) { item3.BuildProgress = StructuresData.BuildDurationGameMinutes(((StructureBrain)item3).Data.ToBuildType); } foreach (Structures_BuildSiteProject item4 in StructureManager.GetAllStructuresOfType<Structures_BuildSiteProject>()) { item4.BuildProgress = StructuresData.BuildDurationGameMinutes(((StructureBrain)item4).Data.ToBuildType); } }); } public static EffectResponse GrowPlants(EffectRequest req) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } return Apply(req, delegate { for (int i = 0; i < 5; i = checked(i + 1)) { StructureManager.UpdateWeeds((FollowerLocation)1); } }); } public static EffectResponse TakeRelic(EffectRequest req) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if ((Object)(object)PlayerFarming.Instance.playerRelic.CurrentRelic == (Object)null || (int)PlayerFarming.Instance.playerRelic.CurrentRelic.RelicType == 0) { return Retry(req, "The Lamb has no relic."); } return Apply(req, delegate { PlayerFarming.Instance.playerRelic.RemoveRelic(true); }); } public static EffectResponse GiveRelic(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if ((Object)(object)MonoSingleton<UIManager>.Instance.CurrentMenu != (Object)null) { return Retry(req, "A menu is open."); } return Apply(req, delegate { //IL_002f: Unknown result type (might be due to invalid IL or missing references) RelicData randomRelicData = EquipmentManager.GetRandomRelicData(true, PlayerFarming.Instance, (RelicSubType)0); PlayerFarming.Instance.playerRelic.EquipRelic(randomRelicData, true, false); CrowdControlMod.Instance.Logger.LogInfo((object)$"gave relic {randomRelicData.RelicType}"); }); } public static EffectResponse ChargeRelic(EffectRequest req) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if ((Object)(object)PlayerFarming.Instance.playerRelic.CurrentRelic == (Object)null || (int)PlayerFarming.Instance.playerRelic.CurrentRelic.RelicType == 0) { return Retry(req, "The Lamb has no relic."); } if (PlayerFarming.Instance.playerRelic.RequiredChargeAmount <= 0f) { return Retry(req, "This relic doesn't charge."); } if (PlayerFarming.Instance.playerRelic.ChargedAmount >= PlayerFarming.Instance.playerRelic.RequiredChargeAmount) { return Retry(req, "The relic is already charged."); } return Apply(req, delegate { PlayerFarming.Instance.playerRelic.FullyCharge(); }); } public static EffectResponse DrainRelic(EffectRequest req) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if ((Object)(object)PlayerFarming.Instance.playerRelic.CurrentRelic == (Object)null || (int)PlayerFarming.Instance.playerRelic.CurrentRelic.RelicType == 0) { return Retry(req, "The Lamb has no relic."); } if (PlayerFarming.Instance.playerRelic.RequiredChargeAmount <= 0f) { return Retry(req, "This relic doesn't charge."); } if (PlayerFarming.Instance.playerRelic.ChargedAmount <= 0f) { return Retry(req, "The relic has no charge to drain."); } return Apply(req, delegate { PlayerFarming.Instance.playerRelic.ChargedAmount = 0f; }); } public static EffectResponse KillEnemies(EffectRequest req) { if (!isDungeon()) { return Retry(req, "The Lamb must be on a crusade."); } if (InBossFight()) { return Retry(req, "Not available during a boss fight."); } if (!HasLivingEnemy()) { return Retry(req, "No enemies to kill."); } return Apply(req, delegate { //IL_0060: Unknown result type (might be due to invalid IL or missing references) foreach (Health item in new List<Health>(Health.team2)) { if ((Object)(object)item != (Object)null) { CrowdControlMod.Instance.Logger.LogInfo((object)("killing - " + ((Object)item).name)); item.invincible = false; ((Behaviour)item).enabled = true; item.DealDamage(float.PositiveInfinity, ((Component)PlayerFarming.Instance).gameObject, Vector3.zero, false, (AttackTypes)2, true, (AttackFlags)2048); } } }); } public static EffectResponse FaithDown(EffectRequest req) { if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } if (CultFaithManager.StaticFaith <= 0f) { return Retry(req, "Cult faith is already at zero."); } return Apply(req, delegate { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown foreach (FollowerInfo follower in DataManager.Instance.Followers) { follower.Faith -= 10f; if (follower.Faith < 0f) { follower.Faith = 0f; } } Flair val = (Flair)2; float num = CultFaithManager.StaticFaith - 10f; if (num < 0f) { num = 0f; } NotificationData val2 = new NotificationData("Crowd Control Faith Down", 0f, -1, val, Array.Empty<string>()); CultFaithManager.StaticFaith = num; CultFaithManager.Instance.BarController.SetBarSize(num / 85f, true, true, val2); }); } public static EffectResponse FaithUp(EffectRequest req) { if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } if (CultFaithManager.StaticFaith > 80f) { return Retry(req, "Cult faith is already near max."); } return Apply(req, delegate { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown foreach (FollowerInfo follower in DataManager.Instance.Followers) { follower.Faith += 10f; if (follower.Faith > 100f) { follower.Faith = 100f; } } Flair val = (Flair)1; float num = CultFaithManager.StaticFaith + 10f; if (num > 85f) { num = 85f; } NotificationData val2 = new NotificationData("Crowd Control Faith Up", 0f, -1, val, Array.Empty<string>()); CultFaithManager.StaticFaith = num; CultFaithManager.Instance.BarController.SetBarSize(num / 85f, true, true, val2); }); } public static EffectResponse HungerDown(EffectRequest req) { if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } return Apply(req, delegate { foreach (FollowerInfo follower in DataManager.Instance.Followers) { follower.Satiation += 10f; if (follower.Satiation > 100f) { follower.Satiation = 100f; } follower.Starvation = 0f; FollowerBrain? obj = FindBrain(follower); if (obj != null) { obj.RemoveThought((Thought)131, true); } } }); } public static EffectResponse HungerUp(EffectRequest req) { if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } return Apply(req, delegate { foreach (FollowerInfo follower in DataManager.Instance.Followers) { follower.Satiation -= 10f; if (follower.Satiation < 0f) { follower.Satiation = 0f; } } }); } public static EffectResponse LoyaltyDown(EffectRequest req) { if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } return Apply(req, delegate { ChangeLoyalty(-10f, bless: false); }); } public static EffectResponse LoyaltyUp(EffectRequest req) { if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } return Apply(req, delegate { ChangeLoyalty(10f, bless: true); }); } private static void ChangeLoyalty(float amount, bool bless) { foreach (FollowerInfo follower in DataManager.Instance.Followers) { FollowerBrain val = FindBrain(follower); if (val != null) { Follower val2 = FollowerManager.FindFollowerByID(follower.ID); if (bless && (Object)(object)val2 != (Object)null) { val.AddAdoration((AdorationActions)9, (Action)null); } FollowerBrainStats stats = val.Stats; stats.Adoration += amount; if (val.Stats.Adoration < 0f) { val.Stats.Adoration = 0f; } if ((Object)(object)val2 != (Object)null) { val2.AdorationUI.BarController.SetBarSize(val.Stats.Adoration / val.Stats.MAX_ADORATION, false, true, (NotificationData)null); } } } } private static bool IsAtCultBase() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 return (int)PlayerFarming.Location == 1; } private static Vector3 GetCultFollowerSpawnPosition() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (IsAtCultBase()) { return ((Component)PlayerFarming.Instance).transform.position; } if ((Object)(object)BiomeBaseManager.Instance != (Object)null && (Object)(object)BiomeBaseManager.Instance.RecruitSpawnLocation != (Object)null) { return BiomeBaseManager.Instance.RecruitSpawnLocation.transform.position; } return Vector3.zero; } private static bool CanSpawnFollowerAtBase() { LocationManager value; return LocationManager.LocationManagers.TryGetValue((FollowerLocation)1, out value); } private static void EnrollCultFollowerOffline(FollowerInfo info) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown FollowerManager.TryAddUniqueFollower(info.ID); DataManager.Instance.Followers.Add(info); DataManager.Instance.Followers.Sort((FollowerInfo a, FollowerInfo b) => a.ID.CompareTo(b.ID)); DataManager.Instance.GetFirstFollower = true; FollowerChanged onFollowerAdded = FollowerManager.OnFollowerAdded; if (onFollowerAdded != null) { onFollowerAdded.Invoke(info.ID); } FollowerBrain orCreateBrain = FollowerBrain.GetOrCreateBrain(info); FollowerManager.SimFollowersAtLocation(info.Location).Add(new SimFollower(orCreateBrain)); orCreateBrain.CompleteCurrentTask(); } private static Follower? EnrollCultFollower(FollowerInfo info, Vector3 position, bool followPlayer = false) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (CanSpawnFollowerAtBase()) { return FollowerManager.CreateNewFollower(info, position, followPlayer); } EnrollCultFollowerOffline(info); return null; } private static void ApplyNewFollowerRole(FollowerInfo info) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (Random.value < 0.5f) { info.FollowerRole = (FollowerRole)0; info.Outfit = (FollowerOutfitType)3; return; } info.FollowerRole = (FollowerRole)1; info.Outfit = (FollowerOutfitType)3; info.WorkerPriority = (WorkerPriority)0; FollowerBrain.GetOrCreateBrain(info).Stats.WorkerBeenGivenOrders = true; } private static void ApplyNewFollowerRoleVisual(Follower follower) { follower.SetOutfit((FollowerOutfitType)3, false, (Thought)0); follower.Brain.CheckChangeTask(); } private static void ConfigureNewFollowerRole(Follower follower) { if (((follower != null) ? follower.Brain : null) == null) { throw new InvalidOperationException("CreateNewFollower returned null."); } ApplyNewFollowerRole(FollowerManager.FindFollowerInfo(follower.Brain.Info.ID) ?? throw new InvalidOperationException($"Could not find follower info for id {follower.Brain.Info.ID}.")); ApplyNewFollowerRoleVisual(follower); } private static void ApplyViewerFaithBonus(string viewerName, bool showNotification) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown float num = CultFaithManager.StaticFaith + 5f; if (num > 85f) { num = 85f; } CultFaithManager.StaticFaith = num; if (showNotification && !((Object)(object)CultFaithManager.Instance?.BarController == (Object)null)) { Flair val = (Flair)1; NotificationData val2 = new NotificationData(viewerName + " has joined the cult!", 0f, -1, val, Array.Empty<string>()); CultFaithManager.Instance.BarController.SetBarSize(num / 85f, true, true, val2); } } private static string? ExtractParameterString(JToken? token) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 if (token == null || (int)token.Type == 10) { return null; } if ((int)token.Type == 1) { JToken val = token[(object)"value"]; if (val != null && (int)val.Type != 10) { return ((object)val).ToString(); } } if ((int)token.Type == 8) { return Extensions.Value<string>((IEnumerable<JToken>)token); } return ((object)token).ToString(); } private static string? GetViewerSpeciesCode(EffectRequest req) { if (!string.IsNullOrEmpty(req.code) && req.code.Contains("_")) { return req.code.Split(new char[1] { '_' }, 2)[1]; } if (req.parameters == null) { return null; } string[] array = new string[2] { "Species", "species" }; foreach (string text in array) { string text2 = ExtractParameterString(req.parameters[(object)text]); if (!string.IsNullOrEmpty(text2)) { return text2; } } JToken parameters = req.parameters; JObject val = (JObject)(object)((parameters is JObject) ? parameters : null); if (val != null) { foreach (JProperty item in val.Properties()) { string text3 = ExtractParameterString(item.Value); if (!string.IsNullOrEmpty(text3)) { return text3; } } } return null; } private static bool TryResolveViewerSkin(string code, out int skinIndex, out SkinAndData skin, out string skinName) { skinIndex = -1; skin = null; skinName = code; if ((Object)(object)WorshipperData.Instance == (Object)null) { return false; } for (int i = 0; i < WorshipperData.Instance.Characters.Count; i = checked(i + 1)) { SkinAndData val = WorshipperData.Instance.Characters[i]; string text = ((val.Skin.Count > 0) ? val.Skin[0].Skin : null); if (string.Equals(val.Title, code, StringComparison.OrdinalIgnoreCase) || val.Contains(code) || (text != null && (string.Equals(text, code, StringComparison.OrdinalIgnoreCase) || text.EndsWith("/" + code, StringComparison.OrdinalIgnoreCase)))) { skinIndex = i; skin = val; skinName = text ?? code; return true; } } return false; } private static void UnlockViewerSkin(SkinAndData skin) { if (skin.Skin.Count != 0) { string skin2 = skin.Skin[0].Skin; if (!DataManager.GetFollowerSkinUnlocked(skin2) && !DataManager.OnBlackList(skin2)) { DataManager.SetFollowerSkinUnlocked(skin2); } } } public static EffectResponse AddFollower(EffectRequest req) { return Apply(req, delegate { //IL_0013: Unknown result type (might be due to invalid IL or missing references) FollowerInfo val = FollowerInfo.NewCharacter((FollowerLocation)1, ""); ApplyNewFollowerRole(val); Follower val2 = EnrollCultFollower(val, GetCultFollowerSpawnPosition()); if ((Object)(object)val2 != (Object)null) { ApplyNewFollowerRoleVisual(val2); } CrowdControlMod.Instance.Logger.LogInfo((object)(((Object)(object)val2 != (Object)null) ? $"AddFollower spawned follower {val.ID} at base" : $"AddFollower enrolled follower {val.ID} while away from base")); }); } public static EffectResponse AddViewer(EffectRequest req) { string code = GetViewerSpeciesCode(req); if (string.IsNullOrEmpty(code)) { CrowdControlMod.Instance.Logger.LogInfo((object)$"AddViewer retry: missing species (code={req.code}, parameters={req.parameters})"); return Retry(req, "No follower species was chosen."); } string viewerName = (string.IsNullOrWhiteSpace(req.viewer) ? "Viewer" : req.viewer); return Apply(req, delegate { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (!TryResolveViewerSkin(code, out int skinIndex, out SkinAndData skin, out string skinName)) { CrowdControlMod.Instance.Logger.LogError((object)$"AddViewer failed: unknown species '{code}' (code={req.code}, parameters={req.parameters})"); throw new EffectFailedException($"Unknown follower species: {code}"); } UnlockViewerSkin(skin); bool showNotification = IsAtCultBase(); FollowerInfo val = FollowerInfo.NewCharacter((FollowerLocation)1, ""); ApplyNewFollowerRole(val); val.Name = viewerName; val.SkinColour = ListExtensions.RandomIndex<SlotsAndColours>(skin.SlotAndColours); val.SkinCharacter = skinIndex; string skinNameFromIndex = WorshipperData.Instance.GetSkinNameFromIndex(val.SkinCharacter); val.SkinVariation = ListExtensions.RandomIndex<CharacterSkin>(WorshipperData.Instance.GetColourData(skinNameFromIndex).Skin); val.SkinName = skinNameFromIndex; val.Satiation = 100f; val.Starvation = 0f; Follower val2 = EnrollCultFollower(val, GetCultFollowerSpawnPosition()); FollowerBrain.GetOrCreateBrain(val).ResetStats(); if ((Object)(object)val2 != (Object)null) { ApplyNewFollowerRoleVisual(val2); Skin val3 = ((SkeletonRenderer)val2.Spine).Skeleton.Data.FindSkin(skinNameFromIndex) ?? ((SkeletonRenderer)val2.Spine).Skeleton.Data.FindSkin(skinName) ?? ((SkeletonRenderer)val2.Spine).Skeleton.Data.FindSkin(code); if (val3 != null) { ((SkeletonRenderer)val2.Spine).Skeleton.SetSkin(val3); ((SkeletonRenderer)val2.Spine).Skeleton.SetSlotsToSetupPose(); } } ApplyViewerFaithBonus(viewerName, showNotification); CrowdControlMod.Instance.Logger.LogInfo((object)(((Object)(object)val2 != (Object)null) ? ("AddViewer spawned '" + viewerName + "' as " + code + " (" + skinNameFromIndex + ")") : ("AddViewer enrolled '" + viewerName + "' as " + code + " (" + skinNameFromIndex + ") while away from base"))); }); } public static EffectResponse KillFollower(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } List<Follower> list = new List<Follower>(); foreach (FollowerInfo follower in DataManager.Instance.Followers) { if (!(follower.HP <= 0f)) { Follower val = FollowerManager.FindFollowerByID(follower.ID); if ((Object)(object)val != (Object)null) { list.Add(val); } } } if (list.Count == 0) { return Retry(req, "No follower can be killed right now."); } Follower target = list[Random.Range(0, list.Count)]; return Apply(req, delegate { target.DieWithAnimation("die", "dead", true, 1, (NotificationType)0, (Action<GameObject>)null, false); }); } public static EffectResponse ReviveFollower(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers_Dead.Count == 0) { return Retry(req, "No followers to revive."); } FollowerInfo target = DataManager.Instance.Followers_Dead[Random.Range(0, DataManager.Instance.Followers_Dead.Count)]; return Apply(req, checked(delegate { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown foreach (DeadWorshipper deadWorshipper in DeadWorshipper.DeadWorshippers) { if ((Object)(object)deadWorshipper != (Object)null && deadWorshipper.followerInfo != null && deadWorshipper.followerInfo.ID == target.ID) { deadWorshipper.HideBody(); deadWorshipper.RemoveWorshipper(); ((Behaviour)deadWorshipper.Spine).enabled = false; ((Behaviour)deadWorshipper.Structure).enabled = false; ((Component)deadWorshipper).gameObject.SetActive(false); StructureManager.RemoveStructure(deadWorshipper.Structure.Brain); break; } } DataManager.Instance.Followers_Dead.Remove(target); DataManager.Instance.Followers_Dead_IDs.Remove(target.ID); Follower obj = FollowerManager.CreateNewFollower(target, ((Component)PlayerFarming.Instance).transform.position, false); if (target.Age > target.LifeExpectancy) { target.LifeExpectancy = target.Age + Random.Range(20, 30); } else { FollowerInfo obj2 = target; obj2.LifeExpectancy += Random.Range(20, 30); } obj.Brain.ResetStats(); FollowerManager.FindFollowerInfo(obj.Brain.Info.ID).Starvation = 0f; obj.Brain.RemoveThought((Thought)131, true); Flair val = (Flair)1; float num = CultFaithManager.StaticFaith + 10f; if (num > 85f) { num = 85f; } NotificationData val2 = new NotificationData(target.Name + " was revived!", 0f, -1, val, Array.Empty<string>()); CultFaithManager.StaticFaith = num; CultFaithManager.Instance.BarController.SetBarSize(num / 85f, true, true, val2); })); } public static EffectResponse InjureFollower(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } List<Follower> list = new List<Follower>(); foreach (FollowerInfo follower in DataManager.Instance.Followers) { if (!(follower.HP <= 0f) && (int)follower.CursedState == 0) { Follower val = FollowerManager.FindFollowerByID(follower.ID); if (!((Object)(object)val == (Object)null) && val.Brain != null && (val.Brain.CurrentTask == null || !val.Brain.CurrentTask.BlockThoughts)) { list.Add(val); } } } if (list.Count == 0) { return Retry(req, "No follower can be made ill right now."); } Follower target = list[Random.Range(0, list.Count)]; return Apply(req, delegate { target.Brain.MakeSick(false); NotificationCentre.Instance.PlayFollowerNotification((NotificationType)13, target.Brain.Info, (Animation)4); }); } public static EffectResponse UnInjureFollower(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } List<FollowerBrain> list = new List<FollowerBrain>(); foreach (FollowerInfo follower in DataManager.Instance.Followers) { FollowerBrain val = FindBrain(follower); if (val != null && val.HasThought((Thought)68)) { list.Add(val); } } if (list.Count == 0) { return Retry(req, "No followers are ill."); } FollowerBrain target = list[Random.Range(0, list.Count)]; return Apply(req, delegate { target.RemoveThought((Thought)68, true); target.RemoveCurseState((Thought)68); foreach (FollowerBrain allBrain in FollowerBrain.AllBrains) { allBrain.RemoveThought((Thought)135, false); allBrain.RemoveThought((Thought)136, false); } NotificationCentre.Instance.PlayFollowerNotification((NotificationType)14, target.Info, (Animation)1); }); } public static EffectResponse SleepFollowers(EffectRequest req) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } return Apply(req, delegate { FollowerManager.MakeAllFollowersFallAsleep(); }); } public static EffectResponse MessFollowers(EffectRequest req) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)PlayerFarming.Location != 1) { return Retry(req, "The Lamb must be at the cult base."); } if (DataManager.Instance.Followers.Count == 0) { return Retry(req, "The cult has no followers."); } return Apply(req, delegate { FollowerManager.MakeAllFollowersPoopOrVomit(); }); } public static EffectResponse LevelUpFollower(EffectRequest req) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: