Exemplo n.º 1
0
        public override void EventFired(object sender, Event e)
        {
            if (e is SelectSoundEvent s)
            {
                Sounds = s.Sounds;
                SelectedElementIndex  = 0;
                SelectedPropertyIndex = 0;
                ListFromIndex         = 0;

                ComponentLocked = false;
                SwitchTo        = (Owner.Systems[ComponentSystem.IdentifierOf <ModalFocusSystem>()] as ModalFocusSystem).CurrentSystem;
            }
            else if (e is ModalChangeEvent ce)
            {
                ModalActive  = true;
                ModalVisible = true;
            }
            else if (e is BeginModalChangeEvent bmce)
            {
                if (ComponentLocked)
                {
                    ComponentLocked = false;
                }
                else
                {
                    bmce.SystemName = SwitchTo;
                    ModalActive     = false;
                    ModalVisible    = false;
                }
            }
        }
 public override void Setup()
 {
     base.Setup();
     NotificationUIManager = ComponentSystem.RegisterComponent <NotificationUI>(20);
     this.OnEvent <uFrame.Kernel.GameReadyEvent>().Subscribe(_ => { DisableAllNotificationUIFilter(_); }).DisposeWith(this);
     this.OnEvent <Playfab.NotificationMessage>().Subscribe(_ => { DisplayNotificationMessageFilter(_); }).DisposeWith(this);
 }
 public override void Setup()
 {
     base.Setup();
     PlayerManager          = ComponentSystem.RegisterComponent <Player>(3);
     HealthComponentManager = ComponentSystem.RegisterComponent <HealthComponent>(2);
     this.OnEvent <test.AttackEvent>().Subscribe(_ => { HealthSystemAttackEventFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 4
0
 public override void EventFired(object sender, Event e)
 {
     if (e is StartObjectEditEvent s)
     {
         SelectedPropertyIndex = 0;
         Members.Clear();
         Object   = s.Object;
         Title    = s.Title;
         ReturnTo = s.ReturnTo;
         foreach (FieldInfo field in Object.GetType().GetFields())
         {
             Members.Add(new FieldSummary(Owner, field, Object));
         }
         foreach (PropertyInfo property in Object.GetType().GetProperties())
         {
             Members.Add(new PropertySummary(Owner, property, Object));
         }
         if (ReturnTo == null)
         {
             ReturnTo = (Owner.Systems[ComponentSystem.IdentifierOf <ModalFocusSystem>()] as ModalFocusSystem)?.CurrentSystem ?? "editor_menu";
         }
     }
     else if (e is ModalChangeEvent)
     {
         ModalActive  = true;
         ModalVisible = true;
     }
     else if (e is BeginModalChangeEvent bmce)
     {
         bmce.SystemName = ReturnTo;
         ModalActive     = false;
         ModalVisible    = false;
     }
 }
 public override void Setup()
 {
     base.Setup();
     TitleDataManager = ComponentSystem.RegisterGroup <TitleDataGroup, ITitleData>();
     TitleDataManager.CreatedObservable.Subscribe(LoadComponentTitleDataFilter).DisposeWith(this);
     this.OnEvent <Playfab.LoadData>().Subscribe(_ => { LoadTitleDataFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 6
0
        /// <summary>
        ///  Computes a transform node's world scale.
        ///  This function uses the computeWorldMatrix function to compute the world
        ///  matrix (bypassing caching), and returns the scale of that.
        ///
        ///  Because lossy scale does not include skew, it does not include enough
        ///  information to recreate a full 4x4 matrix from rotation, position, and
        ///  lossy scale in 3D.
        ///
        ///  This function can be quite resource intensive. If possible, read the
        ///  LocalToWorld component instead.
        /// </summary>
        public static float3 ComputeWorldScaleLossy(ComponentSystem callingSystem, Entity node)
        {
            float4x4 wm = ComputeWorldMatrix(callingSystem, node);
            float3   s  = new float3(math.length(wm[0].xyz), math.length(wm[1].xyz), math.length(wm[2].xyz));

            return(s);
        }
Exemplo n.º 7
0
 public override void Setup()
 {
     base.Setup();
     MenuComponentManager = ComponentSystem.RegisterComponent <MenuComponent>(3);
     HealthManager        = ComponentSystem.RegisterComponent <Health>(1);
     this.OnEvent <uFrame.ECS.UnityUtilities.MouseDownDispatcher>().Subscribe(_ => { InputSystemOnMouseDownFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 8
0
        public void AddSystem(ComponentSystem componentSystem)
        {
            if (componentSystem == null)
            {
                return;
            }

            var debugSystems = componentSystem as DebugSystems;

            if (debugSystems != null)
            {
                debugSystems.gameObject.transform.SetParent(_gameObject.transform, false);
            }


            Type componentSystemType = componentSystem.GetType();

            if (componentSystemType.GetMethod("OnStart").DeclaringType == componentSystemType)
            {
                _startSystemInfos.Add(new SystemInfo(componentSystem));
                _startSystems.Add(componentSystem);
            }
            if (componentSystemType.GetMethod("OnUpdate").DeclaringType == componentSystemType)
            {
                _updateSystemInfos.Add(new SystemInfo(componentSystem));
                _updateSystems.Add(componentSystem);
            }
            if (componentSystemType.GetMethod("OnFixedUpdate").DeclaringType == componentSystemType)
            {
                _fixedUpdateSystemInfos.Add(new SystemInfo(componentSystem));
                _fixedUpdateSystems.Add(componentSystem);
            }
        }
Exemplo n.º 9
0
        public virtual void unregisterEventHandler(ComponentSystem handler)
        {
            foreach (SetMultimap <Type, EventHandlerInfo> eventHandlers in componentSpecificHandlers.Values)
            {
                IEnumerator <EventHandlerInfo> eventHandlerIterator = eventHandlers.values().GetEnumerator();
                while (eventHandlerIterator.MoveNext())
                {
                    EventHandlerInfo eventHandler = eventHandlerIterator.Current;
                    if (eventHandler.Handler.Equals(handler))
                    {
                        eventHandlerIterator.remove();
                    }
                }
            }

            IEnumerator <EventHandlerInfo> eventHandlerIterator = generalHandlers.values().GetEnumerator();

            while (eventHandlerIterator.MoveNext())
            {
                EventHandlerInfo eventHandler = eventHandlerIterator.Current;
                if (eventHandler.Handler.Equals(handler))
                {
                    eventHandlerIterator.remove();
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///  Helper function for transforming from world to window coordinates.
        ///  This only works if the cameraEntity has a valid LocalToWorld
        ///  component. Returns windowPos (window position) and windowSize (window size) in
        ///  the same coordinates.
        /// </summary>
        public static float2 WorldToWindow(ComponentSystem callingSystem, Entity cameraEntity, float3 worldPos, float2 windowSize)
        {
            var mgr = callingSystem.EntityManager;
            DisplayListCamera dlc = mgr.GetComponentData <DisplayListCamera>(cameraEntity);
            Camera2D          c2d = mgr.GetComponentData <Camera2D>(cameraEntity);

            float  aspect = windowSize.x / windowSize.y;
            float2 camsize;

            camsize.x = c2d.halfVerticalSize * aspect;
            camsize.y = c2d.halfVerticalSize;
            // transform from world to window
            float3 viewpos;

            viewpos = math.transform(dlc.inverseWorld, worldPos);
            // to normalized window
            float2 windowPos;

            windowPos.x = viewpos.x / camsize.x;
            windowPos.y = viewpos.y / camsize.y;
            // to output window
            windowPos.x = (windowPos.x * .5f + .5f) * windowSize.x;
            windowPos.y = (windowPos.y * .5f + .5f) * windowSize.y;
            return(windowPos);
        }
Exemplo n.º 11
0
 public override void EventFired(object sender, Event e)
 {
     if (e is StartSpriteSourceEditEvent s)
     {
         SelectedPropertyIndex = 0;
         Members.Clear();
         Sprite   = s.Sprite;
         ReturnTo = s.ReturnTo;
         if (ReturnTo == null)
         {
             ReturnTo = (Owner.Systems[ComponentSystem.IdentifierOf <ModalFocusSystem>()] as ModalFocusSystem).CurrentSystem;
         }
         foreach (FieldInfo field in typeof(Sprite).GetFields())
         {
             Members.Add(new FieldSummary(Owner, field, Sprite));
         }
         foreach (PropertyInfo property in typeof(Sprite).GetProperties())
         {
             Members.Add(new PropertySummary(Owner, property, Sprite));
         }
     }
     else if (e is ModalChangeEvent)
     {
         ModalActive  = true;
         ModalVisible = true;
     }
     else if (e is BeginModalChangeEvent bmce)
     {
         bmce.SystemName = ReturnTo;
         ModalActive     = false;
         ModalVisible    = false;
     }
 }
Exemplo n.º 12
0
        /// <summary>
        ///  Helper function for transforming from window to world coordinates.
        ///  This only works if cameraEntity has a valid LocalToWorld
        ///  component. The windowPos (window position) and windowSize (window size) should be
        ///  in the same coordinates. The Z coordinate is set to 0.
        /// </summary>
        public static float3 WindowToWorld(ComponentSystem callingSystem, Entity cameraEntity, float2 windowPos, float2 windowSize)
        {
            var mgr = callingSystem.EntityManager;

            if (!mgr.HasComponent <DisplayListCamera>(cameraEntity) ||
                !mgr.HasComponent <Camera2D>(cameraEntity))
            {
                return(float3.zero);
            }

            DisplayListCamera dlc = mgr.GetComponentData <DisplayListCamera>(cameraEntity);
            Camera2D          c2d = mgr.GetComponentData <Camera2D>(cameraEntity);

            float  aspect = windowSize.x / windowSize.y;
            float2 camsize;

            camsize.x = c2d.halfVerticalSize * aspect;
            camsize.y = c2d.halfVerticalSize;
            float2 normalizedWindow;

            normalizedWindow.x = (windowPos.x / windowSize.x) * 2.0f - 1.0f;
            normalizedWindow.y = (windowPos.y / windowSize.y) * 2.0f - 1.0f;
            float3 viewpos;

            viewpos.x = normalizedWindow.x * camsize.x;
            viewpos.y = normalizedWindow.y * camsize.y;
            viewpos.z = 0;
            float3 worldPos = math.transform(dlc.world, viewpos);

            return(worldPos);
        }
Exemplo n.º 13
0
        private static float3 InverseTransformPoint(ComponentSystem callingSystem, Entity node, float3 p)
        {
            float4x4 wm = ComputeWorldMatrix(callingSystem, node);

            wm = math.inverse(wm);
            return(math.transform(wm, p));
        }
Exemplo n.º 14
0
        /// <summary>
        ///  Computes a transform node's world rotation.
        ///  This function uses the computeWorldMatrix function to compute the world
        ///  matrix (bypassing caching), and returns the rotation of that.
        ///
        ///  This function can be quite resource intensive. When possible, read the
        ///  LocalToWorld component instead.
        /// </summary>
        public static quaternion ComputeWorldRotation(ComponentSystem callingSystem, Entity node)
        {
            float4x4 wm      = ComputeWorldMatrix(callingSystem, node);
            float3x3 rotpart = new float3x3(wm[0].xyz, wm[1].xyz, wm[2].xyz);

            return(new quaternion(rotpart));
        }
Exemplo n.º 15
0
 public override void Setup()
 {
     base.Setup();
     MenuComponentManager = ComponentSystem.RegisterComponent <MenuComponent>(3);
     HealthManager        = ComponentSystem.RegisterComponent <Health>(1);
     this.OnEvent <test.DamageEvent>().Subscribe(_ => { DamageSystemDamageEventFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 16
0
 public override void Setup()
 {
     base.Setup();
     LobbyButtonManager = ComponentSystem.RegisterComponent <LobbyButton>();
     RoomManager        = ComponentSystem.RegisterComponent <Room>();
     DriverManager      = ComponentSystem.RegisterComponent <Driver>();
     this.OnEvent <uFrame.Kernel.GameReadyEvent>().Subscribe(_ => { PhotonSystemGameReadyFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 17
0
 public override void Setup()
 {
     base.Setup();
     UserLoginInfoManager = ComponentSystem.RegisterComponent <UserLoginInfo>(23);
     BlackBoardSystem.EnsureBlackBoard <UserLoginInfo>();
     this.OnEvent <Playfab.UserLoggedIn>().Subscribe(_ => { LoginSystemUserLoggedInFilter(_); }).DisposeWith(this);
     this.OnEvent <Playfab.UserLoggedOut>().Subscribe(_ => { LoginSystemUserLoggedOutFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 18
0
 public ReflectedEventHandlerInfo(ComponentSystem handler, Method method, int priority, ICollection <Type> filterComponents, ICollection <Type> componentParams)
 {
     this.handler          = handler;
     this.method           = method;
     this.filterComponents = ImmutableList.copyOf(filterComponents);
     this.componentParams  = ImmutableList.copyOf(componentParams);
     this.priority         = priority;
 }
Exemplo n.º 19
0
 public override void Setup()
 {
     base.Setup();
     healthCompManager   = ComponentSystem.RegisterComponent <healthComp>(2);
     playerCompManager   = ComponentSystem.RegisterComponent <playerComp>(3);
     NewGroupNodeManager = ComponentSystem.RegisterGroup <NewGroupNodeGroup, NewGroupNode>();
     this.OnEvent <uFrame.ECS.UnityUtilities.MouseDownDispatcher>().Subscribe(_ => { inpSysOnMouseDownFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 20
0
 public override void Setup()
 {
     base.Setup();
     DriverManager = ComponentSystem.RegisterComponent <Driver>();
     this.OnEvent <uFrame.Kernel.GameReadyEvent>().Subscribe(_ => { KernelGameReadyFilter(_); }).DisposeWith(this);
     this.OnEvent <DireDungeons.LoadSceneEvent>().Subscribe(_ => { KernelLoadSceneEventFilter(_); }).DisposeWith(this);
     this.OnEvent <DireDungeons.UnloadSceneEvent>().Subscribe(_ => { KernelUnloadSceneEventFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 21
0
 public override void Setup()
 {
     base.Setup();
     healthCompManager   = ComponentSystem.RegisterComponent <healthComp>(2);
     playerCompManager   = ComponentSystem.RegisterComponent <playerComp>(3);
     NewGroupNodeManager = ComponentSystem.RegisterGroup <NewGroupNodeGroup, NewGroupNode>();
     this.OnEvent <test.NewEventNode>().Subscribe(_ => { healthSysNewEventNodeFilter(_); }).DisposeWith(this);
 }
 public override void Setup()
 {
     base.Setup();
     HealthManager = ComponentSystem.RegisterComponent <Health>(1);
     SwordManager  = ComponentSystem.RegisterComponent <Sword>(3);
     ShieldManager = ComponentSystem.RegisterComponent <Shield>(2);
     OrcManager    = ComponentSystem.RegisterGroup <OrcGroup, Orc>();
 }
Exemplo n.º 23
0
 public void Update(ComponentSystem cs)
 {
     cachedGetSprite2DRenderer        = cs.GetComponentDataFromEntity <Sprite2DRenderer>();
     cachedGetSprite2DPrivate         = cs.GetComponentDataFromEntity <Sprite2DPrivate>();
     cachedGetSprite2DRendererOptions = cs.GetComponentDataFromEntity <Sprite2DRendererOptions>();
     cachedGetSprite2D       = cs.GetComponentDataFromEntity <Sprite2D>();
     cachedGetSprite2DBorder = cs.GetComponentDataFromEntity <Sprite2DBorder>();
 }
Exemplo n.º 24
0
 private double MonitorSystemFixedUpdateDuration(ComponentSystem _componentSystem)
 {
     _stopwatch.Reset();
     _stopwatch.Start();
     _componentSystem.OnFixedUpdate();
     _stopwatch.Stop();
     return(_stopwatch.Elapsed.TotalMilliseconds);
 }
 public override void Setup()
 {
     base.Setup();
     ShootingGunsManager = ComponentSystem.RegisterGroup <ShootingGunsGroup, ShootingGuns>();
     PlayerGunnerManager = ComponentSystem.RegisterGroup <PlayerGunnerGroup, PlayerGunner>();
     GunManager          = ComponentSystem.RegisterComponent <Gun>(2);
     GunnerInputManager  = ComponentSystem.RegisterComponent <GunnerInput>(3);
     GunnerManager       = ComponentSystem.RegisterComponent <Gunner>(1);
 }
Exemplo n.º 26
0
 public override void Setup()
 {
     base.Setup();
     PlayerGunnerManager = ComponentSystem.RegisterGroup <PlayerGunnerGroup, PlayerGunner>();
     MovableManager      = ComponentSystem.RegisterComponent <Movable>(23);
     HazardManager       = ComponentSystem.RegisterComponent <Hazard>(9);
     WavesGameManager    = ComponentSystem.RegisterComponent <WavesGame>(15);
     PlayerManager       = ComponentSystem.RegisterComponent <Player>(22);
 }
Exemplo n.º 27
0
 public override void Setup()
 {
     base.Setup();
     HealthManager = ComponentSystem.RegisterComponent <Health>(3);
     OrcManager    = ComponentSystem.RegisterGroup <OrcGroup, Orc>();
     SwordManager  = ComponentSystem.RegisterComponent <Sword>(1);
     ShieldManager = ComponentSystem.RegisterComponent <Shield>(2);
     this.OnEvent <uFrame.Kernel.GameReadyEvent>().Subscribe(_ => { DebugSystemGameReadyFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 28
0
        private static float3 InverseTransformScale(ComponentSystem callingSystem, Entity node, float3 s)
        {
            float4x4 wm = ComputeWorldMatrix(callingSystem, node);

            wm = math.inverse(wm);
            float3 sm = new float3(math.length(wm[0].xyz), math.length(wm[1].xyz), math.length(wm[2].xyz));

            return(sm * s);
        }
Exemplo n.º 29
0
 public override void Setup()
 {
     base.Setup();
     LobbyButtonManager     = ComponentSystem.RegisterComponent <LobbyButton>();
     LobbyMenuManager       = ComponentSystem.RegisterComponent <LobbyMenu>();
     UpdateConnectedManager = ComponentSystem.RegisterComponent <UpdateConnected>();
     this.OnEvent <uFrame.ECS.PointerClickDispatcher>().Subscribe(_ => { LobbySystemPointerClickFilter(_); }).DisposeWith(this);
     this.OnEvent <uFrame.ECS.OnConnectedToMasterDispatcher>().Subscribe(_ => { LobbySystemOnConnectedToMasterFilter(_); }).DisposeWith(this);
 }
Exemplo n.º 30
0
 /// <summary>
 ///  Returns the size of the childTransform's parent. If the childTransform
 ///  doesn't have a parent, returns the screen size.
 /// </summary>
 public static float2 GetRectTransformSizeOfParent(ComponentSystem sys, Entity parent)
 {
     // If there is no parent, return screen size.
     if (parent == Entity.Null)
     {
         return(GetScreenSize(sys));
     }
     return(GetRectTransformSizeOfEntity(sys, parent));
 }