private MessageDeliveryType GetDeliveryType(IBroadcastEvent broadcastEvent)
    {
        MessageDeliveryType deliveryType = broadcastEvent.deliveryType;

        if (deliveryType == MessageDeliveryType.Unspecified)
        {
            return(defaultDeliveryType);
        }

        return(deliveryType);
    }
    public BroadcastEvent <T> SetDeliveryType(MessageDeliveryType newDeliveryType)
    {
        Assert.IsFalse(isPosted, "Can't set the delivery type of a broadcast event after it has been posted.");
        Assert.IsFalse(isDelivered, "Can't set the delivery type of a broadcast event after it has been delivered.");
        Assert.IsFalse(wasDeliveryTypeSet, "You can only set the delivery type of a broadcast event once.");

        deliveryType       = newDeliveryType;
        wasDeliveryTypeSet = true;

        return(this);
    }
    public void Post(IBroadcastEvent broadcastEvent)
    {
        MessageDeliveryType deliveryType = GetDeliveryType(broadcastEvent);

        switch (deliveryType)
        {
        case MessageDeliveryType.Immediate:
            broadcastEvent.DeliverEvent();
            break;

        case MessageDeliveryType.FixedUpdate:
            lock (events) events.Enqueue(broadcastEvent);
            break;

        case MessageDeliveryType.Unspecified:
        default:
            throw new ArgumentOutOfRangeException($"Invalid delivery type: {deliveryType}");
        }
    }