Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
DonavinDraws committed Apr 11, 2024
2 parents 4af43ab + 64b11c9 commit 4e98e22
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Fushigi/actor_pack/ActorPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ private void LoadComponents(SARC.SARC sarc, ActorParam param)
break;
case "ModelExpandRef":
this.ModelExpandParamRef ??= BymlSerialize.Deserialize<ModelExpandParam>(data);
this.ModelExpandParamRef.LoadParentIfExists(filePath =>
{
filePath = GetPathGyml(filePath);
return BymlSerialize.Deserialize<ModelExpandParam>(sarc.OpenFile(filePath));
});
break;
case "DrainPipeRef":
this.DrainPipeRef ??= BymlSerialize.Deserialize<DrainPipe>(data);
Expand Down
15 changes: 15 additions & 0 deletions Fushigi/actor_pack/components/ModelExpandParam.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fushigi.Byml.Serializer;
using Fushigi.SARC;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -11,6 +12,20 @@ namespace Fushigi.actor_pack.components
[Serializable]
public class ModelExpandParam
{
public void LoadParentIfExists(Func<string, ModelExpandParam> 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<ModelExpandParamSettings> Settings { get; set; }
}

Expand Down
17 changes: 10 additions & 7 deletions Fushigi/ui/widgets/LevelViewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 4e98e22

Please sign in to comment.