Skip to content

Commit

Permalink
Merge pull request IITC-CE#733 from McBen/artifacts
Browse files Browse the repository at this point in the history
artifacts: inject portals instead of special code
  • Loading branch information
modos189 authored May 15, 2024
2 parents f6e9917 + 8eb9d2e commit 0fe373b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 17 additions & 3 deletions core/code/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ window.artifact.setup = function() {
title: 'Show artifact portal list',
action: window.artifact.showArtifactList,
});

window.addHook('mapDataEntityInject', window.artifact.entityInject);
}

/**
Expand Down Expand Up @@ -201,12 +203,22 @@ window.artifact.isArtifact = function(type) {
/**
* Used to render portals that would otherwise be below the visible level.
* @function window.artifact.getArtifactEntities
* @returns {Array} An array of artifact entities.
* @returns {Array} array of Portal entities with shards or shard targets
*
* unused by IITC
*/
window.artifact.getArtifactEntities = function() {
window.artifact.getArtifactEntities = function () {
return artifact.entities;
}

/**
* Inject artifact portals into render process
* @param {hookdata} data
*/
window.artifact.entityInject = function (data) {
data.callback(window.artifact.entities, 'summary');
};

/**
* Gets the portals that are relevant to the artifacts.
* @function window.artifact.getInterestingPortals
Expand All @@ -232,8 +244,10 @@ window.artifact.isInterestingPortal = function(guid) {
* @param {string} guid - The GUID of the portal.
* @param {string} artifactId - The ID of the artifact type.
* @returns {Object|false} Artifact data for the specified portal and type, or undefined if not available.
*
* unused by IITC
*/
window.artifact.getPortalData = function(guid,artifactId) {
window.artifact.getPortalData = function (guid, artifactId) {
return artifact.portalInfo[guid] && artifact.portalInfo[guid][artifactId];
}

Expand Down
5 changes: 1 addition & 4 deletions core/code/map_data_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ window.MapDataRequest.prototype.refresh = function() {

this.render.startRenderPass(dataBounds);

window.runHooks ('mapDataEntityInject', {callback: this.render.processGameEntities.bind(this.render)});


this.render.processGameEntities(artifact.getArtifactEntities(), 'summary');
window.runHooks('mapDataEntityInject', { callback: this.render.processGameEntities.bind(this.render) });

var logMessage = 'requesting data tiles at zoom '+dataZoom;
logMessage += ' (L'+tileParams.level+'+ portals';
Expand Down

0 comments on commit 0fe373b

Please sign in to comment.