Many asset updates

This commit is contained in:
Bill 2021-08-19 03:33:05 -04:00
parent 97a433225c
commit 73006d4d5b
40 changed files with 214 additions and 113 deletions

View File

@ -82,6 +82,8 @@ export class AssetManager extends Disposable implements IAssetManager
{
if(!data) return null;
console.log(data);
const collection = new GraphicAssetCollection(data, spritesheet);
if(collection)

View File

@ -1,11 +1,9 @@
import { IAssetAnimation } from './animation';
import { IAsset } from './IAsset';
import { IAssetAlias } from './IAssetAlias';
import { IAssetDimension } from './IAssetDimension';
import { IAssetPalette } from './IAssetPalette';
import { IPlanetSystem } from './IPlanetSystem';
import { IParticleSystem } from './particlesystem';
import { ISpritesheet } from './spritesheet';
import { IAssetLogicData } from './logic';
import { ISpritesheetData } from './spritesheet';
import { IAssetVisualizationData } from './visualization';
export interface IAssetData {
@ -13,15 +11,8 @@ export interface IAssetData {
name?: string;
visualizationType?: string;
logicType?: string;
maskType?: string;
credits?: string;
soundSample?: { id?: number, noPitch?: boolean };
action?: { link?: string, startState?: number };
planetSystems?: IPlanetSystem[];
particleSystems?: IParticleSystem[];
spritesheet?: ISpritesheet;
dimensions?: IAssetDimension;
directions?: number[];
spritesheet?: ISpritesheetData;
logic?: IAssetLogicData;
assets?: { [index: string]: IAsset };
aliases?: { [index: string]: IAssetAlias };
animations?: { [index: string]: IAssetAnimation };

View File

@ -2,8 +2,7 @@ export * from './animation';
export * from './IAsset';
export * from './IAssetAlias';
export * from './IAssetData';
export * from './IAssetDimension';
export * from './IAssetPalette';
export * from './IPlanetSystem';
export * from './logic';
export * from './spritesheet';
export * from './visualization';

View File

@ -0,0 +1,4 @@
export interface ICustomVars
{
variables?: string[];
}

View File

@ -0,0 +1,17 @@
import { ICustomVars } from './IAssetLogicCustomVars';
import { IAssetLogicPlanetSystem } from './IAssetLogicPlanetSystem';
import { ISoundSample } from './ISoundSample';
import { IAssetLogicModel } from './model/IAssetLogicModel';
import { IParticleSystem } from './particlesystem';
export interface IAssetLogicData
{
model?: IAssetLogicModel;
maskType?: string;
credits?: string;
soundSample?: ISoundSample;
action?: { link?: string, startState?: number };
planetSystems?: IAssetLogicPlanetSystem[];
particleSystems?: IParticleSystem[];
customVars?: ICustomVars;
}

View File

@ -1,4 +1,4 @@
export interface IPlanetSystem
export interface IAssetLogicPlanetSystem
{
id?: number;
name?: string;

View File

@ -0,0 +1,5 @@
export interface ISoundSample
{
id?: number;
noPitch?: boolean;
}

View File

@ -0,0 +1,6 @@
export * from './IAssetLogicCustomVars';
export * from './IAssetLogicData';
export * from './IAssetLogicPlanetSystem';
export * from './ISoundSample';
export * from './model';
export * from './particlesystem';

View File

@ -0,0 +1,7 @@
import { IAssetDimension } from './IAssetDimension';
export interface IAssetLogicModel
{
dimensions?: IAssetDimension;
directions?: number[];
}

View File

@ -0,0 +1,2 @@
export * from './IAssetDimension';
export * from './IAssetLogicModel';

View File

@ -1,7 +0,0 @@
import { ISpritesheetData } from '@pixi/spritesheet';
import { ISpritesheetMeta } from './ISpritesheetMeta';
export interface ISpritesheet extends ISpritesheetData
{
meta: ISpritesheetMeta;
}

View File

@ -0,0 +1,7 @@
import { ISpritesheetData as PixiSpritesheet } from '@pixi/spritesheet';
import { ISpritesheetMeta } from './ISpritesheetMeta';
export interface ISpritesheetData extends PixiSpritesheet
{
meta: ISpritesheetMeta;
}

View File

@ -0,0 +1,25 @@
export interface ISpritesheetFrame
{
frame: {
x: number;
y: number;
w: number;
h: number;
};
rotated: boolean;
trimmed: boolean;
spriteSourceSize: {
x: number;
y: number;
w: number;
h: number;
};
sourceSize: {
w: number;
h: number;
};
pivot: {
x: number;
y: number;
};
}

View File

@ -1,2 +1,3 @@
export * from './ISpritesheet';
export * from './ISpritesheetData';
export * from './ISpritesheetFrame';
export * from './ISpritesheetMeta';

View File

@ -14,6 +14,7 @@ export interface IAssetVisualizationData
colors?: { [index: string]: IAssetColor };
directions?: { [index: string]: IAssetVisualizationDirection };
animations?: { [index: string]: IAssetVisualAnimation };
postures?: { [index: string]: IAssetPosture };
gestures?: { [index: string]: IAssetGesture };
defaultPosture?: string;
postures?: { defaultPosture?: string, postures?: IAssetPosture[] };
gestures?: IAssetGesture[];
}

View File

@ -342,6 +342,8 @@ export class RoomContentLoader implements IFurnitureDataListener
const collection = new GraphicAssetCollection(data, spritesheet);
console.log(data);
this._collections.set(collection.name, collection);
const petIndex = this._pets[collection.name];
@ -409,7 +411,7 @@ export class RoomContentLoader implements IFurnitureDataListener
if(type === RoomObjectUserType.RENTABLE_BOT) return RoomObjectCategory.UNIT;
if(type === 'tile_cursor' || type === 'selection_arrow') return RoomObjectCategory.CURSOR;
if((type === RoomContentLoader.TILE_CURSOR) || (type === RoomContentLoader.SELECTION_ARROW)) return RoomObjectCategory.CURSOR;
return RoomObjectCategory.MINIMUM;
}
@ -722,17 +724,17 @@ export class RoomContentLoader implements IFurnitureDataListener
switch(type)
{
case RoomContentLoader.PLACE_HOLDER:
return [ this.getAssetUrlWithRoomBase('place_holder') ];
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER) ];
case RoomContentLoader.PLACE_HOLDER_WALL:
return [ this.getAssetUrlWithRoomBase('place_holder_wall') ];
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER_WALL) ];
case RoomContentLoader.PLACE_HOLDER_PET:
return [ this.getAssetUrlWithRoomBase('place_holder_pet') ];
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER_PET) ];
case RoomContentLoader.ROOM:
return [ this.getAssetUrlWithRoomBase('room') ];
return [ this.getAssetUrlWithGenericBase('room') ];
case RoomContentLoader.TILE_CURSOR:
return [ this.getAssetUrlWithRoomBase('tile_cursor') ];
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.TILE_CURSOR) ];
case RoomContentLoader.SELECTION_ARROW:
return [ this.getAssetUrlWithRoomBase('selection_arrow') ];
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.SELECTION_ARROW) ];
default: {
const category = this.getCategoryForType(type);
@ -788,9 +790,9 @@ export class RoomContentLoader implements IFurnitureDataListener
return null;
}
private getAssetUrlWithRoomBase(assetName: string): string
private getAssetUrlWithGenericBase(assetName: string): string
{
return (Nitro.instance.getConfiguration<string>('room.asset.url').replace(/%libname%/gi, assetName));
return (Nitro.instance.getConfiguration<string>('generic.asset.url').replace(/%libname%/gi, assetName));
}
public getAssetUrlWithFurniBase(assetName: string): string

View File

@ -523,7 +523,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
}
instance.createRoomObjectAndInitalize(RoomEngine.CURSOR_OBJECT_ID, RoomEngine.CURSOR_OBJECT_TYPE, RoomObjectCategory.CURSOR);
//instance.createRoomObjectAndInitalize(RoomEngine.ARROW_OBJECT_ID, RoomEngine.ARROW_OBJECT_TYPE, RoomObjectCategory.CURSOR);
instance.createRoomObjectAndInitalize(RoomEngine.ARROW_OBJECT_ID, RoomEngine.ARROW_OBJECT_TYPE, RoomObjectCategory.CURSOR);
return instance;
}

View File

@ -34,6 +34,7 @@ export class RoomObjectVariable
public static FIGURE_GUIDE_STATUS: string = 'figure_guide_status';
public static FIGURE_EXPRESSION: string = 'figure_expression';
public static HEAD_DIRECTION: string = 'head_direction';
public static FURNITURE_CUSTOM_VARIABLES: string = 'furniture_custom_variables';
public static FURNITURE_AUTOMATIC_STATE_INDEX: string = 'furniture_automatic_state_index';
public static FURNITURE_ALWAYS_STACKABLE: string = 'furniture_always_stackable';
public static FURNITURE_DISABLE_PICKING_ANIMATION: string = 'furniture_disable_picking_animation';

View File

@ -20,7 +20,10 @@ export class FurnitureCreditLogic extends FurnitureLogic
let creditValue = 0;
if(asset.credits && (asset.credits !== '') && (asset.credits.length > 0)) creditValue = parseInt(asset.credits);
if(asset.logic)
{
if(asset.logic.credits && (asset.logic.credits !== '') && (asset.logic.credits.length > 0)) creditValue = parseInt(asset.logic.credits);
}
this.object.model.setValue(RoomObjectVariable.FURNITURE_CREDIT_VALUE, creditValue);
}

View File

@ -30,9 +30,12 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
{
super.initialize(asset);
if(asset.action)
if(asset.logic)
{
if(asset.action.startState === 1) this._showStateOnceRendered = true;
if(asset.logic.action)
{
if(asset.logic.action.startState === 1) this._showStateOnceRendered = true;
}
}
}

View File

@ -18,11 +18,14 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
{
super.initialize(asset);
if(asset.action)
if(asset.logic)
{
if(asset.action.link && (asset.action.link !== '') && (asset.action.link.length > 0))
if(asset.logic.action)
{
(this.object && this.object.model && this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.action.link));
if(asset.logic.action.link && (asset.logic.action.link !== '') && (asset.logic.action.link.length > 0))
{
(this.object && this.object.model && this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.logic.action.link));
}
}
}
}

View File

@ -15,7 +15,10 @@ export class FurnitureExternalImageLogic extends FurnitureMultiStateLogic
{
let maskType = '';
if(asset.maskType && (asset.maskType !== '') && (asset.maskType.length > 0)) maskType = asset.maskType;
if(asset.logic)
{
if(asset.logic.maskType && (asset.logic.maskType !== '') && (asset.logic.maskType.length > 0)) maskType = asset.logic.maskType;
}
this.object.model.setValue(RoomObjectVariable.FURNITURE_USES_PLANE_MASK, 0);
this.object.model.setValue(RoomObjectVariable.FURNITURE_PLANE_MASK_TYPE, maskType);

View File

@ -1,5 +1,4 @@
import { IAssetData } from '../../../../../core';
import { IParticleSystem } from '../../../../../core/asset/interfaces/particlesystem';
import { IAssetData, IParticleSystem } from '../../../../../core';
import { RoomObjectEvent } from '../../../../../room/events/RoomObjectEvent';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry';
@ -21,9 +20,12 @@ export class FurnitureFireworksLogic extends FurnitureLogic
{
super.initialize(asset);
if(asset.particleSystems && asset.particleSystems.length)
if(asset.logic)
{
this.object.model.setValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA, asset.particleSystems);
if(asset.logic.particleSystems && asset.logic.particleSystems.length)
{
this.object.model.setValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA, asset.logic.particleSystems);
}
}
}

View File

@ -24,11 +24,14 @@ export class FurnitureInternalLinkLogic extends FurnitureLogic
{
super.initialize(asset);
if(asset.action)
if(asset.logic)
{
this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.action.link);
if(asset.logic.action)
{
this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.logic.action.link);
if(asset.action.startState === 1) this._showStateOnceRendered = true;
if(asset.logic.action.startState === 1) this._showStateOnceRendered = true;
}
}
}

View File

