A game about forced loneliness, made by TACStudios
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4
5namespace Unity.VisualScripting
6{
7 [UnitCategory("Graphs/Graph Nodes")]
8 public abstract class GetGraphs<TGraph, TGraphAsset, TMachine> : Unit
9 where TGraph : class, IGraph, new()
10 where TGraphAsset : Macro<TGraph>
11 where TMachine : Machine<TGraph, TGraphAsset>
12 {
13 /// <summary>
14 /// The GameObject to retrieve the graphs from.
15 /// </summary>
16 [DoNotSerialize]
17 [PortLabelHidden]
18 [NullMeansSelf]
19 public ValueInput gameObject { get; protected set; }
20
21 /// <summary>
22 /// The graph that is set on the GameObject.
23 /// </summary>
24 [DoNotSerialize]
25 [PortLabel("Graphs")]
26 [PortLabelHidden]
27 public ValueOutput graphList { get; protected set; }
28
29 protected override void Definition()
30 {
31 gameObject = ValueInput<GameObject>(nameof(gameObject), null).NullMeansSelf();
32 graphList = ValueOutput(nameof(graphList), Get);
33 }
34
35 List<TGraphAsset> Get(Flow flow)
36 {
37 var go = flow.GetValue<GameObject>(gameObject);
38 return go.GetComponents<TMachine>()
39 .Where(machine => go.GetComponent<TMachine>().nest.macro != null)
40 .Select(machine => machine.nest.macro)
41 .ToList();
42 }
43 }
44}