/// <summary> /// Creates a completion triggered event /// </summary> public SpeciesCompletionType(pSpeciesCompletionType h) : base(1) { object performer; this.species = h.Species; this.isAction = false; this.isStateChange = false; if ("" != h.Action) { this.isAction = true; } this.action = h.Action; if ("" != h.NewState) { this.isStateChange = true; } this.newState = h.NewState; for (int doThis = 0; doThis < h.DoThisList.Count; doThis++) { performer = h.DoThisList[doThis]; switch (performer.GetType().Name.ToString()) { // Chatropom manipulation is not supported here -- what would be the intent? case "pMoveType": this.doThisList.Add(new Move_EventType((pMoveType)performer)); /* * this is not needed because in ScenarioEvent constructor(?) if (!this.AllUnits.Contains(((pMoveType)performer).UnitID)) { this.AllUnits.Add(((pMoveType)performer).UnitID); } */ break; case "pRevealType": Reveal_EventType r = new Reveal_EventType((pRevealType)performer); r.Genus = Genealogy.GetGenus(r.UnitID); this.doThisList.Add(r); break; case "pStateChangeType": this.doThisList.Add(new StateChangeEvent((pStateChangeType)performer)); break; case "pDockType": this.doThisList.Add(new StateChangeEvent((pStateChangeType)performer)); break; case "pTransferType": this.doThisList.Add(new TransferEvent((pTransferType)performer)); break; case "pLaunchType": this.doThisList.Add(new LaunchEventType((pLaunchType)performer)); if (!this.AllUnits.Contains(((pLaunchType)performer).Child)) { this.AllUnits.Add(((pLaunchType)performer).Child); } break; case "pWeaponLaunchType": this.doThisList.Add(new WeaponLaunchEventType((pWeaponLaunchType)performer)); if (!this.AllUnits.Contains(((pWeaponLaunchType)performer).Child)) { this.AllUnits.Add(((pWeaponLaunchType)performer).Child); } break; case "pChangeEngramType": this.doThisList.Add(new ChangeEngramType((pChangeEngramType)performer)); break; case "pRemoveEngramType": this.doThisList.Add(new RemoveEngramEvent((pRemoveEngramType)performer)); break; case "pFlushEventType": this.doThisList.Add(new FlushEvents((pFlushEventsType)performer)); break; default: Coordinator.debugLogger.LogError("Scenario reader", "Unknown happening event type for " + performer.ToString()); break; } } }
public override pSpeciesCompletionType pGetSpeciesCompletion() { string species = "Unknown species"; string action = "", newState = ""; pSpeciesCompletionType returnValue; //object eventToPerform; try { reader.Read(); species = pGetString(); if ("Action" == reader.Name) { action = pGetString(); } else if ("NewState" == reader.Name) { newState = pGetString(); } returnValue = new pSpeciesCompletionType(species, action, newState); List<object> doThisList = pGetDoThisList(); for (int i = 0; i < doThisList.Count; i++) returnValue.AddAction(doThisList[i]); /* while ("DoThis" == reader.Name) { reader.Read(); // bypass the DoThis tag switch (reader.Name) { case "Move_Event": eventToPerform = pGetMove(); break; case "Reveal_Event": eventToPerform = pGetReveal(); break; case "StateChange_Event": eventToPerform = pGetStateChange(); break; case "Transfer_Event": eventToPerform = pGetTransfer(); break; case "Launch_Event": eventToPerform = pGetLaunch(); break; case "ChangeEngram": eventToPerform = pGetChangeEngram(); break; case "RemoveEngram": eventToPerform = pGetRemoveEngram(); break; case "FlushEvents": eventToPerform = pGetFlushEventsType(); break; default: // Coordinator.debugLogger.WriteLine("Unknown Happening Complete Event: " + reader.Name); eventToPerform = null; break; } if (null != eventToPerform) { returnValue.AddAction(eventToPerform); } reader.ReadEndElement(); //Pass the </DoThis> } */ reader.ReadEndElement(); // Pass the </Completion_Event> } catch (System.Exception e) { throw new ApplicationException("Error reading Species_Completion command for species named " + species + ": ", e); } return returnValue; }