ctac.ActionSpawnPieceCommand.Execute C# (CSharp) Method

Execute() public method

public Execute ( ) : void
return void
        public override void Execute()
        {
            if (!processedActions.Verify(spawnedPiece.id)) return;

            if (spawnedPiece.cardInstanceId.HasValue)
            {
                destroyCard.Dispatch(spawnedPiece.cardInstanceId.Value);
            }

            //search for phantom piece that was created when targeting started to update props from real spawn event
            var phantomPiece = pieces.Pieces.FirstOrDefault(p => p.tags.Contains(Constants.targetPieceTag));

            PieceModel pieceModel = null;

            if (phantomPiece != null)
            {
                //update props from real spawn event
                pieceModel = phantomPiece;

                //should be a NOOP but just in case...
                pieceModel.gameObject.transform.position = map.tiles[spawnedPiece.position.Vector2].fullPosition;
                pieceModel.gameObject.name = "Piece " + spawnedPiece.pieceId;
                pieceModel.id = spawnedPiece.pieceId.Value;
                pieceModel.playerId = spawnedPiece.playerId;
                pieceModel.cardTemplateId = spawnedPiece.cardTemplateId;
                pieceModel.tags = spawnedPiece.tags;

            }
            else
            {
                pieceModel = pieceService.CreatePiece(spawnedPiece);
                animationQueue.Add(new PieceView.SpawnAnim() {
                    piece = pieceModel.gameObject.GetComponent<PieceView>(),
                    map = map,
                    mapService = mapService
                });
            }

            pieceSpawned.Dispatch(new PieceSpawnedModel(){ spawnPieceAction = spawnedPiece, piece = pieceModel });
            debug.Log(string.Format("Spawned piece {0} for player {1}", spawnedPiece.cardTemplateId, spawnedPiece.playerId), socketKey);
        }
ActionSpawnPieceCommand