Skip to content

Commit

Permalink
Release v1.3.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmBatby committed Nov 29, 2024
1 parent 1a03416 commit d739afa
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class ExtendedContent : ScriptableObject
public string ModName => ExtendedMod.ModName;
public string AuthorName => ExtendedMod.AuthorName;

public string UniqueIdentificationName => AuthorName.ToLowerInvariant() + "." + ModName.ToLowerInvariant() + "." + name.ToLowerInvariant();

internal virtual void TryCreateMatchingProperties()
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class ExtendedDungeonFlow : ExtendedContent
[field: SerializeField] public Vector2 DynamicDungeonSizeMinMax { get; set; } = new Vector2(1, 1);
[field: SerializeField][field: Range(0, 1)] public float DynamicDungeonSizeLerpRate { get; set; } = 1f;

[field: Space(5)]
[field: Tooltip("Overrides vanilla camera Far Plane Clip Distance, The highest value between current Level and Interior will be used.")]
[field: Range(0f, 10000f)]
[field: SerializeField] public float OverrideCameraMaxDistance = 400;


[field: Space(10)][field: Header("Misc. Settings")]
[field: SerializeField] public bool GenerateAutomaticConfigurationOptions { get; set; } = true;
Expand Down
6 changes: 6 additions & 0 deletions LethalLevelLoader/Components/ExtendedContent/ExtendedLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class ExtendedLevel : ExtendedContent

[field: SerializeField] public List<StringWithRarity> SceneSelections { get; set; } = new List<StringWithRarity>();

[field: Space(5)]
[field: Tooltip("Overrides vanilla camera Far Plane Clip Distance, The highest value between current Level and Interior will be used.")]
[field: Range(0f, 10000f)]
[field: SerializeField] public float OverrideCameraMaxDistance = 400;

[field: Space(5)]
[field: Header("Weather Fog Distance Override Settings")]

Expand Down Expand Up @@ -104,6 +109,7 @@ public int RoutePrice
public TerminalNode RouteNode { get; internal set; }
public TerminalNode RouteConfirmNode { get; internal set; }
public TerminalNode InfoNode { get; internal set; }
public TerminalNode SimulateNode { get; internal set; }

//Dunno about these yet
public List<ExtendedWeatherEffect> EnabledExtendedWeatherEffects { get; set; } = new List<ExtendedWeatherEffect>();
Expand Down
2 changes: 2 additions & 0 deletions LethalLevelLoader/Components/ExtendedContent/ExtendedMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ internal void RegisterExtendedContent(ExtendedContent newExtendedContent)
RegisterExtendedContent(extendedFootstepSurface);
else if (newExtendedContent is ExtendedStoryLog extendedStoryLog)
RegisterExtendedContent(extendedStoryLog);
else if (newExtendedContent is ExtendedBuyableVehicle extendedBuyableVehicle)
RegisterExtendedContent(extendedBuyableVehicle);
else
throw new ArgumentException(nameof(newExtendedContent), newExtendedContent.name + " (" + newExtendedContent.GetType().Name + ") " + " Could Not Be Registered To ExtendedMod: " + ModName + " Due To Unimplemented Registration Check!");
}
Expand Down
32 changes: 32 additions & 0 deletions LethalLevelLoader/Components/LLLSaveFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Unity.Netcode;

namespace LethalLevelLoader
{
Expand All @@ -11,6 +12,7 @@ public class LLLSaveFile : ModDataContainer

public int parityStepsTaken;
public Dictionary<int, AllItemsListItemData> itemSaveData = new Dictionary<int, AllItemsListItemData>();
public List<ExtendedLevelData> extendedLevelSaveData = new List<ExtendedLevelData>();

public LLLSaveFile()
{
Expand All @@ -22,6 +24,7 @@ public void Reset()
CurrentLevelName = string.Empty;
parityStepsTaken = 0;
itemSaveData = new Dictionary<int, AllItemsListItemData>();
extendedLevelSaveData = new List<ExtendedLevelData>();
}
}

Expand Down Expand Up @@ -50,4 +53,33 @@ public AllItemsListItemData(string newItemObjectName, string newItemName, string
saveItemVariable = newSaveItemVariable;
}
}

public struct ExtendedLevelData : INetworkSerializable
{
public string UniqueIdentifier => uniqueIdentifier;
public string uniqueIdentifier = string.Empty;
public bool isHidden;
public bool isLocked;


public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref uniqueIdentifier);
serializer.SerializeValue(ref isHidden);
serializer.SerializeValue(ref isLocked);
}

public ExtendedLevelData(ExtendedLevel extendedLevel)
{
uniqueIdentifier = extendedLevel.UniqueIdentificationName;
isHidden = extendedLevel.IsRouteHidden;
isLocked = extendedLevel.IsRouteLocked;
}

