Skip to content

Instantly share code, notes, and snippets.

@SiunCyclone
Last active June 2, 2020 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiunCyclone/24bb702dab0abe9a6145a71c490f950c to your computer and use it in GitHub Desktop.
Save SiunCyclone/24bb702dab0abe9a6145a71c490f950c to your computer and use it in GitHub Desktop.
class GraphInstance : IAnimGraphInstance, IGraphLogic {
public GraphInstance(EntityManager entityManager, Entity owner, PlayableGraph graph, Entity animStateOwner,
AnimGraph_Stack graphAsset) {
for (var i = 0; i < graphAsset.rootNodes.Count; i++) {
var subGraph = graphAsset.rootNodes[i].Instatiate(entityManager, owner, graph, animStateOwner);
subGraph.SetPlayableInput(0, m_RootPlayable, 0);
var outputPort = 0;
subGraph.GetPlayableOutput(0, ref m_RootPlayable, ref outputPort);
var animStackEntry = new AnimStackEntry() {
subGraph = subGraph,
graphLogic = subGraph as IGraphLogic
};
m_subGraphs.Add(animStackEntry);
}
}
public void Shutdown() {
for (var i = 0; i < m_subGraphs.Count; i++) {
m_subGraphs[i].subGraph.Shutdown();
}
}
public void SetPlayableInput(int index, Playable playable, int playablePort) { }
public void GetPlayableOutput(int index, ref Playable playable, ref int playablePort) {
playable = m_RootPlayable;
playablePort = 0;
}
public void UpdateGraphLogic(GameTime time, float deltaTime) {
for (var i = 0; i < m_subGraphs.Count; i++) {
if (m_subGraphs[i].graphLogic == null)
continue;
m_subGraphs[i].graphLogic.UpdateGraphLogic(time, deltaTime);
}
}
public void ApplyPresentationState(GameTime time, float deltaTime) {
for (var i = 0; i < m_subGraphs.Count; i++) {
m_subGraphs[i].subGraph.ApplyPresentationState(time, deltaTime);
}
}
struct AnimStackEntry {
public IAnimGraphInstance subGraph;
public IGraphLogic graphLogic;
}
Playable m_RootPlayable;
List<AnimStackEntry> m_subGraphs = new List<AnimStackEntry>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment