Skip to content

Commit

Permalink
fix: Remove male and female harcoded values
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Dec 22, 2021
1 parent 5c9d1cd commit 98726d9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 588 deletions.
22 changes: 22 additions & 0 deletions src/modules/editor/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Color4 } from 'decentraland-ecs'
import { WearableBodyShape } from 'modules/item/types'

export function getSkinColors() {
return [
Expand Down Expand Up @@ -42,3 +43,24 @@ export function getEyeColors() {
new Color4(0.2313726, 0.6235294, 0.3137255, 1)
]
}

export const extraAvatarWearablesIds = {
[WearableBodyShape.MALE]: [
'urn:decentraland:off-chain:base-avatars:BaseMale',
'urn:decentraland:off-chain:base-avatars:eyebrows_00',
'urn:decentraland:off-chain:base-avatars:eyes_00',
'urn:decentraland:off-chain:base-avatars:sneakers',
'urn:decentraland:off-chain:base-avatars:brown_pants',
'urn:decentraland:off-chain:base-avatars:mouth_00',
'urn:decentraland:off-chain:base-avatars:green_hoodie'
],
[WearableBodyShape.FEMALE]: [
'urn:decentraland:off-chain:base-avatars:BaseFemale',
'urn:decentraland:off-chain:base-avatars:f_eyebrows_00',
'urn:decentraland:off-chain:base-avatars:f_eyes_00',
'urn:decentraland:off-chain:base-avatars:bun_shoes',
'urn:decentraland:off-chain:base-avatars:f_jeans',
'urn:decentraland:off-chain:base-avatars:f_mouth_00',
'urn:decentraland:off-chain:base-avatars:f_sweater'
]
}
19 changes: 8 additions & 11 deletions src/modules/editor/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ import {
ROTATION_GRID_RESOLUTION,
fromCatalystWearableToWearable
} from './utils'
import { getEyeColors, getHairColors, getSkinColors } from './avatar'

import maleAvatar from './wearables/male.json'
import femaleAvatar from './wearables/female.json'
import { extraAvatarWearablesIds, getEyeColors, getHairColors, getSkinColors } from './avatar'

const editorWindow = window as EditorWindow

Expand Down Expand Up @@ -663,18 +660,18 @@ function handleEntitiesOutOfBoundaries(args: { entities: string[] }) {

function* getDefaultWearables() {
const bodyShape: WearableBodyShape = yield select(getBodyShape)
const baseWearables: Wearable[] = yield select(getBaseWearables)

const selectedBaseWearables: ReturnType<typeof getSelectedBaseWearables> = yield select(getSelectedBaseWearables)
if (!selectedBaseWearables) {
throw new Error('No base wearables selected')
}

const wearables = Object.values(selectedBaseWearables[bodyShape]).filter(wearable => wearable !== null) as Wearable[]
const extras = (bodyShape === WearableBodyShape.MALE ? maleAvatar : femaleAvatar) as Wearable[]
for (const extra of extras) {
if (!wearables.some(wearable => wearable.category === extra.category)) {
wearables.push(extra)
}
}
let wearables = Object.values(selectedBaseWearables[bodyShape]).filter(wearable => wearable !== null) as Wearable[]
const extras = baseWearables
.filter(wearable => extraAvatarWearablesIds[bodyShape].includes(wearable.id))
.filter(extraWearable => !wearables.some(wearable => wearable.category === extraWearable.category))
wearables = wearables.concat(extras)

// @TODO: remove this when unity build accepts urn
return wearables.map(w => ({
Expand Down
276 changes: 0 additions & 276 deletions src/modules/editor/wearables/female.json

This file was deleted.

Loading

0 comments on commit 98726d9

Please sign in to comment.