public void RXInput(bool pGrid, Vector2 pos, CellStruct cs) { //Don't need to ensure local player, grid only assigned to localplayer if (this.actionLocked) { //Debug.Log("Got input, but we're already locked... ignoring"); return; } switch (this.apc) { case ActionProcState.reject: Debug.Log("APC Reject: Ignoring input from grid"); //Do nothing, we ignore the request break; case ActionProcState.multiTower: if (!pGrid) // Only build on our side { break; // Our validator would catch this, but we do some more logic below that relies on this assumption } int idx; Dictionary <pAction, CellStruct> buildDict = new Dictionary <pAction, CellStruct> { { pAction.buildOffenceTower, new CellStruct(CBldg.towerOffence) }, { pAction.buildDefenceTower, new CellStruct(CBldg.towerDefence) }, { pAction.buildIntelTower, new CellStruct(CBldg.towerIntel) } }; CellStruct[][,] currentGrids = this.pb2d.GetGridStates(); ActionReq MultiTowerAR = new ActionReq(this.report.playerId, this.report.playerId, this.actionContext, new Vector2[] { pos }); if (this.v.Validate(MultiTowerAR, currentGrids[0], currentGrids[1], pb2d.GetGridVec2Size(), this.report.latestCapitolLocs)) { idx = this.queuedActions.FindIndex(x => x.a == pAction.noAction); if (idx >= 0) { Debug.Log("Input processor: Valid Move: Add new AR at " + idx.ToString() + ", ar: " + MultiTowerAR.ToString()); this.queuedActions[idx] = MultiTowerAR; this.pb2d.SetCellStruct(true, pos, buildDict[this.actionContext]); break; } } else { Debug.LogFormat("Input processor: Invalid request, don't add to list: {0}", MultiTowerAR.ToString()); } if (this.v.BldgIn(currentGrids[0], pos, buildDict.Values.ToList().Select(cstruct => cstruct.bldg).ToList())) // Now, if there is a tower here already, remove it { idx = this.queuedActions.FindIndex(x => buildDict.Keys.ToList().Contains(x.a) && x.loc != null && x.loc[0] == pos); if (idx >= 0) { Debug.Log("Input processor: Removing AR that is in this place"); this.queuedActions[idx] = new ActionReq(this.report.playerId, this.report.playerId, pAction.noAction, null); this.pb2d.SetCellStruct(true, pos, new CellStruct(CBldg.empty)); } } break; case ActionProcState.basicActions: ActionReq singleAR = new ActionReq(this.report.playerId, this.report.playerId, pAction.noAction, null); // NoAction should always fail eval int target = pGrid ? this.report.playerId : this.report.enemyId; switch (this.actionContext) // May not need this to be a switch statement after refactor... lol TODO { case pAction.noAction: break; // don't do nuthin if no action context case pAction.blockingShot: //These guys don't need a target, don't do anything here, assume handled by set action context case pAction.hellFire: case pAction.flare: break; case pAction.fireBasic: // All of these single targeted actions can be handled the same way case pAction.scout: // All differences in placement rules are handled by the validator case pAction.buildDefenceTower: case pAction.buildOffenceTower: case pAction.buildIntelTower: case pAction.buildWall: case pAction.fireAgain: case pAction.fireRow: // this is multi location, but still single targeted shot case pAction.fireSquare: // this is multi location, but still single targeted shot case pAction.placeMine: case pAction.buildDefenceGrid: case pAction.buildReflector: case pAction.firePiercing: case pAction.placeMole: case pAction.towerTakeover: singleAR = new ActionReq(this.report.playerId, target, this.actionContext, new Vector2[] { pos }); break; case pAction.fireReflected: Debug.LogError("Player input should never be able to make this action! " + this.actionContext.ToString()); break; default: Debug.LogError("Input processor unhandled actionContext: " + this.actionContext.ToString()); break; } if (this.v.Validate(singleAR, this.report.latestPlayerGrid, this.report.latestEnemyGrid, pb2d.GetGridVec2Size(), this.report.latestCapitolLocs)) { Debug.Log("Validated action: " + singleAR.ToString()); if (singleAR.a == pAction.fireBasic) { this.queuedActions[0] = singleAR; } else { this.queuedActions[1] = singleAR; } this.pb2d.SetActions(this.queuedActions); //add new action select UIController.instance.ActionDisplayUpdateShoot(singleAR); } else { Debug.Log("Bad action: " + singleAR.ToString()); } break; default: Debug.LogError("Input processor unhandled actionprocstate: " + this.apc.ToString()); break; } }