More fixes

This commit is contained in:
Clément Pasteau
2025-09-17 16:33:28 +02:00
parent f5dfca9811
commit d550e36294
8 changed files with 896 additions and 88 deletions

View File

@@ -555,22 +555,34 @@ namespace gdjs {
super.updateFromNetworkSyncData(networkSyncData, options);
const behaviorSpecificProps = networkSyncData.props;
if (behaviorSpecificProps.layers !== undefined) {
this.layers = behaviorSpecificProps.layers;
}
if (behaviorSpecificProps.masks !== undefined) {
this.masks = behaviorSpecificProps.masks;
}
this._needToRecreateShape = true;
this._needToRecreateBody = true;
this.updateBodyFromObject();
if (!this._body) return;
if (
behaviorSpecificProps.px !== undefined &&
behaviorSpecificProps.py !== undefined &&
behaviorSpecificProps.pz !== undefined
) {
if (this._body) {
this._sharedData.bodyInterface.SetPosition(
this._body.GetID(),
this.getRVec3(
behaviorSpecificProps.px,
behaviorSpecificProps.py,
behaviorSpecificProps.pz
),
Jolt.EActivation_DontActivate
);
}
this._sharedData.bodyInterface.SetPosition(
this._body.GetID(),
this.getRVec3(
behaviorSpecificProps.px,
behaviorSpecificProps.py,
behaviorSpecificProps.pz
),
Jolt.EActivation_DontActivate
);
}
if (
behaviorSpecificProps.rx !== undefined &&
@@ -578,56 +590,44 @@ namespace gdjs {
behaviorSpecificProps.rz !== undefined &&
behaviorSpecificProps.rw !== undefined
) {
if (this._body) {
this._sharedData.bodyInterface.SetRotation(
this._body.GetID(),
this.getQuat(
behaviorSpecificProps.rx,
behaviorSpecificProps.ry,
behaviorSpecificProps.rz,
behaviorSpecificProps.rw
),
Jolt.EActivation_DontActivate
);
}
this._sharedData.bodyInterface.SetRotation(
this._body.GetID(),
this.getQuat(
behaviorSpecificProps.rx,
behaviorSpecificProps.ry,
behaviorSpecificProps.rz,
behaviorSpecificProps.rw
),
Jolt.EActivation_DontActivate
);
}
if (
behaviorSpecificProps.lvx !== undefined &&
behaviorSpecificProps.lvy !== undefined &&
behaviorSpecificProps.lvz !== undefined
) {
if (this._body) {
this._sharedData.bodyInterface.SetLinearVelocity(
this._body.GetID(),
this.getVec3(
behaviorSpecificProps.lvx,
behaviorSpecificProps.lvy,
behaviorSpecificProps.lvz
)
);
}
this._sharedData.bodyInterface.SetLinearVelocity(
this._body.GetID(),
this.getVec3(
behaviorSpecificProps.lvx,
behaviorSpecificProps.lvy,
behaviorSpecificProps.lvz
)
);
}
if (
behaviorSpecificProps.avx !== undefined &&
behaviorSpecificProps.avy !== undefined &&
behaviorSpecificProps.avz !== undefined
) {
if (this._body) {
this._sharedData.bodyInterface.SetAngularVelocity(
this._body.GetID(),
this.getVec3(
behaviorSpecificProps.avx,
behaviorSpecificProps.avy,
behaviorSpecificProps.avz
)
);
}
}
if (behaviorSpecificProps.layers !== undefined) {
this.layers = behaviorSpecificProps.layers;
}
if (behaviorSpecificProps.masks !== undefined) {
this.masks = behaviorSpecificProps.masks;
this._sharedData.bodyInterface.SetAngularVelocity(
this._body.GetID(),
this.getVec3(
behaviorSpecificProps.avx,
behaviorSpecificProps.avy,
behaviorSpecificProps.avz
)
);
}
}

View File

@@ -168,6 +168,9 @@ namespace gdjs {
this._isHookedToPhysicsStep = true;
}
// Destroy the body before switching the bodyUpdater,
// to ensure no body relicate is left.
behavior.bodyUpdater.destroyBody();
behavior.bodyUpdater =
new gdjs.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(
this,

View File

@@ -207,6 +207,9 @@ namespace gdjs {
this._isHookedToPhysicsStep = true;
}
// Destroy the body before switching the bodyUpdater,
// to ensure no body relicate is left.
behavior.bodyUpdater.destroyBody();
behavior.bodyUpdater =
new gdjs.PhysicsCharacter3DRuntimeBehavior.CharacterBodyUpdater(this);
behavior.collisionChecker = this.collisionChecker;

View File

@@ -88,6 +88,12 @@ namespace gdjs {
loadJustFailed = false;
});
gdjs.registerRuntimeScenePostEventsCallback(
(runtimeScene: gdjs.RuntimeScene) => {
loadGameSnapshotAtTheEndOfFrameIfAny(runtimeScene);
}
);
const getGameSaveState = (runtimeScene: RuntimeScene) => {
const gameSaveState: GameSaveState = {
gameNetworkSyncData: {},
@@ -185,10 +191,10 @@ namespace gdjs {
};
};
export const loadGameSnapshotAtTheEndOfFrameIfAny = function (
const loadGameSnapshotAtTheEndOfFrameIfAny = function (
runtimeScene: RuntimeScene
): boolean {
if (!loadRequestOptions) return false;
) {
if (!loadRequestOptions) return;
const optionsToApply = loadRequestOptions;
// Reset it so we don't load it twice.
@@ -236,8 +242,6 @@ namespace gdjs {
markLoadJustFailed();
});
}
return true;
};
const loadGameFromSave = (

View File

@@ -52,6 +52,7 @@ namespace gdjs {
c: number[];
scale: number;
ta: string;
vta: string;
wrap: boolean;
wrapw: float;
oena: boolean;
@@ -179,9 +180,6 @@ namespace gdjs {
if (oldContent.text !== newContent.text) {
this.setText(newContent.text);
}
if (oldContent.underlined !== newContent.underlined) {
return false;
}
if (oldContent.textAlignment !== newContent.textAlignment) {
this.setTextAlignment(newContent.textAlignment);
}
@@ -220,6 +218,10 @@ namespace gdjs {
if ((oldContent.lineHeight || 0) !== (newContent.lineHeight || 0)) {
this.setLineHeight(newContent.lineHeight || 0);
}
if (oldContent.underlined !== newContent.underlined) {
return false;
}
return true;
}
@@ -238,6 +240,7 @@ namespace gdjs {
c: this._color,
scale: this.getScale(),
ta: this._textAlign,
vta: this._verticalTextAlignment,
wrap: this._wrapping,
wrapw: this._wrappingWidth,
oena: this._isOutlineEnabled,
@@ -289,8 +292,8 @@ namespace gdjs {
if (networkSyncData.ta !== undefined) {
this.setTextAlignment(networkSyncData.ta);
}
if (networkSyncData.ta !== undefined) {
this.setVerticalTextAlignment(networkSyncData.ta);
if (networkSyncData.vta !== undefined) {
this.setVerticalTextAlignment(networkSyncData.vta);
}
if (networkSyncData.wrap !== undefined) {
this.setWrapping(networkSyncData.wrap);

View File

@@ -287,7 +287,7 @@ namespace gdjs {
networkSyncData.anim !== undefined ||
networkSyncData.cc !== undefined
) {
this.invalidateHitboxes();
this.onChildrenLocationChanged();
}
}

View File

@@ -52,16 +52,6 @@ namespace gdjs {
}
const currentScene = this._stack[this._stack.length - 1];
if (gdjs.saveState.loadGameSnapshotAtTheEndOfFrameIfAny) {
const hasUpdatedFromGameSnapshot =
gdjs.saveState.loadGameSnapshotAtTheEndOfFrameIfAny(currentScene);
if (hasUpdatedFromGameSnapshot) {
// If there was a game snapshot, skip the rendering,
// it is handled by the saveState.
return true;
}
}
if (currentScene.renderAndStep(elapsedTime)) {
const request = currentScene.getRequestedChange();

View File

@@ -333,7 +333,13 @@
"folderName": "__ROOT"
},
"objectsGroups": [],
"variables": [],
"variables": [
{
"name": "Test",
"type": "structure",
"children": []
}
],
"layouts": [
{
"b": 255,
@@ -361,9 +367,42 @@
"objectsGroups": [],
"variables": [
{
"name": "Save",
"name": "Saves",
"type": "structure",
"children": []
"children": [
{
"name": "Save",
"type": "number",
"value": 0
}
]
},
{
"name": "Time",
"type": "number",
"value": 0
},
{
"name": "TimeStruct",
"type": "structure",
"children": [
{
"name": "something.lol",
"type": "structure",
"children": [
{
"name": "time",
"type": "number",
"value": 0
}
]
}
]
},
{
"name": "Variable",
"type": "number",
"value": 0
}
],
"instances": [
@@ -702,6 +741,103 @@
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
},
{
"angle": 0,
"customSize": true,
"depth": 2,
"height": 79,
"keepRatio": true,
"layer": "Background",
"name": "NewText3",
"persistentUuid": "68f06239-204d-4618-8730-a61ed8a54d8f",
"width": 205,
"x": 46,
"y": 38,
"zOrder": 33,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
},
{
"angle": 0,
"customSize": false,
"height": 0,
"keepRatio": true,
"layer": "Background",
"name": "NewText4",
"persistentUuid": "b47283df-582d-4c9a-915a-22ae8e090456",
"width": 0,
"x": 1209,
"y": 25,
"zOrder": 34,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
},
{
"angle": 0,
"customSize": false,
"height": 0,
"keepRatio": true,
"layer": "",
"name": "Coins",
"persistentUuid": "9800c3ed-b269-4cbe-bd66-ae8c30b8871f",
"width": 0,
"x": 738,
"y": 476,
"zOrder": 35,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
},
{
"angle": 0,
"customSize": false,
"height": 0,
"keepRatio": true,
"layer": "Background",
"name": "NewText5",
"persistentUuid": "54d8cf4c-d2ee-4a98-90da-da31d0d29388",
"width": 0,
"x": 21,
"y": 101,
"zOrder": 36,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
},
{
"angle": 0,
"customSize": false,
"height": 0,
"keepRatio": true,
"layer": "Background",
"name": "NewText6",
"persistentUuid": "5aec5eda-d63d-409f-bc14-0394320dfb33",
"width": 0,
"x": 19,
"y": 135,
"zOrder": 37,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
},
{
"angle": 0,
"customSize": false,
"height": 0,
"keepRatio": true,
"layer": "Background",
"name": "SaveStatus",
"persistentUuid": "60936079-e7b6-4680-8399-dc06bb742fe4",
"width": 0,
"x": 557,
"y": 42,
"zOrder": 38,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
}
],
"objects": [
@@ -1662,6 +1798,221 @@
]
}
]
},
{
"assetStoreId": "",
"bold": false,
"italic": false,
"name": "NewText3",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"effects": [],
"behaviors": [],
"string": "0",
"font": "",
"textAlignment": "left",
"characterSize": 40,
"color": {
"b": 0,
"g": 0,
"r": 0
},
"content": {
"bold": false,
"isOutlineEnabled": false,
"isShadowEnabled": false,
"italic": false,
"outlineColor": "255;255;255",
"outlineThickness": 2,
"shadowAngle": 90,
"shadowBlurRadius": 2,
"shadowColor": "0;0;0",
"shadowDistance": 4,
"shadowOpacity": 127,
"smoothed": true,
"underlined": false,
"text": "0",
"font": "",
"textAlignment": "left",
"verticalTextAlignment": "top",
"characterSize": 40,
"lineHeight": 0,
"color": "0;0;0"
}
},
{
"assetStoreId": "",
"bold": false,
"italic": false,
"name": "NewText4",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"effects": [],
"behaviors": [],
"string": "0",
"font": "",
"textAlignment": "left",
"characterSize": 40,
"color": {
"b": 0,
"g": 0,
"r": 0
},
"content": {
"bold": false,
"isOutlineEnabled": false,
"isShadowEnabled": false,
"italic": false,
"outlineColor": "255;255;255",
"outlineThickness": 2,
"shadowAngle": 90,
"shadowBlurRadius": 2,
"shadowColor": "0;0;0",
"shadowDistance": 4,
"shadowOpacity": 127,
"smoothed": true,
"underlined": false,
"text": "0",
"font": "",
"textAlignment": "left",
"verticalTextAlignment": "top",
"characterSize": 40,
"lineHeight": 0,
"color": "0;0;0"
}
},
{
"assetStoreId": "",
"bold": false,
"italic": false,
"name": "NewText5",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"effects": [],
"behaviors": [],
"string": "Last save",
"font": "",
"textAlignment": "left",
"characterSize": 20,
"color": {
"b": 0,
"g": 0,
"r": 0
},
"content": {
"bold": false,
"isOutlineEnabled": false,
"isShadowEnabled": false,
"italic": false,
"outlineColor": "255;255;255",
"outlineThickness": 2,
"shadowAngle": 90,
"shadowBlurRadius": 2,
"shadowColor": "0;0;0",
"shadowDistance": 4,
"shadowOpacity": 127,
"smoothed": true,
"underlined": false,
"text": "Last save",
"font": "",
"textAlignment": "left",
"verticalTextAlignment": "top",
"characterSize": 20,
"lineHeight": 0,
"color": "0;0;0"
}
},
{
"assetStoreId": "",
"bold": false,
"italic": false,
"name": "NewText6",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"effects": [],
"behaviors": [],
"string": "Last load",
"font": "",
"textAlignment": "left",
"characterSize": 20,
"color": {
"b": 0,
"g": 0,
"r": 0
},
"content": {
"bold": false,
"isOutlineEnabled": false,
"isShadowEnabled": false,
"italic": false,
"outlineColor": "255;255;255",
"outlineThickness": 2,
"shadowAngle": 90,
"shadowBlurRadius": 2,
"shadowColor": "0;0;0",
"shadowDistance": 4,
"shadowOpacity": 127,
"smoothed": true,
"underlined": false,
"text": "Last load",
"font": "",
"textAlignment": "left",
"verticalTextAlignment": "top",
"characterSize": 20,
"lineHeight": 0,
"color": "0;0;0"
}
},
{
"assetStoreId": "",
"bold": false,
"italic": false,
"name": "SaveStatus",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"effects": [],
"behaviors": [],
"string": "SaveStatus",
"font": "",
"textAlignment": "left",
"characterSize": 30,
"color": {
"b": 0,
"g": 0,
"r": 0
},
"content": {
"bold": false,
"isOutlineEnabled": false,
"isShadowEnabled": false,
"italic": false,
"outlineColor": "255;255;255",
"outlineThickness": 2,
"shadowAngle": 90,
"shadowBlurRadius": 2,
"shadowColor": "0;0;0",
"shadowDistance": 4,
"shadowOpacity": 127,
"smoothed": true,
"underlined": false,
"text": "SaveStatus",
"font": "",
"textAlignment": "left",
"verticalTextAlignment": "top",
"characterSize": 30,
"lineHeight": 0,
"color": "0;0;0"
}
}
],
"objectsFolderStructure": {
@@ -1682,6 +2033,18 @@
{
"objectName": "NewText2"
},
{
"objectName": "NewText3"
},
{
"objectName": "NewText4"
},
{
"objectName": "NewText5"
},
{
"objectName": "NewText6"
},
{
"objectName": "FlagBlue"
},
@@ -1707,6 +2070,9 @@
},
{
"objectName": "ChiChiTheBird"
},
{
"objectName": "SaveStatus"
}
]
},
@@ -1791,7 +2157,7 @@
},
"parameters": [
"",
"Save"
"Test"
]
}
]
@@ -1824,8 +2190,143 @@
"value": "SaveState::LoadGameSnapshotFromVariable"
},
"parameters": [
"",
"Save"
"Test"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"NewText3",
"Text",
"=",
"ToString(round(Time))"
]
},
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"NewText4",
"Text",
"=",
"ToString(round(TimeStruct[\"something.lol\"].time))"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::SecondsSinceLastSave"
},
"parameters": [
">=",
"0"
]
}
],
"actions": [
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"NewText5",
"Text",
"=",
"\"Last save: \" + ToString(SaveState::SecondsSinceLastSave()) + \" s\""
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::SecondsSinceLastSave"
},
"parameters": [
"<",
"0"
]
}
],
"actions": [
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"NewText5",
"Text",
"=",
"\"No save done\""
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::SecondsSinceLastLoad"
},
"parameters": [
">=",
"0"
]
}
],
"actions": [
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"NewText6",
"Text",
"=",
"\"Last load: \" + ToString(SaveState::SecondsSinceLastLoad()) + \" s\""
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::SecondsSinceLastLoad"
},
"parameters": [
"<",
"0"
]
}
],
"actions": [
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"NewText6",
"Text",
"=",
"\"No load done\""
]
}
]
@@ -1843,18 +2344,6 @@
}
],
"actions": [
{
"type": {
"value": "PlayMusic"
},
"parameters": [
"",
"dfcdb6ef0ded864b301b5cc57940b190e803b1ea53d057338043f3b8bcd2a138_04 - Castle Nosferatu (Sega-style FM Synth Remix).aac",
"yes",
"40",
""
]
},
{
"type": {
"value": "Tween::TweenBehavior::AddObjectPositionTween2"
@@ -1869,9 +2358,35 @@
"30",
""
]
},
{
"type": {
"value": "Cache"
},
"parameters": [
"SaveStatus"
]
}
],
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "PlayMusic"
},
"parameters": [
"",
"dfcdb6ef0ded864b301b5cc57940b190e803b1ea53d057338043f3b8bcd2a138_04 - Castle Nosferatu (Sega-style FM Synth Remix).aac",
"yes",
"40",
""
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
@@ -1901,6 +2416,296 @@
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "Tween::TweenSceneVariableNumber3"
},
"parameters": [
"",
"\"time\"",
"Time",
"100",
"\"easeInQuad\"",
"10"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "Tween::TweenSceneVariableNumber3"
},
"parameters": [
"",
"\"timechild\"",
"TimeStruct[\"something.lol\"].time",
"200",
"\"easeInQuint\"",
"10"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "Wait"
},
"parameters": [
"5"
]
},
{
"type": {
"value": "SceneBackground"
},
"parameters": [
"",
"\"21;231;21\""
]
}
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "KeyFromTextPressed"
},
"parameters": [
"",
"\"d\""
]
}
],
"actions": [
{
"type": {
"value": "Wait"
},
"parameters": [
"2"
]
},
{
"type": {
"value": "Delete"
},
"parameters": [
"Coins",
""
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::SaveJustSucceeded"
},
"parameters": []
}
],
"actions": [
{
"type": {
"value": "Montre"
},
"parameters": [
"SaveStatus",
""
]
},
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"SaveStatus",
"Text",
"=",
"\"Save succeeded\""
]
},
{
"type": {
"value": "Wait"
},
"parameters": [
"2"
]
},
{
"type": {
"value": "Cache"
},
"parameters": [
"SaveStatus"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::SaveJustFailed"
},
"parameters": []
}
],
"actions": [
{
"type": {
"value": "Montre"
},
"parameters": [
"SaveStatus",
""
]
},
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"SaveStatus",
"Text",
"=",
"\"Save failed\""
]
},
{
"type": {
"value": "Wait"
},
"parameters": [
"2"
]
},
{
"type": {
"value": "Cache"
},
"parameters": [
"SaveStatus"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::LoadJustFailed"
},
"parameters": []
}
],
"actions": [
{
"type": {
"value": "Montre"
},
"parameters": [
"SaveStatus",
""
]
},
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"SaveStatus",
"Text",
"=",
"\"Load failed\""
]
},
{
"type": {
"value": "Wait"
},
"parameters": [
"2"
]
},
{
"type": {
"value": "Cache"
},
"parameters": [
"SaveStatus"
]
}
]
},
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "SaveState::LoadJustSucceeded"
},
"parameters": []
}
],
"actions": [
{
"type": {
"value": "Montre"
},
"parameters": [
"SaveStatus",
""
]
},
{
"type": {
"value": "TextContainerCapability::TextContainerBehavior::SetValue"
},
"parameters": [
"SaveStatus",
"Text",
"=",
"\"Load successful\""
]
},
{
"type": {
"value": "Wait"
},
"parameters": [
"2"
]
},
{
"type": {
"value": "Cache"
},
"parameters": [
"SaveStatus"
]
}
]
}