예제 #1
0
        public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
        {
            if (!state.playing || state.deltaTime == 0)
            {
                return;
            }

            float threshold = vfxValues.GetFloat(velocityThresholdPropertyId);

            Vector3 pos  = vfxValues.GetVector3(positionPropertyId);
            float   dist = Vector3.Magnitude(m_OldPosition - pos);

            if (threshold <= 0.0f || dist < threshold * state.deltaTime)
            {
                float count = dist * vfxValues.GetFloat(ratePerUnitPropertyId);
                if (vfxValues.GetBool(clampToOnePropertyId))
                {
                    count = Mathf.Min(count, 1.0f);
                }
                state.spawnCount += count;

                state.vfxEventAttribute.SetVector3(oldPositionAttributeId, m_OldPosition);
                state.vfxEventAttribute.SetVector3(positionAttributeId, pos);
            }
            m_OldPosition = pos;
        }
예제 #2
0
        public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
        {
            cachedSqrThreshold  = vfxValues.GetFloat(velocityThresholdPropertyId);
            cachedSqrThreshold *= cachedSqrThreshold;

            cachedRatePerSqrUnit  = vfxValues.GetFloat(ratePerUnitPropertyId);
            cachedRatePerSqrUnit *= cachedRatePerSqrUnit;

            if (!state.playing || state.deltaTime == 0)
            {
                return;
            }

            Vector3 pos         = vfxValues.GetVector3(positionPropertyId);
            float   sqrDistance = Vector3.SqrMagnitude(m_OldPosition - pos);

            if (sqrDistance < cachedSqrThreshold * state.deltaTime)
            {
                state.spawnCount += sqrDistance * cachedRatePerSqrUnit;

                state.vfxEventAttribute.SetVector3(oldPositionAttributeId, m_OldPosition);
                state.vfxEventAttribute.SetVector3(positionAttributeId, pos);
            }
            m_OldPosition = pos;
        }
 public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     if (state.deltaTime != 0.0f)
     {
         s_UpdateCount++;
         s_LastDeltaTime = state.deltaTime;
     }
 }
예제 #4
0
 public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     // Evaluate Loop Count only when hitting start;
     // LoopCount < 0 means infinite mode
     // LoopCount == 0 means no spawn
     m_LoopMaxCount        = vfxValues.GetInt(loopCountPropertyID);
     m_WaitingForTotalTime = vfxValues.GetFloat(loopDurationPropertyID);
     m_LoopCurrentIndex    = 0;
     if (m_LoopMaxCount == m_LoopCurrentIndex)
     {
         state.playing = false;
     }
 }
        public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
        {
            var a = vfxValues.GetGradient("dummyZ");

            if (a != null)
            {
                state.spawnCount = 123.0f;
            }
            else
            {
                state.spawnCount = 456.0f;
            }
        }
예제 #6
0
    public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
    {
        Vector3 checkPosition = vfxValues.GetVector3(CheckPositionID);
        float   maxDistance   = vfxValues.GetFloat(MaxDistanceID);
        bool    InvertCheck   = vfxValues.GetBool(InvertCheckID);
        Vector3 position      = state.vfxEventAttribute.GetVector3(AttribPositionID);

        bool test = (checkPosition - position).sqrMagnitude > (maxDistance * maxDistance);

        if (test != InvertCheck)
        {
            state.spawnCount = 0;
        }
    }
예제 #7
0
 public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     if (m_LoopCurrentIndex != m_LoopMaxCount && state.totalTime > m_WaitingForTotalTime)
     {
         if (state.playing)
         {
             m_WaitingForTotalTime = state.totalTime + vfxValues.GetFloat(delayPropertyID);
             state.playing         = false;                                                   //We are in playing state, if m_LoopCurrentIndex + 1 == m_LoopMaxCount, we have finished here
             m_LoopCurrentIndex    = m_LoopCurrentIndex + 1 > 0 ? m_LoopCurrentIndex + 1 : 0; //It's possible to count to infinite if m_LoopMaxCount < 0, this ternary avoid stop going back to zero
         }
         else
         {
             m_WaitingForTotalTime = vfxValues.GetFloat(loopDurationPropertyID);
             state.totalTime       = 0.0f;
             state.playing         = true; //We are in not playing state, we was waiting for the moment when restart will be launch
         }
     }
 }
