Beispiel #1
0
awl::backends::linux::timerfd::object::value_type
awl::backends::linux::timerfd::object::read()
{
	value_type ret;

	FCPPT_ASSERT_ERROR(
		::read(
			fd_.get(),
			&ret,
			sizeof(
				value_type
			)
		)
		==
		static_cast<
			ssize_t
		>(
			sizeof(
				value_type
			)
		)
	);

	return
		ret;
}
Beispiel #2
0
sge::x11input::xim::supported_styles_unique_ptr
sge::x11input::xim::get_supported_styles(
	sge::x11input::xim::method const &_method
)
{
	XIMStyles *result{
		nullptr
	};

	sge::x11input::xim::get_im_values(
		_method,
		XNQueryInputStyle,
		&result
	);

	FCPPT_ASSERT_ERROR(
		result
		!=
		nullptr
	);

	return
		sge::x11input::xim::supported_styles_unique_ptr{
			result
		};
}
Beispiel #3
0
void
sge::wlinput::processor::add_seat(
	awl::backends::wayland::system::event::seat_added const &_seat
)
{
	FCPPT_ASSERT_ERROR(
		seat_connections_.insert(
			std::make_pair(
				_seat.get().name(),
				_seat.get().caps_callback(
					awl::backends::wayland::system::seat::caps_callback{
						std::bind(
							&sge::wlinput::processor::seat_caps,
							this,
							fcppt::make_cref(
								_seat.get()
							),
							std::placeholders::_1
						)
					}
				)
			)
		).second
	);
}
Beispiel #4
0
sge::dinput::joypad::ff::scoped_download::~scoped_download()
{
	FCPPT_ASSERT_ERROR(
		effect_.Unload()
		==
		DI_OK
	);
}
Beispiel #5
0
sge::gdifont::device_context::~device_context()
{
	FCPPT_ASSERT_ERROR(
		::DeleteDC(
			hdc_
		)
		!= 0
	);
}
Beispiel #6
0
awl::main::exit_code const
awl::backends::windows::system::event::original_processor::exit_code() const
{
	FCPPT_ASSERT_ERROR(
		!this->running()
	);

	return
		*exit_code_;
}
Beispiel #7
0
awl::backends::windows::timer::waitable::~waitable()
{
	FCPPT_ASSERT_ERROR(
		::CloseHandle(
			handle_
		)
		!=
		0
	);
}
Beispiel #8
0
void
sanguis::server::world::sight_range::add(
	sanguis::entity_id const _id
)
{
	FCPPT_ASSERT_ERROR(
		entries_.insert(
			_id
		).second
	);
}
Beispiel #9
0
sanguis::creator::enable_if_tile<
	Tile,
	sanguis::tiles::orientation
>
sanguis::tiles::impl::make_orientation(
	sanguis::tiles::pair<
		Tile
	> const &_pair,
	sanguis::tiles::impl::neighbors<
		Tile
	> const &_neighbors
)
{
	sanguis::tiles::orientation orientation{
		sanguis::tiles::orientation::null()
	};

	// TODO: Check if the tile is _pair.second?
	for(
		sanguis::tiles::direction const value
		:
		fcppt::make_enum_range<
			sanguis::tiles::direction
		>()
	)
	{
		Tile const tile(
			_neighbors[
				value
			]
		);

		FCPPT_ASSERT_ERROR(
			tile
			==
			_pair.first()
			||
			tile
			==
			_pair.second()
		);

		orientation[
			value
		] =
			tile
			==
			_pair.first();
	}

	return
		orientation;
}
Beispiel #10
0
void
sanguis::server::world::sight_range::remove(
	sanguis::entity_id const _id
)
{
	FCPPT_ASSERT_ERROR(
		entries_.erase(
			_id
		)
		> 0
	);
}
Beispiel #11
0
sge::gui::get_focus
sge::gui::widget::edit::on_click(
	sge::rucksack::vector const _pos
)
{
	fcppt::optional::maybe(
		static_text_.text().pos_to_index(
			fcppt::math::vector::structure_cast<
				sge::font::vector,
				fcppt::cast::size_fun
			>(
				_pos
			)
			-
			static_text_.pos()
		),
		[
			_pos,
			this
		]{
			if(
				_pos.x()
				>=
				static_text_.rect().size().w()
				+
				static_text_.pos().x()
			)
				position_
					= text_.size();
		},
		[
			this
		](
			sge::font::index const _index
		)
		{
			FCPPT_ASSERT_ERROR(
				_index
				<=
				text_.size()
			);

			position_ =
				_index;
		}
	);

	return
		sge::gui::get_focus(
			true
		);
}
Beispiel #12
0
void
fcppt::log::context::transfer_to(
	fcppt::log::context &_other
)
{
	typedef
	std::vector<
		fcppt::log::detail::outer_context_node
	>
	outer_context_node_vector;

	outer_context_node_vector const nodes(
		fcppt::algorithm::map_optional<
			outer_context_node_vector
		>(
			fcppt::container::tree::pre_order<
				fcppt::log::detail::context_tree
			>(
				tree_
			),
			[](
				fcppt::log::detail::context_tree &_elem
			)
			{
				return
					fcppt::log::to_outer_node(
						_elem
					);
			}
		)
	);

	for(
		auto const &node
		:
		nodes
	)
		node.object().transfer(
			_other
		);

	FCPPT_ASSERT_ERROR(
		tree_.empty()
	);
}
Beispiel #13
0
void
sanguis::server::ai::behavior::follow_friend::target_enters(
	sanguis::server::entities::with_body &_with_body
)
{
	FCPPT_ASSERT_ERROR(
		potential_targets_.insert(
			fcppt::make_ref(
				_with_body
			)
		)
		.second
	);

	target_ =
		FCPPT_ASSERT_OPTIONAL_ERROR(
			this->first_target()
		).get().link();
}
Beispiel #14
0
sanguis::collision::world::optional_body_enter
sanguis::collision::impl::world::simple::ghost::new_body(
	sanguis::collision::impl::world::simple::body const &_body,
	sanguis::collision::world::created const _created
)
{
	if(
		!sanguis::collision::impl::collides(
			sanguis::collision::impl::world::make_circle(
				_body
			),
			sanguis::collision::impl::world::make_circle(
				*this
			)
		)
	)
		return
			sanguis::collision::world::optional_body_enter();

	FCPPT_ASSERT_ERROR(
		bodies_.insert(
			std::make_pair(
				fcppt::make_cref(
					_body
				),
				body_status::normal
			)
		).second
	);

	return
		sanguis::collision::world::optional_body_enter(
			sanguis::collision::world::body_enter{
				_body.body_base(),
				ghost_base_,
				_created
			}
		);
}
Beispiel #15
0
sge::renderer::texture::stage
sge::opengl::cg::texture::assigned_stage(
	sge::cg::parameter::object const &_parameter
)
{
	GLenum const ret(
		::cgGLGetTextureEnum(
			_parameter.get()
		)
	);

	if(
		ret
		==
		GL_INVALID_OPERATION
	)
		throw sge::renderer::exception(
			FCPPT_TEXT("cgGLGetTextureEnum failed")
		);

	SGE_CG_CHECK_STATE(
		FCPPT_TEXT("cgGLGetTextureEnum failed"),
		sge::renderer::exception
	);

	FCPPT_ASSERT_ERROR(
		ret >= GL_TEXTURE0_ARB
	);

	return
		fcppt::strong_typedef_construct_cast<
			sge::renderer::texture::stage,
			fcppt::cast::static_cast_fun
		>(
			ret
			-
			GL_TEXTURE0_ARB
		);
}
Beispiel #16
0
void
sanguis::server::ai::behavior::follow_friend::target_leaves(
	sanguis::server::entities::with_body &_with_body
)
{
	FCPPT_ASSERT_ERROR(
		potential_targets_.erase(
			fcppt::make_ref(
				_with_body
			)
		)
		==
		1u
	);

	// TODO: Create a function for this!
	fcppt::optional::maybe_void(
		target_.get(),
		[
			&_with_body,
			this
		](
			fcppt::reference<
				sanguis::server::entities::with_links
			> const _target
		)
		{
			if(
				sanguis::server::entities::same_object(
					_target.get(),
					_with_body
				)
			)
				target_ =
					sanguis::server::entities::auto_weak_link();
		}
	);
}
	void
	update()
	{
		implementation_.insert(
			implementation_.end(),
			std::make_move_iterator(
				new_values_.begin()),
			std::make_move_iterator(
				new_values_.end()));

		new_values_.clear();

		FCPPT_ASSERT_ERROR(
			new_values_.empty());

		for(
			T *old
			:
			old_values_
		)
			fcppt::algorithm::remove_if(
				implementation_,
				[
					old
				](
					unique_value_ptr const &_ptr
				)
				{
					return
						_ptr.get_pointer()
						==
						old;
				}
			);

		old_values_.clear();
	}
Beispiel #18
0
fcppt::unique_ptr<fruitapp::fruit::cut_mesh_result>
fruitapp::fruit::cut_mesh(
	fruit::mesh const &input_mesh,
	fruit::plane const &input_plane)
{
	typedef
	sge::renderer::scalar
	scalar;

	typedef
	sge::renderer::vector2
	vector2;

	typedef
	sge::renderer::vector3
	vector3;

	typedef
	fruitlib::def_ctor<
		vector2
	>
	geometry_vector2;

	typedef
	sge::renderer::vector4
	vector4;

	typedef
	sge::renderer::matrix4
	matrix4;

	typedef
	fcppt::math::box::object<scalar,2>
	box2;

	typedef
	fruitlib::def_ctor<
		box2
	>
	geometry_box2;

	typedef
	fcppt::math::box::object<scalar,3>
	box3;

	fcppt::unique_ptr<fruit::cut_mesh_result> result{
		fcppt::make_unique_ptr<fruit::cut_mesh_result>()};

	scalar const epsilon =
		static_cast<scalar>(
			0.01);

	typedef
	std::vector<vector3>
	vector3_sequence;

	vector3_sequence border;

	// First step: Collect all the triangles and the border points.
	for(
		mesh::triangle_sequence::const_iterator input_triangle =
			input_mesh.triangles().begin();
		input_triangle != input_mesh.triangles().end();
		++input_triangle)
	{
		typedef
		fruitlib::math::triangle_plane_intersection<triangle>
		intersection;

		scalar const inner_epsilon =
			static_cast<scalar>(
				0.00001);

		intersection const single_result =
			fruitlib::math::cut_triangle_at_plane(
				*input_triangle,
				input_plane,
				inner_epsilon);

		for(
			intersection::point_sequence::const_iterator current_is_point =
				single_result.points().begin();
			current_is_point != single_result.points().end();
			++current_is_point)
			border.push_back(
				*current_is_point);
		// Only add new points if they're not already in the set
		/*
		BOOST_FOREACH(
			intersection::point_sequence::const_reference r,
			single_result.points())
			if(
				boost::range::find_if(
					border,
					boost::phoenix::bind(
						&fcppt::math::range_compare
						<
							sge::renderer::vector3,
							sge::renderer::vector3,
							sge::renderer::scalar
						>,
						boost::phoenix::arg_names::arg1,
						r,
						epsilon)) == border.end())
				border.push_back(
					r);
		*/

		// Copy all triangles
		boost::range::copy(
			single_result.triangles(),
			std::back_inserter(
				result->mesh().triangles()));
	}

	// If there were no triangles, we can return
	if(result->mesh().triangles().empty())
		return
			result;

	// Step 2: Calculate the bounding box and the barycenter (we can do
	// that in one pass, luckily)
	result->barycenter() = fcppt::math::vector::null<vector3>();

	vector3
		min_pos =
			result->mesh().triangles().front().vertices[0],
		max_pos =
			min_pos;

	for(
		mesh::triangle_sequence::const_iterator current_tri =
			result->mesh().triangles().begin();
		current_tri != result->mesh().triangles().end();
		++current_tri)
	{
		for(
			triangle::vertex_array::const_iterator current_vertex =
				current_tri->vertices.begin();
			current_vertex != current_tri->vertices.end();
			++current_vertex)
		{
			result->barycenter() += *current_vertex;
			for (vector3::size_type i = 0; i < 3; ++i)
			{
				min_pos.get_unsafe(i) = std::min(min_pos.get_unsafe(i),(*current_vertex).get_unsafe(i));
				max_pos.get_unsafe(i) = std::max(max_pos.get_unsafe(i),(*current_vertex).get_unsafe(i));
			}
		}
	}

	result->bounding_box() =
		box3(
			min_pos,
			fcppt::math::vector::to_dim(
				max_pos - min_pos));

	result->barycenter() /=
		static_cast<scalar>(
			result->mesh().triangles().size() * 3);

	for(
		mesh::triangle_sequence::iterator current_tri =
			result->mesh().triangles().begin();
		current_tri != result->mesh().triangles().end();
		++current_tri)
		for(
			triangle::vertex_array::iterator current_vertex =
				current_tri->vertices.begin();
			current_vertex != current_tri->vertices.end();
			++current_vertex)
			(*current_vertex) -= result->barycenter();

	// If we've got no border, quit now. This happens when the cutting
	// plane doesn't intersect with the fruit at all (we "miss", so to
	// speak)
	if(border.size() < static_cast<vector3_sequence::size_type>(3))
		return
			result;

	fcppt::optional::object<matrix4> const cs(
		make_coordinate_system(
			border,
			epsilon));

	if(!cs.has_value())
		return
			result;

	matrix4 const tcs =
		cs.get_unsafe(); // TODO

	matrix4 const coordinate_transformation =
		fcppt::math::matrix::inverse(
			tcs);

	typedef
	boost::geometry::model::multi_point<
		geometry_vector2
	>
	point_cloud_2d;

	typedef
	boost::geometry::model::ring<
		geometry_vector2
	>
	ring_2d;

	point_cloud_2d reduced;

	reduced.reserve(
		border.size());

	// TODO: map
	for(vector3_sequence::const_iterator i = border.begin(); i != border.end(); ++i)
	{
		vector4 const transformed =
			coordinate_transformation *
			vector4(
				(*i).x(),
				(*i).y(),
				(*i).z(),
				// WATCH OUT: ONLY WORKS WITH THE 1 HERE!
				1.f);

		reduced.push_back(
			geometry_vector2(
				fcppt::math::vector::narrow_cast<
					vector2
				>(
					transformed
				)
			)
		);

		FCPPT_ASSERT_ERROR(
			transformed.z() < epsilon);

		/*
		// Warning: Costly assert!
		if(
			fcppt::math::vector::length(
				vector_narrow<vector3>(
					(*cs) * vector4(reduced.back()[0],reduced.back()[1],0,1)) -
				(*i)) > epsilon)
		{
			std::cout <<
				fcppt::math::vector::length(
					vector_narrow<vector3>(
						(*cs) * vector4(reduced.back()[0],reduced.back()[1],0,1)) -
					(*i)) << "\n";
			std::exit(1);
		}
		*/
	}

	ring_2d convex_hull_result;

	boost::geometry::convex_hull(
		reduced,
		convex_hull_result);

	if(convex_hull_result.size() < static_cast<ring_2d::size_type>(3))
		return
			result;

	geometry_box2 const envelope(
		boost::geometry::return_envelope<
			geometry_box2
		>(
			convex_hull_result
		)
	);

	typedef
	std::vector<vector2>
	texcoord_vector;

	texcoord_vector texcoords;
	texcoords.reserve(
		convex_hull_result.size());

	for(
		auto const &element
		:
		convex_hull_result
	)
		texcoords.push_back(
			(element.base() - envelope.pos())
			/
			envelope.size()
		);

	ring_2d::size_type const triangle_count =
		static_cast<ring_2d::size_type>(
			convex_hull_result.size() - 2u);

	result->mesh().triangles().reserve(
		result->mesh().triangles().size() + triangle_count);

	for(
		ring_2d::size_type current_vertex =
			static_cast<ring_2d::size_type>(
				2);
		current_vertex < convex_hull_result.size();
		++current_vertex)
	{
		result->cross_section().triangles().push_back(
			fruit::triangle(
				{{
					fcppt::math::vector::narrow_cast<vector3>(
						tcs *
						vector4(
							convex_hull_result[0].x(),
							convex_hull_result[0].y(),
							0.f,
							1.f)) - result->barycenter(),
					fcppt::math::vector::narrow_cast<vector3>(
						tcs *
						vector4(
							convex_hull_result[current_vertex-1].x(),
							convex_hull_result[current_vertex-1].y(),
							0.f,
							1.f)) - result->barycenter(),
					fcppt::math::vector::narrow_cast<vector3>(
						tcs *
						vector4(
							convex_hull_result[current_vertex].x(),
							convex_hull_result[current_vertex].y(),
							0.f,
							1.f)) - result->barycenter()}},
				{{
					transform_texcoord(
						texcoords[
							0]),
					transform_texcoord(
						texcoords[
							current_vertex-1]),
					transform_texcoord(
						texcoords[
							current_vertex])}},
				{{
					-input_plane.normal(),
					-input_plane.normal(),
					-input_plane.normal()}}));

		result->mesh().triangles().push_back(
			result->cross_section().triangles().back());

		result->area() =
			fruit::area(
				result->area().get() +
				fruitlib::math::triangle::area(
					result->mesh().triangles().back()));
	}

	return
		result;
}
Beispiel #19
0
void
change_caps(
	sge::wlinput::create_function<
		Object
	> const &_create_function,
	std::unordered_map<
		awl::backends::wayland::registry_id,
		fcppt::unique_ptr<
			Object
		>
	> &_map,
	fcppt::signal::object<
		void (
			sge::input::event::discover<
				Base
			> const &
		)
	> &_discover_signal,
	fcppt::signal::object<
		void (
			sge::input::event::remove<
				Base
			> const &
		)
	> &_remove_signal,
	awl::backends::wayland::system::seat::object const &_seat
)
{
	typedef
	std::unordered_map<
		awl::backends::wayland::registry_id,
		fcppt::unique_ptr<
			Object
		>
	>
	object_map;

	if(
		_seat.caps()
		&
		Caps
	)
	{
		if(
			_map.count(
				_seat.name()
			)
			==
			0u
		)
		{
			std::pair<
				typename
				object_map::iterator,
				bool
			> const result{
				_map.insert(
					std::make_pair(
						_seat.name(),
						_create_function(
							_seat.get()
						)
					)
				)
			};

			FCPPT_ASSERT_ERROR(
				result.second
			);

			_discover_signal(
				sge::input::event::discover<
					Base
				>{
					*result.first->second
				}
			);
		}
	}
	else
	{
		fcppt::optional::maybe_void(
			fcppt::container::find_opt_iterator(
				_map,
				_seat.name()
			),
			[
				&_remove_signal,
				&_map
			](
				typename
				object_map::iterator const _iterator
			)
			{
				_remove_signal(
					sge::input::event::remove<
						Base
					>{
						*_iterator->second
					}
				);

				_map.erase(
					_iterator
				);
			}
		);
	}
}
Beispiel #20
0
sge::renderer::display_mode::optional_object
sge::opengl::xrandr::display_mode(
	awl::backends::x11::display &_display,
	awl::backends::x11::window::object &_window
)
{
	sge::opengl::xrandr::screen_resources const resources(
		_display,
		_window
	);

	awl::backends::x11::window::rect const window_rect(
		_window.rect()
	);

	sge::renderer::display_mode::optional_pixel_size pixel_size;

	sge::renderer::display_mode::optional_refresh_rate refresh_rate;

	sge::renderer::display_mode::optional_dimensions dimensions;

	for(
		RRCrtc const crtc
		:
		sge::opengl::xrandr::crtcs_view(
			resources
		)
	)
	{
		sge::opengl::xrandr::crtc_info const crtc_info(
			_display,
			resources,
			crtc
		);

		if(
			crtc_info.pixel_size()
			==
			sge::renderer::display_mode::pixel_size(
				fcppt::math::dim::null<
					sge::renderer::screen_size
				>()
			)
		)
			continue;

		pixel_size =
			sge::opengl::xrandr::combine_pixel_sizes(
				pixel_size,
				crtc_info.pixel_size()
			);

		if(
			!fcppt::math::box::intersects(
				crtc_info.rect(),
				window_rect
			)
		)
			continue;

		for(
			RROutput const output
			:
			sge::opengl::xrandr::outputs_view(
				resources
			)
		)
		{
			sge::opengl::xrandr::output_info const output_info(
				_display,
				resources,
				output
			);

			if(
				fcppt::math::dim::contents(
					output_info.dimensions().get()
				)
				==
				0u
			)
				continue;

			dimensions =
				sge::opengl::xrandr::combine_dimensions(
					dimensions,
					output_info.dimensions()
				);
		}

		for(
			XRRModeInfo const &mode
			:
			sge::opengl::xrandr::modes_view(
				resources
			)
		)
		{
			if(
				mode.id
				!=
				crtc_info.mode()
			)
				continue;

			refresh_rate =
				sge::opengl::xrandr::combine_rates(
					refresh_rate,
					sge::opengl::xrandr::refresh_rate_from_mode(
						mode
					)
				);
		}
	}

	fcppt::optional::maybe_void(
		dimensions,
		[](
			sge::renderer::display_mode::dimensions const _dim
		)
		{
			FCPPT_ASSERT_ERROR(
				fcppt::math::dim::contents(
					_dim.get()
				)
				!=
				0u
			);
		}
	);

	return
		fcppt::optional::map(
			pixel_size,
			[
				dimensions,
				refresh_rate
			](
				sge::renderer::display_mode::pixel_size const _pixel_size
			)
			{
				return
					sge::renderer::display_mode::object(
						_pixel_size,
						dimensions,
						refresh_rate
					);
			}
		);
}
Beispiel #21
0
btBroadphasePair *
sge::projectile::ghost::detail::pair_callback::addOverlappingPair(
    btBroadphaseProxy *proxy0,
    btBroadphaseProxy *proxy1)
{
    btCollisionObject
    *col_obj0 =
        static_cast<btCollisionObject*>(
            proxy0->m_clientObject),
        *col_obj1 =
            static_cast<btCollisionObject*>(
                proxy1->m_clientObject);

    btGhostObject
    *ghost0 =
        btGhostObject::upcast(
            col_obj0),
        *ghost1 =
            btGhostObject::upcast(
                col_obj1);

    // FIXME: ASSERT
    if (ghost0)
    {
        if(!ghost1)
        {
            FCPPT_ASSERT_ERROR(
                ghost0->getUserPointer());
            void *user_pointer0 =
                ghost0->getUserPointer();
            FCPPT_ASSERT_ERROR(
                col_obj1);
            FCPPT_ASSERT_ERROR(
                col_obj1->getUserPointer());
            void *user_pointer1 =
                col_obj1->getUserPointer();

            static_cast<object *>(user_pointer0)->enter_internal(
                *static_cast<body::object const *>(
                    user_pointer1));
        }
        ghost0->addOverlappingObjectInternal(
            proxy1,
            proxy0);
    }

    if (ghost1)
    {
        if(!ghost0)
        {
            FCPPT_ASSERT_ERROR(
                ghost1->getUserPointer());
            void *user_pointer1 =
                ghost1->getUserPointer();
            FCPPT_ASSERT_ERROR(
                col_obj0);
            FCPPT_ASSERT_ERROR(
                col_obj0->getUserPointer());
            void *user_pointer0 =
                col_obj0->getUserPointer();

            static_cast<object *>(user_pointer1)->enter_internal(
                *static_cast<body::object const *>(
                    user_pointer0));
        }

        ghost1->addOverlappingObjectInternal(
            proxy0,
            proxy1);
    }

    return nullptr;
}
Beispiel #22
0
sanguis::creator::top_result
sanguis::creator::generate(
	sanguis::creator::top_parameters const &_parameters
)
{
	fcppt::log::object log{
		_parameters.log_context(),
		sanguis::log_location(),
		sanguis::log_parameters(
			sanguis::creator::impl::log_name()
		)
	};

	sanguis::creator::impl::random::generator gen(
		_parameters.seed()
	);

	sanguis::creator::impl::result const result(
		fcppt::optional::to_exception(
			fcppt::container::find_opt_mapped(
				sanguis::creator::impl::generator_map(),
				_parameters.name()
			),
			[
				&_parameters
			]
			{
				return
					sanguis::creator::exception(
						FCPPT_TEXT("Generator ")
						+
						_parameters.name().get()
						+
						FCPPT_TEXT(" not found!")
					);
			}
		).get()(
			sanguis::creator::impl::parameters(
				log,
				gen,
				_parameters.spawn_boss(),
				_parameters.opening_count_array()
			)
		)
	);

	for(
		auto const opening_type
		:
		fcppt::make_enum_range<
			sanguis::creator::opening_type
		>()
	)
		FCPPT_ASSERT_ERROR(
			result.openings()[
				opening_type
			].size()
			==
			_parameters.opening_count_array()[
				opening_type
			].get()
		);

	FCPPT_ASSERT_ERROR(
		result.grid().size()
		==
		result.background_grid().size()
	);

	if(
		_parameters.spawn_boss().get()
	)
		FCPPT_ASSERT_ERROR(
			fcppt::algorithm::contains_if(
				result.spawns(),
				[](
					sanguis::creator::spawn const &_spawn
				)
				{
					return
						_spawn.enemy_kind()
						==
						sanguis::creator::enemy_kind::boss;
				}
			)
		);

	return
		sanguis::creator::top_result(
			_parameters.seed(),
			_parameters.name(),
			_parameters.spawn_boss(),
			result.grid(),
			result.background_grid(),
			result.openings(),
			result.spawns(),
			result.destructibles()
		);
}
Beispiel #23
0
sanguis::model::object
sanguis::tools::libmergeimage::to_model(
	sanguis::model::cell_size const _cell_size,
	sanguis::tools::libmergeimage::saved_image_vector const &_images
)
{
	sanguis::model::object result(
		_cell_size,
		sanguis::model::optional_animation_delay(),
		sanguis::model::part_map(),
		sanguis::model::optional_image_name()
	);

	for(
		sanguis::tools::libmergeimage::saved_image const &image
		:
		_images
	)
	{
		sanguis::model::animation_index cell_index(
			0u
		);

		for(
			sanguis::tools::libmergeimage::path_count_pair const &element
			:
			image.paths()
		)
		{
			sanguis::tools::libmergeimage::path const &path(
				element.path()
			);

			FCPPT_ASSERT_ERROR(
				path.size()
				==
				sanguis::tools::libmergeimage::impl::tree_depth::value
			);

			sanguis::model::animation_index const range(
				fcppt::cast::size<
					sanguis::model::animation_index
				>(
					element.count()
				)
			);

			result[
				sanguis::model::part_name(
					path[
						0
					]
				)
			][
				sanguis::model::weapon_category_name(
					path[
						1
					]
				)
			].insert(
				sanguis::model::animation_name(
					path[
						2
					]
				),
				sanguis::model::animation(
					sanguis::model::animation_range(
						cell_index,
						cell_index
						+
						range
					),
					sanguis::model::optional_animation_delay(),
					sanguis::model::optional_animation_sound(),
					sanguis::model::optional_image_name(
						image.image_name()
					)
				)
			);

			cell_index +=
				range;
		}
	}

	return
		result;
}