New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@akashic/akashic-engine

Package Overview
Dependencies
Maintainers
4
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@akashic/akashic-engine - npm Package Compare versions

Comparing version 3.0.0-beta.13 to 3.0.0-beta.14

76

lib/Game.d.ts

@@ -15,2 +15,3 @@ import { Trigger } from "@akashic/trigger";

import { Storage } from "./domain/Storage";
import { GameHandlerSet } from "./GameHandlerSet";
import { AssetLike } from "./interfaces/AssetLike";

@@ -26,2 +27,3 @@ import { RendererLike } from "./interfaces/RendererLike";

import { GameMainParameterObject } from "./types/GameMainParameterObject";
import { LocalTickMode } from "./types/LocalTickMode";
import { OperationPlugin } from "./types/OperationPlugin";

@@ -31,2 +33,3 @@ import { InternalOperationPluginOperation } from "./types/OperationPluginOperation";

import { Registrable } from "./types/Registrable";
import { TickGenerationMode } from "./types/TickGenerationMode";
export interface GameResetParameterObject {

@@ -43,2 +46,7 @@ /**

randSeed?: number;
/**
* 乱数生成器のシリアリゼーション。
* 省略された場合、元の値が維持される。
*/
randGenSer?: any;
}

@@ -65,2 +73,6 @@ /**

/**
* この `Game` が用いるハンドラセット
*/
handlerSet: GameHandlerSet;
/**
* アセットのパスの基準となるディレクトリ。

@@ -100,3 +112,3 @@ * @default ""

*/
export declare abstract class Game implements Registrable<E> {
export declare class Game implements Registrable<E> {
/**

@@ -210,2 +222,6 @@ * このコンテンツに関連付けられるエンティティ。(ローカルなエンティティを除く)

/**
* ハンドラセット。
*/
handlerSet: GameHandlerSet;
/**
* ストレージ。

@@ -270,2 +286,14 @@ */

/**
* 直近の `Scene#local` の値。
*
* この値は参照のためにのみ公開されている。ゲーム開発者はこの値を変更すべきではない。
*/
lastLocalTickMode: LocalTickMode | null;
/**
* 直近の `Scene#tickGenerationMode` の値。
*
* この値は参照のためにのみ公開されている。ゲーム開発者はこの値を変更すべきではない。
*/
lastTickGenerationMode: TickGenerationMode | null;
/**
* ゲーム全体で共有するサーフェスアトラス。

@@ -349,3 +377,3 @@ */

*/
_onSceneChange: Trigger<Scene>;
_onSceneChange: Trigger<Scene | undefined>;
/**

@@ -462,3 +490,3 @@ * グローバルアセットの読み込み待ちハンドラ。

*/
_sceneChanged: Trigger<Scene>;
_sceneChanged: Trigger<Scene | undefined>;
/**

@@ -492,14 +520,3 @@ * _handleLoad() 呼び出しから戻る直前を通知するTrigger。

* `Game` のインスタンスを生成する。
* TODO: 優先度の高くないものの移行コストを考慮し、一旦現行の I/F を残している。game-driver 追従後に削除予定。
*
* @param gameConfiguration この `Game` の設定。典型的には game.json の内容をパースしたものを期待する
* @param resourceFactory この `Game` が用いる、リソースのファクトリ
* @param assetBase アセットのパスの基準となるディレクトリ。省略された場合、空文字列
* @param selfId このゲームを実行するユーザのID。省略された場合、`undefined`
* @param operationPluginViewInfo このゲームの操作プラグインに与えるviewの情報
*/
constructor(paramOrConfg: GameConfiguration, resourceFactory: ResourceFactoryLike, assetBase?: string, selfId?: string, operationPluginViewInfo?: OperationPluginViewInfo);
/**
* `Game` のインスタンスを生成する。
*
* @param param この `Game` に指定するパラメータ

@@ -550,3 +567,3 @@ */

*/
scene(): Scene;
scene(): Scene | undefined;
/**

@@ -605,9 +622,2 @@ * この `Game` の時間経過とそれに伴う処理を行う。

/**
* このゲームを離脱する。
*
* 多人数プレイの場合、他のクライアントでは `Game#leave` イベントがfireされる。
* このメソッドの呼び出し後、このクライアントの操作要求は送信されない。
*/
leaveGame(): void;
/**
* このゲームを終了する。

@@ -631,3 +641,3 @@ *

*/
abstract raiseEvent(e: Event): void;
raiseEvent(e: Event): void;
/**

@@ -641,3 +651,3 @@ * ティックを発生させる。

*/
abstract raiseTick(events?: Event[]): void;
raiseTick(events?: Event[]): void;
/**

@@ -656,3 +666,3 @@ * イベントフィルタを追加する。

*/
abstract addEventFilter(filter: EventFilter, handleEmpty?: boolean): void;
addEventFilter(filter: EventFilter, handleEmpty?: boolean): void;
/**

@@ -663,3 +673,3 @@ * イベントフィルタを削除する。

*/
abstract removeEventFilter(filter: EventFilter): void;
removeEventFilter(filter: EventFilter): void;
/**

@@ -677,3 +687,3 @@ * このインスタンスにおいてスナップショットの保存を行うべきかを返す。

*/
abstract shouldSaveSnapshot(): boolean;
shouldSaveSnapshot(): boolean;
/**

@@ -698,3 +708,3 @@ * スナップショットを保存する。

*/
abstract saveSnapshot(snapshot: any, timestamp?: number): void;
saveSnapshot(snapshot: any, timestamp?: number): void;
/**

@@ -706,3 +716,3 @@ * 現在時刻を取得する。

*/
abstract getCurrentTime(): number;
getCurrentTime(): number;
/**

@@ -714,3 +724,3 @@ * このインスタンスがアクティブインスタンスであるかどうか返す。

*/
abstract isActiveInstance(): boolean;
isActiveInstance(): boolean;
/**

@@ -779,9 +789,7 @@ * @private

_handleInitialSceneLoad(): void;
_handleOperationPluginOperated(op: InternalOperationPluginOperation): void;
_handleSceneChanged(scene?: Scene): void;
/**
* @private
*/
abstract _leaveGame(): void;
/**
* @private
*/
_terminateGame(): void;

@@ -788,0 +796,0 @@ /**

@@ -18,3 +18,4 @@ "use strict";

var Scene_1 = require("./Scene");
var g = require("./index.runtime");
var LocalTickMode_1 = require("./types/LocalTickMode");
var TickGenerationMode_1 = require("./types/TickGenerationMode");
/**

@@ -40,22 +41,9 @@ * コンテンツそのものを表すクラス。

var Game = /** @class */ (function () {
function Game(paramOrConfg, resourceFactory, assetBase, selfId, operationPluginViewInfo) {
if (selfId === void 0) { selfId = ""; }
var gameConfiguration;
var engineModule;
if ("resourceFactory" in paramOrConfg) {
gameConfiguration = this._normalizeConfiguration(paramOrConfg.configuration);
assetBase = paramOrConfg.assetBase || "";
resourceFactory = paramOrConfg.resourceFactory;
selfId = paramOrConfg.selfId;
operationPluginViewInfo = paramOrConfg.operationPluginViewInfo;
engineModule = paramOrConfg.engineModule;
}
else {
gameConfiguration = this._normalizeConfiguration(paramOrConfg);
engineModule = g;
// FIXME: インスタンス生成時に直接 `Game` を代入している
engineModule.setGame(Game);
console.warn("[deprecated] Game:This constructor is deprecated." +
" Refer to the API documentation and use Game(param: GameParameterObject) instead.");
}
/**
* `Game` のインスタンスを生成する。
*
* @param param この `Game` に指定するパラメータ
*/
function Game(param) {
var gameConfiguration = this._normalizeConfiguration(param.configuration);
this.fps = gameConfiguration.fps;

@@ -68,5 +56,6 @@ this.width = gameConfiguration.width;

this.age = 0;
this.assetBase = assetBase;
this.resourceFactory = resourceFactory;
this.selfId = selfId;
this.assetBase = param.assetBase || "";
this.resourceFactory = param.resourceFactory;
this.handlerSet = param.handlerSet;
this.selfId = param.selfId;
this.playId = undefined;

@@ -102,2 +91,4 @@ this.audio = new AudioSystemManager_1.AudioSystemManager(this.resourceFactory);

this.lastOmittedLocalTickCount = 0;
this.lastLocalTickMode = null;
this.lastTickGenerationMode = null;
this._onLoad = new trigger_1.Trigger();

@@ -111,3 +102,3 @@ this._onStart = new trigger_1.Trigger();

this.external = {};
this._runtimeValueBase = Object.create(engineModule, {
this._runtimeValueBase = Object.create(param.engineModule, {
game: {

@@ -123,4 +114,4 @@ value: this,

this._moduleManager = new ModuleManager_1.ModuleManager(this._runtimeValueBase, this._assetManager);
var operationPluginsField = (gameConfiguration.operationPlugins || []);
this.operationPluginManager = new OperationPluginManager_1.OperationPluginManager(this, operationPluginViewInfo, operationPluginsField);
var operationPluginsField = gameConfiguration.operationPlugins || [];
this.operationPluginManager = new OperationPluginManager_1.OperationPluginManager(this, param.operationPluginViewInfo, operationPluginsField);
this._onOperationPluginOperated = new trigger_1.Trigger();

@@ -130,3 +121,3 @@ this._operationPluginOperated = this._onOperationPluginOperated;

this._onSceneChange = new trigger_1.Trigger();
this._onSceneChange.add(this._updateEventTriggers, this);
this._onSceneChange.add(this._handleSceneChanged, this);
this._sceneChanged = this._onSceneChange;

@@ -373,11 +364,2 @@ this._initialScene = new Scene_1.Scene({

/**
* このゲームを離脱する。
*
* 多人数プレイの場合、他のクライアントでは `Game#leave` イベントがfireされる。
* このメソッドの呼び出し後、このクライアントの操作要求は送信されない。
*/
Game.prototype.leaveGame = function () {
this._leaveGame();
};
/**
* このゲームを終了する。

@@ -390,3 +372,2 @@ *

Game.prototype.terminateGame = function () {
this._leaveGame();
this._isTerminated = true;

@@ -402,2 +383,110 @@ this._terminateGame();

/**
* イベントを発生させる。
*
* ゲーム開発者は、このメソッドを呼び出すことで、エンジンに指定のイベントを発生させることができる。
*
* @param e 発生させるイベント
*/
Game.prototype.raiseEvent = function (e) {
this.handlerSet.raiseEvent(this._eventConverter.toPlaylogEvent(e));
};
/**
* ティックを発生させる。
*
* ゲーム開発者は、このメソッドを呼び出すことで、エンジンに時間経過を要求することができる。
* 現在のシーンのティック生成モード `Scene#tickGenerationMode` が `TickGenerationMode.Manual` でない場合、エラー。
*
* @param events そのティックで追加で発生させるイベント
*/
Game.prototype.raiseTick = function (events) {
if (events == null || !events.length) {
this.handlerSet.raiseTick();
return;
}
var plEvents = [];
for (var i = 0; i < events.length; i++) {
plEvents.push(this._eventConverter.toPlaylogEvent(events[i]));
}
this.handlerSet.raiseTick(plEvents);
};
/**
* イベントフィルタを追加する。
*
* 一つ以上のイベントフィルタが存在する場合、このゲームで発生したイベントは、通常の処理の代わりにイベントフィルタに渡される。
* エンジンは、イベントフィルタが戻り値として返したイベントを、まるでそのイベントが発生したかのように処理する。
*
* イベントフィルタはローカルイベントに対しても適用される。
* イベントフィルタはローカルティック補間シーンやローカルシーンの間であっても適用される。
* 複数のイベントフィルタが存在する場合、そのすべてが適用される。適用順は登録の順である。
*
* @param filter 追加するイベントフィルタ
* @param handleEmpty イベントが存在しない場合でも定期的にフィルタを呼び出すか否か。省略された場合、偽。
*/
Game.prototype.addEventFilter = function (filter, handleEmpty) {
this.handlerSet.addEventFilter(filter, handleEmpty);
};
/**
* イベントフィルタを削除する。
*
* @param filter 削除するイベントフィルタ
*/
Game.prototype.removeEventFilter = function (filter) {
this.handlerSet.removeEventFilter(filter);
};
/**
* このインスタンスにおいてスナップショットの保存を行うべきかを返す。
*
* スナップショット保存に対応するゲームであっても、
* 必ずしもすべてのインスタンスにおいてスナップショット保存を行うべきとは限らない。
* たとえば多人数プレイ時には、複数のクライアントで同一のゲームが実行される。
* スナップショットを保存するのはそのうちの一つのインスタンスのみでよい。
* 本メソッドはそのような場合に、自身がスナップショットを保存すべきかどうかを判定するために用いることができる。
*
* スナップショット保存に対応するゲームは、このメソッドが真を返す時にのみ `Game#saveSnapshot()` を呼び出すべきである。
* 戻り値は、スナップショットの保存を行うべきであれば真、でなければ偽である。
*/
Game.prototype.shouldSaveSnapshot = function () {
return this.handlerSet.shouldSaveSnapshot();
};
/**
* スナップショットを保存する。
*
* 引数 `snapshot` の値は、スナップショット読み込み関数 (snapshot loader) に引数として渡されるものになる。
* このメソッドを呼び出すゲームは必ずsnapshot loaderを実装しなければならない。
* (snapshot loaderとは、idが "snapshotLoader" であるglobalなScriptAssetに定義された関数である。
* 詳細はスナップショットについてのドキュメントを参照)
*
* このメソッドは `Game#shouldSaveSnapshot()` が真を返す `Game` に対してのみ呼び出されるべきである。
* そうでない場合、このメソッドの動作は不定である。
*
* このメソッドを呼び出す推奨タイミングは、Trigger `Game#snapshotRequest` をhandleすることで得られる。
* ゲームは、 `snapshotRequest` がfireされたとき (それが可能なタイミングであれば) スナップショットを
* 生成してこのメソッドに渡すべきである。ゲーム開発者は推奨タイミング以外でもこのメソッドを呼び出すことができる。
* ただしその頻度は推奨タイミングの発火頻度と同程度に抑えられるべきである。
*
* @param snapshot 保存するスナップショット。JSONとして妥当な値でなければならない。
* @param timestamp 保存時の時刻。 `g.TimestampEvent` を利用するゲームの場合、それらと同じ基準の時間情報を与えなければならない。
*/
Game.prototype.saveSnapshot = function (snapshot, timestamp) {
this.handlerSet.saveSnapshot(this.age, snapshot, this.random.serialize(), timestamp);
};
/**
* 現在時刻を取得する。
*
* 値は1970-01-01T00:00:00Zからのミリ秒での経過時刻である。
* `Date.now()` と異なり、この値は消化されたティックの数から算出される擬似的な時刻である。
*/
Game.prototype.getCurrentTime = function () {
return this.handlerSet.getCurrentTime();
};
/**
* このインスタンスがアクティブインスタンスであるかどうか返す。
*
* ゲーム開発者は、この値の真偽に起因する処理で、ゲームのローカルな実行状態を変更してはならず、
* `raiseEvent()` などによって、グローバルな状態を更新する必要がある。
*/
Game.prototype.isActiveInstance = function () {
return this.handlerSet.getInstanceType() === "active";
};
/**
* @private

@@ -492,4 +581,8 @@ */

this.age = param.age;
if (param.randSeed !== undefined)
if (param.randGenSer !== undefined) {
this.random = XorshiftRandomGenerator_1.XorshiftRandomGenerator.deserialize(param.randGenSer);
}
else if (param.randSeed !== undefined) {
this.random = new XorshiftRandomGenerator_1.XorshiftRandomGenerator(param.randSeed);
}
}

@@ -503,2 +596,3 @@ this.audio._reset();

this.onSkipChange.removeAll();
this.handlerSet.removeAllEventFilters();
this._idx = 0;

@@ -512,2 +606,4 @@ this._localIdx = 0;

this._focusingCamera = undefined;
this.lastLocalTickMode = null;
this.lastTickGenerationMode = null;
this.onSnapshotRequest.removeAll();

@@ -583,2 +679,3 @@ this._sceneChangeRequests = [];

this.onSnapshotRequest = undefined;
this.handlerSet = undefined;
// TODO より能動的にdestroy処理を入れるべきかもしれない

@@ -693,2 +790,20 @@ this.resourceFactory = undefined;

};
Game.prototype._handleOperationPluginOperated = function (op) {
var pev = this._eventConverter.makePlaylogOperationEvent(op);
this.handlerSet.raiseEvent(pev);
};
Game.prototype._handleSceneChanged = function (scene) {
this._updateEventTriggers(scene);
var local = scene ? scene.local : LocalTickMode_1.LocalTickMode.FullLocal;
var tickGenerationMode = scene ? scene.tickGenerationMode : TickGenerationMode_1.TickGenerationMode.ByClock;
if (this.lastLocalTickMode === local && this.lastTickGenerationMode === tickGenerationMode) {
return;
}
this.lastLocalTickMode = local;
this.lastTickGenerationMode = tickGenerationMode;
this.handlerSet.changeSceneMode({
local: local,
tickGenerationMode: tickGenerationMode
});
};
/**

@@ -695,0 +810,0 @@ * @private

@@ -36,2 +36,6 @@ import * as pl from "@akashic/playlog";

/**
* 全てのイベントフィルタを削除する
*/
removeAllEventFilters(): void;
/**
* g.Scene のモード変更を通知する

@@ -38,0 +42,0 @@ * @param mode

export * from "@akashic/trigger";
export * from "./Scene";
export * from "./Game";
export * from "./commons/ExceptionFactory";

@@ -4,0 +5,0 @@ export * from "./commons/Glyph";

@@ -8,2 +8,3 @@ "use strict";

__export(require("./Scene"));
__export(require("./Game"));
__export(require("./commons/ExceptionFactory"));

@@ -10,0 +11,0 @@ __export(require("./commons/Glyph"));

{
"name": "@akashic/akashic-engine",
"version": "3.0.0-beta.13",
"version": "3.0.0-beta.14",
"description": "The core library of Akashic Engine",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc