Skip to content

Commit

Permalink
[Fight For Style] Ajout d'un Show Room et la création de vetement sou…
Browse files Browse the repository at this point in the history
…s forme d'item
  • Loading branch information
DreamXZE committed Apr 9, 2023
1 parent 1faed66 commit 4886432
Show file tree
Hide file tree
Showing 30 changed files with 8,964 additions and 42 deletions.
24 changes: 24 additions & 0 deletions resources/[qb]/qb-core/shared/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2817,6 +2817,30 @@ QBShared.Items = {
['combinable'] = nil,
['description'] = 'L\'outil parfait pour faire infecter un ordinateur'
},
['ffs_crafted_outfit_m'] = {
['name'] = 'ffs_crafted_outfit_m',
['label'] = 'Tenue Sur-mesure',
['weight'] = 1000,
['type'] = 'item',
['unique'] = false,
['useable'] = true,
['shouldClose'] = true,
['combinable'] = nil,
['itemExtraLabel'] = '[Homme]',
['description'] = 'Tenue réalisée spécialement pour: '
},
['ffs_crafted_outfit_f'] = {
['name'] = 'ffs_crafted_outfit_f',
['label'] = 'Tenue Sur-mesure',
['weight'] = 1000,
['type'] = 'item',
['unique'] = false,
['useable'] = true,
['shouldClose'] = true,
['combinable'] = nil,
['itemExtraLabel'] = '[Femme]',
['description'] = 'Tenue réalisée spécialement pour: '
},
-- Vehicle Tools
['repairkit'] = {
['name'] = 'repairkit',
Expand Down
1 change: 1 addition & 0 deletions resources/[soz]/soz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"chokidar": "^3.5.3",
"concurrently": "^7.2.2",
"css-loader": "^6.7.1",
"csvtojson": "^2.0.10",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
Expand Down
86 changes: 65 additions & 21 deletions resources/[soz]/soz-core/src/client/clothing/clothing.service.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
import { Inject, Injectable } from '../../core/decorators/injectable';
import { Component, KeepHairWithMask, Outfit, OutfitItem, Prop } from '../../shared/cloth';
import { Component, ComponentEnum, FfsComponent, KeepHairWithMask, Outfit, OutfitItem, Prop } from '../../shared/cloth';
import { ffsClothConfig } from '../../shared/showRoom/ffsClothConfig';
import { PlayerService } from '../player/player.service';

@Injectable()
export class ClothingService {
@Inject(PlayerService)
public playerService: PlayerService;

public applyComponent(component: Component, outfitItem: OutfitItem) {
public applyComponentToPed(pedId: number, component: Component, outfitItem: OutfitItem) {
SetPedComponentVariation(
PlayerPedId(),
pedId,
Number(component),
Number(outfitItem.Drawable),
Number(outfitItem.Texture),
Number(outfitItem.Palette)
);
}

public applyComponent(component: Component, outfitItem: OutfitItem) {
this.applyComponentToPed(PlayerPedId(), component, outfitItem);
}

public displayHairWithMask(maskDrawable: number): boolean {
return maskDrawable < 103 || KeepHairWithMask[maskDrawable];
}

public applyProp(prop: Prop, outfitItem: OutfitItem) {
public applyPropToPed(pedId: number, prop: Prop, outfitItem: OutfitItem) {
if (outfitItem.Clear) {
ClearPedProp(PlayerPedId(), Number(prop));
ClearPedProp(pedId, Number(prop));
} else {
SetPedPropIndex(PlayerPedId(), Number(prop), outfitItem.Drawable || 0, outfitItem.Texture || 0, true);
SetPedPropIndex(pedId, Number(prop), outfitItem.Drawable || 0, outfitItem.Texture || 0, true);
}
}

public applyProp(prop: Prop, outfitItem: OutfitItem) {
this.applyPropToPed(PlayerPedId(), prop, outfitItem);
}

public applyOutfit(outfit: Outfit) {
for (const [componentIndex, component] of Object.entries(outfit.Components)) {
this.applyComponent(Number(componentIndex), component);
Expand All @@ -48,12 +57,33 @@ export class ClothingService {
}

public getClothSet(): Outfit {
return this.getClothSetForComponentAndProp(Component, Prop, PlayerPedId());
}

public getMaxOptions() {
return this.getMaxOptionsForComponentAndProp(Component, Prop, PlayerPedId());
}

public getFfsClothSet(pedId: number): Outfit {
const ffsClothSet = this.getClothSetForComponentAndProp(FfsComponent, Prop, pedId);
for (const propIndex in ffsClothSet.Props) {
ffsClothSet.Props[propIndex].Drawable = Math.max(ffsClothSet.Props[propIndex].Drawable, 0);
}

return ffsClothSet;
}

public getFfsOptions(model: string) {
return ffsClothConfig[model];
}

private getClothSetForComponentAndProp(component: ComponentEnum, prop: ComponentEnum, pedId: number): Outfit {
const components: Outfit['Components'] = {};

for (const componentIndex of Object.keys(Component).filter(key => !isNaN(Number(key)))) {
for (const componentIndex of Object.keys(component).filter(key => !isNaN(Number(key)))) {
const componentId = Number(componentIndex);
const drawableId = GetPedDrawableVariation(PlayerPedId(), componentId);
const textureId = GetPedTextureVariation(PlayerPedId(), componentId);
const drawableId = GetPedDrawableVariation(pedId, componentId);
const textureId = GetPedTextureVariation(pedId, componentId);

components[componentIndex] = {
Drawable: drawableId,
Expand All @@ -63,10 +93,10 @@ export class ClothingService {
}

const props: Outfit['Props'] = {};
for (const propIndex of Object.values(Prop).filter(key => !isNaN(Number(key)))) {
for (const propIndex of Object.values(prop).filter(key => !isNaN(Number(key)))) {
const propId = Number(propIndex);
const drawableId = GetPedPropIndex(PlayerPedId(), propId);
const textureId = GetPedPropTextureIndex(PlayerPedId(), propId);
const drawableId = GetPedPropIndex(pedId, propId);
const textureId = GetPedPropTextureIndex(pedId, propId);

props[propIndex] = {
Drawable: drawableId,
Expand All @@ -80,24 +110,38 @@ export class ClothingService {
};
}

public getMaxOptions() {
public getMaxOptionsForComponentAndProp(component: ComponentEnum, prop: ComponentEnum, pedId: number) {
const maxOptions = [];
for (const componentIndex of Object.values(Component).filter(key => !isNaN(Number(key)) && key !== '7')) {
for (const componentIndex of Object.values(component).filter(key => !isNaN(Number(key)) && key !== '7')) {
const componentId = Number(componentIndex);
const maxDrawable = GetNumberOfPedDrawableVariations(PlayerPedId(), componentId);
maxOptions.push({
const maxDrawable = GetNumberOfPedDrawableVariations(pedId, componentId);
const maxOptionObject = {
componentIndex: componentIndex,
maxDrawables: maxDrawable,
});
maxTextures: 0,
};
for (let drawableIndex = 0; drawableIndex < maxDrawable; drawableIndex++) {
const maxTextureForDrawable = GetNumberOfPedTextureVariations(pedId, componentId, drawableIndex);
maxOptionObject.maxTextures = Math.max(maxTextureForDrawable, maxOptionObject.maxTextures);
}

maxOptions.push(maxOptionObject);
}

for (const propIndex of Object.values(Prop).filter(key => !isNaN(Number(key)))) {
for (const propIndex of Object.values(prop).filter(key => !isNaN(Number(key)))) {
const propId = Number(propIndex);
const maxDrawable = GetNumberOfPedPropDrawableVariations(PlayerPedId(), propId);
maxOptions.push({
const maxDrawable = GetNumberOfPedPropDrawableVariations(pedId, propId);
const maxOptionObject = {
propIndex: propIndex,
maxDrawables: maxDrawable,
});
maxTextures: 0,
};

for (let drawableIndex = 0; drawableIndex < maxDrawable; drawableIndex++) {
const maxTextureForDrawable = GetNumberOfPedPropTextureVariations(pedId, propId, drawableIndex);
maxOptionObject.maxTextures = Math.max(maxTextureForDrawable, maxOptionObject.maxTextures);
}
maxOptions.push(maxOptionObject);
}

return maxOptions;
Expand Down
2 changes: 2 additions & 0 deletions resources/[soz]/soz-core/src/client/job/ffs/ffs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FightForStyleCraftProvider } from './ffs.craft.provider';
import { FightForStyleHarvestProvider } from './ffs.harvest.provider';
import { FightForStyleProvider } from './ffs.provider';
import { FightForStyleRestockProvider } from './ffs.restock.provider';
import { FightForStylShowRoomProvider } from './ffs.showroom.provider';
import { FightForStyleTransformProvider } from './ffs.transform.provider';

@Module({
Expand All @@ -12,6 +13,7 @@ import { FightForStyleTransformProvider } from './ffs.transform.provider';
FightForStyleCraftProvider,
FightForStyleRestockProvider,
FightForStyleProvider,
FightForStylShowRoomProvider,
],
})
export class FightForStyleModule {}
Loading

0 comments on commit 4886432

Please sign in to comment.