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(); }
pair<UniqueHandle, UniqueHandle> MakePipe() { # if YCL_Win32 ::HANDLE h_raw_read, h_raw_write; YCL_CallWin32F(CreatePipe, &h_raw_read, &h_raw_write, {}, 0); UniqueHandle h_read(h_raw_read), h_write(h_raw_write); YCL_CallWin32F(SetHandleInformation, h_write.get(), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); return {std::move(h_read), std::move(h_write)}; # elif YCL_API_Has_unistd_h int fds[2]; // TODO: Check whether '::socketpair' is available. if(::pipe(fds) != 0) ThrowFileOperationFailure("Failed getting file size."); auto pr(make_pair(UniqueHandle(fds[0]), UniqueHandle(fds[1]))); auto check([](UniqueHandle& h, const char* msg){ // NOTE: %O_NONBLOCK is initially cleared on ::pipe results. // See http://pubs.opengroup.org/onlinepubs/9699919799/. if(!(h && h->SetNonblocking())) ThrowFileOperationFailure(msg); }); check(pr.first, "Failed making pipe for reading."), check(pr.second, "Failed making pipe for writing."); return pr; # else # error "Unsupported platform found." # endif }
DirectoryFindData::DirectoryFindData(const wstring& name) : dir_name(name), find_data() { if(ystdex::rtrim(dir_name, L"/\\").empty()) dir_name = L'.'; YAssert(dir_name.back() != '\\', "Invalid argument found."); using platform::FileOperationFailure; const auto attr(::GetFileAttributesW(dir_name.c_str())); yconstexpr const auto& msg("Opening directory failed."); if(YB_UNLIKELY(attr == INVALID_FILE_ATTRIBUTES)) // TODO: Call %::GetLastError to distinguish concreate errors. throw FileOperationFailure(EINVAL, std::generic_category(), msg); if(attr & FILE_ATTRIBUTE_DIRECTORY) dir_name += L"\\*"; else throw FileOperationFailure(ENOTDIR, std::generic_category(), msg); }
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; }
int fish::getY() { return plat.getY(); }
int fish::getExp() { return plat.getExp(); }
cl_device_id clutil_platform::get_device_ids(cl_device_type device_type) { return platform_util->get_device_ids(device_type); }
int fish::askHP(int ID) { return plat.askHP(ID); }
int fish::getID() { return plat.getID(); }
int fish::getAtt() { return plat.getAtt(); }
std::size_t clutil_platform::get_source_size() { return platform_util->get_source_size(); }
void clutil_platform::cl_build_programs() { platform_util->cl_build_programs(); }
void clutil_platform::cl_create_programs_with_source() { platform_util->cl_create_programs_with_source(); }
void clutil_platform::cl_create_context() { platform_util->cl_create_context(); }
void clutil_platform::context_properties() { platform_util->context_properties(); }
cl_platform_id clutil_platform::get_platform_ids() { return platform_util->get_platform_ids(); }
bool fish::move(int tx,int ty) { return plat.move(tx,ty); }
int fish::getMaxHP() { return plat.getMaxHP(); }
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)); }
int fish::getSp() { return plat.getSp(); }
bool fish::increaseStrength() { return plat.increaseStrength(); }
int fish::askWhat(int x,int y) { return plat.askWhat(x,y); }
bool fish::attack(int tx,int ty) { return plat.attack(tx,ty); }
bool fish::increaseHealth() { return plat.increaseHealth(); }
std::string clutil_platform::get_platforms_info(cl_platform_info name, std::string str) { return platform_util->get_platforms_info(name, str); }
bool fish::increaseSpeed() { return plat.increaseSpeed(); }
int fish::getPoint() { return plat.getPoint(); }
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> ); }
int fish::getLevel() { return plat.getLevel(); }