public void ApplySavedValues(ExtendedLevel extendedLevel)
{
extendedLevel.IsRouteHidden = isHidden;
extendedLevel.IsRouteLocked = isLocked;
}
}
}
39 changes: 37 additions & 2 deletions LethalLevelLoader/General/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class PatchedContent
public static List<string> AllLevelSceneNames { get; internal set; } = new List<string>();

public static List<ExtendedMod> ExtendedMods { get; internal set; } = new List<ExtendedMod>();

internal static Dictionary<string, ExtendedContent> UniqueIdentifiersDictionary = new Dictionary<string, ExtendedContent>();
internal static Dictionary<SelectableLevel, ExtendedLevel> ExtendedLevelDictionary = new Dictionary<SelectableLevel, ExtendedLevel>();
internal static Dictionary<DungeonFlow, ExtendedDungeonFlow> ExtendedDungeonFlowDictionary = new Dictionary<DungeonFlow, ExtendedDungeonFlow>();
internal static Dictionary<Item, ExtendedItem> ExtendedItemDictionary = new Dictionary<Item, ExtendedItem>();
Expand Down Expand Up @@ -261,23 +261,50 @@ internal static void SortExtendedMods()
internal static void PopulateContentDictionaries()
{
foreach (ExtendedLevel extendedLevel in ExtendedLevels)
{
TryAdd(ExtendedLevelDictionary, extendedLevel.SelectableLevel, extendedLevel);
TryAddUUID(extendedLevel);
}
foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows)
{
TryAdd(ExtendedDungeonFlowDictionary, extendedDungeonFlow.DungeonFlow, extendedDungeonFlow);
TryAddUUID(extendedDungeonFlow);
}
foreach (ExtendedItem extendedItem in ExtendedItems)
{
TryAdd(ExtendedItemDictionary, extendedItem.Item, extendedItem);
TryAddUUID(extendedItem);
}
foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes)
{
TryAdd(ExtendedEnemyTypeDictionary, extendedEnemyType.EnemyType, extendedEnemyType);
TryAddUUID(extendedEnemyType);
}
foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles)
{
TryAdd(ExtendedBuyableVehicleDictionary, extendedBuyableVehicle.BuyableVehicle, extendedBuyableVehicle);
TryAddUUID(extendedBuyableVehicle);
}
}

internal static void TryAdd<T1,T2>(Dictionary<T1, T2> dict, T1 key, T2 value)
internal static void TryAddUUID(ExtendedContent extendedContent)
{
TryAdd(UniqueIdentifiersDictionary, extendedContent.UniqueIdentificationName, extendedContent);
}

internal static bool TryAdd<T1,T2>(Dictionary<T1, T2> dict, T1 key, T2 value)
{
if (!dict.ContainsKey(key))
{
dict.Add(key, value);
return (true);
}
else
{
DebugHelper.LogError("Could not add " + key.ToString() + " to dictionary.", DebugType.Developer);
return (false);
}

}

public static bool TryGetExtendedContent(SelectableLevel selectableLevel, out ExtendedLevel extendedLevel)
Expand All @@ -304,6 +331,14 @@ public static bool TryGetExtendedContent(BuyableVehicle buyableVehicle, out Exte
{
return (ExtendedBuyableVehicleDictionary.TryGetValue(buyableVehicle, out extendedBuyableVehicle));
}

public static bool TryGetExtendedContent<T>(string uniqueIdentifierName, out T extendedContent) where T : ExtendedContent
{
extendedContent = null;
if (UniqueIdentifiersDictionary.TryGetValue(uniqueIdentifierName, out ExtendedContent result))
extendedContent = result as T;
return (extendedContent != null);
}
}

public static class OriginalContent
Expand Down
9 changes: 6 additions & 3 deletions LethalLevelLoader/General/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ public static List<SpawnSyncedObject> GetSpawnSyncedObjects(this DungeonFlow dun
{
foreach (GameObjectWeight doorwayTileWeight in dungeonDoorway.ConnectorPrefabWeights)
foreach (SpawnSyncedObject spawnSyncedObject in doorwayTileWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>())
returnList.Add(spawnSyncedObject);
if (!returnList.Contains(spawnSyncedObject))
returnList.Add(spawnSyncedObject);

foreach (GameObjectWeight doorwayTileWeight in dungeonDoorway.BlockerPrefabWeights)
foreach (SpawnSyncedObject spawnSyncedObject in doorwayTileWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>())
returnList.Add(spawnSyncedObject);
if (!returnList.Contains(spawnSyncedObject))
returnList.Add(spawnSyncedObject);
}

foreach (SpawnSyncedObject spawnSyncedObject in dungeonTile.gameObject.GetComponentsInChildren<SpawnSyncedObject>())
returnList.Add(spawnSyncedObject);
if (!returnList.Contains(spawnSyncedObject))
returnList.Add(spawnSyncedObject);
}
return (returnList);
}
Expand Down
38 changes: 38 additions & 0 deletions LethalLevelLoader/General/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ internal static class Patches

