예제 #1
0
void CALifeUpdateManager::teleport_object	(ALife::_OBJECT_ID id, GameGraph::_GRAPH_ID game_vertex_id, u32 level_vertex_id, const Fvector &position)
{
    CSE_ALifeDynamicObject					*object = objects().object(id,true);
    if (!object) {
        Msg									("! cannot teleport entity with id %d",id);
        return;
    }

#ifdef DEBUG
    if (psAI_Flags.test(aiALife)) {
        Msg									("[LSS] teleporting object [%s][%s][%d] from level [%s], position [%f][%f][%f] to level [%s], position [%f][%f][%f]",
                                             object->name_replace(),
                                             *object->s_name,
                                             object->ID,
                                             *(ai().game_graph().header().level(ai().game_graph().vertex(object->m_tGraphID)->level_id()).name()),
                                             VPUSH(ai().game_graph().vertex(object->m_tGraphID)->level_point()),
                                             *(ai().game_graph().header().level(ai().game_graph().vertex(game_vertex_id)->level_id()).name()),
                                             VPUSH(ai().game_graph().vertex(game_vertex_id)->level_point())
                    );
    }
#endif

    if (object->m_bOnline)
        switch_offline						(object);
    graph().change							(object,object->m_tGraphID,game_vertex_id);
    object->m_tNodeID						= level_vertex_id;
    object->o_Position						= position;
    CSE_ALifeMonsterAbstract				*monster_abstract = smart_cast<CSE_ALifeMonsterAbstract*>(object);
    if (monster_abstract)
        monster_abstract->m_tNextGraphID	= object->m_tGraphID;
}
예제 #2
0
IC	void construct_string					(LPSTR result, u32 const result_size, const xr_vector<ALife::_OBJECT_ID> &restrictions)
{
	u32		count = xr_strlen(result) ? _GetItemCount(result) : 0;
	xr_vector<ALife::_OBJECT_ID>::const_iterator	I = restrictions.begin();
	xr_vector<ALife::_OBJECT_ID>::const_iterator	E = restrictions.end();
	for ( ; I != E; ++I) {
		CSE_ALifeDynamicObject	*object = ai().alife().objects().object(*I);
		if (ai().game_graph().vertex(object->m_tGraphID)->level_id() != ai().level_graph().level_id())
			continue;

		if (count)
			xr_strcat(result,result_size,",");
		xr_strcat(result,result_size,object->name_replace());
		++count;
	}
}
예제 #3
0
void CALifeUpdateManager::remove_restriction(ALife::_OBJECT_ID id, ALife::_OBJECT_ID restriction_id, const RestrictionSpace::ERestrictorTypes &restriction_type)
{
    CSE_ALifeDynamicObject					*object = objects().object(id,true);
    if (!object) {
        Msg									("! cannot remove restriction with id %d to the entity with id %d, because there is no creature with the specified id",restriction_id,id);
        return;
    }

    CSE_ALifeDynamicObject					*object_restrictor = objects().object(restriction_id,true);
    if (!object_restrictor) {
        Msg									("! cannot remove restriction with id %d to the entity with id %d, because there is no space restrictor with the specified id",restriction_id,id);
        return;
    }

    CSE_ALifeCreatureAbstract				*creature = smart_cast<CSE_ALifeCreatureAbstract*>(object);
    if (!creature) {
        Msg									("! cannot remove restriction with id %d to the entity with id %d, because there is an object with the specified id, but it is not a creature",restriction_id,id);
        return;
    }

    CSE_ALifeSpaceRestrictor				*restrictor = smart_cast<CSE_ALifeSpaceRestrictor*>(object_restrictor);
    if (!restrictor) {
        Msg									("! cannot remove restriction with id %d to the entity with id %d, because there is an object with the specified id, but it is not a space restrictor",restriction_id,id);
        return;
    }

    switch (restriction_type) {
    case RestrictionSpace::eRestrictorTypeOut : {
        xr_vector<ALife::_OBJECT_ID>::iterator	I = std::find(creature->m_dynamic_out_restrictions.begin(),creature->m_dynamic_out_restrictions.end(),restriction_id);
        if (I == creature->m_dynamic_out_restrictions.end()) {
            Msg							("~ cannot remove restriction with id [%d][%s] to the entity with id [%d][%s], because it is not added",restriction_id,object_restrictor->name_replace(),id,object->name_replace());
            return;
        }

        creature->m_dynamic_out_restrictions.erase(I);

        break;
    }
    case RestrictionSpace::eRestrictorTypeIn : {
        xr_vector<ALife::_OBJECT_ID>::iterator	I = std::find(creature->m_dynamic_in_restrictions.begin(),creature->m_dynamic_in_restrictions.end(),restriction_id);
        if (I == creature->m_dynamic_in_restrictions.end()) {
            Msg							("~ cannot remove restriction with id [%d][%s] to the entity with id [%d][%s], because it is not added",restriction_id,object_restrictor->name_replace(),id,object->name_replace());
            return;
        }

        creature->m_dynamic_in_restrictions.erase(I);

        break;
    }
    default :  {
        Msg								("! Invalid restriction type!");
        return;
    }
    }
}
예제 #4
0
void CALifeSimulatorBase::register_object	(CSE_ALifeDynamicObject *object, bool add_object)
{
	object->on_before_register			();

	if (add_object)
		objects().add					(object);
	
	graph().update						(object);
	scheduled().add						(object);
	story_objects().add					(object->m_story_id,object);
	smart_terrains().add				(object);
	groups().add						(object);

	setup_simulator						(object);
	
	CSE_ALifeInventoryItem				*item = smart_cast<CSE_ALifeInventoryItem*>(object);
	if (item && item->attached()) {
		CSE_ALifeDynamicObject			*II = objects().object(item->base()->ID_Parent);

#ifdef DEBUG
		if (std::find(II->children.begin(),II->children.end(),item->base()->ID) != II->children.end()) {
			Msg							("[LSS] Specified item [%s][%d] is already attached to the specified object [%s][%d]",item->base()->name_replace(),item->base()->ID,II->name_replace(),II->ID);
			FATAL						("[LSS] Cannot recover from the previous error!");
		}
#endif

		II->children.push_back			(item->base()->ID);
		II->attach						(item,true,false);
	}

	if (can_register_objects())
		object->on_register				();
}
예제 #5
0
void add_offline_impl						(CSE_ALifeDynamicObject *object, const xr_vector<ALife::_OBJECT_ID> &saved_children, const bool &update_registries)
{
	for (u32 i=0, n=saved_children.size(); i<n; ++i) {
		CSE_ALifeDynamicObject	*child = smart_cast<CSE_ALifeDynamicObject*>(ai().alife().objects().object(saved_children[i],true));
		R_ASSERT				(child);
		child->m_bOnline		= false;

		CSE_ALifeInventoryItem	*inventory_item = smart_cast<CSE_ALifeInventoryItem*>(child);
		VERIFY2					(inventory_item,"Non inventory item object has parent?!");
#ifdef DEBUG
//		if (psAI_Flags.test(aiALife))
//			Msg					("[LSS] Destroying item [%s][%s][%d]",inventory_item->base()->name_replace(),*inventory_item->base()->s_name,inventory_item->base()->ID);
		Msg						(
			"[LSS][%d] Going offline [%d][%s][%d] with parent [%d][%s] on '%s'",
			Device.dwFrame,
			Device.dwTimeGlobal,
			inventory_item->base()->name_replace(),
			inventory_item->base()->ID,
			object->ID,
			object->name_replace(),
			"*SERVER*"
		);
#endif
		
		ALife::_OBJECT_ID				item_id = inventory_item->base()->ID;
		inventory_item->base()->ID		= object->alife().server().PerformIDgen(item_id);

		if (!child->can_save()) {
			object->alife().release		(child);
			--i;
			--n;
			continue;
		}

#ifdef DEBUG
		if (!child->client_data.empty())
			Msg							("CSE_ALifeTraderAbstract::add_offline: client_data is cleared for [%d][%s]",child->ID,child->name_replace());
#endif // DEBUG
		if (!child->keep_saved_data_anyway())
			child->client_data.clear	();
		object->alife().graph().add		(child,child->m_tGraphID,false);
		object->alife().graph().attach	(*object,inventory_item,child->m_tGraphID,true);
	}

	if (!update_registries)
		return;

	object->alife().scheduled().add		(object);
	object->alife().graph().add			(object,object->m_tGraphID,false);
}