public ParsedMessage(String message, Logger log) { LOG = log; MessageString = message; String messageNoBrackets = message.Replace("{", "").Replace("}", ""); ReadProperties(messageNoBrackets); foreach (var pair in messageElements) { try { switch (pair.Key) { case MESSAGETYPE_FLAG: ParseMessageType(pair.Value); break; case ORDERTYPE_FLAG: ParseOrderType(pair.Value); break; case REQUESTID_FLAG: RequestID = double.Parse(pair.Value); break; case ENTITYID_FLAG: EntityId = long.Parse(pair.Value); break; case PERCENTCARGO_FLAG: PercentCargo = double.Parse(pair.Value); break; case COMMANDID_FLAG: CommanderId = long.Parse(pair.Value); break; case RELATIONSHIP_FLAG: MyRelationsBetweenPlayerAndBlock.TryParse(pair.Value, out Relationship); break; case TARGETID_FLAG: TargetEntityId = long.Parse(pair.Value); break; case NUMMININGDRILLS_FLAG: DrillCount = int.Parse(pair.Value); break; case NUMSENSORS_FLAG: SensorCount = int.Parse(pair.Value); break; case NUMCONNECTORS_FLAG: ConnectorCount = int.Parse(pair.Value); break; case NUMBOUNCES_FLAG: NumBounces = (int)double.Parse(pair.Value); break; case SHIPSIZE_FLAG: ShipSize = double.Parse(pair.Value); break; case MAXBOUNCE_FLAG: MaxNumBounces = (int)double.Parse(pair.Value); break; case TYPE_FLAG: Type = pair.Value; break; case NUMCAMERA_FLAG: CameraCount = int.Parse(pair.Value); break; case ATTACKPOINT_FLAG: AttackPoint = TryParseVector(pair.Value); break; case NAME_FLAG: Name = pair.Value; break; case LOCATION_FLAG: Location = TryParseVector(pair.Value); break; case VELOCITY_FLAG: Velocity = TryParseVector(pair.Value); break; case DOCKEDSTATUS_FLAG: Docked = bool.Parse(pair.Value); break; case STATUS_FLAG: Status = pair.Value; break; case ALIGNFORWARDVECTOR_FLAG: AlignForward = TryParseVector(pair.Value); break; case ALIGNUPVECTOR_FLAG: AlignUp = TryParseVector(pair.Value); break; case AWAKENING_FLAG: IsAwakeningSignal = true; break; case TARGETRADIUS_FLAG: TargetRadius = (int)double.Parse(pair.Value); break; case NUMWEAPONS_FLAG: WeaponCount = int.Parse(pair.Value); break; case HP_FLAG: HP = double.Parse(pair.Value); break; case STORAGEMX_FLAG: MaxStorage = double.Parse(pair.Value); break; case MERGE_FLAG: MergeCount = int.Parse(pair.Value); break; case GUNS_FLAG: GuneCount = int.Parse(pair.Value); break; case ROCKET_FLEG: RocketCount = int.Parse(pair.Value); break; case REACTOR_FLAG: ReactorCount = int.Parse(pair.Value); break; case BATTERY_FLAG: BatteryCount = int.Parse(pair.Value); break; case CURPOWER_FLAG: CurrentPower = double.Parse(pair.Value); break; case MAXPOWER_FLAG: MaxPower = double.Parse(pair.Value); break; default: return; } } catch (Exception e) { log.Error("Error parsing Communications\n" + e.Message + " " + pair.Key + ":" + pair.Value); } } }