Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 |
/////////////////////////////////////////////////////////////////////////////// // HearingNotifier.uc - HearingNotifier class // The HearingNotifier notifies all registered clients when the Listener hears a sound // Clients of the HearingNotifier are stored in the NotificationList, and should be registered through the Pawn class HearingNotifier extends Core.RefCount native; /////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// //// Private Variables ///////////////////////////////////////////////// var private array<IHearingNotification> NotificationList; var private Pawn Listener; ///////////////////////////////////////////////// //// Initialization ///////////////////////////////////////////////// function InitializeHearingNotifier(Pawn InListener) { assert(InListener != None); Listener = InListener; } ///////////////////////////////////////////////// //// Notifications from Pawn ///////////////////////////////////////////////// // when we hear a sound, let all of the clients know we heard it, // whether or not they are interested. function OnHearSound(Actor SoundMaker, vector SoundOrigin, Name SoundCategory) { local int i; for(i=0; i<NotificationList.Length; ++i) { NotificationList[i].OnListenerHeardNoise(Listener, SoundMaker, SoundOrigin, SoundCategory); } } ///////////////////////////////////////////////// //// Registration functions ///////////////////////////////////////////////// // Register to be notified when the Listener hears a noise function RegisterHearingNotification(IHearingNotification Registrant) { assert(Registrant != None); assert(! IsOnHearingNotificationList(Registrant)); // push the registrant onto the notification list NotificationList[NotificationList.Length] = Registrant; } // Unregister to be notified when the Listener hears a noise function UnregisterHearingNotification(IHearingNotification Registrant) { local int i; assert(Registrant != None); #if !IG_TRIBES3 assert(IsOnHearingNotificationList(Registrant)); #endif for(i=0; i<NotificationList.Length; ++i) { if (NotificationList[i] == Registrant) { NotificationList.Remove(i, 1); break; } } } ///////////////////////////////////////////////// //// Vision Notification Private Functions ///////////////////////////////////////////////// // returns true if the Client interface is on the Hearing notification list // returns false if the Client interface is not on the Hearing notification list private function bool IsOnHearingNotificationList(IHearingNotification PossibleRegistrant) { local int i; for(i=0; i<NotificationList.Length; ++i) { if (NotificationList[i] == PossibleRegistrant) { return true; } } // PossibleRegistrant not found return false; } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |