void InstallationObjectImplementation::changeActiveResourceID(uint64 spawnID) {

	// Logic:
	// 1) If operating, and already has an active resource ID - make sure the hopper gets updated
	// 2) Get the spawn information & set the active resource id
	// 3) If hopper size is zero for the resource + is operating, send a packet to the operators to add a zero element for delta packets

	info("updating active ");

	if (isOperating()) {
		updateInstallationWork();
	}

	currentSpawn = getZoneServer()->getObject(spawnID).castTo<ResourceSpawn*>();
	if (currentSpawn == NULL) {
		error("new spawn null");
		return;
	}

	Time timeToWorkTill;

	Time currentTime;

	resourceHopperTimestamp.updateToCurrentTime();

	ManagedReference<ResourceContainer*> container = getContainerFromHopper(currentSpawn);

	if (container == NULL) {
		Locker locker(currentSpawn);
		container = currentSpawn->createResource(0);

		addResourceToHopper(container);
		setActiveResource(container);
	} else {
		setActiveResource(container);
	}

	InstallationObjectDeltaMessage7* inso7 = new InstallationObjectDeltaMessage7( _this.get());
	inso7->updateExtractionRate(getActualRate());
	inso7->updateActiveResourceSpawn(getActiveResourceSpawnID());
	inso7->close();

	broadcastToOperators(inso7);
}
コード例 #2
0
ファイル: resourcemanager.cpp プロジェクト: Svedrin/spectrum
void ResourceManager::setResource(const std::string &resource, int priority, int caps, int show, const std::string &status) {
	if (resource.empty())
		return;
	if (!hasResource(resource)) {
		m_resources[resource].caps = 0;
		m_resources[resource].priority = 0;
		m_resources[resource].show = -1;
	}
	if (priority != -256)
		m_resources[resource].priority = priority;
	if (caps != -1)
		m_resources[resource].caps = caps;
	m_resources[resource].status = status;
	m_resources[resource].name = resource;

	setActiveResource();
}
コード例 #3
0
ファイル: resourcemanager.cpp プロジェクト: Svedrin/spectrum
void ResourceManager::removeResource(const std::string &resource) {
	m_resources.erase(resource);
	setActiveResource();
}