src/core/WeaponSystem.js
/**
	* Changes the current weapon to one of the specified type.
	*
	* @param {WEAPON_TYPES} type - The weapon type.
	* @return {WeaponSystem} A reference to this weapon system.
	*/
Changes the current weapon to one of the specified type.
@param {WEAPON_TYPES} type - The weapon type.
@return {WeaponSystem} A reference to this weapon system.
Changes the current weapon to one of the specified type . @param { WEAPON_TYPES } type - The weapon type . @return { WeaponSystem } A reference to this weapon system .
changeWeapon( type ) {
		const weapon = this.weaponsMap.get( type );
		if ( weapon ) {
			this.currentWeapon = weapon;
			switch ( weapon.type ) {
				case WEAPON_TYPES_BLASTER:
					this.renderComponents.blaster.mesh.visible = true;
					this.renderComponents.shotgun.mesh.visible = false;
					this.renderComponents.assaultRifle.mesh.visible = false;
					if ( this.owner.isPlayer ) weapon.setRenderComponent( this.renderComponents.blaster.mesh, sync );
					break;
				case WEAPON_TYPES_SHOTGUN:
					this.renderComponents.blaster.mesh.visible = false;
					this.renderComponents.shotgun.mesh.visible = true;
					this.renderComponents.assaultRifle.mesh.visible = false;
					if ( this.owner.isPlayer ) weapon.setRenderComponent( this.renderComponents.shotgun.mesh, sync );
					break;
				case WEAPON_TYPES_ASSAULT_RIFLE:
					this.renderComponents.blaster.mesh.visible = false;
					this.renderComponents.shotgun.mesh.visible = false;
					this.renderComponents.assaultRifle.mesh.visible = true;
					if ( this.owner.isPlayer ) weapon.setRenderComponent( this.renderComponents.assaultRifle.mesh, sync );
					break;
				default:
					console.error( 'DIVE.WeaponSystem: Invalid weapon type:', type );
					break;
			}
		}
		return this;
	}
changeWeapon ( type ) { const weapon = this . weaponsMap . get ( type ) ; if ( weapon ) { this . currentWeapon = weapon ; switch ( weapon . type ) { case WEAPON_TYPES_BLASTER : this . renderComponents . blaster . mesh . visible = true ; this . renderComponents . shotgun . mesh . visible = false ; this . renderComponents . assaultRifle . mesh . visible = false ; if ( this . owner . isPlayer ) weapon . setRenderComponent ( this . renderComponents . blaster . mesh , sync ) ; break ; case WEAPON_TYPES_SHOTGUN : this . renderComponents . blaster . mesh . visible = false ; this . renderComponents . shotgun . mesh . visible = true ; this . renderComponents . assaultRifle . mesh . visible = false ; if ( this . owner . isPlayer ) weapon . setRenderComponent ( this . renderComponents . shotgun . mesh , sync ) ; break ; case WEAPON_TYPES_ASSAULT_RIFLE : this . renderComponents . blaster . mesh . visible = false ; this . renderComponents . shotgun . mesh . visible = false ; this . renderComponents . assaultRifle . mesh . visible = true ; if ( this . owner . isPlayer ) weapon . setRenderComponent ( this . renderComponents . assaultRifle . mesh , sync ) ; break ; default : console . error ( 'DIVE.WeaponSystem: Invalid weapon type:' , type ) ; break ; } } return this ; }
Changes the current weapon to one of the specified type.
Changes the current weapon to one of the specified type .
// adjust render components. only a single weapon can be visible