public void SpawnObject() { ICommand cmd = new SpawnObjectCommand(); cmd.execute(templateToCopy, objectGhost.transform.position, objectGhost.transform.rotation); m_undoStack.Push(cmd); m_redoStack.Clear(); }
/// <summary> /// Executes the building logic. /// </summary> public override void Execute() { if (_XYLogic.inputFieldX.text == "" || _XYLogic.inputFieldY.text == "") { return; } SpawnObjectCommand command = new SpawnObjectCommand(Properties.buildings[(int)_buildingType], _buildingType, -15 + _XYLogic.x * 9, 5 + _XYLogic.y * 9); command.Execute(); }
void SpawnInstance(int index) { Ray ray = Camera.main.ViewportPointToRay(new Vector2(.5f, .5f)); int roomBoundsMask = (1 << LayerMask.NameToLayer("RoomBounds")); RaycastHit hit; Vector3? spawnPosition = null; if(Physics.Raycast(ray, out hit, Mathf.Infinity, roomBoundsMask)) { spawnPosition = hit.point; } index = Mathf.Clamp(index, 0, _assetsToSpawn.Length - 1); SpawnObjectCommand command = new SpawnObjectCommand(_assetsToSpawn[index], spawnPosition); UndoManager.GetInstance().Do(command); }
protected void SpawnObjectCommandHandler(SpawnObjectCommand cmd) { cmd.result = _server.SpawnObject(cmd.spawnHandlerID); }