internal static List<string> allSceneNamesCalledToLoad = new List<string>();

internal static Dictionary<Camera, float> playerCameras = new Dictionary<Camera, float>();

//Singletons and such for these are set in each classes Awake function, But they all are accessible on the first awake function of the earliest one of these four managers awake function, so i grab them directly via findobjectoftype to safely access them as early as possible.
public static StartOfRound StartOfRound { get; internal set; }
public static RoundManager RoundManager { get; internal set; }
public static Terminal Terminal { get; internal set; }
public static TimeOfDay TimeOfDay { get; internal set; }

public static ExtendedEvent OnBeforeVanillaContentCollected = new ExtendedEvent();
public static ExtendedEvent OnAfterVanillaContentCollected = new ExtendedEvent();
public static ExtendedEvent OnAfterCustomContentRestored = new ExtendedEvent();

[HarmonyPriority(harmonyPriority)]
[HarmonyPatch(typeof(PreInitSceneScript), "Awake")]
[HarmonyPrefix]
Expand Down Expand Up @@ -173,10 +179,14 @@ internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
{
StartOfRound.allItemsList.itemsList.RemoveAt(2);

OnBeforeVanillaContentCollected.Invoke();

DebugStopwatch.StartStopWatch("Scrape Vanilla Content");
ContentExtractor.TryScrapeVanillaItems(StartOfRound);
ContentExtractor.TryScrapeVanillaContent(StartOfRound, RoundManager);
ContentExtractor.ObtainSpecialItemReferences();

OnAfterVanillaContentCollected.Invoke();
}

//Startup LethalLevelLoader's Network Manager Instance
Expand All @@ -190,6 +200,11 @@ internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
foreach (AudioSource audioSource in Resources.FindObjectsOfTypeAll<AudioSource>())
audioSource.spatialize = false;

playerCameras.Clear();
foreach (Camera camera in UnityEngine.Object.FindObjectsByType<Camera>(FindObjectsSortMode.None))
if (camera.targetTexture != null && camera.targetTexture.name == "PlayerScreen")
playerCameras.Add(camera, camera.farClipPlane);

if (Plugin.IsSetupComplete == false)
{
//Terminal Specific Reference Setup
Expand Down Expand Up @@ -255,6 +270,8 @@ internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
debugString += (PatchedContent.ExtendedDungeonFlows.IndexOf(extendedDungeonFlow) + 1) + ". " + extendedDungeonFlow.DungeonName + " (" + extendedDungeonFlow.DungeonFlow.name + ") (" + extendedDungeonFlow.ContentType + ")" + "\n";
DebugHelper.Log(debugString, DebugType.User);



DebugStopwatch.StartStopWatch("Restore Content");
//Restore Custom Content References To Vanilla Content
foreach (ExtendedLevel customLevel in PatchedContent.CustomExtendedLevels)
Expand All @@ -266,6 +283,8 @@ internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
//Destroy Placeholder Custom Content References That Have Now Been Restored
ContentRestorer.DestroyRestoredAssets();

OnAfterCustomContentRestored.Invoke();

DebugStopwatch.StartStopWatch("Dynamic Risk Level");

//Use Vanilla SelectableLevel's To Populate Information About Moon Difficulty.
Expand Down Expand Up @@ -662,9 +681,28 @@ internal static void RoundManagerFinishGeneratingNewLevelClientRpc_Prefix()
LevelLoader.BakeSceneColliderMaterialData(TimeOfDay.sunAnimator.gameObject.scene);
if (LevelLoader.vanillaWaterShader != null)
LevelLoader.TryRestoreWaterShaders(TimeOfDay.sunAnimator.gameObject.scene);
ApplyCamerDistanceOverride();
}
}

