public void Execute(Entity ent, int index, [ReadOnly] ref PlayerShoot shoot, [ReadOnly] ref Translation pos, [ReadOnly] ref Rotation rotation) { // getting the right TimePassed DynamicBuffer <TimePassed> buffer = data.timePassedBuffers[ent]; TimePassed timePassed = buffer[shoot.timeIdx]; timePassed.time += data.dt; if (timePassed.time >= shoot.shotCooldown) { // get data to update the bubble with WaterShootData shootData = bubbleData[index]; shootData.timeHeld = math.min(timePassed.time - shoot.shotCooldown, maxChargeTime); shootData.maxChargeTime = maxChargeTime; shootData.position = pos.Value; shootData.initialScale = shoot.initialScale; shootData.initialColliderRadius = shoot.initialColliderRadius; shootData.bullet = shoot.bullet; shootData.topSpeed = bubbleBurstTopSpeed; if (data.shooting) { // create a new bubble if (shootData.state == WaterShootState.NotFired) { Entity bullet = data.CreateBullet(index, ref pos, ref rotation, shoot.bullet, 0); data.commandBuffer.AddComponent(index, bullet, new WaterShootIndex { index = index }); data.commandBuffer.AddComponent(index, bullet, new Scale { Value = .3f }); shootData.state = WaterShootState.JustFired; } else { shootData.state = WaterShootState.Charging; } } else { timePassed.time = shoot.shotCooldown; // bullet was updated last frame, so it exists and was charged, // so create burst of bullets if (shootData.state == WaterShootState.UpdatedCharging) { shootData.state = WaterShootState.Burst; } } bubbleData[index] = shootData; } buffer[shoot.timeIdx] = timePassed; }
public void Execute(Entity ent, int index, [ReadOnly] ref PlayerShoot shoot, [ReadOnly] ref Translation pos, [ReadOnly] ref Rotation rotation) { // getting the right TimePassed DynamicBuffer <TimePassed> buffer = data.timePassedBuffers[ent]; TimePassed timePassed = buffer[shoot.timeIdx]; timePassed.time += data.dt; // fire until below period if (data.shooting && timePassed.time > shoot.shotCooldown) { // shoot the pattern // buffers commands to do after thread completes data.CreateBullet(index, ref pos, ref rotation, shoot.bullet, 0); timePassed.time = 0; } buffer[shoot.timeIdx] = timePassed; }
public void Execute(Entity ent, int index, [ReadOnly] ref PlayerShoot shoot, [ReadOnly] ref Translation pos, [ReadOnly] ref Rotation rotation) { // getting the right TimePassed DynamicBuffer <TimePassed> buffer = data.timePassedBuffers[ent]; TimePassed timePassed = buffer[shoot.timeIdx]; timePassed.time += data.dt; // fire until below period if (data.shooting && timePassed.time > shoot.shotCooldown) { for (float angle = 0; angle < 2 * math.PI; angle += rnd.NextFloat(.3f, .5f)) { data.CreateBullet(index, ref pos, ref rotation, shoot.bullet, angle); } timePassed.time = 0; } buffer[shoot.timeIdx] = timePassed; }