private PlayerDeath_PlayStateRuntime CreateGraph(Entity entity, [NotNull] ProcessDefaultAnimationGraph graphSystem, ref Rig rig, ref PlayerDeath_PlayClipRuntime animation) { var set = graphSystem.Set; var data = new PlayerDeath_PlayStateRuntime { ClipPlayerNode = set.Create <ClipPlayerNode>(), DeltaTimeNode = set.Create <ConvertDeltaTimeToFloatNode>(), EntityNode = set.CreateComponentNode(entity), }; set.Connect(data.EntityNode, data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Input); set.Connect(data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Float, data.ClipPlayerNode, ClipPlayerNode.KernelPorts.DeltaTime); set.Connect(data.ClipPlayerNode, ClipPlayerNode.KernelPorts.Output, data.EntityNode, NodeSetAPI.ConnectionType.Feedback); set.SetData(data.ClipPlayerNode, ClipPlayerNode.KernelPorts.Speed, 1.0f); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Configuration, new ClipConfiguration { Mask = ClipConfigurationMask.LoopTime }); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Rig, rig); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Clip, animation.clip); return(data); }
/// <summary> /// The graph executes in the ProcessDefaultAnimationGraph system, but because we connect an EntityNode to the output of the ClipPlayerNode, /// the AnimatedData buffer gets updated on the entity and can be used in other systems, such as the ProcessLateAnimationGraph system. /// </summary> /// <param name="entity">An entity that has a PlayClipComponent and a Rig.</param> /// <param name="graphSystem">The ProcessDefaultAnimationGraph.</param> /// <param name="rig">The rig that will get animated.</param> /// <param name="playClip">The clip to play.</param> /// <returns>Returns a StateComponent containing the NodeHandles of the graph.</returns> static RotatingCube_PlayClipStateComponent CreateGraph( Entity entity, ProcessDefaultAnimationGraph graphSystem, ref Rig rig, ref RotatingCube_PlayClipComponent playClip) { GraphHandle graph = graphSystem.CreateGraph(); var data = new RotatingCube_PlayClipStateComponent { Graph = graph, ClipPlayerNode = graphSystem.CreateNode <ClipPlayerNode>(graph) }; var deltaTimeNode = graphSystem.CreateNode <ConvertDeltaTimeToFloatNode>(graph); var entityNode = graphSystem.CreateNode(graph, entity); var set = graphSystem.Set; // Connect kernel ports set.Connect(entityNode, deltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Input); set.Connect(deltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Output, data.ClipPlayerNode, ClipPlayerNode.KernelPorts.DeltaTime); set.Connect(data.ClipPlayerNode, ClipPlayerNode.KernelPorts.Output, entityNode, NodeSetAPI.ConnectionType.Feedback); // Send messages to set parameters on the ClipPlayerNode set.SetData(data.ClipPlayerNode, ClipPlayerNode.KernelPorts.Speed, 1.0f); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Configuration, new ClipConfiguration { Mask = ClipConfigurationMask.LoopTime }); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Rig, rig); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Clip, playClip.Clip); return(data); }
protected override void OnCreate() { _endSimulationEntityCommandBufferSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>(); _graphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); _graphSystem.AddRef(); _graphSystem.Set.RendererModel = NodeSet.RenderExecutionModel.Islands; }
private void DestroyGraph(Entity entity, [NotNull] ProcessDefaultAnimationGraph graphSystem, ref PlayerDeath_PlayStateRuntime data) { var set = graphSystem.Set; set.Destroy(data.EntityNode); set.Destroy(data.DeltaTimeNode); set.Destroy(data.ClipPlayerNode); EntityManager.RemoveComponent <PlayerDeath_PlayStateRuntime>(entity); }
protected override void OnCreate() { //will probably create the system since we are updating before DefaultAnimationSystemGroup and ProcessDefaultAnimationGraph update in group. _animationGraphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); // Increase the reference count on the graph system so it knows // that we want to use it _animationGraphSystem.AddRef(); _ecbSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>(); //Connected components in the graph will be executed in one job. _animationGraphSystem.Set.RendererModel = NodeSet.RenderExecutionModel.Islands; }
protected override void OnCreate() { base.OnCreate(); m_GraphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); // Increase the reference count on the graph system so it knows // that we want to use it. m_GraphSystem.AddRef(); m_ECBSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>(); m_AnimationDataQuery = GetEntityQuery(new EntityQueryDesc() { None = new ComponentType[] { typeof(RotatingCube_PlayClipComponent) }, All = new ComponentType[] { typeof(RotatingCube_PlayClipStateComponent) } }); m_GraphSystem.Set.RendererModel = NodeSet.RenderExecutionModel.Islands; }
protected override void OnCreate() { base.OnCreate(); _graphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); _graphSystem.AddRef(); _ecBSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>(); //Used for destroying the graph and see if any entity has graph is so destroy. _animationDataQuery = GetEntityQuery(new EntityQueryDesc { All = new ComponentType[] { typeof(PlayerDeath_PlayStateRuntime) }, None = new ComponentType[] { typeof(PlayerDeath_PlayClipRuntime) } }); _graphSystem.Set.RendererModel = NodeSet.RenderExecutionModel.Islands; }
private void DestroyGraph(Entity e, [NotNull] ProcessDefaultAnimationGraph graphSystem, ref PlayerShootReloadDataRuntime data) { if (!EntityManager.HasComponent <PlayerShootReloadClipNodeBuffer>(e)) { throw new InvalidExpressionException("entity missing PlayerShootReloadDataAssetRuntime"); } var set = graphSystem.Set; var clipNodeBuffer = EntityManager.GetBuffer <PlayerShootReloadClipNodeBuffer>(e); for (byte i = 0; i < clipNodeBuffer.Length; i++) { set.Destroy(clipNodeBuffer[i].ClipNode); } EntityManager.RemoveComponent <PlayerShootReloadClipNodeBuffer>(e); set.Destroy(data.ComponentNode); set.Destroy(data.DeltaTimeNode); set.Destroy(data.MixerNode); }
private static SimpleAnimationGraphData CreateGraph( EntityManager entityManager, Entity entity, ProcessDefaultAnimationGraph graphSystem, in SimpleAnimation simpleAnimation,
protected override void OnCreate() { m_GraphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); }
//protected EndSimulationEntityCommandBufferSystem _ecbSystem; protected sealed override void OnCreate() { base.OnCreate(); GraphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); //_ecbSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>(); }
private void CreateGraph(Entity e, ref Rig rig, ProcessDefaultAnimationGraph graphSystem) { if (!EntityManager.HasComponent <ShootReload_PlayClipBuffer>(e)) { return; } var ecb = _endSimulationEntityCommandBufferSystem.CreateCommandBuffer(); var set = graphSystem.Set; var data = new PlayerShootReloadDataRuntime(); data.DeltaTimeNode = set.Create <ConvertDeltaTimeToFloatNode>(); data.ComponentNode = set.CreateComponentNode(e); var clipBuffer = EntityManager.GetBuffer <ShootReload_PlayClipBuffer>(e); Assert.AreNotEqual(clipBuffer.Length, 0); var clipPlayerNodes = new NativeArray <NodeHandle <ClipPlayerNode> >(clipBuffer.Length, Allocator.Temp); data.MixerNode = set.Create <MixerNode>(); clipPlayerNodes[0] = set.Create <ClipPlayerNode>(); clipPlayerNodes[1] = set.Create <ClipPlayerNode>(); set.SetData(clipPlayerNodes[0], ClipPlayerNode.KernelPorts.Speed, 1.0f); set.SetData(clipPlayerNodes[1], ClipPlayerNode.KernelPorts.Speed, 1.0f); set.Connect(data.ComponentNode, data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Input); set.Connect(data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Float, clipPlayerNodes[0], ClipPlayerNode.KernelPorts.DeltaTime); set.Connect(data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Float, clipPlayerNodes[1], ClipPlayerNode.KernelPorts.DeltaTime); set.Connect(clipPlayerNodes[0], ClipPlayerNode.KernelPorts.Output, data.MixerNode, MixerNode.KernelPorts.Input0); set.Connect(clipPlayerNodes[1], ClipPlayerNode.KernelPorts.Output, data.MixerNode, MixerNode.KernelPorts.Input1); //set.Connect(set.Create<BlendNode>(), BlendNode.KernelPorts.Weight, data.MixerNode, MixerNode.KernelPorts.Weight); set.Connect(data.MixerNode, MixerNode.KernelPorts.Output, data.ComponentNode, NodeSetAPI.ConnectionType.Feedback); set.SendMessage(clipPlayerNodes[0], ClipPlayerNode.SimulationPorts.Configuration, new ClipConfiguration { Mask = ClipConfigurationMask.LoopTime }); set.SendMessage(clipPlayerNodes[1], ClipPlayerNode.SimulationPorts.Configuration, new ClipConfiguration { Mask = ClipConfigurationMask.LoopTime }); set.SendMessage(clipPlayerNodes[0], ClipPlayerNode.SimulationPorts.Rig, rig); set.SendMessage(clipPlayerNodes[1], ClipPlayerNode.SimulationPorts.Rig, rig); set.SendMessage(clipPlayerNodes[0], ClipPlayerNode.SimulationPorts.Clip, clipBuffer[0].Clip); set.SendMessage(clipPlayerNodes[1], ClipPlayerNode.SimulationPorts.Clip, clipBuffer[1].Clip); set.SendMessage(data.MixerNode, MixerNode.SimulationPorts.Rig, rig); set.SetData(data.MixerNode, MixerNode.KernelPorts.Weight, 0); var clipNodeBuffer = ecb.AddBuffer <PlayerShootReloadClipNodeBuffer>(e); for (byte i = 0; i < clipPlayerNodes.Length; i++) { clipNodeBuffer.Add(new PlayerShootReloadClipNodeBuffer { ClipNode = clipPlayerNodes[i] }); } ecb.AddComponent(e, data); }
protected override void OnStartRunning() { m_GraphSystem = World.GetOrCreateSystem <ProcessDefaultAnimationGraph>(); m_LastTriggerTime = Time.ElapsedTime; TriggerBlend(); }