IEnumerator WaitForLoad() { while (!loaded) { obstaclePool = Resources.FindObjectsOfTypeAll <PlayerHeadAndObstacleInteraction>().FirstOrDefault()?.GetField <ObstacleController.Pool, PlayerHeadAndObstacleInteraction>("_obstaclePool"); playerController = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault(); if (obstaclePool == null || playerController == null) { yield return(new WaitForSeconds(0.1f)); } else { loaded = true; } } yield return(new WaitForSeconds(0.1f)); sabers = new Saber[2]; sabers[0] = playerController.leftSaber; sabers[1] = playerController.rightSaber; }
public override void BeatmapObjectSpawnCallback(BeatmapObjectData beatmapObjectData) { if (_disableSpawning) { return; } float num = _moveDistance / _moveSpeed; float num2 = _jumpDistance / _noteJumpMovementSpeed; if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Obstacle) { ObstacleData obstacleData = (ObstacleData)beatmapObjectData; Vector3 forward = transform.forward; Vector3 a = transform.position; a += forward * (_moveDistance + _jumpDistance * 0.5f); Vector3 a2 = a - forward * _moveDistance; Vector3 a3 = a - forward * (_moveDistance + _jumpDistance); Vector3 noteOffset = GetNoteOffset(beatmapObjectData.lineIndex, NoteLineLayer.Base); noteOffset.y = ((obstacleData.obstacleType != ObstacleType.Top) ? _verticalObstaclePosY : (_topObstaclePosY + _globalYJumpOffset)); ObstacleController.Pool pool = (obstacleData.obstacleType != ObstacleType.Top) ? _fullHeightObstaclePool : _topObstaclePool; ObstacleController obstacleController = pool.Spawn(); SetObstacleEventCallbacks(obstacleController); obstacleController.transform.SetPositionAndRotation(a + noteOffset, Quaternion.identity); obstacleController.Init(obstacleData, a + noteOffset, a2 + noteOffset, a3 + noteOffset, num, num2, beatmapObjectData.time - _spawnAheadTime, _noteLinesDistance); obstacleController.SetPrivateField("_playerController", owner); obstacleController.SetPrivateField("_audioTimeSyncController", onlineSyncController); obstacleController.finishedMovementEvent += ResetControllers; obstacleController.didDissolveEvent += ResetControllers; _activeObstacles.Add(obstacleController); } else { NoteData noteData = (NoteData)beatmapObjectData; Vector3 forward2 = transform.forward; Vector3 a4 = transform.position; a4 += forward2 * (_moveDistance + _jumpDistance * 0.5f); Vector3 a5 = a4 - forward2 * _moveDistance; Vector3 a6 = a4 - forward2 * (_moveDistance + _jumpDistance); if (noteData.noteLineLayer == NoteLineLayer.Top) { a6 += forward2 * _topLinesZPosOffset * 2f; } Vector3 noteOffset2 = GetNoteOffset(noteData.lineIndex, noteData.startNoteLineLayer); float jumpGravity = JumpGravityForLineLayer(noteData.noteLineLayer, noteData.startNoteLineLayer); if (noteData.noteType == NoteType.Bomb) { NoteController bombNoteController = _bombNotePool.Spawn(); SetNoteControllerEventCallbacks(bombNoteController); bombNoteController.transform.SetPositionAndRotation(a4 + noteOffset2, Quaternion.identity); bombNoteController.Init(noteData, a4 + noteOffset2, a5 + noteOffset2, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity); var noteJump = bombNoteController.GetComponent <NoteJump>(); noteJump.SetPrivateField("_playerController", owner); noteJump.SetPrivateField("_audioTimeSyncController", onlineSyncController); bombNoteController.GetComponent <NoteFloorMovement>().SetPrivateField("_audioTimeSyncController", onlineSyncController); bombNoteController.noteDidFinishJumpEvent += ResetControllers; bombNoteController.noteWasCutEvent += ResetControllersNoteWasCut; bombNoteController.noteDidDissolveEvent += ResetControllers; _activeNotes.Add(bombNoteController); } else if (noteData.noteType.IsBasicNote()) { NoteController.Pool pool2 = (noteData.noteType != NoteType.NoteA) ? _noteBPool : _noteAPool; NoteController basicNoteController = pool2.Spawn(); SetNoteControllerEventCallbacks(basicNoteController); Vector3 noteOffset3 = GetNoteOffset(noteData.flipLineIndex, noteData.startNoteLineLayer); basicNoteController.transform.SetPositionAndRotation(a4 + noteOffset3, Quaternion.identity); GameNoteController gameNoteController = basicNoteController as GameNoteController; if (gameNoteController != null) { gameNoteController.Init(noteData, a4 + noteOffset3, a5 + noteOffset3, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity, _disappearingArrows, _ghostNotes); } else { basicNoteController.Init(noteData, a4 + noteOffset3, a5 + noteOffset3, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity); } var noteJump = basicNoteController.GetComponent <NoteJump>(); noteJump.SetPrivateField("_playerController", owner); noteJump.SetPrivateField("_audioTimeSyncController", onlineSyncController); basicNoteController.GetComponent <NoteFloorMovement>().SetPrivateField("_audioTimeSyncController", onlineSyncController); basicNoteController.GetComponentsInChildren <BoxCollider>().First(x => x.name == "BigCuttable").size = _defaultBigCuttableSize * 1.65f; basicNoteController.GetComponentsInChildren <BoxCollider>().First(x => x.name == "SmallCuttable").size = _defaultSmallCuttableSize * 1.65f; basicNoteController.noteDidFinishJumpEvent += ResetControllers; basicNoteController.noteWasCutEvent += ResetControllersNoteWasCut; basicNoteController.noteDidDissolveEvent += ResetControllers; _prevSpawnedNormalNoteController = basicNoteController; _activeNotes.Add(basicNoteController); } } }
private static bool Prefix(BeatmapObjectSpawnController __instance, BeatmapObjectData beatmapObjectData, ref bool ____disableSpawning, ref float ____moveDistance, ref float ____moveSpeed, ref float ____jumpDistance, ref float ____noteJumpMovementSpeed, ref float ____topObstaclePosY, ref float ____globalYJumpOffset, ref float ____verticalObstaclePosY, ref ObstacleController.Pool ____obstaclePool, ref float ____spawnAheadTime, ref float ____noteLinesDistance, ref Action <BeatmapObjectSpawnController, ObstacleController> ___obstacleDiStartMovementEvent, ref float ____topLinesZPosOffset, ref NoteController.Pool ____bombNotePool, ref NoteController.Pool ____noteAPool, ref NoteController.Pool ____noteBPool, ref int ____numberOfSpawnedBasicNotes, ref float ____firstBasicNoteTime, ref NoteController ____prevSpawnedNormalNoteController, ref bool ____disappearingArrows, ref bool ____ghostNotes, ref Action <BeatmapObjectSpawnController, BeatmapObjectData, float, float> ___beatmapObjectWasSpawnedEvent, ref float ____topObstacleHeight, ref float ____verticalObstacleHeight) { if (!Plugin.active) { return(true); } float angleFloat; Quaternion angle = ExtraBeatmapData.beatmapObjectsAngles.TryGetValue(beatmapObjectData.id, out angleFloat) ? Quaternion.Euler(0f, angleFloat, 0f) : Quaternion.identity; if (____disableSpawning) { return(false); } float num2 = ____moveDistance / ____moveSpeed; float num3 = ____jumpDistance / ____noteJumpMovementSpeed; if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Obstacle) { ObstacleData obstacleData = (ObstacleData)beatmapObjectData; Vector3 forward = __instance.transform.forward; Vector3 vector = __instance.transform.position; vector += forward * (____moveDistance + ____jumpDistance * 0.5f); Vector3 vector2 = vector - forward * ____moveDistance; Vector3 vector3 = vector - forward * (____moveDistance + ____jumpDistance); Vector3 noteOffset = __instance.GetNoteOffset(beatmapObjectData.lineIndex, NoteLineLayer.Base); noteOffset.y = ((obstacleData.obstacleType == ObstacleType.Top) ? (____topObstaclePosY + ____globalYJumpOffset) : ____verticalObstaclePosY); float height = (obstacleData.obstacleType == ObstacleType.Top) ? ____topObstacleHeight : ____verticalObstacleHeight; ObstacleController obstacleController = ____obstaclePool.Spawn(); __instance.SetObstacleEventCallbacks(obstacleController); obstacleController.transform.SetPositionAndRotation(angle * (vector + noteOffset), angle); obstacleController.Init(obstacleData, angle * (vector + noteOffset), angle * (vector2 + noteOffset), angle * (vector3 + noteOffset), num2, num3, beatmapObjectData.time - ____spawnAheadTime, ____noteLinesDistance, height); ___obstacleDiStartMovementEvent?.Invoke(__instance, obstacleController); } else { NoteData noteData = (NoteData)beatmapObjectData; Vector3 forward2 = __instance.transform.forward; Vector3 vector4 = __instance.transform.position; vector4 += forward2 * (____moveDistance + ____jumpDistance * 0.5f); Vector3 vector5 = vector4 - forward2 * ____moveDistance; Vector3 vector6 = vector4 - forward2 * (____moveDistance + ____jumpDistance); if (noteData.noteLineLayer == NoteLineLayer.Top) { vector6 += forward2 * ____topLinesZPosOffset * 2f; } Vector3 noteOffset2 = __instance.GetNoteOffset(noteData.lineIndex, noteData.startNoteLineLayer); float jumpGravity = __instance.JumpGravityForLineLayer(noteData.noteLineLayer, noteData.startNoteLineLayer); if (noteData.noteType == NoteType.Bomb) { NoteController noteController = ____bombNotePool.Spawn(); __instance.SetNoteControllerEventCallbacks(noteController); noteController.transform.SetPositionAndRotation(angle * (vector4 + noteOffset2), angle); lastSpawnedObjectId = beatmapObjectData.id; noteController.Init(noteData, angle * (vector4 + noteOffset2), angle * (vector5 + noteOffset2), angle * (vector6 + noteOffset2), num2, num3, noteData.time - ____spawnAheadTime, jumpGravity); } else { if (noteData.noteType.IsBasicNote()) { MemoryPool <NoteController> memoryPool = (noteData.noteType == NoteType.NoteA) ? ____noteAPool : ____noteBPool; if (____numberOfSpawnedBasicNotes == 0) { ____firstBasicNoteTime = noteData.time; } bool isFirstNote = ____firstBasicNoteTime == noteData.time; NoteController noteController2 = memoryPool.Spawn(); __instance.SetNoteControllerEventCallbacks(noteController2); Vector3 noteOffset3 = __instance.GetNoteOffset(noteData.flipLineIndex, noteData.startNoteLineLayer); noteController2.transform.SetPositionAndRotation(angle * (vector4 + noteOffset3), angle); GameNoteController gameNoteController = noteController2 as GameNoteController; lastSpawnedObjectId = beatmapObjectData.id; if (gameNoteController != null) { gameNoteController.Init(noteData, angle * (vector4 + noteOffset3), angle * (vector5 + noteOffset3), angle * (vector6 + noteOffset2), num2, num3, noteData.time - ____spawnAheadTime, jumpGravity, ____disappearingArrows, ____ghostNotes && !isFirstNote); } else { noteController2.Init(noteData, angle * (vector4 + noteOffset3), angle * (vector5 + noteOffset3), angle * (vector6 + noteOffset2), num2, num3, noteData.time - ____spawnAheadTime, jumpGravity); } ____numberOfSpawnedBasicNotes++; if (____prevSpawnedNormalNoteController != null) { float time = ____prevSpawnedNormalNoteController.noteData.time; float time2 = noteController2.noteData.time; } ____prevSpawnedNormalNoteController = noteController2; } } } ___beatmapObjectWasSpawnedEvent?.Invoke(__instance, beatmapObjectData, num2, num3); return(false); }