public void AddInstruction(Item _item, Vector3Int _position, int _rotation) { ItemGenerateInstruction instruction = new ItemGenerateInstruction(); instruction.id = _item.id; instruction.item = _item; instruction.position = _position; instruction.rotation = _rotation; itemGenerateInstructions.Add(instruction); this.AddItemInMap(instruction); }
public void AddItemInMap(ItemGenerateInstruction _instruction) { Vector3Int pos1 = new Vector3Int(), pos2 = new Vector3Int(); GetStartAndEnd(_instruction, ref pos1, ref pos2); for (int i = pos1.x; i <= pos2.x; i++) { for (int j = pos1.z; j <= pos2.z; j++) { m_instructions[i, pos1.y / 2, j] = _instruction; } } }
public void RemoveInstruction(ItemGenerateInstruction _instruction) { itemGenerateInstructions.Remove(_instruction); Vector3Int pos1 = new Vector3Int(), pos2 = new Vector3Int(); GetStartAndEnd(_instruction, ref pos1, ref pos2); for (int i = pos1.x; i <= pos2.x; i++) { for (int j = pos1.z; j <= pos2.z; j++) { m_instructions[i, pos1.y / 2, j] = null; } } }
public void GetStartAndEnd(ItemGenerateInstruction _instruction, ref Vector3Int _pos1, ref Vector3Int _pos2) { GetStartAndEnd(_instruction.position, _instruction.rotation, _instruction.item.size, ref _pos1, ref _pos2); }