Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Adds the specified screen to the screen manager.
 /// </summary>
 /// <param name="screen">The screen to be added.</param>
 public virtual void AddScreen(Screen screen)
 {
     _Screens.Add(screen.Name, screen);
     DepthCheck();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a binding to the list to be monitored.
 /// </summary>
 /// <param name="bind">The new key binding to monitor.</param>
 public virtual void AddBind(Bind bind)
 {
     _Binds.Add(bind.Name, bind);
 }