From 64b11c969b676f8d4a00c8cfc96f5de11dc9cd38 Mon Sep 17 00:00:00 2001 From: jupahe64 Date: Sat, 9 Mar 2024 14:42:06 +0100 Subject: [PATCH] support inheritance for ModelExpandParam and fix GoalPole visuals --- Fushigi/actor_pack/ActorPack.cs | 5 +++++ .../actor_pack/components/ModelExpandParam.cs | 15 +++++++++++++++ Fushigi/ui/widgets/LevelViewport.cs | 17 ++++++++++------- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Fushigi/actor_pack/ActorPack.cs b/Fushigi/actor_pack/ActorPack.cs index c1a4a1b6..374786c0 100644 --- a/Fushigi/actor_pack/ActorPack.cs +++ b/Fushigi/actor_pack/ActorPack.cs @@ -190,6 +190,11 @@ private void LoadComponents(SARC.SARC sarc, ActorParam param) break; case "ModelExpandRef": this.ModelExpandParamRef ??= BymlSerialize.Deserialize(data); + this.ModelExpandParamRef.LoadParentIfExists(filePath => + { + filePath = GetPathGyml(filePath); + return BymlSerialize.Deserialize(sarc.OpenFile(filePath)); + }); break; case "DrainPipeRef": this.DrainPipeRef ??= BymlSerialize.Deserialize(data); diff --git a/Fushigi/actor_pack/components/ModelExpandParam.cs b/Fushigi/actor_pack/components/ModelExpandParam.cs index d0a3d194..f5be8bae 100644 --- a/Fushigi/actor_pack/components/ModelExpandParam.cs +++ b/Fushigi/actor_pack/components/ModelExpandParam.cs @@ -1,4 +1,5 @@ using Fushigi.Byml.Serializer; +using Fushigi.SARC; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +12,20 @@ namespace Fushigi.actor_pack.components [Serializable] public class ModelExpandParam { + public void LoadParentIfExists(Func fileLoader) + { + if (ParentRef == null) + return; + + Parent = fileLoader(ParentRef); + Parent.LoadParentIfExists(fileLoader); + } + + [BymlProperty(Key = "$parent")] + public string? ParentRef { get; set; } + + public ModelExpandParam? Parent { get; set; } + public List Settings { get; set; } } diff --git a/Fushigi/ui/widgets/LevelViewport.cs b/Fushigi/ui/widgets/LevelViewport.cs index 1b7d01a6..5007e681 100644 --- a/Fushigi/ui/widgets/LevelViewport.cs +++ b/Fushigi/ui/widgets/LevelViewport.cs @@ -431,6 +431,7 @@ private void RenderActor(CourseActor actor, ModelInfo modelInfo) if(actor.mActorPack.ModelExpandParamRef != null) { ActorModelExpand(actor, model); + ActorModelExpand(actor, model, "Main"); //yeah idk either //TODO SubModels } @@ -510,15 +511,17 @@ private void ActorModelExpand(CourseActor actor, BfresRender.BfresModel model, s { //Model Expand Param - Debug.Assert(actor.mActorPack.ModelExpandParamRef.Settings.Count > 0); - - if (actor.mActorPack.ModelExpandParamRef.Settings.Count == 0) - return; - //TODO is that actually how the game does it? - var setting = actor.mActorPack.ModelExpandParamRef.Settings.FindLast(x=>x.mModelKeyName == modelKeyName); + var param = actor.mActorPack.ModelExpandParamRef; + ModelExpandParamSettings? setting = null; + do + { + if (param.Settings != null) + setting = param.Settings.FindLast(x => x.mModelKeyName == modelKeyName); + + param = param.Parent; + } while (setting == null && param != null); - //Debug.Assert(setting != null); if (setting == null) return;