/** * @brief Makes the door immediately open or closed. * @param door_open true to make it opened, false to make it closed. */ void Door::set_open(bool door_open) { state = door_open ? OPEN : CLOSED; if (door_open) { set_collision_modes(COLLISION_NONE); // to avoid being the hero's facing entity } else { get_sprite().set_current_animation("closed"); set_collision_modes(COLLISION_FACING_POINT | COLLISION_SPRITE); // ensure that we are not closing the door on the hero if (is_on_map() && overlaps(get_hero())) { get_hero().avoid_collision(*this, (get_direction() + 2) % 4); } } if (is_on_map()) { update_dynamic_tiles(); if (is_saved()) { get_savegame().set_boolean(savegame_variable, door_open); } if (door_open) { get_lua_context().door_on_opened(*this); } else { get_lua_context().door_on_closed(*this); } } }
// ----------------------------------------------------------- // object owned by a player // ----------------------------------------------------------- void t_owned_adv_object::destroy() { if (is_on_map() && m_owner >= 0) get_owner()->remove_object( this ); t_stationary_adventure_object::destroy(); }
/** * \brief Notifies this pickable item that its movement has just changed. */ void Pickable::notify_movement_changed() { if (is_on_map()) { // Notify the Lua equipment item. get_equipment().get_item(treasure.get_item_name()).notify_movement_changed(*this); } }
/** * @brief Notifies this entity that it was just enabled or disabled. * @param enabled true if the entity is now enabled */ void DynamicTile::notify_enabled(bool enabled) { if (is_on_map() && !enabled && test_collision_custom(get_hero())) { // the tile under the hero is disabled: the hero's ground may have changed get_hero().check_position(); } }
// ----------------------------------------------------------- // object owned by a player // ----------------------------------------------------------- void t_owned_adv_object::setup_flag_color() { if ( is_on_map() ) { t_float_object floater( this ); if ( m_owner >= 0 ) set_flag_color( m_map->get_player( m_owner ).get_color() ); else set_flag_color( k_player_gray ); } }
// ----------------------------------------------------------- // object owned by a player // ----------------------------------------------------------- void t_owned_adv_object::set_owner( int player_number ) { if ( player_number == m_owner ) return; if (m_map!=NULL) m_map->record_set_owner_event( this, player_number ); int old_owner = m_owner; if (is_on_map() && m_owner >= 0) get_owner()->remove_object( this ); m_owner = player_number; if (is_on_map() && m_owner >= 0) get_owner()->add_object( this ); setup_flag_color(); on_owner_changed( m_owner, old_owner ); }
/** * \brief Notifies this entity that it was just enabled or disabled. * \param enabled true if the entity is now enabled */ void Enemy::notify_enabled(bool enabled) { Detector::notify_enabled(enabled); if (!is_on_map()) { return; } if (enabled) { restart(); get_lua_context().entity_on_enabled(*this); } else { get_lua_context().entity_on_disabled(*this); } }