Skip to content

Commit

Permalink
handle tier textures
Browse files Browse the repository at this point in the history
  • Loading branch information
Longi94 committed Dec 7, 2019
1 parent aa9d7c4 commit 62da864
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/utils/ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,33 @@ export const BODY_RYE_TIER1_ID = 3155; // Maverick
export const BODY_RYE_TIER2_ID = 3156; // Maverick G1
export const BODY_RYE_TIER3_ID = 3157; // Maverick GXT
export const BODY_RON_ID = 3265; // McLaren 570S
export const BODY_ENSPIER_TIER3_ID = 3594; // Artemis GXT
export const BODY_ENSPIER_TIER1_ID = 3614; // Artemis
export const BODY_ENSPIER_TIER2_ID = 3622; // Artemis G1
export const BODY_MANGO_TIER3_ID = 3875; // Guardian GXT
export const BODY_MANGO_TIER1_ID = 3879; // Guardian
export const BODY_MANGO_TIER2_ID = 3880; // Guardian G1
export const BODY_FELINE_ID = 4014; // K.I.T.T.
export const BODY_SLIME_ID = 4155; // Ecto-1
export const BODY_MELON_TIER1_ID = 4318; // Mudcat
export const BODY_MELON_TIER2_ID = 4319; // Mudcat G1
export const BODY_MELON_TIER3_ID = 4320; // Mudcat GXT
export const BODY_DURIAN_TIER3_ID = 4472; // Chikara GXT
export const BODY_DURIAN_TIER1_ID = 4473; // Chikara
export const BODY_DURIAN_TIER2_ID = 4770; // Chikara G1

export const TIER_2_BODIES = new Set<number>([
BODY_RYE_TIER2_ID,
BODY_MANGO_TIER2_ID,
BODY_MELON_TIER2_ID,
BODY_ENSPIER_TIER2_ID,
BODY_DURIAN_TIER2_ID
]);

export const TIER_3_BODIES = new Set<number>([
BODY_RYE_TIER3_ID,
BODY_MANGO_TIER3_ID,
BODY_MELON_TIER3_ID,
BODY_ENSPIER_TIER3_ID,
BODY_DURIAN_TIER3_ID
]);
16 changes: 16 additions & 0 deletions src/utils/network.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RocketConfig, TextureFormat, TextureQuality } from '../model/rocket-config';
import { TIER_2_BODIES, TIER_3_BODIES } from './ids';

export async function doRequest<T>(request: RequestInfo | string): Promise<T> {
const response = await fetch(request);
Expand Down Expand Up @@ -31,3 +32,18 @@ export function getAssetUrl(path: string, rocketConfig: RocketConfig): string {
}
return `${rocketConfig.assetHost}/${path}`;
}

export function fixTierUrl(bodyId: number, path: string): string {
if (path == undefined || path.length === 0) {
return undefined;
}
if (path.toLowerCase().includes('TierAll')) {
return path;
}
if (TIER_2_BODIES.has(bodyId)) {
return path.replace('Tier1', 'Tier2');
} else if (TIER_3_BODIES.has(bodyId)) {
return path.replace('Tier1', 'Tier3');
}
return path;
}
4 changes: 2 additions & 2 deletions src/webgl/static-decal-texture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Color } from 'three';
import { Decal } from '../model/decal';
import { getAssetUrl } from '../utils/network';
import { fixTierUrl, getAssetUrl } from '../utils/network';
import { BodyTexture } from '../3d/body/body-texture';
import { Body } from '../model/body';
import { PaintConfig } from '../model/paint-config';
Expand Down Expand Up @@ -105,7 +105,7 @@ export class StaticDecalTexture extends WebGLCanvasTexture implements BodyTextur
constructor(body: Body, decal: Decal, paints: PaintConfig, rocketConfig: RocketConfig) {
super(decal.base_texture != undefined ? getAssetUrl(decal.base_texture, rocketConfig) :
getAssetUrl(body.base_skin, rocketConfig), rocketConfig);
this.rgbaMapUrl = getAssetUrl(decal.rgba_map, rocketConfig);
this.rgbaMapUrl = fixTierUrl(body.id, getAssetUrl(decal.rgba_map, rocketConfig));
this.bodyBlankSkinUrl = getAssetUrl(body.blank_skin, rocketConfig);

this.primary = paints.primary;
Expand Down

0 comments on commit 62da864

Please sign in to comment.