diff --git a/Fushigi/course/CourseArea.cs b/Fushigi/course/CourseArea.cs index 44df50db..0c032d03 100644 --- a/Fushigi/course/CourseArea.cs +++ b/Fushigi/course/CourseArea.cs @@ -73,7 +73,7 @@ public void Load() if (root.ContainsKey("Links")) { BymlArrayNode? linksArray = root["Links"] as BymlArrayNode; - mLinkHolder = new(linksArray, mActorHolder); + mLinkHolder = new(linksArray); } else { @@ -83,7 +83,7 @@ public void Load() if (root.ContainsKey("SimultaneousGroups")) { BymlArrayNode? groupsArray = root["SimultaneousGroups"] as BymlArrayNode; - mGroups = new CourseGroupHolder(groupsArray, mActorHolder); + mGroups = new CourseGroupHolder(groupsArray); } else { diff --git a/Fushigi/course/CourseGroup.cs b/Fushigi/course/CourseGroup.cs index c6a26c7a..e658d2d3 100644 --- a/Fushigi/course/CourseGroup.cs +++ b/Fushigi/course/CourseGroup.cs @@ -10,7 +10,7 @@ namespace Fushigi.course { public class CourseGroup { - public CourseGroup(BymlHashTable table, CourseActorHolder actorHolder) + public CourseGroup(BymlHashTable table) { mHash = BymlUtil.GetNodeData(table["Hash"]); @@ -18,7 +18,7 @@ public CourseGroup(BymlHashTable table, CourseActorHolder actorHolder) foreach (BymlBigDataNode node in groups.Array) { - mActors.Add(actorHolder[node.Data]); + mActorHashes.Add(node.Data); } } @@ -29,12 +29,12 @@ public ulong GetHash() public bool IsActorValid(ulong hash) { - return mActors.Any(a => a.GetHash() == hash); + return mActorHashes.Any(a => a == hash); } public bool TryGetIndexOfActor(ulong hash, out int index) { - index = mActors.FindIndex(a => a.GetHash() == hash); + index = mActorHashes.FindIndex(a => a == hash); return index != -1; } @@ -43,29 +43,24 @@ public BymlHashTable BuildNode() BymlHashTable tableNode = new(); tableNode.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Hash", mHash), "Hash"); - BymlArrayNode actorsArray = new((uint)mActors.Count); + BymlArrayNode actorsArray = new((uint)mActorHashes.Count); - foreach (CourseActor actor in mActors) + foreach (ulong actor in mActorHashes) { - /* there are levels that were created in non-legit editors and that caused some things to be null when they should not have been */ - if (actor == null) - { - continue; - } - actorsArray.AddNodeToArray(BymlUtil.CreateNode("", actor.GetHash())); + actorsArray.AddNodeToArray(BymlUtil.CreateNode("", actor)); } tableNode.AddNode(BymlNodeId.Array, actorsArray, "Actors"); return tableNode; } - public List GetActors() + public List GetActors() { - return mActors; + return mActorHashes; } ulong mHash; - List mActors = new(); + List mActorHashes = new(); } public class CourseGroupHolder @@ -75,11 +70,11 @@ public CourseGroupHolder() } - public CourseGroupHolder(BymlArrayNode array, CourseActorHolder actorHolder) + public CourseGroupHolder(BymlArrayNode array) { foreach (BymlHashTable tbl in array.Array) { - mGroups.Add(new CourseGroup(tbl, actorHolder)); + mGroups.Add(new CourseGroup(tbl)); } } diff --git a/Fushigi/course/CourseLink.cs b/Fushigi/course/CourseLink.cs index b7d60cc8..b85669b3 100644 --- a/Fushigi/course/CourseLink.cs +++ b/Fushigi/course/CourseLink.cs @@ -13,58 +13,35 @@ public class CourseLink { public CourseLink(string linkName) { + mSource = 0; + mDest = 0; mLinkName = linkName; } - public CourseLink(BymlHashTable table, CourseActorHolder actorHolder) + public CourseLink(BymlHashTable table) { - mSource = actorHolder[BymlUtil.GetNodeData(table["Src"])]; - mDest = actorHolder[BymlUtil.GetNodeData(table["Dst"])]; + mSource = BymlUtil.GetNodeData(table["Src"]); + mDest = BymlUtil.GetNodeData(table["Dst"]); mLinkName = BymlUtil.GetNodeData(table["Name"]); } public BymlHashTable BuildNode() { BymlHashTable tbl = new(); - tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Dst", mDest.GetHash()), "Dst"); + tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Dst", mDest), "Dst"); tbl.AddNode(BymlNodeId.String, BymlUtil.CreateNode("Name", mLinkName), "Name"); - tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Src", mSource.GetHash()), "Src"); + tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Src", mSource), "Src"); return tbl; } public ulong GetSrcHash() { - if (mSource == null) - { - return 0; - } - - return mSource.GetHash(); + return mSource; } public ulong GetDestHash() { - if (mDest == null) - { - return 0; - } - - return mDest.GetHash(); - } - - public void SetSrcHash(ulong hash, CourseActorHolder actorHolder) - { - mSource = actorHolder[hash]; - } - - public void SetDestHash(ulong hash, CourseActorHolder actorHolder) - { - mDest = actorHolder[hash]; - } - - public bool AreLinksValid(CourseActorHolder actorHolder) - { - return actorHolder.HasHash(mSource.GetHash()) && actorHolder.HasHash(mDest.GetHash()); + return mDest; } public string GetLinkName() @@ -72,28 +49,8 @@ public string GetLinkName() return mLinkName; } - public bool IsSourceValid(CourseActorHolder actorHolder) - { - return actorHolder.HasHash(mSource.GetHash()); - } - - public bool IsDestValid(CourseActorHolder actorHolder) - { - return actorHolder.HasHash(mDest.GetHash()); - } - - public bool IsSourceActorExist() - { - return mSource != null; - } - - public bool IsDestActorExist() - { - return mDest != null; - } - - CourseActor? mSource; - CourseActor? mDest; + public ulong mSource; + public ulong mDest; string mLinkName; } @@ -104,11 +61,11 @@ public CourseLinkHolder() } - public CourseLinkHolder(BymlArrayNode linkArray, CourseActorHolder actorHolder) + public CourseLinkHolder(BymlArrayNode linkArray) { foreach (BymlHashTable tbl in linkArray.Array) { - mLinks.Add(new CourseLink(tbl, actorHolder)); + mLinks.Add(new CourseLink(tbl)); } } @@ -193,29 +150,13 @@ public List GetLinks() return mLinks; } - public bool IsAnyLinkInvalid(CourseActorHolder holder) - { - foreach (CourseLink link in mLinks) - { - if (!link.IsSourceValid(holder) || !link.IsDestValid(holder)) - { - return true; - } - } - - return false; - } - public BymlArrayNode SerializeToArray() { BymlArrayNode node = new(); foreach(CourseLink link in mLinks) { - if (link.IsSourceActorExist() && link.IsDestActorExist()) - { - node.AddNodeToArray(link.BuildNode()); - } + node.AddNodeToArray(link.BuildNode()); } return node; diff --git a/Fushigi/course/CourseRail.cs b/Fushigi/course/CourseRail.cs index 23edd8fd..270b430c 100644 --- a/Fushigi/course/CourseRail.cs +++ b/Fushigi/course/CourseRail.cs @@ -379,9 +379,9 @@ public class CourseActorToRailLinks { struct Link { - public CourseActor? Source; - public CourseRail? Dest; - public CourseRail.CourseRailPoint? Point; + public ulong Source; + public ulong Dest; + public ulong Point; public string Name; } @@ -395,9 +395,9 @@ public CourseActorToRailLinks(BymlArrayNode array, CourseActorHolder actorHolder string name = BymlUtil.GetNodeData(railLink["Name"]); Link link = new(); - link.Source = actorHolder[sourceHash]; - link.Dest = railHolder[destHash]; - link.Point = link.Dest[pointHash]; + link.Source = sourceHash; + link.Dest = destHash; + link.Point = pointHash; link.Name = name; mLinks.Add(link); @@ -414,7 +414,7 @@ public void RemoveLinkFromSrc(ulong hash) int idx = -1; foreach (Link link in mLinks) { - if (link.Source.GetHash() == hash) + if (link.Source == hash) { idx = mLinks.IndexOf(link); break; @@ -434,10 +434,10 @@ public BymlArrayNode SerializeToArray() foreach (Link link in mLinks) { BymlHashTable tbl = new(); - tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Dst", link.Dest.GetHash()), "Dst"); + tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Dst", link.Dest), "Dst"); tbl.AddNode(BymlNodeId.String, BymlUtil.CreateNode("Name", link.Name), "Name"); - tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Point", link.Point.GetHash()), "Point"); - tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Src", link.Source.GetHash()), "Src"); + tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Point", link.Point), "Point"); + tbl.AddNode(BymlNodeId.UInt64, BymlUtil.CreateNode("Src", link.Source), "Src"); node.AddNodeToArray(tbl); } diff --git a/Fushigi/ui/CourseAreaEditContext.cs b/Fushigi/ui/CourseAreaEditContext.cs index 7d7b871e..d2ae7a28 100644 --- a/Fushigi/ui/CourseAreaEditContext.cs +++ b/Fushigi/ui/CourseAreaEditContext.cs @@ -198,11 +198,6 @@ public bool IsActorDestForLink(CourseActor actor) return area.mLinkHolder.GetLinkWithDestHash(actor.GetHash()) != null; } - public bool IsAnyLinkInvalid() - { - return area.mLinkHolder.IsAnyLinkInvalid(area.mActorHolder); - } - public void AddLink(CourseLink link) { Console.WriteLine($"Adding Link: Source: {link.GetSrcHash()} -- Dest: {link.GetDestHash()}"); diff --git a/Fushigi/ui/widgets/LevelViewport.cs b/Fushigi/ui/widgets/LevelViewport.cs index d00d4ff1..ce653c26 100644 --- a/Fushigi/ui/widgets/LevelViewport.cs +++ b/Fushigi/ui/widgets/LevelViewport.cs @@ -419,7 +419,7 @@ Click on any actor to delete it. { CurCourseLink = new(mNewLinkType); CourseActor selActor = mEditContext.GetSelectedObjects().ElementAt(0); - CurCourseLink.SetSrcHash(selActor.GetHash(), mEditContext.GetActorHolder()); + CurCourseLink.mSource = selActor.GetHash(); mIsLinkNew = false; } @@ -431,7 +431,7 @@ Click on any actor to delete it. /* new links have a destination of 0 because there is no hash associated with a null actor */ bool isNewLink = CurCourseLink.GetDestHash() == 0; ulong hash = hoveredActor.GetHash(); - CurCourseLink.SetDestHash(hash, mEditContext.GetActorHolder()); + CurCourseLink.mDest = hash; if (isNewLink) {