Example #1
0
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                BufferAccessor <SkillBuffer>   skillBufffers = chunk.GetBufferAccessor(SkillBufferChunk);
                BufferAccessor <EFFECT_BUFFER> effectBuffers = chunk.GetBufferAccessor(EffectBufferChunk);
                NativeArray <Target>           targets       = chunk.GetNativeArray(TargetChunk);

                EffectContextWriter.PrepareChunk(chunk);

                ConsumerWriter.BeginForEachIndex(chunkIndex);
                for (int entityIndex = 0; entityIndex < chunk.Count; ++entityIndex)
                {
                    NativeArray <SkillBuffer>   SkillBufferArray  = skillBufffers[entityIndex].AsNativeArray();
                    NativeArray <EFFECT_BUFFER> effectBufferArray = effectBuffers[entityIndex].AsNativeArray();
                    for (int skillIndex = 0; skillIndex < SkillBufferArray.Length; ++skillIndex)
                    {
                        Skill Skill = SkillBufferArray[skillIndex];
                        if (Skill.State != SkillState.Active)
                        {
                            continue;
                        }
                        for (int effectIndex = 0; effectIndex < effectBufferArray.Length; effectIndex++)
                        {
                            EFFECT_BUFFER EffectBuffer = effectBufferArray[effectIndex];
                            if (EffectBuffer.SkillIndex != skillIndex)
                            {
                                continue;
                            }

                            EffectContextWriter.WriteContextualizedEffect(entityIndex, ref ConsumerWriter, EffectBuffer.Effect, targets[entityIndex].Value);
                        }
                    }
                }
                ConsumerWriter.EndForEachIndex();
            }
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                BufferAccessor <AbilityBuffer> abilityBufffers = chunk.GetBufferAccessor(AbilityBufferChunk);
                BufferAccessor <EFFECT_BUFFER> effectBuffers   = chunk.GetBufferAccessor(EffectBufferChunk);
                NativeArray <Target>           targets         = chunk.GetNativeArray(TargetChunk);
                NativeArray <Entity>           entities        = chunk.GetNativeArray(EntityChunk);

                EffectContextWriter.PrepareChunk(chunk);

                ConsumerWriter.BeginForEachIndex(chunkIndex);
                for (int entityIndex = 0; entityIndex < chunk.Count; ++entityIndex)
                {
                    NativeArray <AbilityBuffer> AbilityBufferArray = abilityBufffers[entityIndex].AsNativeArray();
                    NativeArray <EFFECT_BUFFER> effectBufferArray  = effectBuffers[entityIndex].AsNativeArray();
                    for (int abilityIndex = 0; abilityIndex < AbilityBufferArray.Length; ++abilityIndex)
                    {
                        Ability Ability = AbilityBufferArray[abilityIndex];
                        if (Ability.State != AbilityState.Active)
                        {
                            continue;
                        }
                        for (int effectIndex = 0; effectIndex < effectBufferArray.Length; effectIndex++)
                        {
                            EFFECT_BUFFER EffectBuffer = effectBufferArray[effectIndex];
                            if (EffectBuffer.AbilityIndex != abilityIndex)
                            {
                                continue;
                            }

                            EffectContextWriter.WriteContextualizedEffect(entityIndex, ref ConsumerWriter, EffectBuffer.Effect, EffectBuffer.Effect.Affects == EffectAffectType.Target ? targets[entityIndex].Value : entities[effectIndex]);
                        }
                    }
                }
                ConsumerWriter.EndForEachIndex();
            }