MusicSpinner¶
A component meant to be attached on any GameObject via Unity, it will get a RigidBody component on its own on Start.
This component is only used in the BugariaTheater map to implement GameObjects spinning as a sound is played multiple times in succession with varying pitch and length as it is spinned using Beetle's Horn Slash field ability. When it has spun enough, an item is launched from it if it wasn't obtained already.
While it's only used there, it has several configurations available. Here are the public fields:
notes: The list of pitches and length of each times to play thesoundclipduring a full spinning cycle. Each x componets represents the timestamps the playback should happen in seconds and each y components represents the pitch to use for the playbackmaxtime: The maximum playback time of all thenotesin a full spinning cycle before restarting from the firstnoteselementspinlimit: The spin value requited (the value increases in increments ofspinhiteach Horn Slash) before the item spawns if it wasn't obtained alreadymaxspin: The maximum spin value (the value increases in increments ofspinhiteach Horn Slash)spinstop: An amount of frames that presents the value to decrease the spin value on each LateUpdate (the value increases in increments ofspinhiteach Horn Slash)spinhit: The increment to increase the spin value of thespinneron each Horn Slash (done on OnTriggerEnter with anyBeetleHorntagged colliders)musiclower: The volume multiplier to use as the destination of a lerp applied tomusic[0].volume on each LateUpdate while the music is playing (the lerp is done from the existing volume with a factor of the spin /maxspinwhere spin is clamped from 0.0 tomaxspinso it approaches the scaled volume more as the cylinder spins more). This is mostly used to fade the current music using a value between 0.0 and 1.0flag: A flag slot indicating if the item was obtained already (also bound to the NPCControl'sactivationflagof the created item when launched ifitemtypeisn't 3 so not a Crystal Berry). Ifitemtypeis 3 (Crystal Berry), this value is a crystalbflags insteaditemtype: The type of item launched from the cylinder:itemid: The item, medal id or crystalbflags of the launched item. NOTE: Ifitemtypeis 3 (Crystal Berry), this value MUST match theflagbecause they're both used differently, but represents the same thingitemtime: The amount of time in frames to spawn the item before it disappears. If it's -1.0, the item won't disappearitempos: The position to spawn the item before it is launchedbouncepos: The direction to launch the item once it is spawnedspinner: The list of GameObject to rotate using the spin value. All of them's isStatic will be set to false if they weren't when they spinrotation: The axis of rotate of eachspinneras they rotatesoundclip: The base sound to use to play thenotesmusicvolume: This field is UNUSED and it doesn't do anything.
On Start, the GameObject gets a Rigidbody component added without gravity in kinematic. Additionally, if the item hasn't been obtained yet and the Detector medal is equipped, MainManager.map.hiddenitem is set to 100 which lets the beeper sound play.
All the spinning and item spawning logic happens in LateUpdate and the logic to detect Horn Slash to start the spin happens in OnTriggerEnter where the collider has the BeetleHorn tag.