public static BaseWorldMessage ReadMessage(IncomingMessage inMessage)
 {
     BaseWorldMessage rv;
     long oid = inMessage.ReadInt64();
     WorldMessageType messageType = inMessage.ReadMessageType();
     switch (messageType) {
         case WorldMessageType.LoginResponse:
             rv = new LoginResponseMessage();
             break;
         case WorldMessageType.Comm:
             rv = new CommMessage();
             break;
         case WorldMessageType.Direction:
             rv = new DirectionMessage();
             break;
         case WorldMessageType.Orientation:
             rv = new OrientationMessage();
             break;
         case WorldMessageType.TerrainConfig:
             rv = new TerrainConfigMessage();
             break;
         case WorldMessageType.SkyboxMaterial:
             rv = new SkyboxMaterialMessage();
             break;
         case WorldMessageType.NewObject:
             rv = new NewObjectMessage();
             break;
         case WorldMessageType.FreeObject:
             rv = new FreeObjectMessage();
             break;
         case WorldMessageType.AcquireResponse:
             rv = new AcquireResponseMessage();
             break;
         case WorldMessageType.EquipResponse:
             rv = new EquipResponseMessage();
             break;
         case WorldMessageType.UnequipResponse:
             rv = new UnequipResponseMessage();
             break;
         case WorldMessageType.Attach:
             rv = new AttachMessage();
             break;
         case WorldMessageType.Detach:
             rv = new DetachMessage();
             break;
         case WorldMessageType.StatUpdate:
             rv = new StatUpdateMessage();
             break;
         case WorldMessageType.Damage:
             rv = new DamageMessage();
             break;
         case WorldMessageType.Animation:
             rv = new AnimationMessage();
             break;
         case WorldMessageType.Sound:
             rv = new SoundMessage();
             break;
         case WorldMessageType.AmbientSound:
             rv = new AmbientSoundMessage();
             break;
         case WorldMessageType.FollowTerrain:
             rv = new FollowTerrainMessage();
             break;
         case WorldMessageType.Portal:
             rv = new PortalMessage();
             break;
         case WorldMessageType.AmbientLight:
             rv = new AmbientLightMessage();
             break;
         case WorldMessageType.NewLight:
             rv = new NewLightMessage();
             break;
         case WorldMessageType.TradeStartRequest:
             rv = new TradeStartRequestMessage();
             break;
         case WorldMessageType.TradeStart:
             rv = new TradeStartMessage();
             break;
         case WorldMessageType.TradeOfferRequest:
             rv = new TradeOfferRequestMessage();
             break;
         case WorldMessageType.TradeComplete:
             rv = new TradeCompleteMessage();
             break;
         case WorldMessageType.TradeOfferUpdate:
             rv = new TradeOfferUpdateMessage();
             break;
         case WorldMessageType.StateMessage:
             rv = new StateMessage();
             break;
         case WorldMessageType.QuestInfoRequest:
             rv = new QuestInfoRequestMessage();
             break;
         case WorldMessageType.QuestInfoResponse:
             rv = new QuestInfoResponseMessage();
             break;
         case WorldMessageType.QuestResponse:
             rv = new QuestResponseMessage();
             break;
         case WorldMessageType.RegionConfig:
             rv = new RegionConfigMessage();
             break;
         case WorldMessageType.InventoryUpdate:
             rv = new InventoryUpdateMessage();
             break;
         case WorldMessageType.QuestLogInfo:
             rv = new QuestLogInfoMessage();
             break;
         case WorldMessageType.QuestStateInfo:
             rv = new QuestStateInfoMessage();
             break;
         case WorldMessageType.RemoveQuestRequest:
             rv = new RemoveQuestRequestMessage();
             break;
         case WorldMessageType.RemoveQuestResponse:
             rv = new RemoveQuestResponseMessage();
             break;
         case WorldMessageType.GroupInfo:
             rv = new GroupInfoMessage();
             break;
         case WorldMessageType.UiTheme:
             rv = new UiThemeMessage();
             break;
         case WorldMessageType.LootAll:
             rv = new LootAllMessage();
             break;
         case WorldMessageType.OldModelInfo:
             rv = new OldModelInfoMessage();
             break;
         case WorldMessageType.FragmentMessage:
             rv = new FragmentMessage();
             break;
         case WorldMessageType.RoadInfo:
             rv = new RoadInfoMessage();
             break;
         case WorldMessageType.Fog:
             rv = new FogMessage();
             break;
         case WorldMessageType.AbilityInfo:
             rv = new AbilityInfoMessage();
             break;
         case WorldMessageType.AbilityUpdate:
             rv = new AbilityUpdateMessage();
             break;
         case WorldMessageType.OldObjectProperty:
             rv = new OldObjectPropertyMessage();
             break;
         case WorldMessageType.ObjectProperty:
             rv = new ObjectPropertyMessage();
             break;
         case WorldMessageType.AddParticleEffect:
             rv = new AddParticleEffectMessage();
             break;
         case WorldMessageType.RemoveParticleEffect:
             rv = new RemoveParticleEffectMessage();
             break;
         case WorldMessageType.TrackObjectInterpolation:
             rv = new TrackObjectInterpolationMessage();
             break;
         case WorldMessageType.TrackLocationInterpolation:
             rv = new TrackLocationInterpolationMessage();
             break;
         case WorldMessageType.OldExtension:
             rv = new OldExtensionMessage();
             break;
         case WorldMessageType.Extension:
             rv = new ExtensionMessage();
             break;
         case WorldMessageType.InvokeEffect:
             rv = new InvokeEffectMessage();
             break;
         case WorldMessageType.MobPath:
             rv = new MobPathMessage();
             break;
         case WorldMessageType.AggregatedRDP:
             rv = new AggregatedRDPMessage();
             break;
         case WorldMessageType.NewDecal:
             rv = new NewDecalMessage();
             break;
         case WorldMessageType.FreeDecal:
             rv = new FreeDecalMessage();
             break;
         case WorldMessageType.ModelInfo:
             rv = new ModelInfoMessage();
             break;
         case WorldMessageType.SoundControl:
             rv = new SoundControlMessage();
             break;
         case WorldMessageType.DirLocOrient:
             rv = new DirLocOrientMessage();
             break;
         case WorldMessageType.AuthorizedLogin:
             rv = new AuthorizedLoginMessage();
             break;
         case WorldMessageType.AuthorizedLoginResponse:
             rv = new AuthorizedLoginResponseMessage();
             break;
         case WorldMessageType.LoadingState:
             rv = new LoadingStateMessage();
             break;
         default:
             log.ErrorFormat("Unhandled world message type: {0}", messageType);
             return null;
     }
     rv.ParseWorldMessage(oid, inMessage);
     return rv;
 }
 public void RebuildIfFinishedLoading(ExtensionMessage msg, bool loadingState)
 {
     if (!loadingState) {
         log.DebugFormat("StaticGeometryHelper.RebuildIfFinishedLoading: Rebuilding because loadingState is {0}", loadingState);
         Rebuild();
     }
 }