Пример #1
0
        /// <summary>
        /// Registers an IComponentBroadcasterService along with a ComponentBroadcasterDefinition. This service and definition
        /// control how a particular type of Component is both broadcast and observed.
        /// </summary>
        /// <param name="service">The service which controls broadcasting and observing component changes.</param>
        /// <param name="componentDefinition">The definition controlling when a component should be broadcast.</param>
        public void RegisterService(IComponentBroadcasterService service, ComponentBroadcasterDefinition componentDefinition)
        {
            if (componentBroadcasterServices.TryGetValue(service.GetID(), out IComponentBroadcasterService existingService))
            {
                Debug.LogError($"Duplicate IComponentBroadcasterService key detected: {service.GetID().ToString()} was previously registered for a service with type {existingService.GetType().Name} and now it is being re-registered for a service with type {service.GetType().Name}.");
                return;
            }

            componentBroadcasterDefinitions.Add(componentDefinition);
            componentBroadcasterServices.Add(service.GetID(), service);
        }
Пример #2
0
 /// <summary>
 /// Registers an IComponentBroadcasterService along with a ComponentBroadcasterDefinition. This service and definition
 /// control how a particular type of Component is both broadcast and observed.
 /// </summary>
 /// <param name="service">The service which controls broadcasting and observing component changes.</param>
 /// <param name="componentDefinition">The definition controlling when a component should be broadcast.</param>
 public void RegisterService(IComponentBroadcasterService service, ComponentBroadcasterDefinition componentDefinition)
 {
     componentBroadcasterDefinitions.Add(componentDefinition);
     componentBroadcasterServices.Add(service.GetID(), service);
 }