Skip to content

Snapshot Save Single Action #7500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f527b30
first commit
NeylMahfouf2608 Mar 10, 2025
9cbb13a
TOFIX
NeylMahfouf2608 Mar 11, 2025
8469d9a
psuh for save
NeylMahfouf2608 Mar 13, 2025
684aea6
WIP working version with saving on localstorage
NeylMahfouf2608 Mar 24, 2025
a661377
Update Model3DRuntimeObject.ts
NeylMahfouf2608 Mar 24, 2025
527307b
updated all runtimesobjects to have syncOptions, moved loading logic…
NeylMahfouf2608 Apr 8, 2025
f751e7e
Update multiplayerobjectruntimebehavior.ts
NeylMahfouf2608 Apr 8, 2025
8a33193
Update after clement comments on pr. Fixed several missed points and …
NeylMahfouf2608 Apr 9, 2025
356a48e
last small details for concept (still needs support for expression ma…
NeylMahfouf2608 Apr 9, 2025
7f2da3f
Update PhysicsCharacter3DRuntimeBehavior.ts
NeylMahfouf2608 Apr 9, 2025
a3dc189
added a try catch for indexeDB opening
NeylMahfouf2608 Apr 9, 2025
190ca61
wip soundManager management in save/load
NeylMahfouf2608 Apr 14, 2025
082afc1
fix soundManager save/load
NeylMahfouf2608 Apr 14, 2025
332542e
small update (abort tween management)
NeylMahfouf2608 Apr 16, 2025
52a2489
final functionnal commit to review
NeylMahfouf2608 Apr 17, 2025
18298b4
Update howler-sound-manager.ts
NeylMahfouf2608 Apr 17, 2025
fdb9e0b
Update howler-sound-manager.ts
NeylMahfouf2608 Apr 17, 2025
a9ddbbd
Update scenestack.ts
NeylMahfouf2608 Apr 17, 2025
3749c9e
Update scenestack.ts
NeylMahfouf2608 Apr 17, 2025
6f320ec
created loadRequestOptions type + added security and consistency on i…
NeylMahfouf2608 Apr 18, 2025
2349386
updated loadRequest signature and loading system in scenestack
NeylMahfouf2608 Apr 18, 2025
01fbdb5
fixed confusion between constants + added nullification for _loadRequ…
NeylMahfouf2608 Apr 18, 2025
2869732
forgot format
NeylMahfouf2608 Apr 18, 2025
ffefdea
[NOT WORKING] fixed variable null object misconception in savestate f…
NeylMahfouf2608 Apr 18, 2025
726adef
Update scenestack.ts
NeylMahfouf2608 Apr 18, 2025
6aa7eca
forced "syncOptions" parameter existence, repaired normalized value t…
NeylMahfouf2608 Apr 23, 2025
f4c2414
2 exemples for demonstrating the simplicity of the system
NeylMahfouf2608 Apr 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Extensions/3D/A_RuntimeObject3D.ts
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ namespace gdjs {
type Object3DNetworkSyncDataType = {
// z is position on the Z axis, different from zo, which is Z order
z: number;
w: number;
h: number;
d: number;
rx: number;
ry: number;
@@ -112,12 +110,12 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): Object3DNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): Object3DNetworkSyncData {
return {
...super.getNetworkSyncData(),
...super.getNetworkSyncData(syncOptions),
z: this.getZ(),
w: this.getWidth(),
h: this.getHeight(),
d: this.getDepth(),
rx: this.getRotationX(),
ry: this.getRotationY(),
@@ -127,11 +125,12 @@ namespace gdjs {
};
}

updateFromNetworkSyncData(networkSyncData: Object3DNetworkSyncData) {
super.updateFromNetworkSyncData(networkSyncData);
updateFromNetworkSyncData(
networkSyncData: Object3DNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
) {
super.updateFromNetworkSyncData(networkSyncData, options);
if (networkSyncData.z !== undefined) this.setZ(networkSyncData.z);
if (networkSyncData.w !== undefined) this.setWidth(networkSyncData.w);
if (networkSyncData.h !== undefined) this.setHeight(networkSyncData.h);
if (networkSyncData.d !== undefined) this.setDepth(networkSyncData.d);
if (networkSyncData.rx !== undefined)
this.setRotationX(networkSyncData.rx);
11 changes: 7 additions & 4 deletions Extensions/3D/Cube3DRuntimeObject.ts
Original file line number Diff line number Diff line change
@@ -434,9 +434,11 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): Cube3DObjectNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): Cube3DObjectNetworkSyncData {
return {
...super.getNetworkSyncData(),
...super.getNetworkSyncData(syncOptions),
mt: this._materialType,
fo: this._facesOrientation,
bfu: this._backFaceUpThroughWhichAxisRotation,
@@ -448,9 +450,10 @@ namespace gdjs {
}

updateFromNetworkSyncData(
networkSyncData: Cube3DObjectNetworkSyncData
networkSyncData: Cube3DObjectNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData);
super.updateFromNetworkSyncData(networkSyncData, options);

if (networkSyncData.mt !== undefined) {
this._materialType = networkSyncData.mt;
35 changes: 35 additions & 0 deletions Extensions/3D/CustomRuntimeObject3D.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
namespace gdjs {
type Custom3DObjectNetworkSyncDataType = CustomObjectNetworkSyncDataType & {
z: float;
d: float;
rx: float;
ry: float;
ifz: boolean;
};

/**
* Base class for 3D custom objects.
*/
@@ -78,6 +86,33 @@ namespace gdjs {
}
}

getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): Custom3DObjectNetworkSyncDataType {
return {
...super.getNetworkSyncData(syncOptions),
z: this.getZ(),
d: this.getDepth(),
rx: this.getRotationX(),
ry: this.getRotationY(),
ifz: this.isFlippedZ(),
};
}

updateFromNetworkSyncData(
networkSyncData: Custom3DObjectNetworkSyncDataType,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData, options);
if (networkSyncData.z !== undefined) this.setZ(networkSyncData.z);
if (networkSyncData.d !== undefined) this.setDepth(networkSyncData.d);
if (networkSyncData.rx !== undefined)
this.setRotationX(networkSyncData.rx);
if (networkSyncData.ry !== undefined)
this.setRotationY(networkSyncData.ry);
if (networkSyncData.ifz !== undefined) this.flipZ(networkSyncData.ifz);
}

/**
* Set the object position on the Z axis.
*/
16 changes: 12 additions & 4 deletions Extensions/3D/Model3DRuntimeObject.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ namespace gdjs {
/** The base parameters of the Model3D object */
content: Object3DDataContent & {
modelResourceName: string;
depth: number;
rotationX: number;
rotationY: number;
rotationZ: number;
@@ -198,9 +199,11 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): Model3DObjectNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): Model3DObjectNetworkSyncData {
return {
...super.getNetworkSyncData(),
...super.getNetworkSyncData(syncOptions),
mt: this._materialType,
op: this._originPoint,
cp: this._centerPoint,
@@ -209,13 +212,15 @@ namespace gdjs {
ass: this._animationSpeedScale,
ap: this._animationPaused,
cfd: this._crossfadeDuration,
d: this.getDepth(),
};
}

updateFromNetworkSyncData(
networkSyncData: Model3DObjectNetworkSyncData
networkSyncData: Model3DObjectNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData);
super.updateFromNetworkSyncData(networkSyncData, options);

if (networkSyncData.mt !== undefined) {
this._materialType = networkSyncData.mt;
@@ -243,6 +248,9 @@ namespace gdjs {
if (networkSyncData.cfd !== undefined) {
this._crossfadeDuration = networkSyncData.cfd;
}
if (networkSyncData.d !== undefined) {
this.setDepth(networkSyncData.d);
}
}

_reloadModel(objectData: Model3DObjectData) {
11 changes: 7 additions & 4 deletions Extensions/BBText/bbtextruntimeobject.ts
Original file line number Diff line number Diff line change
@@ -132,9 +132,11 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): BBTextObjectNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): BBTextObjectNetworkSyncData {
return {
...super.getNetworkSyncData(),
...super.getNetworkSyncData(syncOptions),
text: this._text,
o: this._opacity,
c: this._color,
@@ -148,9 +150,10 @@ namespace gdjs {
}

updateFromNetworkSyncData(
networkSyncData: BBTextObjectNetworkSyncData
networkSyncData: BBTextObjectNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData);
super.updateFromNetworkSyncData(networkSyncData, options);
if (this._text !== undefined) {
this.setBBText(networkSyncData.text);
}
11 changes: 7 additions & 4 deletions Extensions/BitmapText/bitmaptextruntimeobject.ts
Original file line number Diff line number Diff line change
@@ -148,9 +148,11 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): BitmapTextObjectNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): BitmapTextObjectNetworkSyncData {
return {
...super.getNetworkSyncData(),
...super.getNetworkSyncData(syncOptions),
text: this._text,
opa: this._opacity,
tint: this._tint,
@@ -164,9 +166,10 @@ namespace gdjs {
}

updateFromNetworkSyncData(
networkSyncData: BitmapTextObjectNetworkSyncData
networkSyncData: BitmapTextObjectNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData);
super.updateFromNetworkSyncData(networkSyncData, options);
if (this._text !== undefined) {
this.setText(networkSyncData.text);
}
13 changes: 9 additions & 4 deletions Extensions/Lighting/lightruntimeobject.ts
Original file line number Diff line number Diff line change
@@ -87,16 +87,21 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): LightNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): LightNetworkSyncData {
return {
...super.getNetworkSyncData(),
...super.getNetworkSyncData(syncOptions),
rad: this.getRadius(),
col: this.getColor(),
};
}

updateFromNetworkSyncData(networkSyncData: LightNetworkSyncData): void {
super.updateFromNetworkSyncData(networkSyncData);
updateFromNetworkSyncData(
networkSyncData: LightNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData, options);

if (networkSyncData.rad !== undefined) {
this.setRadius(networkSyncData.rad);
4 changes: 3 additions & 1 deletion Extensions/Multiplayer/messageManager.ts
Original file line number Diff line number Diff line change
@@ -729,7 +729,9 @@ namespace gdjs {
behavior.playerNumber = ownerPlayerNumber;
}

instance.updateFromNetworkSyncData(messageData);
instance.updateFromNetworkSyncData(messageData, {
forceInputClear: false,
});

setLastClockReceivedForInstanceOnScene({
sceneNetworkId,
18 changes: 15 additions & 3 deletions Extensions/Multiplayer/multiplayerobjectruntimebehavior.ts
Original file line number Diff line number Diff line change
@@ -278,7 +278,9 @@ namespace gdjs {

const instanceNetworkId = this._getOrCreateInstanceNetworkId();
const objectName = this.owner.getName();
const objectNetworkSyncData = this.owner.getNetworkSyncData();
const objectNetworkSyncData = this.owner.getNetworkSyncData({
forceSyncEverything: false,
});

// this._logToConsoleWithThrottle(
// `Synchronizing object ${this.owner.getName()} (instance ${
@@ -293,13 +295,16 @@ namespace gdjs {
x: objectNetworkSyncData.x,
y: objectNetworkSyncData.y,
z: objectNetworkSyncData.z,
w: objectNetworkSyncData.w,
h: objectNetworkSyncData.h,
zo: objectNetworkSyncData.zo,
a: objectNetworkSyncData.a,
hid: objectNetworkSyncData.hid,
lay: objectNetworkSyncData.lay,
if: objectNetworkSyncData.if,
pfx: objectNetworkSyncData.pfx,
pfy: objectNetworkSyncData.pfy,
n: objectNetworkSyncData.n,
});
const shouldSyncObjectBasicInfo =
!this._hasObjectBasicInfoBeenSyncedRecently() ||
@@ -369,13 +374,16 @@ namespace gdjs {
this._lastSentBasicObjectSyncData = {
x: objectNetworkSyncData.x,
y: objectNetworkSyncData.y,
w: objectNetworkSyncData.w,
h: objectNetworkSyncData.h,
zo: objectNetworkSyncData.zo,
a: objectNetworkSyncData.a,
hid: objectNetworkSyncData.hid,
lay: objectNetworkSyncData.lay,
if: objectNetworkSyncData.if,
pfx: objectNetworkSyncData.pfx,
pfy: objectNetworkSyncData.pfy,
n: objectNetworkSyncData.n,
};
this._numberOfForcedBasicObjectUpdates = Math.max(
this._numberOfForcedBasicObjectUpdates - 1,
@@ -443,7 +451,9 @@ namespace gdjs {
objectOwner: this.playerNumber,
objectName,
instanceNetworkId,
objectNetworkSyncData: this.owner.getNetworkSyncData(),
objectNetworkSyncData: this.owner.getNetworkSyncData({
forceSyncEverything: false,
}),
sceneNetworkId,
});
this._sendDataToPeersWithIncreasedClock(
@@ -593,7 +603,9 @@ namespace gdjs {
debugLogger.info(
'Sending update message to move the object immediately.'
);
const objectNetworkSyncData = this.owner.getNetworkSyncData();
const objectNetworkSyncData = this.owner.getNetworkSyncData({
forceSyncEverything: false,
});
const {
messageName: updateMessageName,
messageData: updateMessageData,
27 changes: 7 additions & 20 deletions Extensions/PanelSpriteObject/panelspriteruntimeobject.ts
Original file line number Diff line number Diff line change
@@ -25,8 +25,6 @@ namespace gdjs {
export type PanelSpriteObjectData = ObjectData & PanelSpriteObjectDataType;

export type PanelSpriteNetworkSyncDataType = {
wid: number;
hei: number;
op: number;
color: string;
};
@@ -86,12 +84,6 @@ namespace gdjs {
oldObjectData: PanelSpriteObjectData,
newObjectData: PanelSpriteObjectData
): boolean {
if (oldObjectData.width !== newObjectData.width) {
this.setWidth(newObjectData.width);
}
if (oldObjectData.height !== newObjectData.height) {
this.setHeight(newObjectData.height);
}
let updateTexture = false;
if (oldObjectData.rightMargin !== newObjectData.rightMargin) {
this._rBorder = newObjectData.rightMargin;
@@ -121,29 +113,24 @@ namespace gdjs {
return true;
}

getNetworkSyncData(): PanelSpriteNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): PanelSpriteNetworkSyncData {
return {
...super.getNetworkSyncData(),
wid: this.getWidth(),
hei: this.getHeight(),
...super.getNetworkSyncData(syncOptions),
op: this.getOpacity(),
color: this.getColor(),
};
}

updateFromNetworkSyncData(
networkSyncData: PanelSpriteNetworkSyncData
networkSyncData: PanelSpriteNetworkSyncData,
options: UpdateFromNetworkSyncDataOptions
): void {
super.updateFromNetworkSyncData(networkSyncData);
super.updateFromNetworkSyncData(networkSyncData, options);

// Texture is not synchronized, see if this is asked or not.

if (networkSyncData.wid !== undefined) {
this.setWidth(networkSyncData.wid);
}
if (networkSyncData.hei !== undefined) {
this.setHeight(networkSyncData.hei);
}
if (networkSyncData.op !== undefined) {
this.setOpacity(networkSyncData.op);
}
Loading