From aa947eaba1d3cafc716e59fe041ff8168080a533 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 2 Oct 2021 00:01:47 +0200 Subject: [PATCH] Update to Techblox 2021.09.27.15.17 Fixed block name print regex Made Game.WorkshopId obsolete as it's removed from the game Fixed removing blocks --- TechbloxModdingAPI/App/Game.cs | 21 +++---------------- TechbloxModdingAPI/App/GameMenuEngine.cs | 4 ++-- TechbloxModdingAPI/Blocks/BlockIDs.cs | 6 +++++- .../Blocks/Engines/RemovalEngine.cs | 4 ++-- .../Tests/TechbloxModdingAPIPluginTest.cs | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index 18e62bd..5a9cccc 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -233,8 +233,7 @@ namespace TechbloxModdingAPI.App { // this likely breaks things GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, - GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, value, - GameMode.SaveGameDetails.WorkshopId); + GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, value); } } } @@ -244,30 +243,16 @@ namespace TechbloxModdingAPI.App /// In most cases this is invalid and returns 0, so this can be ignored. /// /// The workshop identifier. + [Obsolete] public ulong WorkshopId { get { - if (!VerifyMode()) return 0uL; - if (menuMode) return 0uL; // MyGames don't have workshop IDs - return GameMode.SaveGameDetails.WorkshopId; + return 0uL; // Not supported anymore } set { - VerifyMode(); - if (menuMode) - { - // MyGames don't have workshop IDs - // menuEngine.GetGameInfo(EGID).GameName.Set(value); - } - else - { - // this likely breaks things - GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, - GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, - GameMode.SaveGameDetails.Folder, value); - } } } diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 86f622b..9d8e448 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -79,11 +79,11 @@ namespace TechbloxModdingAPI.App return EnterGame(mgdes.GameName, mgdes.SavedGamePath); } - public bool EnterGame(string gameName, string path, ulong workshopId = 0uL, bool autoEnterSim = false) + public bool EnterGame(string gameName, string path, bool autoEnterSim = false) { GameMode.CurrentMode = autoEnterSim ? RCXMode.Play : RCXMode.Build; GameMode.SaveGameDetails = new SaveGameDetails(MachineStorageId.CreateNew().ToString(), - SaveGameMode.NewSave, gameName, path, workshopId); + SaveGameMode.NewSave, gameName, path); // the private FullGameCompositionRoot.SwitchToGame() method gets passed to menu items for this reason AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, Array.Empty()); return true; diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 415e7ec..09016aa 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -163,6 +163,10 @@ namespace TechbloxModdingAPI.Blocks TruckArchSingleFlare, FormulaWheel = 270, FormulaWheelRear, - FormulaSeat = 277 + FormulaSeat = 277, + MonsterTruckWheel = 285, + MonsterTruckEngine = 290, + MonsterTruckWheelRigNoSteering = 350, + MonsterTruckWheelRigWithSteering, } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs index 4a0ea5b..7999443 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs @@ -23,8 +23,8 @@ namespace TechbloxModdingAPI.Blocks.Engines return false; var connections = entitiesDB.QueryEntity(target); var groups = entitiesDB.FindGroups(); - using var connStructMapper = - entitiesDB.QueryNativeMappedEntities(groups, Allocator.Temp); + using var connStructMapper = //The allocator needs to be persistent because that's what is used in the Dispose() method + entitiesDB.QueryNativeMappedEntities(groups, Allocator.Persistent); for (int i = connections.connections.Count() - 1; i >= 0; i--) _connectionFactory.RemoveConnection(connections, i, connStructMapper); _entityFunctions.RemoveEntity(target); diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index f6dba81..32ef656 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -268,7 +268,7 @@ namespace TechbloxModdingAPI.Tests string name = LocalizationService.Localize(data.CubeNameKey).Replace(" ", ""); foreach (var rkv in toReplace) { - name = Regex.Replace(name, "([^A-Za-z])" + rkv.Key + "([^A-Za-z])", "$1" + rkv.Value + "$2"); + name = Regex.Replace(name, rkv.Key + "([A-Z]|$)", rkv.Value + "$1"); } Console.WriteLine($"{name}{(currentKey != lastKey + 1 ? $" = {currentKey}" : "")},"); lastKey = currentKey;