Ejemplo n.º 1
0
        /// <summary>
        /// Checks if a given active entity should be unloaded.
        /// </summary>
        /// <param name="ent">The entity to check.</param>
        /// <param name="activeList">The list for loaded entities.</param>
        /// <param name="inactiveList">The list for unloaded entities.</param>
        /// <param name="p3">Not used.</param>
        /// <returns>Not used.</returns>
        public bool CheckActive(Entity ent, object activeList, object inactiveList, object p3)
        {
            // Cast lists
            ThreadDictionary <UInt64, Entity> alist = (ThreadDictionary <UInt64, Entity>)activeList;
            ThreadDictionary <UInt64, Entity> ilist = (ThreadDictionary <UInt64, Entity>)inactiveList;

            // Check if entity is outside the loadport bounds
            if (ent.Position.X + ent.Radius < Location.X ||
                ent.Position.Y + ent.Radius < Location.Y ||
                ent.Position.X - ent.Radius > Location.X + Size.X ||
                ent.Position.Y - ent.Radius > Location.Y + Size.Y)
            {
                // If it's a temporary entity we just delete it instead of unloading it
                if (ent.Temporary)
                {
                    ent.Dispose(); return(true);
                }
                if (ent as Crosshair != null)
                {
                    return(true);
                }

                alist.Remove(ent.ID);   // Remove entity from loaded list
                ilist.Add(ent.ID, ent); // Add entity to unloaded list
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new screen manager.
        /// </summary>
        public ScreenManager()
        {
            // Setup input
            _Input = new InputManager();
            _Input.StateChanged += OnInput;

            // Setup screens
            _Screens = new ThreadDictionary <string, Screen>();
            _Screens.QueuesEmptied += DepthCheck;
            SetResolution(new Vector2(DefaultHorizontalResolution, DefaultHorizontalResolution / DefaultScreenRatio));

            // Register events
            _Screens.ItemAdded   += OnScreenAdded;
            _Screens.ItemRemoved += OnScreenRemoved;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks if a given inactive entity should be loaded.
        /// </summary>
        /// <param name="ent">The entity to check.</param>
        /// <param name="activeList">The list for loaded entities.</param>
        /// <param name="inactiveList">The list for unloaded entities.</param>
        /// <param name="p3">Not used.</param>
        /// <returns>Not used.</returns>
        public bool CheckInactive(Entity ent, object activeList, object inactiveList, object p3)
        {
            // Cast lists
            ThreadDictionary <UInt64, Entity> alist = (ThreadDictionary <UInt64, Entity>)activeList;
            ThreadDictionary <UInt64, Entity> ilist = (ThreadDictionary <UInt64, Entity>)inactiveList;

            // Check if entity is within loadport bounds
            if (!(ent.Position.X + ent.Radius < Location.X ||
                  ent.Position.Y + ent.Radius < Location.Y ||
                  ent.Position.X - ent.Radius > Location.X + Size.X ||
                  ent.Position.Y - ent.Radius > Location.Y + Size.Y))
            {
                ilist.Remove(ent.ID);   // Remove the entity from the inactive list
                alist.Add(ent.ID, ent); // Add the entity to the active list
            }
            return(true);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates an input manager to monitor the keyboard state.
 /// </summary>
 public InputManager()
 {
     _Binds       = new ThreadDictionary <string, Bind>();
     _ScrollValue = Mouse.GetState().ScrollWheelValue;
 }