/// <summary> /// Constructs a changeset for overwriting an integer field. /// </summary> /// <param name="modifier">Reference to the modifier object.</param> /// <param name="tileset">The tileset of this changeset.</param> public CellDataChangeSetBase(ICellDataModifier modifier, TileSet tileset) { if (tileset == null) { throw new ArgumentNullException("tileset"); } if (modifier == null) { throw new ArgumentNullException("modifier"); } this.tileset = tileset; this.modifier = modifier; }
/// <summary> /// Constructs a changeset for overwriting an integer field. /// </summary> /// <param name="targetQuarter">The quarter of the isometric tile to perform the changeset.</param> /// <param name="modifier">Reference to the modifier.</param> /// <param name="tileset">The tileset of this changeset.</param> public IsoQuarterChangeSet(MapDirection targetQuarter, ICellDataModifier modifier, TileSet tileset) : base(modifier, tileset) { this.CheckAndAssignCtorParams(targetQuarter); }
/// <summary> /// Constructs a changeset for overwriting an integer field. /// </summary> /// <param name="targetRow">The row of the target to perform the changeset.</param> /// <param name="modifier">Reference to the modifier.</param> /// <param name="tileset">The tileset of this changeset.</param> public RowChangeSet(int targetRow, ICellDataModifier modifier, TileSet tileset) : base(modifier, tileset) { this.CheckAndAssignCtorParams(targetRow); }
/// <summary> /// Constructs a changeset for overwriting an integer field. /// </summary> /// <param name="targetCell">The cell of the target to perform the changeset.</param> /// <param name="modifier">Reference to the modifier.</param> /// <param name="tileset">The tileset of this changeset.</param> public CellChangeSet(RCIntVector targetCell, ICellDataModifier modifier, TileSet tileset) : base(modifier, tileset) { this.CheckAndAssignCtorParams(targetCell); }
/// <summary> /// Constructs a changeset for overwriting an integer field. /// </summary> /// <param name="targetCol">The column of the target to perform the changeset.</param> /// <param name="modifier">Reference to the modifier.</param> /// <param name="tileset">The tileset of this changeset.</param> public ColumnChangeSet(int targetCol, ICellDataModifier modifier, TileSet tileset) : base(modifier, tileset) { this.CheckAndAssignCtorParams(targetCol); }
/// <summary> /// Load a cell data changeset from the given XML element. /// </summary> /// <param name="fromElem">The XML element to load from.</param> /// <param name="tileset">The tileset being loaded.</param> /// <returns>The loaded cell data changeset.</returns> private static ICellDataChangeSet LoadCellDataChangeSet(XElement fromElem, TileSet tileset) { ICellDataChangeSet retObj = null; ICellDataModifier modifier = null; /// Load the name of the target field. XAttribute fieldAttr = fromElem.Attribute(XmlTileSetConstants.CELLDATACHANGESET_FIELD_ATTR); if (fieldAttr == null) { throw new TileSetException("Field name not defined for a data changeset element!"); } if (fieldAttr.Value == XmlTileSetConstants.CELLDATA_ISWALKABLE_NAME) { modifier = new WalkabilityFlagModifier(XmlHelper.LoadBool(fromElem.Value)); } else if (fieldAttr.Value == XmlTileSetConstants.CELLDATA_ISBUILDABLE_NAME) { modifier = new BuildabilityFlagModifier(XmlHelper.LoadBool(fromElem.Value)); } else if (fieldAttr.Value == XmlTileSetConstants.CELLDATA_GROUNDLEVEL_NAME) { modifier = new GroundLevelModifier(XmlHelper.LoadInt(fromElem.Value)); } if (modifier == null) { throw new TileSetException("Unexpected field name defined for a data changeset element!"); } switch (fromElem.Name.LocalName) { case XmlTileSetConstants.CELLDATACHANGESET_ALL_ELEM: retObj = new CellDataChangeSetBase(modifier, tileset); break; case XmlTileSetConstants.CELLDATACHANGESET_CELL_ELEM: XAttribute cellAttr = fromElem.Attribute(XmlTileSetConstants.CELLDATACHANGESET_CELL_CELL_ATTR); if (cellAttr == null) { throw new TileSetException("Cell not defined for a cell data changeset element!"); } retObj = new CellChangeSet(XmlHelper.LoadIntVector(cellAttr.Value), modifier, tileset); break; case XmlTileSetConstants.CELLDATACHANGESET_COL_ELEM: XAttribute colIndexAttr = fromElem.Attribute(XmlTileSetConstants.CELLDATACHANGESET_COL_INDEX_ATTR); if (colIndexAttr == null) { throw new TileSetException("Column not defined for a column data changeset element!"); } retObj = new ColumnChangeSet(XmlHelper.LoadInt(colIndexAttr.Value), modifier, tileset); break; case XmlTileSetConstants.CELLDATACHANGESET_QUARTER_ELEM: XAttribute quarterAttr = fromElem.Attribute(XmlTileSetConstants.CELLDATACHANGESET_QUARTER_WHICH_ATTR); if (quarterAttr == null) { throw new TileSetException("Quarter not defined for a quarter data changeset element!"); } MapDirection quarter; if (!EnumMap <MapDirection, string> .TryDemap(quarterAttr.Value, out quarter)) { throw new TileSetException(string.Format("Unexpected quarter '{0}' defined for quarter data changeset!", quarterAttr.Value)); } retObj = new IsoQuarterChangeSet(quarter, modifier, tileset); break; case XmlTileSetConstants.CELLDATACHANGESET_RECT_ELEM: XAttribute rectAttr = fromElem.Attribute(XmlTileSetConstants.CELLDATACHANGESET_RECT_RECT_ATTR); if (rectAttr == null) { throw new TileSetException("Rectangle not defined for a rectangle data changeset element!"); } retObj = new RectangleChangeSet(XmlHelper.LoadIntRectangle(rectAttr.Value), modifier, tileset); break; case XmlTileSetConstants.CELLDATACHANGESET_ROW_ELEM: XAttribute rowIndexAttr = fromElem.Attribute(XmlTileSetConstants.CELLDATACHANGESET_ROW_INDEX_ATTR); if (rowIndexAttr == null) { throw new TileSetException("Row not defined for a row data changeset element!"); } retObj = new RowChangeSet(XmlHelper.LoadInt(rowIndexAttr.Value), modifier, tileset); break; default: throw new TileSetException(string.Format("Unexpected data changeset element '{0}'!", fromElem.Name)); } if (retObj == null) { throw new TileSetException("Unable to load cell data changeset!"); } return(retObj); }
/// <summary> /// Constructs a changeset for overwriting an integer field. /// </summary> /// <param name="targetRect">The rectangle of the target to perform the changeset.</param> /// <param name="modifier">Reference to the modifier.</param> /// <param name="tileset">The tileset of this changeset.</param> public RectangleChangeSet(RCIntRectangle targetRect, ICellDataModifier modifier, TileSet tileset) : base(modifier, tileset) { this.CheckAndAssignCtorParams(targetRect); }