Exemple #1
0
        public SignalBus(
            [Inject(Source = InjectSources.Local)]
            List <SignalDeclarationBindInfo> signalBindings,
            [Inject(Source = InjectSources.Parent, Optional = true)]
            SignalBus parentBus,
            [InjectOptional]
            ZenjectSettings zenjectSettings)
        {
            if (zenjectSettings != null && zenjectSettings.Signals != null)
            {
                _settings = zenjectSettings.Signals;
            }
            else
            {
                _settings = ZenjectSettings.SignalSettings.Default;
            }

            _localDeclarations   = new List <SignalDeclaration>();
            _localDeclarationMap = new Dictionary <Type, SignalDeclaration>();
            _parentBus           = parentBus;

            for (int i = 0; i < signalBindings.Count; i++)
            {
                var signalBindInfo = signalBindings[i];

                var declaration = SignalDeclaration.Pool.Spawn(
                    signalBindInfo.SignalType,
                    signalBindInfo.MissingHandlerResponse,
                    signalBindInfo.RunAsync, _settings);

                _localDeclarations.Add(declaration);
                _localDeclarationMap.Add(signalBindInfo.SignalType, declaration);
            }
        }
Exemple #2
0
        public SignalBus(
            [Inject(Source = InjectSources.Local)]
            List <SignalDeclaration> signalDeclarations,
            [Inject(Source = InjectSources.Parent, Optional = true)]
            SignalBus parentBus,
            [InjectOptional]
            ZenjectSettings zenjectSettings,
            SignalSubscription.Pool subscriptionPool,
            SignalDeclaration.Factory signalDeclarationFactory,
            DiContainer container)
        {
            _subscriptionPool         = subscriptionPool;
            zenjectSettings           = zenjectSettings ?? ZenjectSettings.Default;
            _settings                 = zenjectSettings.Signals ?? ZenjectSettings.SignalSettings.Default;
            _signalDeclarationFactory = signalDeclarationFactory;
            _container                = container;

            signalDeclarations.ForEach(x =>
            {
                if (!_localDeclarationMap.ContainsKey(x.BindingId))
                {
                    _localDeclarationMap.Add(x.BindingId, x);
                }
                else
                {
                    _localDeclarationMap[x.BindingId].Subscriptions.AllocFreeAddRange(x.Subscriptions);
                }
            });
            _parentBus = parentBus;
        }
        public SignalDeclaration(
            SignalDeclarationBindInfo bindInfo,
            [InjectOptional] ZenjectSettings zenjectSettings)
        {
            zenjectSettings = zenjectSettings ?? ZenjectSettings.Default;
            _settings       = zenjectSettings.Signals ?? ZenjectSettings.SignalSettings.Default;

            _bindingId = new BindingId(bindInfo.SignalType, bindInfo.Identifier);
            _missingHandlerResponses = bindInfo.MissingHandlerResponse;
            _isAsync     = bindInfo.RunAsync;
            TickPriority = bindInfo.TickPriority;
        }
Exemple #4
0
        public SignalDeclaration(
            Type signalType,
            SignalDeclarationBindInfo bindInfo,
            [InjectOptional]
            ZenjectSettings zenjectSettings)
        {
            zenjectSettings = zenjectSettings ?? ZenjectSettings.Default;
            _settings       = zenjectSettings.Signals ?? ZenjectSettings.SignalSettings.Default;

            _signalType = signalType;
            _missingHandlerResponses = bindInfo.MissingHandlerResponse;
            _isAsync     = bindInfo.RunAsync;
            TickPriority = bindInfo.TickPriority;
        }
Exemple #5
0
        public SignalBus(
            [Inject(Source = InjectSources.Local)]
            List <SignalDeclaration> signalDeclarations,
            [Inject(Source = InjectSources.Parent, Optional = true)]
            SignalBus parentBus,
            [InjectOptional]
            ZenjectSettings zenjectSettings,
            SignalSubscription.Pool subscriptionPool)
        {
            _subscriptionPool = subscriptionPool;
            zenjectSettings   = zenjectSettings ?? ZenjectSettings.Default;
            _settings         = zenjectSettings.Signals ?? ZenjectSettings.SignalSettings.Default;

            _localDeclarationMap = signalDeclarations.ToDictionary(x => x.BindingId, x => x);
            _parentBus           = parentBus;
        }