You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
🆙 Fix Sleep & Blinking eye's
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Container, Texture } from 'pixi.js';
|
||||
import { IAvatarFigureContainer } from './IAvatarFigureContainer';
|
||||
import { IGraphicAsset } from '../../asset';
|
||||
import { IAnimationLayerData, ISpriteDataContainer } from './animation';
|
||||
import { IPartColor } from './structure';
|
||||
|
||||
@@ -15,6 +16,7 @@ export interface IAvatarImage
|
||||
processAsTexture(setType: string, hightlight: boolean, texture?: Texture): Texture;
|
||||
processAsImageUrl(setType: string): string;
|
||||
processAsContainer(setType: string): Container;
|
||||
getAsset(name: string): IGraphicAsset;
|
||||
getDirection(): number;
|
||||
getFigure(): IAvatarFigureContainer;
|
||||
getPartColor(_arg_1: string): IPartColor;
|
||||
|
||||
@@ -371,6 +371,12 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
||||
public getAsset(name: string): IGraphicAsset
|
||||
{
|
||||
return this._assets.getAsset(name);
|
||||
}
|
||||
|
||||
public getDirection(): number
|
||||
{
|
||||
return this._mainDirection;
|
||||
@@ -460,6 +466,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
||||
case AvatarAction.TALK:
|
||||
case AvatarAction.EXPRESSION_WAVE:
|
||||
case AvatarAction.SLEEP:
|
||||
case AvatarAction.BLINK:
|
||||
case AvatarAction.SIGN:
|
||||
case AvatarAction.EXPRESSION_RESPECT:
|
||||
case AvatarAction.EXPRESSION_BLOW_A_KISS:
|
||||
|
||||
@@ -27,6 +27,7 @@ export class AvatarActionManager
|
||||
const definition = new ActionDefinition(action);
|
||||
|
||||
this._actions.set(definition.state, definition);
|
||||
this._actions.set(definition.state.toLowerCase(), definition);
|
||||
}
|
||||
|
||||
if(data.actionOffsets) this.parseActionOffsets(data.actionOffsets);
|
||||
@@ -38,7 +39,7 @@ export class AvatarActionManager
|
||||
|
||||
for(const offset of offsets)
|
||||
{
|
||||
const action = this._actions.get(offset.action);
|
||||
const action = this.getActionByState(offset.action);
|
||||
|
||||
if(!action) continue;
|
||||
|
||||
@@ -58,6 +59,13 @@ export class AvatarActionManager
|
||||
}
|
||||
}
|
||||
|
||||
private getActionByState(state: string): ActionDefinition
|
||||
{
|
||||
if(!state) return null;
|
||||
|
||||
return (this._actions.get(state) || this._actions.get(state.toLowerCase()) || this._actions.get(state.toUpperCase()) || null);
|
||||
}
|
||||
|
||||
public getActionDefinition(id: string): ActionDefinition
|
||||
{
|
||||
if(!id) return null;
|
||||
@@ -74,11 +82,7 @@ export class AvatarActionManager
|
||||
|
||||
public getActionDefinitionWithState(state: string): ActionDefinition
|
||||
{
|
||||
const existing = this._actions.get(state);
|
||||
|
||||
if(!existing) return null;
|
||||
|
||||
return existing;
|
||||
return this.getActionByState(state);
|
||||
}
|
||||
|
||||
public getDefaultAction(): ActionDefinition
|
||||
@@ -105,7 +109,7 @@ export class AvatarActionManager
|
||||
{
|
||||
if(!activeAction) continue;
|
||||
|
||||
const action = this._actions.get(activeAction.actionType);
|
||||
const action = this.getActionByState(activeAction.actionType);
|
||||
const offsets = action && action.getOffsets(_arg_2, _arg_3);
|
||||
|
||||
if(offsets) canvasOffsets = offsets;
|
||||
@@ -126,7 +130,7 @@ export class AvatarActionManager
|
||||
{
|
||||
if(!action) continue;
|
||||
|
||||
const definition = this._actions.get(action.actionType);
|
||||
const definition = this.getActionByState(action.actionType);
|
||||
|
||||
if(!definition) continue;
|
||||
|
||||
@@ -161,7 +165,7 @@ export class AvatarActionManager
|
||||
{
|
||||
if(!action) continue;
|
||||
|
||||
const localAction = this._actions.get(action.actionType);
|
||||
const localAction = this.getActionByState(action.actionType);
|
||||
|
||||
if(localAction) preventions = preventions.concat(localAction.getPrevents(action.actionParameter));
|
||||
}
|
||||
|
||||
@@ -188,19 +188,30 @@ export class AvatarLogic extends MovingObjectLogic
|
||||
}
|
||||
}
|
||||
|
||||
if((this._blinkingStartTimestamp > -1) && (time > this._blinkingStartTimestamp))
|
||||
{
|
||||
model.setValue(RoomObjectVariable.FIGURE_BLINK, 1);
|
||||
const isSleeping = (model.getValue<number>(RoomObjectVariable.FIGURE_SLEEP) > 0);
|
||||
|
||||
this._blinkingStartTimestamp = time + this.randomBlinkStartTimestamp();
|
||||
this._blinkingEndTimestamp = time + this.randomBlinkEndTimestamp();
|
||||
}
|
||||
|
||||
if((this._blinkingEndTimestamp > 0) && (time > this._blinkingEndTimestamp))
|
||||
if(isSleeping)
|
||||
{
|
||||
model.setValue(RoomObjectVariable.FIGURE_BLINK, 0);
|
||||
|
||||
this._blinkingEndTimestamp = 0;
|
||||
this._blinkingStartTimestamp = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((this._blinkingStartTimestamp > -1) && (time > this._blinkingStartTimestamp))
|
||||
{
|
||||
model.setValue(RoomObjectVariable.FIGURE_BLINK, 1);
|
||||
|
||||
this._blinkingStartTimestamp = time + this.randomBlinkStartTimestamp();
|
||||
this._blinkingEndTimestamp = time + this.randomBlinkEndTimestamp();
|
||||
}
|
||||
|
||||
if((this._blinkingEndTimestamp > 0) && (time > this._blinkingEndTimestamp))
|
||||
{
|
||||
model.setValue(RoomObjectVariable.FIGURE_BLINK, 0);
|
||||
|
||||
this._blinkingEndTimestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if((this._effectChangeTimeStamp > 0) && (time > this._effectChangeTimeStamp))
|
||||
@@ -305,6 +316,9 @@ export class AvatarLogic extends MovingObjectLogic
|
||||
if(message instanceof ObjectAvatarSleepUpdateMessage)
|
||||
{
|
||||
model.setValue(RoomObjectVariable.FIGURE_SLEEP, message.isSleeping ? 1 : 0);
|
||||
model.setValue(RoomObjectVariable.FIGURE_BLINK, 0);
|
||||
|
||||
this._blinkingEndTimestamp = 0;
|
||||
|
||||
if(message.isSleeping) this._blinkingStartTimestamp = -1;
|
||||
else this._blinkingStartTimestamp = (this.time + this.randomBlinkStartTimestamp());
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { AlphaTolerance, AvatarAction, AvatarGuideStatus, AvatarSetType, IAdvancedMap, IAvatarEffectListener, IAvatarImage, IAvatarImageListener, IGraphicAsset, IObjectVisualizationData, IRoomGeometry, IRoomObject, IRoomObjectModel, RoomObjectSpriteType, RoomObjectVariable } from '@nitrots/api';
|
||||
import { GetAssetManager } from '@nitrots/assets';
|
||||
import { AdvancedMap, GetRenderer } from '@nitrots/utils';
|
||||
import { Container, RenderTexture, Sprite, Texture } from 'pixi.js';
|
||||
import { RoomObjectSpriteVisualization } from '../RoomObjectSpriteVisualization';
|
||||
@@ -429,7 +428,7 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
|
||||
|
||||
const assetName = ((((((this._avatarImage.getScale() + '_') + spriteData.member) + '_') + dd) + '_') + frameNumber);
|
||||
|
||||
const asset = GetAssetManager().getAsset(assetName);
|
||||
const asset = this._avatarImage.getAsset(assetName);
|
||||
|
||||
if(!asset) continue;
|
||||
|
||||
@@ -958,7 +957,15 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
|
||||
|
||||
if(this._talk) this._avatarImage.appendAction(AvatarAction.TALK);
|
||||
|
||||
if(this._sleep || this._blink) this._avatarImage.appendAction(AvatarAction.SLEEP);
|
||||
if(this._sleep)
|
||||
{
|
||||
this._avatarImage.appendAction(AvatarAction.SLEEP);
|
||||
}
|
||||
else if(this._blink)
|
||||
{
|
||||
this._avatarImage.appendAction(AvatarAction.BLINK);
|
||||
this._avatarImage.appendAction(AvatarAction.SLEEP);
|
||||
}
|
||||
|
||||
if(this._expression > 0)
|
||||
{
|
||||
@@ -1189,7 +1196,7 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
|
||||
{
|
||||
sprite.libraryAssetName = 'sh_std_sd_1_0_0';
|
||||
|
||||
this._shadow = GetAssetManager().getAsset(sprite.libraryAssetName);
|
||||
this._shadow = this._avatarImage.getAsset(sprite.libraryAssetName);
|
||||
|
||||
offsetX = -8;
|
||||
offsetY = ((this._canStandUp) ? 6 : -3);
|
||||
@@ -1198,7 +1205,7 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
|
||||
{
|
||||
sprite.libraryAssetName = 'h_std_sd_1_0_0';
|
||||
|
||||
this._shadow = GetAssetManager().getAsset(sprite.libraryAssetName);
|
||||
this._shadow = this._avatarImage.getAsset(sprite.libraryAssetName);
|
||||
|
||||
offsetX = -17;
|
||||
offsetY = ((this._canStandUp) ? 10 : -7);
|
||||
|
||||
Reference in New Issue
Block a user