From ba44e3aaa246125296062631486e5cce684317aa Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Mon, 9 May 2022 18:01:23 -0400 Subject: [PATCH] Display item box doubles and singles by themselves --- Plugins/TurboLibrary/Actors/ActorModelBase.cs | 5 +++++ Plugins/TurboLibrary/Actors/MapObjItemBox.cs | 22 +++++++++++++++---- .../MapObjEditor/MapObjectToolMenu.cs | 3 ++- .../MapEditor/MapObjEditor/ObjectEditor.cs | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Plugins/TurboLibrary/Actors/ActorModelBase.cs b/Plugins/TurboLibrary/Actors/ActorModelBase.cs index 0543dfc..85bda40 100644 --- a/Plugins/TurboLibrary/Actors/ActorModelBase.cs +++ b/Plugins/TurboLibrary/Actors/ActorModelBase.cs @@ -44,6 +44,11 @@ public virtual void UpdateModel(BfresRender render) { Transform = render.Transform; } + public virtual void Reload() + { + + } + public override void BeginFrame() { UpdateCalc = true; diff --git a/Plugins/TurboLibrary/Actors/MapObjItemBox.cs b/Plugins/TurboLibrary/Actors/MapObjItemBox.cs index 8492fbf..d889cb4 100644 --- a/Plugins/TurboLibrary/Actors/MapObjItemBox.cs +++ b/Plugins/TurboLibrary/Actors/MapObjItemBox.cs @@ -13,6 +13,8 @@ public class MapObjItemBox : ActorModelBase { BfresSkeletalAnim IdleAnimation { get; set; } + public bool IsDouble => this.Parameters[0] == 1; + public MapObjItemBox() { @@ -24,17 +26,29 @@ public override void Init() //Add an addtional hardcoded skeletal animation for idle animations // IdleAnimation = CreateItemBoxIdle(Render.Name); - // ToggleMeshes(Render); + ToggleMeshes(Render); + } + + public override void Reload() + { + base.Reload(); + ToggleMeshes(Render); } private void ToggleMeshes(BfresRender render) { + //Need to make sure the item box actually contains doubles so the double param doesn't make it disappear + bool hasDoubleItemBox = render.Models.Any(x => x.Name.StartsWith("DoubleItemBox")); foreach (var model in render.Models) { - foreach (BfresMeshRender mesh in model.MeshList) + //Doubles + if (model.Name.StartsWith("DoubleItemBox")) + { + model.IsVisible = IsDouble; + } //Singles but file includes double item boxes + else if (hasDoubleItemBox) { - if (mesh.Name.StartsWith("DoubleItemBox")) - mesh.IsVisible = false; + model.IsVisible = !IsDouble; } } } diff --git a/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/MapObjectToolMenu.cs b/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/MapObjectToolMenu.cs index 5f8231c..34fa54f 100644 --- a/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/MapObjectToolMenu.cs +++ b/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/MapObjectToolMenu.cs @@ -26,6 +26,7 @@ private void RandomizeDoubleItemBoxes() { Random rnd = new Random(); + var node = new Toolbox.Core.ViewModels.NodeBase(); foreach (var obj in Editor.Root.Children) { var objData = obj.Tag as Obj; @@ -36,7 +37,7 @@ private void RandomizeDoubleItemBoxes() bool isDouble = rnd.Next(0, 2) != 0; objData.Params[0] = isDouble ? 1 : 0; - Console.WriteLine($"Randomized {objData.ObjId} {objData.Params[0]} "); + objData.NotifyPropertyChanged("Params"); } } } diff --git a/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/ObjectEditor.cs b/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/ObjectEditor.cs index 83b0432..145d913 100644 --- a/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/ObjectEditor.cs +++ b/Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/ObjectEditor.cs @@ -563,6 +563,7 @@ private EditableObject Create(Obj obj) //Update actor parameters into the actor class ((ActorModelBase)ActorInfo).Parameters = obj.Params; + ((ActorModelBase)ActorInfo).Reload(); //Update the view if properties are updated. GLContext.ActiveContext.UpdateViewport = true;