Skip to content

Commit

Permalink
Display item box doubles and singles by themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
KillzXGaming committed May 9, 2022
1 parent 72a079a commit ba44e3a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Plugins/TurboLibrary/Actors/ActorModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public virtual void UpdateModel(BfresRender render) {
Transform = render.Transform;
}

public virtual void Reload()
{

}

public override void BeginFrame()
{
UpdateCalc = true;
Expand Down
22 changes: 18 additions & 4 deletions Plugins/TurboLibrary/Actors/MapObjItemBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class MapObjItemBox : ActorModelBase
{
BfresSkeletalAnim IdleAnimation { get; set; }

public bool IsDouble => this.Parameters[0] == 1;

public MapObjItemBox()
{

Expand All @@ -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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ba44e3a

Please sign in to comment.