import { Shape } from "../shape" ; import { MissionElementItem } from "../parsing/mis_parser" ; import { Util } from "../util" ; const GEM_COLORS = [ "blue" , "red" , "yellow" , "purple" , "green" , "turquoise" , "orange" , "black" ] ; /** Gems need to be collected before being able to finish. */ export class Gem extends Shape { dtsPath = "shapes/items/gem.dts" ; ambientRotate = true ; collideable = false ; pickedUp = false ; shareMaterials = false ; showSequences = false ; sounds = [ 'gotgem.wav' , 'gotallgems.wav' , 'missinggems.wav' ] ; constructor ( element ) { super ( ) ; let color = element . datablock . slice ( "GemItem" . length ) ; if ( color . length === 0 ) color = Gem . pickRandomColor ( ) ; this . matNamesOverride [ "base.gem" ] = color . toLowerCase ( ) + ".gem" ; } onMarbleInside ( t ) { if ( this . pickedUp ) return ; this . pickedUp = true ; this . setOpacity ( 0 ) ; this . level . pickUpGem ( t ) ; this . level . replay . recordMarbleInside ( this ) ; this . setCollisionEnabled ( false ) ; } reset ( ) { super . reset ( ) ; this . pickedUp = false ; this . setOpacity ( 1 ) ; this . setCollisionEnabled ( true ) ; } static pickRandomColor ( ) { return Util . randomFromArray ( GEM_COLORS ) ; } }