Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UFrameIT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FrameIT
UFrameIT
Commits
419ec29c
Commit
419ec29c
authored
2 years ago
by
Tobias Schöner
Browse files
Options
Downloads
Patches
Plain Diff
fix: FactExplorer use factState methods for getting child and parent facts
parent
ec7f833d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/Scripts/UI/FactExplorer/FactExplorer.cs
+3
-31
3 additions, 31 deletions
Assets/Scripts/UI/FactExplorer/FactExplorer.cs
with
3 additions
and
31 deletions
Assets/Scripts/UI/FactExplorer/FactExplorer.cs
+
3
−
31
View file @
419ec29c
...
@@ -51,27 +51,13 @@ public void Initialize(Fact fact, Vector3 factPosition)
...
@@ -51,27 +51,13 @@ public void Initialize(Fact fact, Vector3 factPosition)
#
region
Implementation
#
region
Implementation
private
List
<
Fact
>
GetParentFacts
()
private
List
<
Fact
>
GetParentFacts
()
{
{
//TODO: TSC how to get all current facts without this dumb workaround
_
=
StageStatic
.
stage
.
factState
.
safe_dependencies
(
mainFact
.
Id
,
out
var
parentFactIds
);
var
allFacts
=
DisplayFacts
.
displayedFacts
.
Values
.
Select
(
x
=>
x
.
GetComponent
<
FactWrapper
>().
fact
);
return
parentFactIds
.
Distinct
().
Select
(
factId
=>
StageStatic
.
stage
.
factState
[
factId
]).
Where
(
f
=>
f
!=
mainFact
).
ToList
();
List
<
Fact
>
_parentFacts
=
new
();
// get all facts that reference the mainFact
foreach
(
Fact
f
in
allFacts
)
if
(
GetReferencedPids
(
f
).
Contains
(
mainFact
.
Id
))
// if f contains reference to mainFact
_parentFacts
.
Add
(
f
);
return
_parentFacts
;
}
}
private
List
<
Fact
>
GetChildFacts
()
private
List
<
Fact
>
GetChildFacts
()
{
{
List
<
Fact
>
childFacts
=
new
();
return
mainFact
.
getDependentFactIds
().
Distinct
().
Select
(
factId
=>
StageStatic
.
stage
.
factState
[
factId
]).
ToList
();
// get all properties of Type mainFactType that are strings and start with "pid"
foreach
(
string
factId
in
GetReferencedPids
(
mainFact
))
childFacts
.
Add
(
StageStatic
.
stage
.
factState
[
factId
]);
return
childFacts
;
}
}
private
void
UpdateFactExplorerUI
()
private
void
UpdateFactExplorerUI
()
...
@@ -175,18 +161,4 @@ private void SpawnChildLines(GameObject parent, Transform mainFactUI)
...
@@ -175,18 +161,4 @@ private void SpawnChildLines(GameObject parent, Transform mainFactUI)
});
});
}
}
#
endregion
Spawner
#
endregion
Spawner
#
region
Helper
/// <summary>
/// Check all fields of a Fact for references to other facts and return their ids
/// </summary>
/// <param name="f"></param>
/// <returns>An Enumerable containing the ids of facts referenced by the input fact</returns>
private
static
IEnumerable
<
string
>
GetReferencedPids
(
Fact
f
)
{
return
(
f
.
GetType
().
GetFields
()
.
Where
(
field
=>
field
.
FieldType
==
typeof
(
string
)
&&
field
.
Name
.
ToLower
().
StartsWith
(
"pid"
))
).
Select
(
fi
=>
(
string
)
fi
.
GetValue
(
f
));
}
#
endregion
Helper
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment