Example #1
0
            public void Execute(int i)
            {
                var pos          = local_to_world_list_[i].Value.c3.xyz;
                var td           = trail_data_list_[i];
                var trail_points = trail_points_list_[i];

                // flow
                for (var j = 0; j < trail_points.Length; ++j)
                {
                    var tp = trail_points[j];
                    tp.position_.z += flow_z_;
                    trail_points[j] = tp;
                }

                var index = td.trail_head_index_;

                if (current_time_ - td.last_update_index_time_ > 1f / 60f)
                {
                    ++index;
                    if (index >= TrailConfig.NODE_NUM)
                    {
                        index = 0;
                    }
                    td.trail_head_index_       = index;
                    td.last_update_index_time_ = current_time_;
                    trail_data_list_[i]        = td;
                }

                var prev_idx = td.trail_head_index_ - 1;

                if (prev_idx < 0)
                {
                    prev_idx = TrailConfig.NODE_NUM - 1;
                }
                var prev_pos = trail_points[prev_idx].position_;
                var normal   = math.normalize(pos - prev_pos);

                trail_points[index] = new TrailPoint {
                    position_ = pos, normal_ = normal,
                };
            }
Example #2
0
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            var data = new TrailComponent {
                ColorBitPattern = Utility.ConvColorBitPattern(in color),
            };

            dstManager.AddComponentData(entity, data);

            DynamicBuffer <TrailPoint> buf = dstManager.AddBuffer <TrailPoint>(entity);

            for (var i = 0; i < buf.Length; ++i)
            {
                buf[i] = new TrailPoint {
                    Position = float3.zero,
                };
            }

            dstManager.RemoveComponent(entity, typeof(Unity.Transforms.Translation));
            dstManager.RemoveComponent(entity, typeof(Unity.Transforms.Rotation));
            dstManager.RemoveComponent(entity, typeof(Unity.Transforms.LocalToWorld));
        }