ItemLoaderRepo::ItemLoaderRepo()
    : Repository<PropertyLoaderBase<Item> >( mDefault )
{
    int32_t id = AutoId( "plasma_gun" );
    mElements.insert( id, new PlasmaGunLoader() );
    id = AutoId( "guard_plasma_gun" );
    mElements.insert( id, new PlasmaGunLoader() );
    id = AutoId( "pistol" );
    mElements.insert( id, new PistolLoader() );
    id = AutoId( "shotgun" );
    mElements.insert( id, new ShotgunLoader() );
    id = AutoId( "rocket_launcher" );
    mElements.insert( id, new RocketLauncherLoader() );
    id = AutoId( "ion_gun" );
    mElements.insert( id, new IonGunLoader() );
    id = AutoId( "gatling_gun" );
    mElements.insert( id, new GatlingGunLoader() );
    id = AutoId( "gauss_gun" );
    mElements.insert( id, new GaussGunLoader() );
    id = AutoId( "lucky_rocket" );
    mElements.insert( id, new LuckyRocketLoader() );
    id = AutoId("rusty_reaper"); 
    mElements.insert(id, new RustyReaperLoader());
    Init();
}
RenderableLayer::RenderableLayer()
{
    mIdToRendLayerMap[AutoId( "background" )] = RenderableLayer::Background;
    mIdToRendLayerMap[AutoId( "background_1" )] = RenderableLayer::Background_1;
    mIdToRendLayerMap[AutoId( "corpses" )] = RenderableLayer::Corpses;
    mIdToRendLayerMap[AutoId( "creeps" )] = RenderableLayer::Creeps;
    mIdToRendLayerMap[AutoId( "players" )] = RenderableLayer::Players;
    mIdToRendLayerMap[AutoId( "buildings" )] = RenderableLayer::Buildings;
}
bool ItemLoaderRepo::LoadItemFromOneDesc( Json::Value& ItemDesc )
{
    std::string nameStr;
    if( !Json::GetStr( ItemDesc["name"], nameStr ) )
    {
        return false;
    }
    PropertyLoaderBase<Item>& itemLoader = operator()( AutoId( nameStr ) );

    Json::Value& setters = ItemDesc["set"];
    if ( !setters.isArray() )
    {
        return false;
    }
    if ( setters.empty() )
    {
        return true;
    }
    L1( "Load item_loader: %s\n", nameStr.c_str() );
    itemLoader.Load( *setters.begin() );
    return true;
}
ComponentFactory::ComponentFactory()
{
    Bind( AutoId( "default_component" ), &CreateComponent<DefaultComponent> );
    SetDefault( AutoId( "default_component" ) );

    Bind( AutoId( "position_component" ), &CreateComponent<PositionComponent> );
    Bind( AutoId( "rotate_component" ), &CreateComponent<RotateComponent> );
    Bind( AutoId( "visual_box_multiplier_component" ), &CreateComponent<render::VisualBoxMultiplierComponent> );
    Bind( AutoId( "move_component" ), &CreateComponent<MoveComponent> );
    Bind( AutoId( "acceleration_component" ), &CreateComponent<AccelerationComponent> );

    Bind( AutoId( "player_controller_component" ), &CreateComponent<PlayerControllerComponent> );
    Bind( AutoId( "target_player_controller_component" ), &CreateComponent<TargetPlayerControllerComponent> );
    Bind( AutoId( "random_controller_component" ), &CreateComponent<RandomControllerComponent> );
    Bind( AutoId( "guard_controller_component" ), &CreateComponent<GuardControllerComponent> );
    Bind( AutoId( "path_controller_component" ), &CreateComponent<PathControllerComponent> );

    Bind( AutoId( "inventory_component" ), &CreateComponent<InventoryComponent> );
    Bind( AutoId( "static_actor_component" ), &CreateComponent<StaticActorComponent> );
    Bind( AutoId( "health_component" ), &CreateComponent<HealthComponent> );

    Bind( AutoId( "collision_component" ), &CreateComponent<CollisionComponent> );
    Bind( AutoId( "shot_collision_component" ), &CreateComponent<ShotCollisionComponent> );
    Bind( AutoId( "wall_collision_component" ), &CreateComponent<WallCollisionComponent> );
    Bind( AutoId( "water_collision_component" ), &CreateComponent<WaterCollisionComponent> );
    Bind( AutoId( "pickup_collision_component" ), &CreateComponent<PickupCollisionComponent> );
    Bind( AutoId( "aoe_collision_component" ), &CreateComponent<AoeCollisionComponent> );
    Bind( AutoId( "bounce_collision_component" ), &CreateComponent<BounceCollisionComponent> );

    Bind( AutoId( "renderable_component" ), &CreateComponent<RenderableComponent> );
    Bind( AutoId( "border_component" ), &CreateComponent<BorderComponent> );

    Bind( AutoId( "remove_on_death_component" ), &CreateComponent<RemoveOnDeathComponent> );
    Bind( AutoId( "explode_on_death_component" ), &CreateComponent<ExplodeOnDeathComponent> );
    Bind( AutoId( "drop_on_death_component" ), &CreateComponent<DropOnDeathComponent> );
    Bind( AutoId( "stop_on_death_component" ), &CreateComponent<StopOnDeathComponent> );
    Bind( AutoId( "score_on_death_component" ), &CreateComponent<ScoreOnDeathComponent> );
    Bind( AutoId( "owner_component" ), &CreateComponent<OwnerComponent> );
    Bind( AutoId( "kill_score_on_death_component" ), &CreateComponent<KillScoreOnDeathComponent> );

    Bind( AutoId( "notify_parent_on_death_component" ), &CreateComponent<NotifyParentOnDeathComponent> );
    Bind( AutoId( "listen_child_death_component" ), &CreateComponent<ListenChildDeathComponent> );
    Bind( AutoId( "pointer_target_controller_component" ), &CreateComponent<PointerTargetControllerComponent> );
    Bind( AutoId( "heat_source_component" ), &CreateComponent<HeatSourceComponent> );

    Bind( AutoId( "fade_out_component" ), &CreateComponent<FadeOutComponent> );

    Bind( AutoId( "explosion_component" ), &CreateComponent<ExplosionComponent> );

    Bind( AutoId( "target_holder_component" ), &CreateComponent<TargetHolderComponent> );
    Bind( AutoId( "buff_holder_component" ), &CreateComponent<BuffHolderComponent> );
    Bind( AutoId( "accuracy_component" ), &CreateComponent<AccuracyComponent> );
    Bind( AutoId( "armor_component" ), &CreateComponent<ArmorComponent> );
    Bind( AutoId( "cloak_component" ), &CreateComponent<CloakComponent> );

    Bind( AutoId( "team_component" ), &CreateComponent<TeamComponent> );
    Bind( AutoId( "flag_collision_component" ), &CreateComponent<ctf::FlagCollisionComponent> );
    Bind( AutoId( "attachable_component" ), &CreateComponent<ctf::AttachableComponent> );
    Bind( AutoId( "flag_carrier_component" ), &CreateComponent<ctf::FlagCarrierComponent> );
    Bind( AutoId( "flag_receiver_component" ), &CreateComponent<ctf::FlagReceiverComponent> );

    Bind( AutoId( "emitter_component" ), &CreateComponent<EmitterComponent> );
    Bind( AutoId( "explode_on_hit_component" ), &CreateComponent<ExplodeOnHitComponent> );
    Bind( AutoId( "detonate_on_hit_component" ), &CreateComponent<DetonateOnHitComponent> );
    Bind( AutoId( "audible_component" ), &CreateComponent<AudibleComponent> );
    Bind( AutoId( "remove_components_on_death_component" ), &CreateComponent<RemoveComponentsOnDeathComponent> );
    Bind( AutoId( "cell_component" ), &CreateComponent<CellComponent> );
    Bind( AutoId( "level_end_component" ), &CreateComponent<LevelEndComponent> );
}
void CollisionComponentLoader::BindValues()
{
    Bind( "radius", func_double( &CollisionComponent::SetRadius ) );
    std::string istr;
    if( Json::GetStr( ( *mSetters )["class"], istr ) )
    {
        Bind<CollisionClass::Type>( &CollisionComponent::SetCollisionClass, mCollisionClass( AutoId( istr ) ) );
    }
    Bind("clip_scene", func_bool(&CollisionComponent::SetClipScene));

}