@ -99,28 +99,42 @@ export class FurnitureLogic extends MovingObjectLogic
if(!model) return;
const dimensions = asset.dimensions;
if(!dimensions) return;
this._sizeX = dimensions.x;
this._sizeY = dimensions.y;
this._sizeZ = dimensions.z;
this._centerX = (this._sizeX / 2);
this._centerY = (this._sizeY / 2);
this._centerZ = (this._sizeZ / 2);
const directions = asset.directions;
if(directions && directions.length)
if(asset.logic)
{
for(const direction of directions) this._directions.push(direction);
this._directions.sort((a, b) =>
if(asset.logic.model)
{
return a - b;
});
const dimensions = asset.logic.model.dimensions;
if(dimensions)
{
this._sizeX = dimensions.x;
this._sizeY = dimensions.y;
this._sizeZ = dimensions.z;
this._centerX = (this._sizeX / 2);
this._centerY = (this._sizeY / 2);
this._centerZ = (this._sizeZ / 2);
}
const directions = asset.logic.model.directions;
if(directions && directions.length)
{
for(const direction of directions) this._directions.push(direction);
this._directions.sort();
}
}
if(asset.logic.customVars)
{
const variables = asset.logic.customVars.variables;
if(variables && variables.length)
{
model.setValue(RoomObjectVariable.FURNITURE_CUSTOM_VARIABLES, variables);
}
}
}
model.setValue(RoomObjectVariable.FURNITURE_SIZE_X, this._sizeX);

View File

@ -1,4 +1,4 @@
import { IAssetData, IPlanetSystem } from '../../../../../core/asset/interfaces';
import { IAssetData, IAssetLogicPlanetSystem } from '../../../../../core/asset/interfaces';
import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureLogic } from './FurnitureLogic';
@ -8,9 +8,12 @@ export class FurniturePlanetSystemLogic extends FurnitureLogic
{
super.initialize(asset);
if(asset.planetSystems)
if(asset.logic)
{
this.object.model.setValue<IPlanetSystem[]>(RoomObjectVariable.FURNITURE_PLANETSYSTEM_DATA, asset.planetSystems);
if(asset.logic.planetSystems)
{
this.object.model.setValue<IAssetLogicPlanetSystem[]>(RoomObjectVariable.FURNITURE_PLANETSYSTEM_DATA, asset.logic.planetSystems);
}
}
}
}

View File

@ -1,5 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces';
import { IParticleSystem } from '../../../../../core/asset/interfaces/particlesystem';
import { IAssetData, IParticleSystem } from '../../../../../core/asset/interfaces';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry';
@ -33,9 +32,12 @@ export class FurniturePresentLogic extends FurnitureLogic
{
super.initialize(asset);
if(asset.particleSystems && asset.particleSystems.length)
if(asset.logic)
{
this.object.model.setValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA, asset.particleSystems);
if(asset.logic.particleSystems && asset.logic.particleSystems.length)
{
this.object.model.setValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA, asset.logic.particleSystems);
}
}
}

View File

@ -32,10 +32,14 @@ export class FurnitureSoundBlockLogic extends FurnitureMultiStateLogic
{
super.initialize(asset);
if(!asset.soundSample) return;
this._sampleId = asset.soundSample.id;
this._noPitch = asset.soundSample.noPitch;
if(asset.logic)
{
if(asset.logic.soundSample)
{
this._sampleId = asset.logic.soundSample.id;
this._noPitch = asset.logic.soundSample.noPitch;
}
}
this.object.model.setValue(RoomObjectVariable.FURNITURE_SOUNDBLOCK_RELATIVE_ANIMATION_SPEED, 1);
}

View File

@ -10,7 +10,10 @@ export class FurnitureWindowLogic extends FurnitureMultiStateLogic
let maskType = '';
if(asset.maskType && (asset.maskType !== '') && (asset.maskType.length > 0)) maskType = asset.maskType;
if(asset.logic)
{
if(asset.logic.maskType && (asset.logic.maskType !== '') && (asset.logic.maskType.length > 0)) maskType = asset.logic.maskType;
}
this.object.model.setValue(RoomObjectVariable.FURNITURE_USES_PLANE_MASK, 0);
this.object.model.setValue(RoomObjectVariable.FURNITURE_PLANE_MASK_TYPE, maskType);

