@casual-simulation/aux-common
Version:
Common library for AUX projects
44 lines • 1.67 kB
TypeScript
import type { PrecalculatedBotsState, Bot, PartialPrecalculatedBotsState, PartialBot, UpdatedBot } from './Bot';
import type { CurrentVersion } from '../common';
/**
* Defines an event for state updates from the VM.
*/
export interface StateUpdatedEvent {
/**
* The state that was updated. This is a partial precalculated bots state instance,
* so it must be merged with the previous version to get the full updated bot state.
*
* You can use the merge() function from aux-common or lodash to do this.
*/
state: PartialPrecalculatedBotsState;
/**
* The list of Bot IDs that were added.
*/
addedBots: string[];
/**
* The list of Bot IDs that were removed.
*/
removedBots: string[];
/**
* The list of Bot IDs that were updated.
*/
updatedBots: string[];
/**
* The version of this state.
*/
version: CurrentVersion | null;
}
/**
* Applies the given update to the given state and returns a new object representing the final state.
* @param currentState The current state.
* @param update The update to apply.
*/
export declare function applyUpdates(currentState: PrecalculatedBotsState, update: StateUpdatedEvent): PrecalculatedBotsState;
/**
* Calculates the StateUpdatedEvent from the given partial bots state.
* @param state The state update.
* @param version The version of the state.
*/
export declare function stateUpdatedEvent(state: PartialPrecalculatedBotsState, version?: CurrentVersion): StateUpdatedEvent;
export declare function updatedBot(partialBot: PartialBot, currentBot: Bot): UpdatedBot;
//# sourceMappingURL=StateUpdatedEvent.d.ts.map