Exemplo n.º 1
0
 public void Setup(IUcProfile profile, IUnityMainThreadDispatcher unityMainThreadDispatcher, SignalBus signalBus, ICommonValues commonValues)
 {
     this._profile = profile;
     this._unityMainThreadDispatcher = unityMainThreadDispatcher;
     this._signalBus    = signalBus;
     this._commonValues = commonValues;
 }
 public static void Initialise()
 {
     if (_instance == null)
     {
         _instance = Current();
     }
 }
        public static IUnityMainThreadDispatcher Current()
        {
            IUnityMainThreadDispatcher dispatcher = null;

            try
            {
                // NOTE: This causes strange behaviour when you do async from the editor while the
                // game is playing.  What happens is the editor async calls end up hooking
                // the main game loop.  Any ideas, let me know how you can find out if you are on
                // the Game thread, or the Editor thread.

#if UNITY_EDITOR
                // There is an issue here, that being if code is being ran
                // in the editor UI and in the player, you can end up with editor UI
                // code running on the player thread.  It's backwards.
                // Not sure how to avoid this for now.
                if (!Application.isEditor || Application.isPlaying)
                {
                    dispatcher = UnityGameThreadDispatcher.Instance;
                }
                else
                {
                    dispatcher = UnityEditorThreadDispatcher.Instance;
                }
#else
                dispatcher = UnityGameThreadDispatcher.Instance;
#endif
            }
            catch (Exception e)
            {
                Debug.LogError("UnityMainThreadDispatcher.Initialise() must be called from the main thread prior to dispatching back to the main thread.");
                Debug.LogError(e.StackTrace);
            }
            return(dispatcher);
        }
        public static IUnityMainThreadDispatcher Current()
        {
            IUnityMainThreadDispatcher dispatcher = null;

            try
            {
                // NOTE: This causes strange behaviour when you do async from the editor while the
                // game is playing.  What happens is the editor async calls end up hooking
                // the main game loop.  Any ideas, let me know how you can find out if you are on
                // the Game thread, or the Editor thread.
                //if (!Application.isEditor || Application.isPlaying)
                //{
                #if UNITY_CORE_EDITOR
                dispatcher = UnityEditorThreadDispatcher.Instance;
                #else
                dispatcher = UnityGameThreadDispatcher.Instance;
                #endif
            }
            catch (Exception e)
            {
                Debug.LogError("UnityMainThreadDispatcher.Initialise() must be called from the main thread prior to dispatching back to the main thread.");
            }
            return(dispatcher);
        }
Exemplo n.º 5
0
 public static UcSourceInstance GetUcSourceInstanceFromUcSourceAndDtoSourceInstance(UcSource appropriateSource, SourceInstanceDto dtoSourceInstance, float pixelToUnityUnitScale, IUnityMainThreadDispatcher dispatcher)
 {
     return(new UcSourceInstance(appropriateSource, dtoSourceInstance.WallId, dtoSourceInstance.X, dtoSourceInstance.Y, dtoSourceInstance.Width, dtoSourceInstance.Height, pixelToUnityUnitScale, dispatcher, dtoSourceInstance.Id));
 }
Exemplo n.º 6
0
 public ExodusGameObject(string color, IUnityMainThreadDispatcher dispatcher, PrimitiveType primitiveType = PrimitiveType.Cube)
 {
     this.UnityMainThreadDispatcher = dispatcher;
     this.ChangeColor(color);
     this.PrimitiveType = primitiveType;
 }
Exemplo n.º 7
0
 public ExodusGameObject(Color color, IUnityMainThreadDispatcher dispatcher, PrimitiveType primitiveType = PrimitiveType.Cube)
 {
     this.UnityMainThreadDispatcher = dispatcher;
     this.Color         = color;
     this.PrimitiveType = primitiveType;
 }
Exemplo n.º 8
0
        public static ObservableCollection <UcWall> GetUcWallListFromDtoWallList(IEnumerable <WallDto> dtoWallList, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher)
        {
            ObservableCollection <UcWall> UcWallList = new ObservableCollection <UcWall>();

            foreach (var dtoWall in dtoWallList)
            {
                UcWallList.Add(GetUcWallFromDtoWall(dtoWall, pixelToUnityUnitScale, wallCenterLocation, dispatcher));
            }

            return(UcWallList);
        }
Exemplo n.º 9
0
        public UcSourceInstance(UcSource source, int wallId, int x, int y, int width, int height, float pixelToUnityUnitScale, IUnityMainThreadDispatcher dispatcher, int sourceInstanceId = 0)
            : base(source.Name, source.DefaultWidth, source.DefaultHeight, source.Color, source.SourceId)
        {
            this.ExodusSourceInstanceGameObject = new ExodusSourceInstanceGameObject(dispatcher, this.Color);

            this.SourceInstanceId = sourceInstanceId;
            this.WallId           = wallId;
            this.X      = x;
            this.Y      = y;
            this.Width  = width;
            this.Height = height;
            this.PixelToUnityUnitScale = pixelToUnityUnitScale;
        }
Exemplo n.º 10
0
        public static void HandToThreadAndWait <TPrevious>(Task <TPrevious> task, Action <Task <TPrevious> > action, IUnityMainThreadDispatcher dispatcher)
        {
            var t = dispatcher.Enqueue(() => action(task));

            t.Wait();
        }
Exemplo n.º 11
0
 //Very bad how i'm not injecting the main thread dispatcher... but this is a prototype and I'm running out of time.
 public static UcWall GetUcWallFromDtoWall(WallDto dtoWall, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher unityMainThreadDispatcher)
 {
     return(new UcWall(dtoWall.Name, dtoWall.Width, dtoWall.Height, new ObservableCollection <UcSourceInstance>(), pixelToUnityUnitScale, wallCenterLocation, unityMainThreadDispatcher, dtoWall.Id));
 }