View File

@ -64,16 +64,19 @@ export class PetLogic extends MovingObjectLogic
if(!model) return;
const directions = asset.directions;
if(directions && directions.length)
if(asset.logic)
{
for(const direction of directions) this._directions.push(direction);
this._directions.sort((a, b) =>
if(asset.logic.model)
{
return a - b;
});
const directions = asset.logic.model.directions;
if(directions && directions.length)
{
for(const direction of directions) this._directions.push(direction);
this._directions.sort();
}
}
}
model.setValue(RoomObjectVariable.PET_ALLOWED_DIRECTIONS, this._directions);

View File

@ -18,38 +18,32 @@ export class PetSizeData extends AnimationSizeData
this._defaultPosture = null;
}
public processPostures(postures: { [index: string]: IAssetPosture }): boolean
public processPostures(postures: { defaultPosture?: string, postures: IAssetPosture[] }): boolean
{
if(!postures) return false;
for(const key in postures)
{
const posture = postures[key];
if(postures.defaultPosture && postures.defaultPosture.length) this._defaultPosture = postures.defaultPosture;
if(!posture) continue;
// for(const posture of postures.postures)
// {
// if(this._posturesToAnimations.get(posture.id)) continue;
if(this._posturesToAnimations.get(posture.id)) continue;
// if(this._defaultPosture === null) this._defaultPosture = posture.id;
if(this._defaultPosture === null) this._defaultPosture = posture.id;
this._posturesToAnimations.set(posture.id, posture.animationId);
}
// this._posturesToAnimations.set(posture.id, posture.animationId);
// }
if(this._posturesToAnimations.get(this._defaultPosture) === undefined) return false;
return true;
}
public processGestures(gestures: { [index: string]: IAssetGesture }): boolean
public processGestures(gestures: IAssetGesture[]): boolean
{
if(!gestures) return false;
for(const key in gestures)
for(const gesture of gestures)
{
const gesture = gestures[key];
if(!gesture) continue;
if(this._gesturesToAnimations.get(gesture.id)) continue;
this._gesturesToAnimations.set(gesture.id, gesture.animationId);

View File

@ -1,5 +1,4 @@
import { AdvancedMap, NitroLogger } from '../../../../../core';
import { IParticleSystem } from '../../../../../core/asset/interfaces/particlesystem';
import { AdvancedMap, IParticleSystem, NitroLogger } from '../../../../../core';
import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureAnimatedVisualization } from './FurnitureAnimatedVisualization';
import { FurnitureParticleSystem } from './FurnitureParticleSystem';

View File

@ -2,8 +2,7 @@ import { RenderTexture, Texture } from '@pixi/core';
import { AlphaFilter } from '@pixi/filter-alpha';
import { Graphics } from '@pixi/graphics';
import { Matrix } from '@pixi/math';
import { AdvancedMap, NitroPoint, NitroSprite } from '../../../../../core';
import { IParticleSystem } from '../../../../../core/asset/interfaces/particlesystem';
import { AdvancedMap, IParticleSystem, NitroPoint, NitroSprite } from '../../../../../core';
import { IGraphicAsset, IRoomObjectSprite } from '../../../../../room';
import { Vector3D } from '../../../../avatar';
import { Nitro } from '../../../../Nitro';

View File

@ -1,4 +1,4 @@
import { IPlanetSystem } from '../../../../../core';
import { IAssetLogicPlanetSystem } from '../../../../../core';
import { Vector3d } from '../../../../../room';
import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureAnimatedVisualization } from './FurnitureAnimatedVisualization';
@ -86,7 +86,7 @@ export class FurniturePlanetSystemVisualization extends FurnitureAnimatedVisuali
{
if(!this.object || !this.object.model) return;
const planetSystems = this.object.model.getValue<IPlanetSystem[]>(RoomObjectVariable.FURNITURE_PLANETSYSTEM_DATA);
const planetSystems = this.object.model.getValue<IAssetLogicPlanetSystem[]>(RoomObjectVariable.FURNITURE_PLANETSYSTEM_DATA);
if(!planetSystems) return false;