Initial
This commit is contained in:
parent
7a77b79dc5
commit
cdadd75ee9
104 changed files with 9416 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using HarmonyLib;
|
||||
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public class AdvancedCompanyPatch : ModPatch {
|
||||
|
||||
public override string warningMessage => "AC compability will stay but if it breaks in the future, I'm not fixing it. Apologies.";
|
||||
|
||||
public AdvancedCompanyPatch(string guid) : base(guid) { }
|
||||
|
||||
public override void AddPatch() {
|
||||
try {
|
||||
var desiredTypeString = "AdvancedCompany.Game.Manager+Moons, AdvancedCompany";
|
||||
var moonManagerType = System.Type.GetType(desiredTypeString);
|
||||
|
||||
var GetInsideEnemiesAC = moonManagerType.GetMethod("GetInsideEnemies", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
|
||||
var GetLootTableAC = moonManagerType.GetMethod("GetLootTable", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
|
||||
var GetScrapAmountAC = moonManagerType.GetMethod("GetScrapAmountModifier", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
|
||||
|
||||
GamePatch.LoadAssetsIntoLevelPatch.enemiesInjection.instructions.Add(new CodeInstruction(OpCodes.Call, GetInsideEnemiesAC));
|
||||
//GamePatch.LoadAssetsIntoLevelPatch.itemsInjection.instructions.Add(new CodeInstruction(OpCodes.Call, GetLootTableAC));
|
||||
GamePatch.RoundManagerPatch.scrapInjection.instructions.Add(new CodeInstruction(OpCodes.Call, GetScrapAmountAC));
|
||||
|
||||
} catch (System.Exception e) {
|
||||
Plugin.logger.LogError("Failed to setup patching for Advanced Company. Custom enemies and items for SDM will not spawn, but bugs should not happen maybe possibly?");
|
||||
Plugin.logger.LogError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public class FacilityMeltdownPatch : ModPatch {
|
||||
|
||||
public override string version => "2.4.4";
|
||||
|
||||
public FacilityMeltdownPatch(string guid) : base(guid) { }
|
||||
|
||||
public override void AddPatch(){
|
||||
GamePatch.Components.ScarletBedroom.onBedroomEndEvent.AddEvent("FacilityMeltdown", Call);
|
||||
}
|
||||
|
||||
public static void Call(){
|
||||
if (StartOfRound.Instance.IsHost && PluginConfig.Instance.facilityMeltdownActiveValue){
|
||||
FacilityMeltdown.API.MeltdownAPI.StartMeltdown(Plugin.modGUID);
|
||||
GamePatch.Managers.AngerManager.Instance.TriggerAngerLightForever();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
157
ScarletMansion/ScarletMansion/ModPatch/LethalConfigPatch.cs
Normal file
157
ScarletMansion/ScarletMansion/ModPatch/LethalConfigPatch.cs
Normal file
|
@ -0,0 +1,157 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using LethalConfig;
|
||||
using LethalConfig.ConfigItems;
|
||||
using BepInEx.Configuration;
|
||||
using System.Reflection;
|
||||
|
||||
using ChangeList = ScarletMansion.PresetConfig.ChangeList;
|
||||
using ConfigEntryBundleInt = ScarletMansion.PluginConfig.ConfigEntryBundle<int>;
|
||||
using ConfigEntryBundleFloat = ScarletMansion.PluginConfig.ConfigEntryBundle<float>;
|
||||
using ConfigEntryBundleString = ScarletMansion.PluginConfig.ConfigEntryBundle<string>;
|
||||
using ConfigEntryBundleBool = ScarletMansion.PluginConfig.ConfigEntryBundle<bool>;
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public class LethalConfigPatch : ModPatch {
|
||||
|
||||
public const string section = "_Presets";
|
||||
public const string descriptionPrefix = "These are a set of preset config values for your convience. Your config values will automatically update to these preset values every time SDM is loaded. To disable this feature, set this value to Custom.";
|
||||
public const string requiresNewLobby = "Requires a lobby restart for the values to be updated.";
|
||||
|
||||
public LethalConfigPatch(string guid) : base(guid) { }
|
||||
|
||||
public static void ForceUIUpdate(){
|
||||
try {
|
||||
var desiredTypeString = "LethalConfig.MonoBehaviours.ConfigMenu, LethalConfig";
|
||||
var configMenuType = Type.GetType(desiredTypeString);
|
||||
var configMenuObject = GameObject.FindObjectOfType(configMenuType);
|
||||
|
||||
var closeFunction = configMenuType.GetMethod("Close", BindingFlags.Instance | BindingFlags.Public);
|
||||
var openFunction = configMenuType.GetMethod("Open", BindingFlags.Instance | BindingFlags.Public);
|
||||
closeFunction.Invoke(configMenuObject, new object[] {false} );
|
||||
openFunction.Invoke(configMenuObject, new object[] {} );
|
||||
|
||||
} catch (Exception e) {
|
||||
Plugin.logger.LogWarning("Could not force Lethal Config UI update");
|
||||
Plugin.logger.LogError(e.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static LethalConfig.ConfigItems.Options.CanModifyResult CanModifyCallback(){
|
||||
if (ScarletNetworkManager.Instance) {
|
||||
return LethalConfig.ConfigItems.Options.CanModifyResult.False("Cannot edit in game");
|
||||
}
|
||||
return LethalConfig.ConfigItems.Options.CanModifyResult.True();
|
||||
}
|
||||
|
||||
public static void CreateConfig(ConfigEntryBase configEntry) {
|
||||
if (configEntry is ConfigEntry<int>) CreateIntConfig(configEntry as ConfigEntry<int>);
|
||||
else if (configEntry is ConfigEntry<float>) CreateFloatConfig(configEntry as ConfigEntry<float>);
|
||||
else if (configEntry is ConfigEntry<string>) CreateStringConfig(configEntry as ConfigEntry<string>);
|
||||
else if (configEntry is ConfigEntry<bool>) CreateBoolConfig(configEntry as ConfigEntry<bool>);
|
||||
}
|
||||
|
||||
public static void CreateIntConfig(ConfigEntry<int> configEntry){
|
||||
var options = new LethalConfig.ConfigItems.Options.IntSliderOptions{
|
||||
Section = configEntry.Definition.Section,
|
||||
Name = configEntry.Definition.Key,
|
||||
Description = configEntry.Description.Description,
|
||||
RequiresRestart = false,
|
||||
CanModifyCallback = CanModifyCallback,
|
||||
};
|
||||
|
||||
var entry = new IntSliderConfigItem(configEntry, options);
|
||||
LethalConfigManager.AddConfigItem(entry);
|
||||
}
|
||||
|
||||
public static void CreateFloatConfig(ConfigEntry<float> configEntry){
|
||||
var options = new LethalConfig.ConfigItems.Options.FloatSliderOptions{
|
||||
Section = configEntry.Definition.Section,
|
||||
Name = configEntry.Definition.Key,
|
||||
Description = configEntry.Description.Description,
|
||||
RequiresRestart = false,
|
||||
CanModifyCallback = CanModifyCallback,
|
||||
};
|
||||
|
||||
var entry = new FloatSliderConfigItem(configEntry, options);
|
||||
LethalConfigManager.AddConfigItem(entry);
|
||||
}
|
||||
|
||||
public static void CreateStringConfig(ConfigEntry<string> configEntry){
|
||||
var options = new LethalConfig.ConfigItems.Options.TextInputFieldOptions{
|
||||
Section = configEntry.Definition.Section,
|
||||
Name = configEntry.Definition.Key,
|
||||
Description = configEntry.Description.Description,
|
||||
RequiresRestart = false,
|
||||
CanModifyCallback = CanModifyCallback,
|
||||
};
|
||||
|
||||
var entry = new TextInputFieldConfigItem(configEntry, options);
|
||||
LethalConfigManager.AddConfigItem(entry);
|
||||
}
|
||||
|
||||
public static void CreateBoolConfig(ConfigEntry<bool> configEntry){
|
||||
var options = new LethalConfig.ConfigItems.Options.BoolCheckBoxOptions{
|
||||
Section = configEntry.Definition.Section,
|
||||
Name = configEntry.Definition.Key,
|
||||
Description = configEntry.Description.Description,
|
||||
RequiresRestart = false,
|
||||
CanModifyCallback = CanModifyCallback,
|
||||
};
|
||||
|
||||
var entry = new BoolCheckBoxConfigItem(configEntry, options);
|
||||
LethalConfigManager.AddConfigItem(entry);
|
||||
}
|
||||
|
||||
public static void CreatePresetConfig<T>(ConfigEntry<T> configEntry, List<ChangeList> changeList) where T: Enum {
|
||||
configEntry.SettingChanged += (obj, args) => ForceUIUpdate();
|
||||
|
||||
var description = $"{requiresNewLobby}\n\n{descriptionPrefix}\n\n";
|
||||
foreach(var c in changeList) {
|
||||
description += $"<b>{c.name}</b>\n{c.description}\n\n";
|
||||
}
|
||||
|
||||
var options = new LethalConfig.ConfigItems.Options.EnumDropDownOptions{
|
||||
Section = "_Presets",
|
||||
Name = configEntry.Definition.Key,
|
||||
Description = description,
|
||||
RequiresRestart = false,
|
||||
CanModifyCallback = CanModifyCallback,
|
||||
};
|
||||
|
||||
var entry = new EnumDropDownConfigItem<T>(configEntry, options);
|
||||
LethalConfigManager.AddConfigItem(entry);
|
||||
}
|
||||
|
||||
public static void AutoGenerateConfigs(params object[] ignoreTargets){
|
||||
var fields = typeof(PluginConfig).GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
foreach(var p in fields){
|
||||
var value = p.GetValue(null);
|
||||
if (ignoreTargets.Contains(value)) continue;
|
||||
|
||||
var valueBundle = value as PluginConfig.ConfigEntryBundleBase;
|
||||
if (valueBundle != null){
|
||||
foreach(var c in valueBundle.GetConfigs()){
|
||||
CreateConfig(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddPatch() {
|
||||
LethalConfigManager.SkipAutoGen();
|
||||
|
||||
CreatePresetConfig(PluginConfig.lcDungeonGenerationPreset.config, PresetConfig.dungeonGenerationChangeList);
|
||||
CreatePresetConfig(PluginConfig.lcDungeonLightingPreset.config, PresetConfig.dungeonLightingChangeList);
|
||||
|
||||
AutoGenerateConfigs(PluginConfig.lcDungeonGenerationPreset, PluginConfig.lcDungeonLightingPreset);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
37
ScarletMansion/ScarletMansion/ModPatch/MimicsPatch.cs
Normal file
37
ScarletMansion/ScarletMansion/ModPatch/MimicsPatch.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using DunGen;
|
||||
using ScarletMansion.GamePatch.FixValues;
|
||||
using UnityEngine.Events;
|
||||
using GameNetcodeStuff;
|
||||
using ScarletMansion.GamePatch.Components;
|
||||
using System.IO;
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public class MimicsPatch : ModPatch {
|
||||
|
||||
public override string version => "2.6.0";
|
||||
|
||||
public MimicsPatch(string guid) : base(guid) { }
|
||||
|
||||
public override void AddPatch() {
|
||||
var assemblyPath = Assembly.GetExecutingAssembly().Location;
|
||||
var folderPath = Path.GetDirectoryName(assemblyPath);
|
||||
var pathAssemblyPath = Path.Combine(folderPath, "ScarletMansionMimicsPatch.dll");
|
||||
|
||||
var assembly = Assembly.LoadFile(pathAssemblyPath);
|
||||
var type = assembly.GetType("ScarletMansion.ModPatch.Patch");
|
||||
Activator.CreateInstance(type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
41
ScarletMansion/ScarletMansion/ModPatch/ModCompability.cs
Normal file
41
ScarletMansion/ScarletMansion/ModPatch/ModCompability.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BepInEx;
|
||||
using BepInEx.Bootstrap;
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public class ModCompability {
|
||||
|
||||
public const string advancedCompanyGuid = "com.potatoepet.AdvancedCompany";
|
||||
public const string lethalConfigGuid = "ainavt.lc.lethalconfig";
|
||||
public const string facilityMeldownGuid = "me.loaforc.facilitymeltdown";
|
||||
public const string reserveFlashlightGuid = "FlipMods.ReservedFlashlightSlot";
|
||||
public const string mimicsGuid = "x753.Mimics";
|
||||
|
||||
public static readonly ModPatch[] modPatches = new ModPatch[] {
|
||||
new AdvancedCompanyPatch(advancedCompanyGuid),
|
||||
new LethalConfigPatch(lethalConfigGuid),
|
||||
new FacilityMeltdownPatch(facilityMeldownGuid),
|
||||
new ReservedItemSlotPatch(reserveFlashlightGuid),
|
||||
new MimicsPatch(mimicsGuid)
|
||||
};
|
||||
|
||||
public static void GetActiveMods(){
|
||||
foreach(var m in modPatches)
|
||||
m.CheckIfActive();
|
||||
}
|
||||
|
||||
public static void ActivateActiveMods(){
|
||||
foreach(var m in modPatches)
|
||||
m.Activate();
|
||||
}
|
||||
|
||||
public static int GetStartOfRoundScriptLength(){
|
||||
return StartOfRound.Instance.allPlayerScripts.Length;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
56
ScarletMansion/ScarletMansion/ModPatch/ModPatch.cs
Normal file
56
ScarletMansion/ScarletMansion/ModPatch/ModPatch.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BepInEx;
|
||||
using BepInEx.Bootstrap;
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public abstract class ModPatch {
|
||||
|
||||
public string guid;
|
||||
public bool active;
|
||||
|
||||
public virtual string version => null;
|
||||
public virtual string warningMessage => null;
|
||||
|
||||
public abstract void AddPatch();
|
||||
|
||||
public ModPatch(string guid){
|
||||
this.guid = guid;
|
||||
active = false;
|
||||
}
|
||||
|
||||
public void CheckIfActive(){
|
||||
var modLoaded = Chainloader.PluginInfos.ContainsKey(guid);
|
||||
if (!modLoaded) return;
|
||||
|
||||
bool validVersion;
|
||||
var pluginInfo = Chainloader.PluginInfos[guid];
|
||||
var loadedVersion = pluginInfo.Metadata.Version;
|
||||
if (string.IsNullOrWhiteSpace(version)){
|
||||
validVersion = true;
|
||||
} else {
|
||||
var requiredVersion = new Version(version);
|
||||
validVersion = loadedVersion >= requiredVersion;
|
||||
}
|
||||
|
||||
if (validVersion) {
|
||||
active = true;
|
||||
Plugin.logger.LogInfo($"Loading compability patch for {guid}");
|
||||
if (!string.IsNullOrWhiteSpace(warningMessage)) Plugin.logger.LogWarning(warningMessage);
|
||||
}
|
||||
|
||||
else {
|
||||
Plugin.logger.LogWarning($"Failed to load compability patch for {guid}. Requires version {version} but found {loadedVersion}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate(){
|
||||
if (active)
|
||||
AddPatch();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReservedItemSlotCore.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ScarletMansion.ModPatch {
|
||||
public class ReservedItemSlotPatch : ModPatch {
|
||||
|
||||
public override string version => "2.0.0";
|
||||
|
||||
public ReservedItemSlotPatch(string guid) : base(guid) { }
|
||||
|
||||
public override void AddPatch(){
|
||||
Assets.onAssetsLoadEvent.AddEvent("LoadFlashlight", LoadFlashlight);
|
||||
}
|
||||
|
||||
public static void LoadFlashlight(){
|
||||
var proFlashlight = new ReservedItemData(Assets.flashlight.displayName, PlayerBone.Spine3, new Vector3(0.2f, 0.25f, 0f), new Vector3(90f, 0f, 0f));
|
||||
var flashlight = new ReservedItemData(Assets.flashlightBB.displayName, PlayerBone.Spine3, new Vector3(0.2f, 0.25f, 0f), new Vector3(90f, 0f, 0f));
|
||||
|
||||
ReservedItemSlotData.TryAddItemDataToReservedItemSlot(proFlashlight, "flashlight");
|
||||
ReservedItemSlotData.TryAddItemDataToReservedItemSlot(flashlight, "flashlight");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue