// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. using System; using System.Collections.Generic; using UnityEngine; namespace Google.Play.AssetDelivery { /// /// A CustomYieldInstruction /// used to monitor the asynchronous retrieval of a batch of asset packs. /// public abstract class PlayAssetPackBatchRequest : CustomYieldInstruction { /// /// A dictionary of asset pack requests, keyed by name, that are present in this batch. /// public IDictionary Requests; /// /// Returns true if all requests in this batch are in either the or /// status, false otherwise. /// public bool IsDone { get; protected set; } /// /// Event indicating that all the requests in this batch are complete. If an event handler is registered after /// the operation has completed, and thus after this event has been invoked, then the handler will be called /// synchronously. /// public virtual event Action Completed = delegate { }; /// /// Implements the CustomYieldInstruction.keepWaiting /// property so that this request can be yielded on in a coroutine. /// public override bool keepWaiting { get { return !IsDone; } } /// /// Invokes the event. /// protected void InvokeCompletedEvent() { Completed.Invoke(this); } } }