示例#1
0
void ContextZone::Update() {
	int16 index;

	// Check every ground object and determine if its context should be changed by this zone
	for (std::vector<MapObject*>::iterator i = MapMode::CurrentInstance()->GetObjectSupervisor()->_ground_objects.begin();
		i != MapMode::CurrentInstance()->GetObjectSupervisor()->_ground_objects.end(); i++)
	{
		// If the object does not have a context equal to one of the two switching contexts, do not examine it further
		if ((*i)->GetContext() != _context_one && (*i)->GetContext() != _context_two) {
			continue;
		}

		// If the object is inside the zone, set their context to that zone's context
		// (This may result in no change from the object's current context depending on the zone section)
		index = _IsInsideZone(*i);
		if (index >= 0) {
			(*i)->SetContext(_section_contexts[index] ? _context_one : _context_two);
		}
	}
}
示例#2
0
void ContextZone::Update() {
	int16 index;

	// Check every ground object and determine if its context should be changed by this zone
	// TODO: get the object container from the proper layer, not just the default layer
	vector<MapObject*>* objects = MapMode::CurrentInstance()->GetObjectSupervisor()->_object_layers[DEFAULT_LAYER_ID].GetObjects();
	for (uint32 i = 0;	i < objects->size(); ++i) {
		// If the object does not have a context equal to one of the two switching contexts, do not examine it further
		if (objects->at(i)->GetContext() != _context_one && objects->at(i)->GetContext() != _context_two) {
			continue;
		}

		// If the object is inside the zone, set their context to that zone's context
		// (This may result in no change from the object's current context depending on the zone section)
		index = _IsInsideZone(objects->at(i));
		if (index >= 0) {
			objects->at(i)->SetContext(_section_contexts[index] ? _context_one : _context_two);
		}
	}
}