public void Execute() { var bound1 = math.float2(-_screenAspect, -1); var bound2 = math.float2(+_screenAspect, +1); var actives = _info[0].ActiveCount; var written = 0; for (var i = 0; i < actives; i++) { var p = _bullets[i].Position; if (math.any(p < bound1)) { continue; } if (math.any(p > bound2)) { continue; } if (i != written) { _bullets[written] = _bullets[i]; } written++; } _info[0] = BulletGroupInfo.ChangeActiveCount(_info[0], written); }
void Start() { _bullets = new NativeArray <Bullet>(MaxBulletCount, Allocator.Persistent); _info = new NativeArray <BulletGroupInfo>(1, Allocator.Persistent); _info[0] = BulletGroupInfo.InitialState(); _mesh = new Mesh { indexFormat = IndexFormat.UInt32 }; _mesh.MarkDynamic(); }
public void Execute() { var seed = _info[0].SpawnCount + 1; var actives = _info[0].ActiveCount; var spawns = math.min(_bullets.Length - actives, _count); var hash = new Klak.Math.XXHash((uint)seed); for (var i = 0; i < spawns; i++) { var bulletTypeIndex = hash.Int(0, 6, 0u); _bullets[actives + i] = Bullet.Spawn(_position, seed + i, bulletTypeIndex); } _info[0] = BulletGroupInfo.AddActiveAndSpawnCount(_info[0], spawns); }