예제 #8
0
        public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
        {
            if (m_RemainingLoops == int.MinValue)
            {
                m_RemainingLoops = vfxValues.GetInt(numLoopsPropertyID);
            }

            if (state.totalTime > vfxValues.GetFloat(loopDurationPropertyID))
            {
                if (!m_Waiting)
                {
                    m_WaitTTL = vfxValues.GetFloat(delayPropertyID);
                    m_Waiting = true;
                }
                else
                {
                    m_WaitTTL -= state.deltaTime;

                    if (m_WaitTTL < 0.0f)
                    {
                        m_Waiting       = false;
                        state.totalTime = 0.0f;

                        if (m_RemainingLoops > 0) // if positive, remove one from count
                        {
                            m_RemainingLoops--;
                        }

                        if (m_RemainingLoops != 0)                         // if 0, stop forever
                        {
                            state.playing = true;                          // Re-enable the spawn context
                        }
                        m_RemainingLoops = Math.Max(-1, m_RemainingLoops); // sustain at -1 if in infinite mode
                    }
                    else
                    {
                        state.playing = false; // Stop the Spawn context for the duration of the delay
                    }
                }
            }
        }
예제 #9
0
        public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
        {
            if (state.totalTime < m_LastTime)
            {
                // We got reset shomehow (loop and delay?)
                Reset(vfxValues.GetFloat(startTimePropertyID), vfxValues.GetFloat(durationPropertyID), vfxValues.GetUInt(countPropertyID), state.totalTime);
            }

            if (state.deltaTime > 0.0f && m_Remaining >= 0 && state.totalTime > m_StartTime)
            {
                float frameRatio = Mathf.Clamp01((state.totalTime - m_StartTime) / state.deltaTime);  // How much of the entirety of a frame did we elapse
                float count      = Mathf.Min(m_Remaining, frameRatio * m_Rate * state.deltaTime);

                m_Remaining -= count;
                m_Incoming  += count;

                int toSpawn = (int)Mathf.Floor(m_Incoming);
                state.spawnCount += toSpawn;
                m_Incoming       -= toSpawn;
            }

            m_LastTime = state.totalTime;
        }
예제 #10
0
 public sealed override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     m_LoopCurrentIndex = m_LoopMaxCount;
 }
예제 #11
0
 public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     s_ReadTotalTimeThroughInput = vfxValues.GetFloat(s_totalTimeID);
     s_ReadInternalTotalTime     = state.totalTime;
 }
예제 #12
0
 public override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
 }
예제 #13
0
 public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     Reset(vfxValues.GetFloat(startTimePropertyID), vfxValues.GetFloat(durationPropertyID), vfxValues.GetUInt(countPropertyID));
 }
예제 #14
0
 public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     state.spawnCount = s_SpawnCount;
     state.totalTime  = vfxValues.GetFloat("totalTime");
     state.vfxEventAttribute.SetFloat("lifetime", s_LifeTime);
 }
예제 #15
0
 public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     state.spawnCount = Mathf.Min(state.spawnCount, vfxValues.GetUInt(maxSpawnPerFrameName));
 }
 public override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     m_Index = (m_Index + 1) % Math.Max(1, vfxValues.GetUInt(stripMaxCountID));
     state.vfxEventAttribute.SetUint(stripIndexID, m_Index);
 }
예제 #17
0
 public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     state.vfxEventAttribute.SetFloat(spawnTimeID, state.totalTime);
 }
예제 #18
0
 public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     m_OldPosition = vfxValues.GetVector3(positionPropertyId);
 }
예제 #19
0
 public sealed override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
 }
예제 #20
0
 public override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     s_ReceivedSpawnCount.Add((int)state.vfxEventAttribute.GetFloat(kSpawnCount));
 }