当前位置: 首页>>代码示例>>C++>>正文


C++ ServerActiveObject::getId方法代码示例

本文整理汇总了C++中ServerActiveObject::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ ServerActiveObject::getId方法的具体用法?C++ ServerActiveObject::getId怎么用?C++ ServerActiveObject::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServerActiveObject的用法示例。


在下文中一共展示了ServerActiveObject::getId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_server_sound_params

static void read_server_sound_params(lua_State *L, int index,
		ServerSoundParams &params)
{
	if(index < 0)
		index = lua_gettop(L) + 1 + index;
	// Clear
	params = ServerSoundParams();
	if(lua_istable(L, index)){
		getfloatfield(L, index, "gain", params.gain);
		getstringfield(L, index, "to_player", params.to_player);
		lua_getfield(L, index, "pos");
		if(!lua_isnil(L, -1)){
			v3f p = read_v3f(L, -1)*BS;
			params.pos = p;
			params.type = ServerSoundParams::SSP_POSITIONAL;
		}
		lua_pop(L, 1);
		lua_getfield(L, index, "object");
		if(!lua_isnil(L, -1)){
			ObjectRef *ref = ObjectRef::checkobject(L, -1);
			ServerActiveObject *sao = ObjectRef::getobject(ref);
			if(sao){
				params.object = sao->getId();
				params.type = ServerSoundParams::SSP_OBJECT;
			}
		}
		lua_pop(L, 1);
		params.max_hear_distance = BS*getfloatfield_default(L, index,
				"max_hear_distance", params.max_hear_distance/BS);
		getboolfield(L, index, "loop", params.loop);
	}
}
开发者ID:AngelCry,项目名称:minetest,代码行数:32,代码来源:scriptapi.cpp

示例2: l_set_detach

// set_detach(self)
int ObjectRef::l_set_detach(lua_State *L)
{
	GET_ENV_PTR;

	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if (co == NULL)
		return 0;

	int parent_id = 0;
	std::string bone = "";
	v3f position;
	v3f rotation;
	co->getAttachment(&parent_id, &bone, &position, &rotation);
	ServerActiveObject *parent = NULL;
	if (parent_id) {
		parent = env->getActiveObject(parent_id);
		co->setAttachment(0, "", position, rotation);
	} else {
		co->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
	}
	// Do it
	if (parent != NULL)
		parent->removeAttachmentChild(co->getId());
	return 0;
}
开发者ID:theDrake,项目名称:minetest,代码行数:27,代码来源:l_object.cpp

示例3: l_remove

// remove(self)
int ObjectRef::l_remove(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if(co == NULL) return 0;
	verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
	co->m_removed = true;
	return 0;
}
开发者ID:ChuanonlyGame,项目名称:myisland,代码行数:11,代码来源:l_object.cpp

示例4: l_set_attach

// set_attach(self, parent, bone, position, rotation)
int ObjectRef::l_set_attach(lua_State *L)
{
	GET_ENV_PTR;

	ObjectRef *ref = checkobject(L, 1);
	ObjectRef *parent_ref = checkobject(L, 2);
	ServerActiveObject *co = getobject(ref);
	ServerActiveObject *parent = getobject(parent_ref);
	if (co == NULL)
		return 0;
	if (parent == NULL)
		return 0;
	// Do it
	int parent_id = 0;
	std::string bone = "";
	v3f position = v3f(0, 0, 0);
	v3f rotation = v3f(0, 0, 0);
	co->getAttachment(&parent_id, &bone, &position, &rotation);
	if (parent_id) {
		ServerActiveObject *old_parent = env->getActiveObject(parent_id);
		if (old_parent)
		old_parent->removeAttachmentChild(co->getId());
	}

	bone = "";
	if (!lua_isnil(L, 3))
		bone = lua_tostring(L, 3);
	position = v3f(0, 0, 0);
	if (!lua_isnil(L, 4))
		position = read_v3f(L, 4);
	rotation = v3f(0, 0, 0);
	if (!lua_isnil(L, 5))
		rotation = read_v3f(L, 5);
	co->setAttachment(parent->getId(), bone, position, rotation);
	parent->addAttachmentChild(co->getId());
	return 0;
}
开发者ID:Mab879,项目名称:freeminer,代码行数:38,代码来源:l_object.cpp

示例5: l_remove

// remove(self)
int ObjectRef::l_remove(lua_State *L)
{
	GET_ENV_PTR;

	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if (co == NULL)
		return 0;
	if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
		return 0;

	co->clearChildAttachments();
	co->clearParentAttachment();

	verbosestream << "ObjectRef::l_remove(): id=" << co->getId() << std::endl;
	co->m_pending_removal = true;
	return 0;
}
开发者ID:rubenwardy,项目名称:minetest,代码行数:19,代码来源:l_object.cpp

示例6: l_remove

// remove(self)
int ObjectRef::l_remove(lua_State *L)
{
	GET_ENV_PTR;

	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if (co == NULL)
		return 0;
	if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
		return 0;

	std::set<int> child_ids = co->getAttachmentChildIds();
	std::set<int>::iterator it;
	for (it = child_ids.begin(); it != child_ids.end(); ++it) {
		ServerActiveObject *child = env->getActiveObject(*it);
		child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
	}

	verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
	co->m_removed = true;
	return 0;
}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:23,代码来源:l_object.cpp

示例7: l_set_attach

// set_attach(self, parent, bone, position, rotation)
int ObjectRef::l_set_attach(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	ObjectRef *parent_ref = checkobject(L, 2);
	ServerActiveObject *co = getobject(ref);
	ServerActiveObject *parent = getobject(parent_ref);
	if(co == NULL) return 0;
	if(parent == NULL) return 0;
	// Do it
	std::string bone = "";
	if(!lua_isnil(L, 3))
		bone = lua_tostring(L, 3);
	v3f position = v3f(0, 0, 0);
	if(!lua_isnil(L, 4))
		position = read_v3f(L, 4);
	v3f rotation = v3f(0, 0, 0);
	if(!lua_isnil(L, 5))
		rotation = read_v3f(L, 5);
	co->setAttachment(parent->getId(), bone, position, rotation);
	return 0;
}
开发者ID:Nate-Devv,项目名称:freeminer,代码行数:23,代码来源:l_object.cpp

示例8: l_remove

// remove(self)
int ObjectRef::l_remove(lua_State *L)
{
	GET_ENV_PTR;

	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if (co == NULL)
		return 0;
	if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
		return 0;

	const UNORDERED_SET<int> &child_ids = co->getAttachmentChildIds();
	UNORDERED_SET<int>::const_iterator it;
	for (it = child_ids.begin(); it != child_ids.end(); ++it) {
		// Child can be NULL if it was deleted earlier
		if (ServerActiveObject *child = env->getActiveObject(*it))
			child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
	}

	verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
	co->m_removed = true;
	return 0;
}
开发者ID:theDrake,项目名称:minetest,代码行数:24,代码来源:l_object.cpp


注:本文中的ServerActiveObject::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。