/** * Utility method to carry out tasks required for weapon fire events * * @param fires the data for the weapon fire events */ private void HandleFires( FireWeaponData[] fires ) { // there's nothing really that we need to do here (unless we animate the bullet itself...?) foreach( FireWeaponData fireWeaponData in fires ) { GameObject unityRepresentation = this.lvcUnityAmbassador.GameObjectForLvcId( fireWeaponData.targeting.firingId ); if( unityRepresentation!=null ) { // check for any entity type specific handling for firing LVCExtraFireHandler extraFireHandler = unityRepresentation.GetComponent<LVCExtraFireHandler>(); if( extraFireHandler!=null ) { // there's additional work to be done using the fire data - do that now. extraFireHandler.HandleFire( fireWeaponData, unityRepresentation ); } } } if(showLogging && fires.Length>0) Debug.Log(fires.Length + " External Fire Events Handled."); }
/** * Fires a fire weapon event. This is triggered as a result of an *incoming* LVC update * event triggered by an LVC Game external to this one, meaning that the equivalent Unity game * object should fire. For example, cause the tank inside Unity to which represents the * remote VBS2 owned/controlled tank to fire. * * @param data data associated with the event * @return true if the event was handled successfully */ public bool FireWeapon( ref FireWeaponData data ) { lock( pendingExternalFireLock ) { // Debug.Log("External FIREWEAPON event received."); // add the data as a pending external deletion. Since this event arrived "outside" // Unity's event/threading system, this will eventually be handled by the LVCHelper // Monobehaviour during an Update() event. pendingExternalFires.Add( data ); } return true; }