internal static void ApplyCamerDistanceOverride()
{
float newDistance = 0;
if (LevelManager.CurrentExtendedLevel.OverrideCameraMaxDistance > 400f || (DungeonManager.CurrentExtendedDungeonFlow != null && DungeonManager.CurrentExtendedDungeonFlow.OverrideCameraMaxDistance > 400f))
{
if (LevelManager.CurrentExtendedLevel.OverrideCameraMaxDistance > DungeonManager.CurrentExtendedDungeonFlow.OverrideCameraMaxDistance)
newDistance = LevelManager.CurrentExtendedLevel.OverrideCameraMaxDistance;
else
newDistance = DungeonManager.CurrentExtendedDungeonFlow.OverrideCameraMaxDistance;
}
foreach (KeyValuePair<Camera, float> cameraPair in playerCameras)
{
if (newDistance > cameraPair.Value)
cameraPair.Key.farClipPlane = newDistance;
else
cameraPair.Key.farClipPlane = cameraPair.Value;
}
}
/*
[HarmonyPriority(harmonyPriority)]
[HarmonyPatch(typeof(MoldSpreadManager), nameof(MoldSpreadManager.Start))]
Expand Down
15 changes: 15 additions & 0 deletions LethalLevelLoader/Patches/LethalLevelLoaderNetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ public void SetDungeonFlowSizeClientRpc(float hostSize)
Patches.RoundManager.dungeonGenerator.Generate();
}

[ServerRpc]
internal void SetExtendedLevelValuesServerRpc(ExtendedLevelData extendedLevelData)
{
if (PatchedContent.TryGetExtendedContent(extendedLevelData.UniqueIdentifier, out ExtendedLevel extendedLevel))
SetExtendedLevelValuesClientRpc(extendedLevelData);
else
DebugHelper.Log("Failed To Send Level Info!", DebugType.User);
}
[ClientRpc]
internal void SetExtendedLevelValuesClientRpc(ExtendedLevelData extendedLevelData)
{
if (PatchedContent.TryGetExtendedContent(extendedLevelData.UniqueIdentifier, out ExtendedLevel extendedLevel))
extendedLevelData.ApplySavedValues(extendedLevel);
}


public static void RegisterNetworkPrefab(GameObject prefab)
{
Expand Down
15 changes: 15 additions & 0 deletions LethalLevelLoader/Patches/SaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,31 @@ internal static void InitializeSave()

parityCheck = false;
}

if (currentSaveFile.extendedLevelSaveData != null)
{
foreach (ExtendedLevelData extendedLevelData in currentSaveFile.extendedLevelSaveData)
LethalLevelLoaderNetworkManager.Instance.SetExtendedLevelValuesServerRpc(extendedLevelData);
}
}

internal static void SaveGameValues()
{
currentSaveFile.itemSaveData = GetAllItemsListItemDataDict();
currentSaveFile.parityStepsTaken = Patches.StartOfRound.gameStats.allStepsTaken;

SaveAllLevels();

currentSaveFile.Save();
}

internal static void SaveAllLevels()
{
currentSaveFile.extendedLevelSaveData.Clear();
foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
currentSaveFile.extendedLevelSaveData.Add(new ExtendedLevelData(extendedLevel));
}

internal static void SaveCurrentSelectableLevel(SelectableLevel selectableLevel)
{
/*
Expand Down
7 changes: 6 additions & 1 deletion LethalLevelLoader/Patches/TerminalManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static Terminal Terminal

internal static string currentTagFilter;

internal static float defaultTerminalFontSize;
public static float defaultTerminalFontSize;

internal static TerminalKeyword lastParsedVerbKeyword;

Expand Down Expand Up @@ -922,8 +922,13 @@ internal static void CreateMoonsFilterTerminalAssets()
foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
simulateMoonsKeywords.Add(extendedLevel.NumberlessPlanetName.StripSpecialCharacters().Sanitized());

int counter = 0;
foreach (TerminalNode simulateNode in CreateTerminalEventNodes("simulate", simulateMoonsKeywords))
{
AddTerminalNodeEventListener(simulateNode, SetSimulationResultsText, LoadNodeActionType.Before);
PatchedContent.ExtendedLevels[counter].SimulateNode = simulateNode;
counter++;
}
}

internal static List<TerminalNode> CreateTerminalEventNodes(string newVerbKeywordWord, List<Enum> terminalEventEnumStrings)
Expand Down
2 changes: 1 addition & 1 deletion LethalLevelLoader/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "imabatby.lethallevelloader";
public const string ModName = "LethalLevelLoader";
public const string ModVersion = "1.3.10";
public const string ModVersion = "1.3.11";

internal static Plugin Instance;

Expand Down
4 changes: 4 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
"MaxWasUnavailable-LethalModDataLib-1.2.2",
"Evaisa-FixPluginTypesSerialization-1.1.1",
"BepInEx-BepInExPack-5.4.2100"
],
"incompatibilities":[
"HolographicWings-LethalExpansion-1.3.45",
"jockie-LethalExpansionCore-1.3.15"
]
}

0 comments on commit d739afa

Please sign in to comment.