123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //TRANSMITTER BASE
- class TransmitterBase extends ItemTransmitter
- {
- //Sounds
- string SOUND_RADIO_TURNED_ON = "";
- protected EffectSound m_SoundLoop;
-
- // --- SYSTEM EVENTS
- override void OnStoreSave( ParamsWriteContext ctx )
- {
- super.OnStoreSave( ctx );
-
- //store tuned frequency
- ctx.Write( GetTunedFrequencyIndex() );
- }
-
- override bool OnStoreLoad( ParamsReadContext ctx, int version )
- {
- if ( !super.OnStoreLoad( ctx, version ) )
- return false;
-
- //--- Transmitter data ---
- //load and set tuned frequency
- int tuned_frequency_idx;
- if ( !ctx.Read( tuned_frequency_idx ) )
- {
- SetFrequencyByIndex( 0 ); //set default
- return false;
- }
- SetFrequencyByIndex( tuned_frequency_idx );
- //---
-
- return true;
- }
-
- override bool IsTransmitter()
- {
- return true;
- }
-
- //--- ACTIONS
- void SetNextFrequency( PlayerBase player = NULL )
- {
- SetNextChannel();
-
- /*
- if ( player )
- {
- DisplayRadioInfo( GetTunedFrequency().ToString(), player );
- }
- */
- }
-
- //--- HUD
- /*
- protected Hud GetHud( PlayerBase player )
- {
- if ( !player )
- {
- return NULL;
- }
-
- return player.m_Hud;
- }
-
- void DisplayRadioInfo( string message, PlayerBase player )
- {
- Hud hud;
- if ( player )
- {
- hud = GetHud( player );
- }
-
- if ( hud )
- {
- hud.SetWalkieTalkieText( message );
- hud.ShowWalkieTalkie( 3 );
- }
- }
- */
-
- //--- POWER EVENTS
- override void OnSwitchOn()
- {
- if ( !GetCompEM().CanWork() )
- {
- GetCompEM().SwitchOff();
- }
- }
-
- override void OnWorkStart()
- {
- //turn on broadcasting/receiving
- EnableBroadcast ( true );
- EnableReceive ( true );
- SwitchOn ( true );
-
- //play sound
- SoundTurnedOnNoiseStart();
- }
- override void OnWorkStop()
- {
- //auto switch off (EM)
- GetCompEM().SwitchOff();
-
- //turn off broadcasting/receiving
- EnableBroadcast ( false );
- EnableReceive ( false );
- SwitchOn ( false );
-
- //stop sound
- SoundTurnedOnNoiseStop();
- }
-
- //================================================================
- // SOUNDS
- //================================================================
- //Static noise when the radio is turned on
- protected void SoundTurnedOnNoiseStart()
- {
- PlaySoundSetLoop( m_SoundLoop, SOUND_RADIO_TURNED_ON, 1.0, 1.0 );
- }
- protected void SoundTurnedOnNoiseStop()
- {
- StopSoundSet( m_SoundLoop );
- }
-
- override void SetActions()
- {
- super.SetActions();
-
- AddAction(ActionTurnOnTransmitter);
- AddAction(ActionTurnOffTransmitter);
- AddAction(ActionTuneFrequency);
- }
- }
|