public void AddEntityFromSchema(EntitySchema aEntitySchema, Vector2Int aPos, Vector2Int aFacing, Color aDefaultColor, bool aIsFixed = false, bool aIsBoundary = false) { // if the area isn't clear, throw an exception Debug.Log("AddEntityFromSchema aPos: " + aPos); if (!this.currentState.IsRectEmpty(aPos, aEntitySchema.size, null, aEntitySchema.isFront)) { throw new Exception("AddEntity - Position is invalid pos:" + aPos + " schema:" + aEntitySchema.name + " schema size:" + aEntitySchema.size); } // generate a fresh entityState without an ID EntityState newEntityStateWithoutId = EntityState.CreateEntityState(aEntitySchema, aPos, aFacing, aDefaultColor, aIsFixed, aIsBoundary); // add it to the board and get the new boardState and entityState with ID back (BoardState newBoard, EntityState newEntityStateWithId) = BoardState.AddEntity(this.currentState, newEntityStateWithoutId); // update the boardState UpdateBoardState(newBoard); CreateEntityBase(newEntityStateWithId); }