KeChancellor Posted July 1, 2024 Share Posted July 1, 2024 Hi guys from here: https://github.com/GhChancellor/Oni-DoorOverhaul/tree/main/Door Overhaul I built a new item, Work. ( PneumaticTrapDoor ) With a button at runtime, i create another PneumaticTrapDoor item but with a different recipe According to the logs, its seems to be working correctly but I have this error bye // class PneumaticTrapDoor.cs private void DuplicateDoor(string doorID) { try { PneumaticTrapDoor pneumaticTrapDoor = new PneumaticTrapDoor(); PneumaticTrapDoorManager pneumaticTrapDoorManager = new PneumaticTrapDoorManager(); pneumaticTrapDoorManager.Destroy(deconstructable); pneumaticTrapDoor.SetReplacement(true); // Create new BuildingDef and log its details BuildingDef newBuildingDef = pneumaticTrapDoor.CreateBuildingDef(); Debug.Log("DuplicateDoor - New BuildingDef created: " + newBuildingDef); Debug.Log("DuplicateDoor - New BuildingDef PrefabID: " + newBuildingDef.PrefabID); Debug.Log("DuplicateDoor - New BuildingDef ConstructionTime: " + newBuildingDef.ConstructionTime); // Add new BuildingDef to Assets if (!Assets.BuildingDefs.Contains(newBuildingDef)) { Assets.BuildingDefs.Add(newBuildingDef); Debug.Log("DuplicateDoor - New BuildingDef added to Assets."); } PlanScreen planScreen = PlanScreen.Instance; planScreen.CopyBuildingOrder(newBuildingDef, PneumaticTrapDoor.ID); } catch (Exception ex) { Debug.LogError("DuplicateDoor - Exception: " + ex.Message); } [13:22:39.984] [1] [INFO] PneumaticTrapDoor SetReplacement - True [13:22:39.985] [1] [INFO] PneumaticTrapDoor - _isReplacement before if - True [13:22:39.985] [1] [INFO] Replace - constructionMass: 5, constructionTime: 1 [13:22:39.985] [1] [INFO] PneumaticTrapDoor Replace - True [13:22:39.985] [1] [INFO] PneumaticTrapDoor - constructionTime 1 [13:22:39.985] [1] [INFO] PneumaticTrapDoor - Final constructionTime in BuildingDef: 1 [13:22:39.985] [1] [INFO] DuplicateDoor - New BuildingDef created: PneumaticTrapDoor (BuildingDef) [13:22:39.985] [1] [INFO] DuplicateDoor - New BuildingDef PrefabID: PneumaticTrapDoor [13:22:39.985] [1] [INFO] DuplicateDoor - New BuildingDef ConstructionTime: 1 [13:22:39.985] [1] [INFO] DuplicateDoor - New BuildingDef added to Assets. [13:22:39.995] [1] [ERROR] DuplicateDoor - Exception: The given key was not present in the dictionary. [13:22:40.005] [1] [INFO] Lele-DoorOverhaul's assembly declared the method Door_Overhaul.MoveButton:DuplicateDoor in the stack trace, adding to referenced mods list DuplicateDoor - Exception: The given key was not present in the dictionary. [13:22:40.126] [1] [INFO] Checking which steam branch we're on. Got: [] NullReferenceException: Object reference not set to an instance of an object at KPrefabIDExtensions.HasTag (UnityEngine.GameObject go, Tag tag) [0x00000] in <3d436e4ec1d5455793674ec559b0cc77>:0 at PlanScreen.GetBuildableStateForDef (BuildingDef def) [0x0002f] in <3d436e4ec1d5455793674ec559b0cc77>:0 at PlanScreen.RefreshBuildableStates (System.Boolean force_update) [0x00098] in <3d436e4ec1d5455793674ec559b0cc77>:0 at PlanScreen.ScreenUpdate (System.Boolean topLevel) [0x00007] in <3d436e4ec1d5455793674ec559b0cc77>:0 at KScreenManager.Update () [0x00030] in <3ca21dc18eae422d87255277091f8593>:0 Link to comment https://forums.kleientertainment.com/forums/topic/157792-copybuildingorder-runtime-duplication-of-an-existing-item/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.