Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Region"/> class.
 /// </summary>
 /// <param name="region">Region which should be copied.</param>
 public Region(Region region)
 {
     m_regionPosition = region.m_regionPosition;
     m_terrains = region.m_terrains;
     m_entities = region.m_entities;
     m_territory = region.m_territory;
     m_actions = new DatedActions();
     m_actions.Actions = new LinkedList<Core.Models.Action>();
     m_exist = region.m_exist;
     m_mutex = region.m_mutex;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Region"/> class.
 /// </summary>
 /// <param name="regionPosition">Region position.</param>
 /// <param name="terrains">Terrains of the region.</param>
 public Region(RegionPosition regionPosition, TerrainDefinition[,] terrains)
 {
     m_regionPosition = regionPosition;
     m_terrains       = terrains;
     m_entities       = new DatedEntities();
     m_territory      = new Dictionary <PositionI, Account>();
     throw new Exception("Territory need to be load");
     m_actions = new DatedActions();
     m_exist   = true;
     m_mutex   = new ReaderWriterLockSlim();
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Region"/> class.
 /// </summary>
 /// <param name="region">Region which should be copied.</param>
 public Region(Region region)
 {
     m_regionPosition  = region.m_regionPosition;
     m_terrains        = region.m_terrains;
     m_entities        = region.m_entities;
     m_territory       = region.m_territory;
     m_actions         = new DatedActions();
     m_actions.Actions = new LinkedList <Core.Models.Action>();
     m_exist           = region.m_exist;
     m_mutex           = region.m_mutex;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Region"/> class.
 /// Use Only when there are not data. It will create an empty region where nothing can be changed.
 /// </summary>
 /// <param name="regionPosition">Region position.</param>
 public Region(RegionPosition regionPosition)
 {
     m_regionPosition = regionPosition;
     m_terrains = new TerrainDefinition[Constants.REGION_SIZE_X, Constants.REGION_SIZE_Y];
     m_entities = new DatedEntities();
     m_entities.Entities = new LinkedList<Entity>();
     m_territory = new Dictionary<PositionI, Account>();
     m_actions = new DatedActions();
     m_actions.Actions = new LinkedList<Core.Models.Action>();
     m_exist = Cheats.DONT_LOAD_REGIONS_MODE;
     m_mutex = new ReaderWriterLockSlim();
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Region"/> class.
 /// Use Only when there are not data. It will create an empty region where nothing can be changed.
 /// </summary>
 /// <param name="regionPosition">Region position.</param>
 public Region(RegionPosition regionPosition)
 {
     m_regionPosition    = regionPosition;
     m_terrains          = new TerrainDefinition[Constants.REGION_SIZE_X, Constants.REGION_SIZE_Y];
     m_entities          = new DatedEntities();
     m_entities.Entities = new LinkedList <Entity>();
     m_territory         = new Dictionary <PositionI, Account>();
     m_actions           = new DatedActions();
     m_actions.Actions   = new LinkedList <Core.Models.Action>();
     m_exist             = Cheats.DONT_LOAD_REGIONS_MODE;
     m_mutex             = new ReaderWriterLockSlim();
 }
Beispiel #6
0
        /// <summary>
        /// Builds a new list with all actions which are lower then the given startTime.
        /// </summary>
        /// <param name="startTime">Date time when region was last time loaded.</param>
        /// <returns>DatedActions from startTime</returns>
        public DatedActions GetCompletedActions(DateTime startTime)
        {
            var returnActions  = new DatedActions();
            var currentActions = m_actions;

            var actionsCollection = new LinkedList <Core.Models.Action>();

            foreach (var action in currentActions.Actions)
            {
                if (action.ActionTime <= startTime)
                {
                    break;
                }
                actionsCollection.AddFirst(action);
            }

            returnActions.Actions        = actionsCollection;
            returnActions.DateTime       = currentActions.DateTime;
            returnActions.RegionPosition = RegionPosition;

            return(returnActions);
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Region"/> class.
 /// </summary>
 /// <param name="regionPosition">Region position.</param>
 /// <param name="terrains">Terrains of the region.</param>
 public Region(RegionPosition regionPosition, TerrainDefinition[,] terrains)
 {
     m_regionPosition = regionPosition;
     m_terrains = terrains;
     m_entities = new DatedEntities();
     m_territory = new Dictionary<PositionI, Account>();
     throw new Exception("Territory need to be load");
     m_actions = new DatedActions();
     m_exist = true;
     m_mutex = new ReaderWriterLockSlim();
 }
Beispiel #8
0
        /// <summary>
        /// Builds a new list with all actions which are lower then the given startTime.
        /// </summary>
        /// <param name="startTime">Date time when region was last time loaded.</param>
        /// <returns>DatedActions from startTime</returns>
        public DatedActions GetCompletedActions(DateTime startTime)
        {
            var returnActions = new DatedActions();
            var currentActions = m_actions;

            var actionsCollection = new LinkedList<Core.Models.Action>();
            foreach (var action in currentActions.Actions)
            {
                if (action.ActionTime <= startTime)
                {
                    break;
                }
                actionsCollection.AddFirst(action);
            }

            returnActions.Actions = actionsCollection;
            returnActions.DateTime = currentActions.DateTime;
            returnActions.RegionPosition = RegionPosition;

            return returnActions;
        }