Exemplo n.º 1
0
        public void Dispose()
        {
            if (this == null || wasDisposed || !ViewInitialized)
            {
                return;
            }
            wasDisposed = true;

            OnDispose();



            if (this.gameObject != null && destroyOnDispose)
            {
                disposeOnDestroy = false;
                Destroy(this.gameObject);
            }

            //_tManager.Remove(this);
            RemoveTickable(this);
            _dManager.Remove(this);

            Controller = null;
            ControllerProperty.Dispose();
            ViewInitializedProperty.Dispose();
            Model = null;
            ModelProperty.Dispose();

            _eventService = null;
            _dManager     = null;
            _tManager     = null;
        }
Exemplo n.º 2
0
        void Initialize(
            [Inject] DisposableManager dManager,
            [Inject] Service.Events.IEventsService eventService,
            [Inject] Service.AsyncManager.IAsyncManager asyncManager
            )
        {
            _dManager     = dManager;
            _eventService = eventService;
            _asyncManager = asyncManager;

            // register as disposable
            _dManager.Add(this);

            try {
                System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                watch.Start();
                AfterInitialize();
                watch.Stop();
#if UNITY_EDITOR || DEVELOPMENT_BUILD
                UnityEngine.Debug.LogWarning($"Service /*name:serviceName*/PrototypeService/*endname*/ AfterInitialize() took {watch.Elapsed.TotalSeconds}s");
#endif
                Observable.NextFrame().Subscribe(_ => {
                    InitAPI();
                });
            }
            catch (Exception e) {
                UnityEngine.Debug.LogError("Catched exception in AfterInitialize() from service:" + GetType());
                UnityEngine.Debug.LogException(e);
            }
        }
Exemplo n.º 3
0
        public void Dispose()
        {
            if (this == null || wasDisposed || !ViewInitialized)
            {
                return;
            }
            wasDisposed = true;

            OnDispose();



            if (this.gameObject != null && destroyOnDispose)
            {
                disposeOnDestroy = false;
                Destroy(this.gameObject);
            }

            //_tManager.Remove(this);
            RemoveTickable(this);
            _dManager.Remove(this);

            //Debug.Log(this + " disposed");

            if (disposeControllerOnDispose && Controller != null)
            {
                Controller.Dispose();
            }
            Controller = null;

            _eventService = null;
            _dManager     = null;
            _tManager     = null;
        }
Exemplo n.º 4
0
        public void Dispose()
        {
            if (this == null || wasDisposed || !ViewInitialized)
            {
                return;
            }
            wasDisposed = true;

            OnDispose();

            RemoveTickable(this);
            _dManager.Remove(this);

            //Debug.Log(this + " disposed");

            if (disposeControllerOnDispose && Controller != null)
            {
                Controller.Dispose();
            }
            Controller = null;

            _eventService = null;
            _dManager     = null;
            _tManager     = null;
        }
Exemplo n.º 5
0
 void Start()
 {
     //Resolve disposableManager
     dManager = Container.Resolve <DisposableManager>();
     //Let the program know, that Kernel has finished loading
     eventService = Container.Resolve <Service.Events.IEventsService>();
     eventService.Publish(new Events.KernelReadyEvent());
 }
Exemplo n.º 6
0
        void Initialize(
            [Inject] Service.Events.IEventsService eventService
            )
        {
#if UNITY_ADS
            _eventService = eventService;
#endif
        }
Exemplo n.º 7
0
        void Initialize(
            [Inject] DisposableManager dManager,
            [Inject] Service.Events.IEventsService eventService
            )
        {
            _dManager     = dManager;
            _eventService = eventService;

            _dManager.Add(this);
        }
Exemplo n.º 8
0
        void Initialize(
            [Inject] Service.Events.IEventsService eventService,
            [Inject] DisposableManager dManager
            )
        {
            _eventService = eventService;

            _dManager = dManager;
            _dManager.Add(this);

            disposables.Add(_eventService.OnEvent <Service.Backend.Events.GotUserDataEvent>().Subscribe(e => OnGotUserData(e)));
        }
Exemplo n.º 9
0
        void Initialize(
          [Inject] DisposableManager dManager,
          [Inject] Service.Events.IEventsService eventService,
          [Inject] Service.AsyncManager.IAsyncManager asyncManager
        ) {
            _dManager = dManager;
            _eventService = eventService;
            _asyncManager = asyncManager;

            // register as disposable
            _dManager.Add(this);

            AfterInitialize();
        }
Exemplo n.º 10
0
        public void Initialize(
            [Inject] DiContainer diContainer,
            [Inject] DisposableManager dManager,
            [Inject] TickableManager tManager,
            [Inject] Service.Events.IEventsService eventService)
        {
            if (ViewInitialized)
            {
                return;
            }
            ViewInitialized = true;

            PreBind();

            Container     = diContainer;
            _dManager     = dManager;
            _tManager     = tManager;
            _eventService = eventService;

            this.ControllerProperty.DistinctUntilChanged().Subscribe(e => ListenToControllerDispose()).AddTo(this);

            //Create controller if this view is created through editor/sceneload
            if (createController && Controller == null)
            {
                IController _c = CreateController();
                _c.Bind();
                SetController(_c);
            }

            //To make IDisposable work, we have to add this instance to the disposable manager
            _dManager.Add(this);

            //Make ITickable work
            AddTickable(this);

            //Bind all interfaces for this instance
            //Container.BindAllInterfacesFromInstance(this);
            Container.Bind <IView>().FromInstance(this);
            Container.Bind <ITickable>().FromInstance(this);

            //Debug.Log(this + " init");

            AfterBind();
        }
Exemplo n.º 11
0
        void Initialize(
            [Inject] DisposableManager dManager,
            [Inject] Service.Events.IEventsService eventService,
            [Inject] Service.AsyncManager.IAsyncManager asyncManager
            )
        {
            _dManager     = dManager;
            _eventService = eventService;
            _asyncManager = asyncManager;
            // register as disposable
            _dManager.Add(this);

            try {
                AfterInitialize();
            }
            catch (Exception e) {
                UnityEngine.Debug.LogError("Catched exception in Service-AfterInitialize() from service:" + GetType());
                UnityEngine.Debug.LogException(e);
            }
        }
Exemplo n.º 12
0
        void Initialize(
            [Inject] DisposableManager dManager,
            [Inject] Service.Events.IEventsService eventService
            )
        {
            _dManager     = dManager;
            _eventService = eventService;

            _dManager.Add(this);

            //Fire events on button up/down
            disposables.Add(Observable.EveryUpdate().Subscribe(e => {
                if (inputEnabled)
                {
                    //Check button down
                    foreach (KeyValuePair <object, List <Func <bool> > > kv in buttonDownHandlers)
                    {
                        if (GetButtonDown(kv.Key))
                        {
                            _eventService.Publish(new Events.ButtonDownEvent()
                            {
                                button = kv.Key
                            });
                        }
                    }
                    //Check button up
                    foreach (KeyValuePair <object, List <Func <bool> > > kv in buttonUpHandlers)
                    {
                        if (GetButtonUp(kv.Key))
                        {
                            _eventService.Publish(new Events.ButtonUpEvent()
                            {
                                button = kv.Key
                            });
                        }
                    }
                }
            }));
        }
Exemplo n.º 13
0
 void OnInject(
     [Inject] Service.Events.IEventsService eventService
     )
 {
     this.eventService = eventService;
 }