refactor: rename states for clarity and consistency
- Updated state names in constants and related files from WAIT, REACT, TYPE, SLEEP to WAITING, REACTING, TYPING, SLEEPING. - Adjusted all references to the renamed states across the codebase, including state handlers and transition logic. - Ensured that logging messages reflect the new state names for better readability.
This commit is contained in:
@ -17,7 +17,7 @@ export class ReactStateHandler extends StateHandler {
|
||||
* @param {OwenAnimationContext} context - The animation context
|
||||
*/
|
||||
constructor (context) {
|
||||
super(States.REACT, context)
|
||||
super(States.REACTING, context)
|
||||
|
||||
/**
|
||||
* Current emotional state
|
||||
@ -33,7 +33,7 @@ export class ReactStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async enter (_fromState = null, emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Entering REACT state with emotion: ${emotion}`)
|
||||
console.log(`Entering REACTING state with emotion: ${emotion}`)
|
||||
this.emotion = emotion
|
||||
|
||||
// Play appropriate reaction
|
||||
@ -51,7 +51,7 @@ export class ReactStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async exit (toState = null, emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Exiting REACT state to ${toState} with emotion: ${emotion}`)
|
||||
console.log(`Exiting REACTING state to ${toState} with emotion: ${emotion}`)
|
||||
|
||||
if (this.currentClip) {
|
||||
await this.stopCurrentClip()
|
||||
@ -154,6 +154,6 @@ export class ReactStateHandler extends StateHandler {
|
||||
* @returns {string[]} Array of available state transitions
|
||||
*/
|
||||
getAvailableTransitions () {
|
||||
return [States.TYPE, States.WAIT]
|
||||
return [ States.TYPING, States.WAITING ]
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ export class SleepStateHandler extends StateHandler {
|
||||
* @param {OwenAnimationContext} context - The animation context
|
||||
*/
|
||||
constructor (context) {
|
||||
super(States.SLEEP, context)
|
||||
super(States.SLEEPING, context)
|
||||
|
||||
/**
|
||||
* Sleep animation clip
|
||||
@ -39,7 +39,7 @@ export class SleepStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async enter (fromState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Entering SLEEP state from ${fromState}`)
|
||||
console.log(`Entering SLEEPING state from ${fromState}`)
|
||||
|
||||
// Play sleep transition if available
|
||||
const sleepTransition = this.context.getClip('wait_2sleep_T')
|
||||
@ -65,7 +65,7 @@ export class SleepStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async exit (toState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Exiting SLEEP state to ${toState}`)
|
||||
console.log(`Exiting SLEEPING state to ${toState}`)
|
||||
this.isDeepSleep = false
|
||||
|
||||
if (this.currentClip) {
|
||||
@ -107,8 +107,8 @@ export class SleepStateHandler extends StateHandler {
|
||||
// Any message should wake up the character
|
||||
if (this.isDeepSleep) {
|
||||
console.log('Waking up due to user message')
|
||||
// This will trigger a state transition to REACT
|
||||
await this.context.transitionTo(States.REACT)
|
||||
// This will trigger a state transition to REACTING
|
||||
await this.context.transitionTo(States.REACTING)
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ export class SleepStateHandler extends StateHandler {
|
||||
* @returns {string[]} Array of available state transitions
|
||||
*/
|
||||
getAvailableTransitions () {
|
||||
return [States.WAIT, States.REACT]
|
||||
return [ States.WAITING, States.REACTING ]
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,7 +134,7 @@ export class SleepStateHandler extends StateHandler {
|
||||
*/
|
||||
async wakeUp () {
|
||||
if (this.isDeepSleep) {
|
||||
await this.context.transitionTo(States.WAIT)
|
||||
await this.context.transitionTo(States.WAITING)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,10 +26,10 @@ export class StateFactory {
|
||||
this.stateHandlers = new Map()
|
||||
|
||||
// Register default state handlers
|
||||
this.registerStateHandler(States.WAIT, WaitStateHandler)
|
||||
this.registerStateHandler(States.REACT, ReactStateHandler)
|
||||
this.registerStateHandler(States.TYPE, TypeStateHandler)
|
||||
this.registerStateHandler(States.SLEEP, SleepStateHandler)
|
||||
this.registerStateHandler(States.WAITING, WaitStateHandler);
|
||||
this.registerStateHandler(States.REACTING, ReactStateHandler);
|
||||
this.registerStateHandler(States.TYPING, TypeStateHandler);
|
||||
this.registerStateHandler(States.SLEEPING, SleepStateHandler)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -17,7 +17,7 @@ export class TypeStateHandler extends StateHandler {
|
||||
* @param {OwenAnimationContext} context - The animation context
|
||||
*/
|
||||
constructor (context) {
|
||||
super(States.TYPE, context)
|
||||
super(States.TYPING, context)
|
||||
|
||||
/**
|
||||
* Current emotional state
|
||||
@ -39,7 +39,7 @@ export class TypeStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async enter (_fromState = null, emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Entering TYPE state with emotion: ${emotion}`)
|
||||
console.log(`Entering TYPING state with emotion: ${emotion}`)
|
||||
this.emotion = emotion
|
||||
this.isTyping = true
|
||||
|
||||
@ -63,7 +63,7 @@ export class TypeStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async exit (toState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Exiting TYPE state to ${toState}`)
|
||||
console.log(`Exiting TYPING state to ${toState}`)
|
||||
this.isTyping = false
|
||||
|
||||
if (this.currentClip) {
|
||||
@ -106,7 +106,7 @@ export class TypeStateHandler extends StateHandler {
|
||||
* @returns {string[]} Array of available state transitions
|
||||
*/
|
||||
getAvailableTransitions () {
|
||||
return [States.WAIT, States.REACT]
|
||||
return [ States.WAITING, States.REACTING ]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -17,7 +17,7 @@ export class WaitStateHandler extends StateHandler {
|
||||
* @param {OwenAnimationContext} context - The animation context
|
||||
*/
|
||||
constructor (context) {
|
||||
super(States.WAIT, context)
|
||||
super(States.WAITING, context)
|
||||
|
||||
/**
|
||||
* The main idle animation clip
|
||||
@ -51,7 +51,7 @@ export class WaitStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async enter (fromState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Entering WAIT state from ${fromState}`)
|
||||
console.log(`Entering WAITING state from ${fromState}`)
|
||||
|
||||
// Play idle loop
|
||||
this.idleClip = this.context.getClip('wait_idle_L')
|
||||
@ -72,7 +72,7 @@ export class WaitStateHandler extends StateHandler {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async exit (toState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Exiting WAIT state to ${toState}`)
|
||||
console.log(`Exiting WAITING state to ${toState}`)
|
||||
|
||||
if (this.currentClip) {
|
||||
await this.stopCurrentClip()
|
||||
@ -133,6 +133,6 @@ export class WaitStateHandler extends StateHandler {
|
||||
* @returns {string[]} Array of available state transitions
|
||||
*/
|
||||
getAvailableTransitions () {
|
||||
return [States.REACT, States.SLEEP]
|
||||
return [ States.REACTING, States.SLEEPING ]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user