Exemplo n.º 12
0
 public ExodusSourceInstanceGameObject(IUnityMainThreadDispatcher dispatcher, string hexColor, PrimitiveType primitiveType = PrimitiveType.Cube) : base(hexColor, dispatcher, primitiveType)
 {
 }
Exemplo n.º 13
0
        private static TResult HandToThreadAndWait <TPrevious, TResult>(Task <TPrevious> task, Func <Task <TPrevious>, TResult> func, IUnityMainThreadDispatcher dispatcher)
        {
            var t = dispatcher.Enqueue(() => func.Invoke(task));

            t.Wait();
            return(t.Result);
        }
 public static void ForceInitialise()
 {
     _instance = Current();
 }
Exemplo n.º 15
0
        public static ObservableCollection <UcSourceInstance> GetUcSourceInstanceListFromUcSourceListAndDtoSourceInstanceList(IEnumerable <UcSource> UcSourceList, IEnumerable <SourceInstanceDto> dtoSourceInstanceList, float pixelToUnityUnitScale, IUnityMainThreadDispatcher dispatcher)
        {
            ObservableCollection <UcSourceInstance> UcSourceInstanceList = new ObservableCollection <UcSourceInstance>();

            foreach (var dtoSourceInstance in dtoSourceInstanceList)
            {
                UcSource appropriateSource = UcSourceList.FirstOrDefault(s => s.SourceId == dtoSourceInstance.SourceId);
                if (appropriateSource == null)
                {
                    continue;
                }
                UcSourceInstanceList.Add(GetUcSourceInstanceFromUcSourceAndDtoSourceInstance(appropriateSource, dtoSourceInstance, pixelToUnityUnitScale, dispatcher));
            }

            return(UcSourceInstanceList);
        }
Exemplo n.º 16
0
 public static UcPhysicalWall GetUcPhysicalWallFromDtoPhysicalWallAndSourceInstances(PhysicalWallDto dtoPhysicalWall, ObservableCollection <UcSourceInstance> sourceInstances, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher)
 {
     return(new UcPhysicalWall(dtoPhysicalWall.Name, dtoPhysicalWall.Width, dtoPhysicalWall.Height, sourceInstances, pixelToUnityUnitScale, wallCenterLocation, dispatcher, dtoPhysicalWall.Id));
 }
Exemplo n.º 17
0
        public static ObservableCollection <UcPhysicalWall> GetUcPhysicalWallListFromDtoPhysicalWallList(IEnumerable <UcSourceInstance> sourceInstances, IEnumerable <PhysicalWallDto> dtoPhysicalWallList, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher)
        {
            ObservableCollection <UcPhysicalWall> UcPhysicalWallList = new ObservableCollection <UcPhysicalWall>();

            foreach (var dtoPhysicalWall in dtoPhysicalWallList)
            {
                var matchingSourceInstanceList = sourceInstances.Where(s => s.WallId == dtoPhysicalWall.Id);
                var matchingSourceInstanceOc   = new ObservableCollection <UcSourceInstance>(matchingSourceInstanceList);
                UcPhysicalWallList.Add(PhysicalWallMapper.GetUcPhysicalWallFromDtoPhysicalWallAndSourceInstances(dtoPhysicalWall, matchingSourceInstanceOc, pixelToUnityUnitScale, wallCenterLocation, dispatcher));
            }

            return(UcPhysicalWallList);
        }
Exemplo n.º 18
0
 /// <summary>
 /// The constructor. Takes in base. The other child properties are takenindependently.
 /// </summary>
 /// <param name="wall"></param>
 public UcDigitalWall(UcWall wall, IUnityMainThreadDispatcher dispatcher)
     : base(wall.Name, wall.Width, wall.Height, wall.SourceInstances, wall.PixelToUnityUnitScale, wall.WallCenterLocation, dispatcher, wall.WallId)
 {
 }
Exemplo n.º 19
0
 /// <summary>
 /// The constructor. Takes in all properties indivudually.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="sourceInstances"></param>
 public UcDigitalWall(string name, int width, int height, ObservableCollection <UcSourceInstance> sourceInstances, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher, int wallId = 0)
     : base(name, width, height, sourceInstances, pixelToUnityUnitScale, wallCenterLocation, dispatcher, wallId)
 {
 }
Exemplo n.º 20
0
 public void Setup(IUnityMainThreadDispatcher unityMainThreadDispatcher, IUcProfile profile)
 {
     this._dispatcher = unityMainThreadDispatcher;
     this._profile    = profile;
 }
Exemplo n.º 21
0
        /// <summary>
        /// The wall constructor
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="sourceInstances"></param>
        public UcWall(string name, int width, int height, ObservableCollection <UcSourceInstance> sourceInstances, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher unityMainThreadDispatcher, int wallId = 0)
        {
            this.PixelToUnityUnitScale = pixelToUnityUnitScale;
            this.WallCenterLocation    = wallCenterLocation;
            this.ExodusWallGameObject  = new ExodusWallGameObject(unityMainThreadDispatcher);


            this.WallId = wallId;
            this.Name   = name;
            this.Width  = width;
            this.Height = height;

            this.InitializeWallGameObject();
            this.SourceInstances = sourceInstances;
        }
Exemplo n.º 22
0
 public void Setup(SignalBus signalBus, IUcSignalrProxy signalrProxy, IUnityMainThreadDispatcher unityMainThreadDispatcher)
 {
     this._signalBus    = signalBus;
     this._signalrProxy = signalrProxy;
     this._unityMainThreadDispatcher = unityMainThreadDispatcher;
 }