Skip to content

Commit

Permalink
Fix CoreLib submodules for 0.9.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
limoka committed Aug 26, 2024
1 parent 2a9857c commit 2f5a77d
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 30 deletions.
5 changes: 3 additions & 2 deletions Assets/CoreLibPackage/CoreLib.Audio/Scripts/AudioModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public static void AddMusicToRoster(MusicRosterType rosterType, AudioClip music,
MusicManager.MusicRoster roster = GetRosterTracks(rosterType);
MusicManager.MusicTrack track = new MusicManager.MusicTrack();

track.track = music;
track.optionalIntro = intro;
//TODO fix this
//track.track = music;
//track.optionalIntro = intro;

roster.tracks.Add(track);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"Unity.Mathematics",
"Unity.NetCode",
"Unity.NetCode.Physics",
"Unity.Networking.Transport",
"Unity.Physics",
"Unity.Physics.Hybrid",
"Unity.Properties",
"Unity.Transforms",
"NaughtyAttributes.Core",
"Unity.Networking.Transport",
"Unity.Addressables",
"Unity.ResourceManager",
"PugMod.SDK",
"CoreLib",
"CoreLib.RewiredExtension"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public static IEnumerable<IClientCommandHandler> GetClientCommandHandlers(string

#region Private Implementation

internal override GameVersion Build => new GameVersion(0, 7, 4, "a28f");
internal override string Version => "3.1.1";
internal override GameVersion Build => new GameVersion(0, 7, 5, "3339");
internal override string Version => "3.1.2";
internal override Type[] Dependencies => new[] { typeof(RewiredExtensionModule) };
internal static CommandsModule Instance => CoreLibMod.GetModuleInstance<CommandsModule>();

Expand All @@ -146,6 +146,7 @@ public static IEnumerable<IClientCommandHandler> GetClientCommandHandlers(string
internal static string UP_KEY = "CoreLib_UpKey";
internal static string DOWN_KEY = "CoreLib_DownKey";
internal static string COMPLETE_KEY = "CoreLib_CompleteKey";
internal static string TOGGLE_QC = "CoreLib_ToggleQC";

internal static List<CommandPair> commandHandlers = new List<CommandPair>();
internal static Dictionary<string, ObjectID> friendlyNameDict = new Dictionary<string, ObjectID>();
Expand All @@ -158,7 +159,7 @@ public static IEnumerable<IClientCommandHandler> GetClientCommandHandlers(string
internal override void SetHooks()
{
CoreLibMod.Patch(typeof(ChatWindow_Patch));
CoreLibMod.Patch(typeof(TitleScreenAnimator_Patch));
//CoreLibMod.Patch(typeof(TitleScreenAnimator_Patch));
CoreLibMod.Patch(typeof(ECSManager_Patch));
CoreLibMod.Patch(typeof(MenuManager_Patch));
}
Expand Down Expand Up @@ -188,6 +189,8 @@ internal override void PostLoad()
RewiredExtensionModule.AddKeybind(UP_KEY, "Next command", KeyboardKeyCode.UpArrow);
RewiredExtensionModule.AddKeybind(DOWN_KEY, "Previous command", KeyboardKeyCode.DownArrow);
RewiredExtensionModule.AddKeybind(COMPLETE_KEY, "Autocomplete command", KeyboardKeyCode.Tab);

RewiredExtensionModule.AddKeybind(TOGGLE_QC, "Toggle Quantum console", KeyboardKeyCode.Delete);

API.Client.OnWorldCreated += ClientWorldReady;
API.Server.OnWorldCreated += ServerWorldReady;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public static void AfterInit()
CheckModItemsSafe();
}

[HarmonyPatch(typeof(ECSManager), nameof(ECSManager.LoadSubScenes))]
//TODO
/*[HarmonyPatch(typeof(ECSManager), nameof(ECSManager.LoadSubScenes))]
[HarmonyPostfix]
public static void OnLoadSubScenes()
{
CheckModItemsSafe();
}
}*/


private static void CheckModItemsSafe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public class MenuManager_Patch
public static void OnInit(MenuManager __instance)
{
if (__instance.quantumConsolePrefab == null) return;

var result = __instance.quantumConsolePrefab.LoadAssetAsync<GameObject>();
var prefab = result.WaitForCompletion();

var prefab = __instance.quantumConsolePrefab.gameObject;
var console = Object.Instantiate(prefab, null, true);

var quantumConsole = console.GetComponent<QuantumConsole>();
Expand Down Expand Up @@ -44,7 +46,7 @@ public static void OnAwake(SceneHandler __instance)
[HarmonyPostfix]
public static void OnUpdate(MenuManager __instance)
{
if (Input.GetKeyDown(KeyCode.Delete))
if (CommandsModule.rewiredPlayer.GetButtonDown(CommandsModule.TOGGLE_QC))
{
CommandsModule.ToggleQC();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using HarmonyLib;
using I2.Loc;
using PugMod;

/*
namespace CoreLib.Commands.Patches
{
public class TitleScreenAnimator_Patch
Expand Down Expand Up @@ -44,4 +44,4 @@ private static void AddItemFrendlyNames()
CoreLibMod.Log.LogInfo($"Got {count} friendly name entries!");
}
}
}
}*/
3 changes: 3 additions & 0 deletions Assets/CoreLibPackage/CoreLib.Commands/Scripts/System.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using I2.Loc;
using PugMod;
using Unity.Entities;

namespace CoreLib.Commands
{
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation | WorldSystemFilterFlags.ClientSimulation)]
[UpdateInGroup(typeof(RunSimulationSystemGroup))]
public partial class LoadItemDictSystem : PugSimulationSystemBase
{
private static bool initialized;

protected override void OnCreate()
{
RequireForUpdate<PugDatabase.DatabaseBankCD>();
UpdatesInRunGroup();
base.OnCreate();
}

protected override void OnUpdate()
{
if (initialized)
{
base.OnUpdate();
return;
}

if (LocalizationManager.Sources.Count > 0)
{
AddItemFrendlyNames();
}

initialized = true;
Enabled = false;

base.OnUpdate();
}

private static void AddItemFrendlyNames()
{
int count = 0;
var modAuthorings = (API.Authoring as ModAPIAuthoring).ObjectIDLookup;
foreach (var pair in modAuthorings)
{
if (LocalizationManager.TryGetTranslation($"Items/{pair.Key}", out var translation, overrideLanguage: "english"))
{
if (!CommandsModule.friendlyNameDict.ContainsKey(translation.ToLower()))
{
CommandsModule.friendlyNameDict.Add(translation.ToLower(), pair.Value);
count++;
}
}
}

CoreLibMod.Log.LogInfo($"Got {count} friendly name entries!");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static CommandOutput ParseItemName(string fullName, out ObjectID objectID
string[] keys = CommandsModule.friendlyNameDict.Keys.Where(s => s.Contains(fullName)).ToArray();
if (keys.Length == 0)
{
objectID = ObjectID.None;
CoreLibMod.Log.LogDebug($"friendlyNameDict state: {CommandsModule.friendlyNameDict.Count} entries, first entries: {CommandsModule.friendlyNameDict.Keys.Take(10).Join()}");
objectID = ObjectID.None;
return new CommandOutput($"No item named '{fullName}' found!", CommandStatus.Error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CoreLib.ModResources;
using CoreLib.Submodules.ModEntity;
using CoreLib.Util.Extensions;
using PlayerEquipment;
using UnityEngine;

namespace CoreLib.Equipment
Expand All @@ -26,13 +27,13 @@ public static ObjectType GetObjectType(string typeName)
return (ObjectType)index;
}

public static EquipmentSlot.EquipmentSlotType GetEquipmentSlotType<T>()
public static EquipmentSlotType GetEquipmentSlotType<T>()
where T : EquipmentSlot, IModEquipmentSlot
{
string typeName = typeof(T).FullName;

int index = equipmentSlotTypeBind.HasIndex(typeName) ? equipmentSlotTypeBind.GetIndex(typeName) : equipmentSlotTypeBind.GetNextId(typeName);
return (EquipmentSlot.EquipmentSlotType)index;
return (EquipmentSlotType)index;
}

public static void RegisterEquipmentSlot<T>(GameObject prefab)
Expand Down
6 changes: 3 additions & 3 deletions Assets/CoreLibPackage/CoreLib/Scripts/CoreLibMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class CoreLibMod : IMod
public const string ID = "CoreLib";
public const string NAME = "Core Lib";
public const string CONFIG_FOLDER = "CoreLib/Config/";
public const string VERSION = "3.1.2";
public const string VERSION = "3.1.3";

internal static LoadedMod modInfo;

internal static Logger Log = new Logger(NAME);
internal static ConfigFile Config;
public static readonly GameVersion buildFor = new GameVersion(0, 7, 5, "5317");
public static readonly GameVersion buildFor = new GameVersion(0, 7, 5, "3339");

internal static SubmoduleHandler submoduleHandler;

Expand All @@ -55,7 +55,7 @@ public void EarlyInit()
var gameBuild = new GameVersion(Application.version);

CheckIfUsedOnRightGameVersion(gameBuild);

Log.LogInfo($"Loading CoreLib version {VERSION}!");

submoduleHandler = new SubmoduleHandler(gameBuild, Log);
Expand Down
14 changes: 12 additions & 2 deletions Assets/CoreLibPackage/CoreLib/Scripts/Util/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public void Clear()
private static Queue<MarkerData> freePointMarkers = new Queue<MarkerData>();
private static Queue<MarkerData> freeLineMarkers = new Queue<MarkerData>();

private static Transform myAnchor;

private static Transform GetMyAnchor()
{
if (myAnchor != null) return myAnchor;

myAnchor = Manager.camera.GetRenderAnchor();
return myAnchor;
}

/// <summary>
/// Place a colored dot at specified position
/// </summary>
Expand Down Expand Up @@ -198,7 +208,7 @@ private static MarkerData CreatePointMarker()
MeshRenderer meshRenderer = sphere.GetComponent<MeshRenderer>();
Object.Destroy(sphere.GetComponent<SphereCollider>());
meshRenderer.material.shader = Shader.Find("Radical/SpritesDefault");
sphere.transform.parent = Manager.camera.OrigoTransform;
sphere.transform.parent = GetMyAnchor();
sphere.transform.localScale *= 0.2f;

MarkerData data = new MarkerData(sphere, meshRenderer, null);
Expand All @@ -225,7 +235,7 @@ private static MarkerData CreateLineMarker()
Object.Destroy(line.GetComponent<MeshCollider>());
meshRenderer.material.shader = Shader.Find("Radical/SpritesDefault");

line.transform.parent = Manager.camera.OrigoTransform;
line.transform.parent = GetMyAnchor();
//line.transform.localScale *= 0.2f;

MarkerData data = new MarkerData(line, null, meshRenderer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace CoreLib.Util.Extensions
{
public static class ModExtensions
{
public static string randomPath = Guid.NewGuid().ToString();

public static LoadedMod GetModInfo(this IMod mod)
{
return API.ModLoader.LoadedMods.FirstOrDefault(modInfo => modInfo.Handlers.Contains(mod));
Expand Down Expand Up @@ -59,9 +61,17 @@ public static void TryLoadBurstAssembly(this LoadedMod modInfo)
string directory = API.ModLoader.GetDirectory(modInfo.ModId);
string fileExtension = GetPlatformExtension(platform);
string ID = modInfo.Metadata.name;


var productName = Application.dataPath;
var modLoaderDir = Path.Combine(Application.temporaryCachePath, "ModLoader");

if (productName.ToLower().Contains("dedicated"))
{
modLoaderDir = Path.Combine(modLoaderDir, "DedicatedServer", randomPath);
}

// need elevated access
var tempDirectory = Path.Combine(Application.temporaryCachePath, "ModLoader", ID);
var tempDirectory = Path.Combine(modLoaderDir, ID);
var assemblyName = $"{ID}_burst_generated_{platform}.{fileExtension}";

string newAssemblyPath = Path.Combine(tempDirectory, assemblyName);
Expand Down
1 change: 1 addition & 0 deletions Assets/Metadata/CoreLib.Audio.asset
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ MonoBehaviour:
guid: 5b8fa4658f2c4485bf8456cc8b789182
name: CoreLib.Audio
skipSafetyChecks: 0
disableScripts: 0
accessesExtraAssemblies: 1
disableHarmonyPatching: 0
requiredOn: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/Resources/SpriteAssetManifest.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MonoBehaviour:
m_Name: SpriteAssetManifest
m_EditorClassIdentifier:
spriteAssets:
- {fileID: 11400000, guid: 9e5aa8becaff59e40b5758e408e72387, type: 2}
- {fileID: 11400000, guid: d6d36324533a3a14092a17ce22ea322a, type: 2}
- {fileID: 11400000, guid: b05d94f23f54e82429431780ad02a96e, type: 2}
- {fileID: 11400000, guid: 18ee6ee5463d288409e5abde9e80fc0e, type: 2}
gradientMaps: []
transformAnimations: []
Loading

0 comments on commit 2f5a77d

Please sign in to comment.