public void Subscribe(StateOption options, Subscriber callback) { SubscriberOptions subscriberOption = new SubscriberOptions(); subscriberOption.option = options; subscriberOption.subscriber = callback; if (!subscribers.Contains(subscriberOption)) { subscribers.Add(subscriberOption); } PublishIfMatches(subscriberOption, true); }
private void PublishIfMatches(SubscriberOptions subscriberOption, bool forceDirtyBit = false) { if ( subscriberOption.option.Matches( previousNetworkState, previousGameState, networkState, gameState, isNetworkDirty, isGameDirty ) ) { subscriberOption.subscriber(); } }