public override void Update(float delta, float total) { base.Update(delta, total); time_t position = m_audio?.Position ?? 0; m_judge.Position = position; m_highwayControl.Position = position; m_playback.Position = position; float GetPathValueLerped(int stream) { var s = m_playback.Chart[stream]; var mrPoint = s.MostRecent <PathPointEvent>(position); if (mrPoint == null) { return(((PathPointEvent)s.FirstObject)?.Value ?? 0); } if (mrPoint.HasNext) { float alpha = (float)((position - mrPoint.AbsolutePosition).Seconds / (mrPoint.Next.AbsolutePosition - mrPoint.AbsolutePosition).Seconds); return(MathL.Lerp(mrPoint.Value, ((PathPointEvent)mrPoint.Next).Value, alpha)); } else { return(mrPoint.Value); } } m_highwayControl.MeasureDuration = m_chart.ControlPoints.MostRecent(position).MeasureDuration; float leftLaserPos = GetTempRollValue(position, 6, out float leftLaserRange); float rightLaserPos = GetTempRollValue(position, 7, out float rightLaserRange, true); m_highwayControl.LeftLaserInput = leftLaserPos; m_highwayControl.RightLaserInput = rightLaserPos; m_highwayControl.Zoom = GetPathValueLerped(StreamIndex.Zoom); m_highwayControl.Pitch = GetPathValueLerped(StreamIndex.Pitch); m_highwayControl.Offset = GetPathValueLerped(StreamIndex.Offset); m_highwayControl.Roll = GetPathValueLerped(StreamIndex.Roll); m_highwayView.PlaybackPosition = position; for (int i = 0; i < 8; i++) { bool active = m_streamHasActiveEffects[i] && m_activeObjects[i] != null; if (i == 6) { active |= m_streamHasActiveEffects[i + 1] && m_activeObjects[i + 1] != null; } m_audioController.SetEffectActive(i, active); } UpdateEffects(); m_audioController.EffectsActive = true; m_highwayControl.Update(Time.Delta); m_highwayControl.ApplyToView(m_highwayView); for (int i = 0; i < 8; i++) { var obj = m_activeObjects[i]; m_highwayView.SetStreamActive(i, m_streamHasActiveEffects[i]); m_debugOverlay?.SetStreamActive(i, m_streamHasActiveEffects[i]); if (obj == null) { continue; } float glow = -0.5f; int glowState = 0; if (m_streamHasActiveEffects[i]) { glow = MathL.Cos(10 * MathL.TwoPi * (float)position) * 0.35f; glowState = 2 + MathL.FloorToInt(position.Seconds * 20) % 2; } m_highwayView.SetObjectGlow(obj, glow, glowState); } m_highwayView.Update(); { var camera = m_highwayView.Camera; var defaultTransform = m_highwayView.DefaultTransform; var defaultZoomTransform = m_highwayView.DefaultZoomedTransform; var totalWorldTransform = m_highwayView.WorldTransform; var critLineTransform = m_highwayView.CritLineTransform; Vector2 comboLeft = camera.Project(defaultTransform, new Vector3(-0.8f / 6, 0, 0)); Vector2 comboRight = camera.Project(defaultTransform, new Vector3(0.8f / 6, 0, 0)); m_comboDisplay.DigitSize = (comboRight.X - comboLeft.X) / 4; Vector2 critRootPosition = camera.Project(critLineTransform, Vector3.Zero); Vector2 critRootPositionWest = camera.Project(critLineTransform, new Vector3(-1, 0, 0)); Vector2 critRootPositionEast = camera.Project(critLineTransform, new Vector3(1, 0, 0)); Vector2 critRootPositionForward = camera.Project(critLineTransform, new Vector3(0, 0, -1)); float GetCursorPosition(float xWorld) { var critRootCenter = camera.Project(defaultZoomTransform, Vector3.Zero); var critRootCursor = camera.Project(defaultZoomTransform, new Vector3(xWorld, 0, 0)); return(critRootCursor.X - critRootCenter.X); } m_critRoot.LeftCursorPosition = GetCursorPosition((leftLaserPos - 0.5f) * 5.0f / 6 * leftLaserRange); m_critRoot.RightCursorPosition = GetCursorPosition(-(rightLaserPos - 0.5f) * 5.0f / 6 * rightLaserRange); Vector2 critRotationVector = critRootPositionEast - critRootPositionWest; float critRootRotation = MathL.Atan(critRotationVector.Y, critRotationVector.X); //m_critRoot.Roll = m_highwayView.LaserRoll; //m_critRoot.EffectRoll = m_highwayControl.EffectRoll; //m_critRoot.EffectOffset = m_highwayControl.EffectOffset; m_critRoot.Position = critRootPosition; m_critRoot.Rotation = MathL.ToDegrees(critRootRotation) + m_highwayControl.CritLineEffectRoll * 25; } m_background.HorizonHeight = m_highwayView.HorizonHeight; m_background.Update(delta, total); }
public override void Update(float delta, float total) { time_t audioPosition = m_audio?.Position ?? 0; time_t visualPosition = audioPosition - m_visualOffset; m_audioPlayback.Position = audioPosition; m_judge.Position = audioPosition; m_visualPlayback.Position = visualPosition; m_highwayControl.Position = visualPosition; //Logger.Log($"{ m_visualPlayback.ViewDistanceForward } / { m_visualPlayback.ViewDistanceForward }"); float GetPathValueLerped(time_t pos, HybridLabel stream) { var s = m_audioPlayback.Chart[stream]; var mrPoint = s.MostRecent <GraphPointEvent>(pos); if (mrPoint == null) { return(((GraphPointEvent?)s.First)?.Value ?? 0); } if (mrPoint.HasNext) { float alpha = (float)((pos - mrPoint.AbsolutePosition).Seconds / (mrPoint.Next.AbsolutePosition - mrPoint.AbsolutePosition).Seconds); return(MathL.Lerp(mrPoint.Value, ((GraphPointEvent)mrPoint.Next).Value, alpha)); } else { return(mrPoint.Value); } } for (int i = 0; i < m_queuedSlamSamples.Count;) { time_t slam = m_queuedSlamSamples[i]; if (slam < audioPosition) { m_queuedSlamSamples.RemoveAt(i); m_slamSample.Replay(); } else { i++; } } for (int e = 0; e < m_queuedSlamTiedEvents.Count;) { var evt = m_queuedSlamTiedEvents[e]; if (evt.AbsolutePosition < visualPosition) { switch (evt) { case SpinImpulseEvent spin: m_highwayControl.ApplySpin(spin.Params, visualPosition); break; case SwingImpulseEvent swing: m_highwayControl.ApplySwing(swing.Params, visualPosition); break; case WobbleImpulseEvent wobble: m_highwayControl.ApplyWobble(wobble.Params, visualPosition); break; default: e++; continue; } m_queuedSlamTiedEvents.RemoveAt(e); } else { e++; } } time_t laserAnticipateLookAhead = visualPosition + m_chart.ControlPoints.MostRecent(visualPosition).MeasureDuration * 0.5; time_t laserSlamSwingDuration = 0.15; for (int i = 0; i < 2; i++) { m_laserInputs[i] = i; // 0 or 1, default values for each side var currentLaser = m_chart[i + 6].MostRecent <AnalogEntity>(visualPosition); if (currentLaser == null || visualPosition > currentLaser.AbsoluteEndPosition) { float inputValue = m_laserInputs[i]; if (currentLaser is { } slam&& slam.IsInstant && visualPosition <= slam.AbsoluteEndPosition + laserSlamSwingDuration) { inputValue = slam.FinalValue; } var checkAnalog = m_chart[i + 6].MostRecent <AnalogEntity>(laserAnticipateLookAhead)?.Head; while (checkAnalog != null && checkAnalog.HasPrevious && checkAnalog.Previous is AnalogEntity pAnalog && (pAnalog = pAnalog.Head).AbsolutePosition > visualPosition) { checkAnalog = pAnalog; } if (checkAnalog != null && checkAnalog.AbsolutePosition > visualPosition) { if (i == 0) { inputValue = MathL.Max(checkAnalog !.InitialValue, inputValue); } else { inputValue = MathL.Min(checkAnalog !.InitialValue, inputValue); } } m_laserInputs[i] = inputValue; } else { m_laserInputs[i] = currentLaser.SampleValue(visualPosition); } } m_highwayControl.MeasureDuration = m_chart.ControlPoints.MostRecent(visualPosition).MeasureDuration; m_highwayControl.LeftLaserInput = m_laserInputs[0]; m_highwayControl.RightLaserInput = 1 - m_laserInputs[1]; m_highwayControl.Zoom = GetPathValueLerped(visualPosition, NscLane.CameraZoom); //m_highwayControl.Zoom = 0; m_highwayControl.Pitch = GetPathValueLerped(visualPosition, NscLane.CameraPitch); //m_highwayControl.Pitch = m_tempPitch; //Console.WriteLine(m_tempPitch); m_highwayControl.Offset = GetPathValueLerped(visualPosition, NscLane.CameraOffset); m_highwayControl.Roll = GetPathValueLerped(visualPosition, NscLane.CameraTilt); m_highwayView.Split0 = GetPathValueLerped(visualPosition, NscLane.Split2); m_highwayView.Split1 = GetPathValueLerped(visualPosition, NscLane.Split2); m_highwayView.Split2 = GetPathValueLerped(visualPosition, NscLane.Split2); m_highwayView.Split3 = GetPathValueLerped(visualPosition, NscLane.Split2); m_highwayView.Split4 = GetPathValueLerped(visualPosition, NscLane.Split2); for (int i = 0; i < 8; i++) { var judge = m_judge[i]; m_streamHasActiveEffects[i] = judge.IsBeingPlayed; } for (int i = 0; i < 8; i++) { bool active = m_streamHasActiveEffects[i] && m_activeObjects[i] != null; if (i == 6) { active |= m_streamHasActiveEffects[i + 1] && m_activeObjects[i + 1] != null; } m_audioController.SetEffectActive(i, active); } UpdateEffects(); m_audioController.EffectsActive = true; m_highwayControl.Update(Time.Delta); m_highwayControl.ApplyToView(m_highwayView); for (int i = 0; i < 8; i++) { var obj = m_activeObjects[i]; m_highwayView.SetStreamActive(i, m_streamHasActiveEffects[i]); if (obj == null) { continue; } float glow = -0.5f; int glowState = 0; if (m_streamHasActiveEffects[i]) { glow = MathL.Cos(10 * MathL.TwoPi * (float)visualPosition) * 0.35f; glowState = 2 + MathL.FloorToInt(visualPosition.Seconds * 20) % 2; } m_highwayView.SetObjectGlow(obj, glow, glowState); } const float SCALING = 1.05f; if (Window.Width > Window.Height) { m_highwayView.Viewport = ((int)(Window.Width - Window.Height * SCALING) / 2, (int)(Window.Height * 0.95f - Window.Height * SCALING), (int)(Window.Height * SCALING)); } else { m_highwayView.Viewport = (0, (Window.Height - Window.Width) / 2 - Window.Width / 5, Window.Width); } m_highwayView.Update(); { //var camera = m_highwayView.Camera; var defaultTransform = m_highwayView.DefaultTransform; var defaultZoomTransform = m_highwayView.DefaultZoomedTransform; var totalWorldTransform = m_highwayView.WorldTransform; var critLineUiTransform = m_highwayView.CritLineTransform; Vector2 comboLeft = m_highwayView.Project(defaultTransform, new Vector3(-0.8f / 6, 0, 0)); Vector2 comboRight = m_highwayView.Project(defaultTransform, new Vector3(0.8f / 6, 0, 0)); m_comboDisplay.DigitSize = (comboRight.X - comboLeft.X) / 4; Vector2 critRootUiPosition = m_highwayView.Project(critLineUiTransform, Vector3.Zero); Vector2 critRootUiPositionWest = m_highwayView.Project(critLineUiTransform, new Vector3(-1, 0, 0)); Vector2 critRootUiPositionEast = m_highwayView.Project(critLineUiTransform, new Vector3(1, 0, 0)); Vector2 critRootPositionForward = m_highwayView.Project(critLineUiTransform, new Vector3(0, 0, -1)); Vector2 critRootWorldPosition = m_highwayView.Project(totalWorldTransform, Vector3.Zero); Vector2 critRootWorldPositionWest = m_highwayView.Project(totalWorldTransform, new Vector3(-1, 0, 0)); Vector2 critRootWorldPositionEast = m_highwayView.Project(totalWorldTransform, new Vector3(1, 0, 0)); for (int i = 0; i < 2; i++) { if (m_cursorsActive[i]) { m_cursorAlphas[i] = MathL.Min(1, m_cursorAlphas[i] + delta * 3); } else { m_cursorAlphas[i] = MathL.Max(0, m_cursorAlphas[i] - delta * 5); } } void GetCursorPosition(int lane, out float pos, out float range) { var judge = (LaserJudge)m_judge[lane + 6]; pos = judge.CursorPosition; range = judge.LaserRange; } float GetCursorPositionWorld(float xWorld) { var critRootCenter = m_highwayView.Project(defaultZoomTransform, Vector3.Zero); var critRootCursor = m_highwayView.Project(defaultZoomTransform, new Vector3(xWorld, 0, 0)); return(critRootCursor.X - critRootCenter.X); } GetCursorPosition(0, out float leftLaserPos, out float leftLaserRange); GetCursorPosition(1, out float rightLaserPos, out float rightLaserRange); float critRootWorldWidth = (m_highwayView.Project(defaultZoomTransform, new Vector3(-0.5f, 0, 0)) - m_highwayView.Project(defaultZoomTransform, new Vector3(0.5f, 0, 0))).Length(); m_critRootWorld.WorldUnitSize = critRootWorldWidth; m_critRootWorld.LeftCursorPosition = 2 * (leftLaserPos - 0.5f) * (5.0f / 6) * leftLaserRange; m_critRootWorld.LeftCursorAlpha = m_cursorAlphas[0]; m_critRootWorld.RightCursorPosition = 2 * (rightLaserPos - 0.5f) * (5.0f / 6) * rightLaserRange; m_critRootWorld.RightCursorAlpha = m_cursorAlphas[1]; Vector2 critUiRotationVector = critRootUiPositionEast - critRootUiPositionWest; float critRootUiRotation = MathL.Atan(critUiRotationVector.Y, critUiRotationVector.X); Vector2 critWorldRotationVector = critRootWorldPositionEast - critRootWorldPositionWest; float critRootWorldRotation = MathL.Atan(critWorldRotationVector.Y, critWorldRotationVector.X); m_critRootUi.Position = critRootUiPosition; m_critRootWorld.Position = critRootWorldPosition; m_critRootUi.Rotation = MathL.ToDegrees(critRootUiRotation) + m_highwayControl.CritLineEffectRoll * 25; m_critRootWorld.Rotation = MathL.ToDegrees(critRootWorldRotation); } m_background.HorizonHeight = m_highwayView.HorizonHeight; m_background.CombinedTilt = m_highwayControl.LaserRoll + m_highwayControl.Roll * 360; m_background.EffectRotation = m_highwayControl.EffectRoll * 360; m_background.SpinTimer = m_highwayControl.SpinTimer; m_background.SwingTimer = m_highwayControl.SwingTimer; m_background.Update(delta, total); SetLuaDynamicData(); //m_script.Update(delta, total); base.Update(delta, total); }