/// <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; }
/// <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(); }
/// <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(); }
/// <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(); }
/// <summary> /// Removes the entity to a specific time. /// </summary> /// <param name="dateTime">Date time when the action was called.</param> /// <param name="entity">Entity which should be removed from this region.</param> public void RemoveEntity(DateTime dateTime, Entity entity) { var newDatedEntities = new DatedEntities(); var newEntities = new LinkedList <Entity>(m_entities.Entities); newEntities.Remove(entity); newDatedEntities.DateTime = dateTime; newDatedEntities.Entities = newEntities; newDatedEntities.RegionPosition = RegionPosition; m_entities = newDatedEntities; }
/// <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(); }
/// <summary> /// Removes the entity to a specific time. /// </summary> /// <param name="dateTime">Date time when the action was called.</param> /// <param name="entity">Entity which should be removed from this region.</param> public void RemoveEntity(DateTime dateTime, Entity entity) { var newDatedEntities = new DatedEntities(); var newEntities = new LinkedList<Entity>(m_entities.Entities); newEntities.Remove(entity); newDatedEntities.DateTime = dateTime; newDatedEntities.Entities = newEntities; newDatedEntities.RegionPosition = RegionPosition; m_entities = newDatedEntities; }