mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 08:36:52 +00:00
Fixed clock sync and camera tracking.
This commit is contained in:
@@ -47,6 +47,8 @@ message BattleColliderInfo {
|
||||
int32 maxChasingRenderFramesPerUpdate = 17;
|
||||
int32 playerBattleState = 18;
|
||||
double rollbackEstimatedDt = 19;
|
||||
double rollbackEstimatedDtMillis = 20;
|
||||
int64 rollbackEstimatedDtNanos = 21;
|
||||
}
|
||||
|
||||
message Player {
|
||||
|
@@ -304,7 +304,6 @@
|
||||
"__id__": 5
|
||||
},
|
||||
"_enabled": true,
|
||||
"useDiffFrameAlgo": true,
|
||||
"canvasNode": {
|
||||
"__id__": 2
|
||||
},
|
||||
@@ -317,22 +316,9 @@
|
||||
"player2Prefab": {
|
||||
"__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3"
|
||||
},
|
||||
"treasurePrefab": {
|
||||
"__uuid__": "ec3f3234-9b84-43c2-a3cd-58b924cce8e5"
|
||||
},
|
||||
"trapPrefab": {
|
||||
"__uuid__": "9f340a31-ddfa-46c2-94c7-d11615aedcb1"
|
||||
},
|
||||
"speedShoePrefab": null,
|
||||
"polygonBoundaryBarrierPrefab": {
|
||||
"__uuid__": "4154eec0-d644-482f-a889-c00ae6b69958"
|
||||
},
|
||||
"polygonBoundaryShelterPrefab": {
|
||||
"__uuid__": "f820a6ec-e7a9-46cf-9b8a-331aa3e21487"
|
||||
},
|
||||
"polygonBoundaryShelterZReducerPrefab": {
|
||||
"__uuid__": "a36d024b-a979-4d18-b089-19af313ffb82"
|
||||
},
|
||||
"keyboardInputControllerNode": {
|
||||
"__id__": 8
|
||||
},
|
||||
@@ -351,9 +337,6 @@
|
||||
"countdownLabel": {
|
||||
"__id__": 30
|
||||
},
|
||||
"trapBulletPrefab": {
|
||||
"__uuid__": "7673e0e4-bebd-4caa-8a10-a6e1e86f1b2f"
|
||||
},
|
||||
"resultPanelPrefab": {
|
||||
"__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184"
|
||||
},
|
||||
@@ -369,13 +352,12 @@
|
||||
"playersInfoPrefab": {
|
||||
"__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e"
|
||||
},
|
||||
"guardTowerPrefab": {
|
||||
"__uuid__": "31a63530-7811-45bc-a4ee-571faf917e35"
|
||||
},
|
||||
"forceBigEndianFloatingNumDecoding": false,
|
||||
"backgroundMapTiledIns": {
|
||||
"__id__": 4
|
||||
},
|
||||
"renderFrameIdLagTolerance": 4,
|
||||
"teleportEps1D": 0.001,
|
||||
"_id": "d12gkAmppNlIzqcRDELa91"
|
||||
},
|
||||
{
|
||||
@@ -557,7 +539,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
217.54856073274254,
|
||||
210.4441731196186,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -1579,6 +1561,7 @@
|
||||
"mapNode": {
|
||||
"__id__": 5
|
||||
},
|
||||
"speed": 5000,
|
||||
"_id": "76ImpM7XtPSbiLHDXdsJa+"
|
||||
},
|
||||
{
|
||||
@@ -1631,7 +1614,6 @@
|
||||
"joyStickEps": 0.1,
|
||||
"magicLeanLowerBound": 0.414,
|
||||
"magicLeanUpperBound": 2.414,
|
||||
"pollerFps": 24,
|
||||
"linearScaleFacBase": 1,
|
||||
"minScale": 1,
|
||||
"maxScale": 2,
|
||||
|
@@ -440,7 +440,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
209.57814771583418,
|
||||
210.4441731196186,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@@ -6,7 +6,10 @@ cc.Class({
|
||||
type: cc.Node,
|
||||
default: null
|
||||
},
|
||||
|
||||
speed: {
|
||||
type: cc.Float,
|
||||
default: 500
|
||||
},
|
||||
},
|
||||
|
||||
onLoad () {
|
||||
@@ -26,6 +29,9 @@ cc.Class({
|
||||
if (!selfPlayerRichInfo) return;
|
||||
const selfPlayerNode = selfPlayerRichInfo.node;
|
||||
if (!selfPlayerNode) return;
|
||||
self.mainCamera.node.setPosition(selfPlayerNode.position);
|
||||
const pDiff = selfPlayerNode.position.sub(self.mainCamera.node.position);
|
||||
pDiff.normalizeSelf();
|
||||
const newCamPos = self.mainCamera.node.position.add(pDiff.mul(dt*self.speed));
|
||||
self.mainCamera.node.setPosition(newCamPos);
|
||||
}
|
||||
});
|
||||
|
@@ -111,6 +111,10 @@ cc.Class({
|
||||
type: cc.Integer,
|
||||
default: 4 // implies (renderFrameIdLagTolerance >> inputScaleFrames) count of inputFrameIds
|
||||
},
|
||||
teleportEps1D: {
|
||||
type: cc.Float,
|
||||
default: 1e-3
|
||||
},
|
||||
},
|
||||
|
||||
_inputFrameIdDebuggable(inputFrameId) {
|
||||
@@ -415,8 +419,10 @@ cc.Class({
|
||||
self.inputScaleFrames = parsedBattleColliderInfo.inputScaleFrames;
|
||||
self.inputFrameUpsyncDelayTolerance = parsedBattleColliderInfo.inputFrameUpsyncDelayTolerance;
|
||||
|
||||
self.battleDurationNanos = parsedBattleColliderInfo.battleDurationNanos;
|
||||
self.rollbackEstimatedDt = parsedBattleColliderInfo.rollbackEstimatedDt;
|
||||
self.rollbackEstimatedDtMillis = 1000.0 * self.rollbackEstimatedDt;
|
||||
self.rollbackEstimatedDtMillis = parsedBattleColliderInfo.rollbackEstimatedDtMillis;
|
||||
self.rollbackEstimatedDtNanos = parsedBattleColliderInfo.rollbackEstimatedDtNanos;
|
||||
self.rollbackEstimatedDtToleranceMillis = self.rollbackEstimatedDtMillis / 1000.0;
|
||||
self.maxChasingRenderFramesPerUpdate = parsedBattleColliderInfo.maxChasingRenderFramesPerUpdate;
|
||||
|
||||
@@ -799,6 +805,12 @@ cc.Class({
|
||||
|
||||
// Inside "self.rollbackAndChase", the "self.latestCollisionSys" is ALWAYS ROLLED BACK to "self.recentRenderCache.get(self.renderFrameId)" before being applied dynamics from corresponding inputFrameDownsync, REGARDLESS OF whether or not "self.chaserRenderFrameId == self.renderFrameId" now.
|
||||
const rdf = self.rollbackAndChase(self.renderFrameId, self.renderFrameId + 1, self.latestCollisionSys, self.latestCollisionSysMap);
|
||||
/*
|
||||
const nonTrivialChaseEnded = (prevChaserRenderFrameId < nextChaserRenderFrameId && nextChaserRenderFrameId == self.renderFrameId);
|
||||
if (nonTrivialChaseEnded) {
|
||||
console.debug("Non-trivial chase ended, prevChaserRenderFrameId=" + prevChaserRenderFrameId + ", nextChaserRenderFrameId=" + nextChaserRenderFrameId);
|
||||
}
|
||||
*/
|
||||
self.applyRoomDownsyncFrameDynamics(rdf);
|
||||
let t3 = performance.now();
|
||||
} catch (err) {
|
||||
@@ -806,7 +818,7 @@ cc.Class({
|
||||
} finally {
|
||||
// Update countdown
|
||||
if (null != self.countdownNanos) {
|
||||
self.countdownNanos -= (performance.now() - self.lastRenderFrameIdTriggeredAt) * 1000000;
|
||||
self.countdownNanos = self.battleDurationNanos - self.renderFrameId*self.rollbackEstimatedDtNanos;
|
||||
if (self.countdownNanos <= 0) {
|
||||
self.onBattleStopped(self.playerRichInfoDict);
|
||||
return;
|
||||
@@ -975,8 +987,15 @@ cc.Class({
|
||||
|
||||
self.playerRichInfoDict.forEach((playerRichInfo, playerId) => {
|
||||
const immediatePlayerInfo = rdf.players[playerId];
|
||||
playerRichInfo.node.setPosition(immediatePlayerInfo.x, immediatePlayerInfo.y);
|
||||
playerRichInfo.scriptIns.scheduleNewDirection(immediatePlayerInfo.dir, true);
|
||||
const dx = (immediatePlayerInfo.x-playerRichInfo.node.x);
|
||||
const dy = (immediatePlayerInfo.y-playerRichInfo.node.y);
|
||||
const selfJiggling = (playerId == self.selfPlayerInfo.playerId && (0 != dx && self.teleportEps1D >= Math.abs(dx) && 0 != dy && self.teleportEps1D >= Math.abs(dy)));
|
||||
if (!selfJiggling) {
|
||||
playerRichInfo.node.setPosition(immediatePlayerInfo.x, immediatePlayerInfo.y);
|
||||
} else {
|
||||
console.log("selfJiggling: dx = ", dx, ", dy = ", dy);
|
||||
}
|
||||
playerRichInfo.scriptIns.scheduleNewDirection(immediatePlayerInfo.dir, false);
|
||||
playerRichInfo.scriptIns.updateSpeed(immediatePlayerInfo.speed);
|
||||
});
|
||||
},
|
||||
|
@@ -1,24 +1,20 @@
|
||||
window.DIRECTION_DECODER = [
|
||||
[0, 0, null],
|
||||
[0, +1, null],
|
||||
[0, -1, null],
|
||||
[+2, 0, null],
|
||||
[-2, 0, null],
|
||||
[+2, +1, null],
|
||||
[-2, -1, null],
|
||||
[+2, -1, null],
|
||||
[-2, +1, null],
|
||||
[+2, 0, null],
|
||||
[-2, 0, null],
|
||||
[0, +1, null],
|
||||
[0, -1, null],
|
||||
// The 3rd value matches low-precision constants in backend.
|
||||
[0, 0, 0.0],
|
||||
[0, +1, 1.0],
|
||||
[0, -1, 1.0],
|
||||
[+2, 0, 0.5],
|
||||
[-2, 0, 0.5],
|
||||
[+2, +1, 0.4472],
|
||||
[-2, -1, 0.4472],
|
||||
[+2, -1, 0.4472],
|
||||
[-2, +1, 0.4472],
|
||||
[+2, 0, 0.5],
|
||||
[-2, 0, 0.5],
|
||||
[0, +1, 1.0],
|
||||
[0, -1, 1.0],
|
||||
];
|
||||
|
||||
for (let k in window.DIRECTION_DECODER) {
|
||||
const length = Math.sqrt(window.DIRECTION_DECODER[k][0]*window.DIRECTION_DECODER[k][0] + window.DIRECTION_DECODER[k][1]*window.DIRECTION_DECODER[k][1]);
|
||||
window.DIRECTION_DECODER[k][2] = (0 == length ? 0 : (1.0/length));
|
||||
}
|
||||
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
properties: {
|
||||
|
@@ -1198,6 +1198,8 @@ $root.treasurehunterx = (function() {
|
||||
* @property {number|null} [maxChasingRenderFramesPerUpdate] BattleColliderInfo maxChasingRenderFramesPerUpdate
|
||||
* @property {number|null} [playerBattleState] BattleColliderInfo playerBattleState
|
||||
* @property {number|null} [rollbackEstimatedDt] BattleColliderInfo rollbackEstimatedDt
|
||||
* @property {number|null} [rollbackEstimatedDtMillis] BattleColliderInfo rollbackEstimatedDtMillis
|
||||
* @property {number|Long|null} [rollbackEstimatedDtNanos] BattleColliderInfo rollbackEstimatedDtNanos
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -1369,6 +1371,22 @@ $root.treasurehunterx = (function() {
|
||||
*/
|
||||
BattleColliderInfo.prototype.rollbackEstimatedDt = 0;
|
||||
|
||||
/**
|
||||
* BattleColliderInfo rollbackEstimatedDtMillis.
|
||||
* @member {number} rollbackEstimatedDtMillis
|
||||
* @memberof treasurehunterx.BattleColliderInfo
|
||||
* @instance
|
||||
*/
|
||||
BattleColliderInfo.prototype.rollbackEstimatedDtMillis = 0;
|
||||
|
||||
/**
|
||||
* BattleColliderInfo rollbackEstimatedDtNanos.
|
||||
* @member {number|Long} rollbackEstimatedDtNanos
|
||||
* @memberof treasurehunterx.BattleColliderInfo
|
||||
* @instance
|
||||
*/
|
||||
BattleColliderInfo.prototype.rollbackEstimatedDtNanos = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
|
||||
|
||||
/**
|
||||
* Creates a new BattleColliderInfo instance using the specified properties.
|
||||
* @function create
|
||||
@@ -1437,6 +1455,10 @@ $root.treasurehunterx = (function() {
|
||||
writer.uint32(/* id 18, wireType 0 =*/144).int32(message.playerBattleState);
|
||||
if (message.rollbackEstimatedDt != null && Object.hasOwnProperty.call(message, "rollbackEstimatedDt"))
|
||||
writer.uint32(/* id 19, wireType 1 =*/153).double(message.rollbackEstimatedDt);
|
||||
if (message.rollbackEstimatedDtMillis != null && Object.hasOwnProperty.call(message, "rollbackEstimatedDtMillis"))
|
||||
writer.uint32(/* id 20, wireType 1 =*/161).double(message.rollbackEstimatedDtMillis);
|
||||
if (message.rollbackEstimatedDtNanos != null && Object.hasOwnProperty.call(message, "rollbackEstimatedDtNanos"))
|
||||
writer.uint32(/* id 21, wireType 0 =*/168).int64(message.rollbackEstimatedDtNanos);
|
||||
return writer;
|
||||
};
|
||||
|
||||
@@ -1585,6 +1607,14 @@ $root.treasurehunterx = (function() {
|
||||
message.rollbackEstimatedDt = reader.double();
|
||||
break;
|
||||
}
|
||||
case 20: {
|
||||
message.rollbackEstimatedDtMillis = reader.double();
|
||||
break;
|
||||
}
|
||||
case 21: {
|
||||
message.rollbackEstimatedDtNanos = reader.int64();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
@@ -1691,6 +1721,12 @@ $root.treasurehunterx = (function() {
|
||||
if (message.rollbackEstimatedDt != null && message.hasOwnProperty("rollbackEstimatedDt"))
|
||||
if (typeof message.rollbackEstimatedDt !== "number")
|
||||
return "rollbackEstimatedDt: number expected";
|
||||
if (message.rollbackEstimatedDtMillis != null && message.hasOwnProperty("rollbackEstimatedDtMillis"))
|
||||
if (typeof message.rollbackEstimatedDtMillis !== "number")
|
||||
return "rollbackEstimatedDtMillis: number expected";
|
||||
if (message.rollbackEstimatedDtNanos != null && message.hasOwnProperty("rollbackEstimatedDtNanos"))
|
||||
if (!$util.isInteger(message.rollbackEstimatedDtNanos) && !(message.rollbackEstimatedDtNanos && $util.isInteger(message.rollbackEstimatedDtNanos.low) && $util.isInteger(message.rollbackEstimatedDtNanos.high)))
|
||||
return "rollbackEstimatedDtNanos: integer|Long expected";
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -1767,6 +1803,17 @@ $root.treasurehunterx = (function() {
|
||||
message.playerBattleState = object.playerBattleState | 0;
|
||||
if (object.rollbackEstimatedDt != null)
|
||||
message.rollbackEstimatedDt = Number(object.rollbackEstimatedDt);
|
||||
if (object.rollbackEstimatedDtMillis != null)
|
||||
message.rollbackEstimatedDtMillis = Number(object.rollbackEstimatedDtMillis);
|
||||
if (object.rollbackEstimatedDtNanos != null)
|
||||
if ($util.Long)
|
||||
(message.rollbackEstimatedDtNanos = $util.Long.fromValue(object.rollbackEstimatedDtNanos)).unsigned = false;
|
||||
else if (typeof object.rollbackEstimatedDtNanos === "string")
|
||||
message.rollbackEstimatedDtNanos = parseInt(object.rollbackEstimatedDtNanos, 10);
|
||||
else if (typeof object.rollbackEstimatedDtNanos === "number")
|
||||
message.rollbackEstimatedDtNanos = object.rollbackEstimatedDtNanos;
|
||||
else if (typeof object.rollbackEstimatedDtNanos === "object")
|
||||
message.rollbackEstimatedDtNanos = new $util.LongBits(object.rollbackEstimatedDtNanos.low >>> 0, object.rollbackEstimatedDtNanos.high >>> 0).toNumber();
|
||||
return message;
|
||||
};
|
||||
|
||||
@@ -1809,6 +1856,12 @@ $root.treasurehunterx = (function() {
|
||||
object.maxChasingRenderFramesPerUpdate = 0;
|
||||
object.playerBattleState = 0;
|
||||
object.rollbackEstimatedDt = 0;
|
||||
object.rollbackEstimatedDtMillis = 0;
|
||||
if ($util.Long) {
|
||||
var long = new $util.Long(0, 0, false);
|
||||
object.rollbackEstimatedDtNanos = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
||||
} else
|
||||
object.rollbackEstimatedDtNanos = options.longs === String ? "0" : 0;
|
||||
}
|
||||
if (message.stageName != null && message.hasOwnProperty("stageName"))
|
||||
object.stageName = message.stageName;
|
||||
@@ -1858,6 +1911,13 @@ $root.treasurehunterx = (function() {
|
||||
object.playerBattleState = message.playerBattleState;
|
||||
if (message.rollbackEstimatedDt != null && message.hasOwnProperty("rollbackEstimatedDt"))
|
||||
object.rollbackEstimatedDt = options.json && !isFinite(message.rollbackEstimatedDt) ? String(message.rollbackEstimatedDt) : message.rollbackEstimatedDt;
|
||||
if (message.rollbackEstimatedDtMillis != null && message.hasOwnProperty("rollbackEstimatedDtMillis"))
|
||||
object.rollbackEstimatedDtMillis = options.json && !isFinite(message.rollbackEstimatedDtMillis) ? String(message.rollbackEstimatedDtMillis) : message.rollbackEstimatedDtMillis;
|
||||
if (message.rollbackEstimatedDtNanos != null && message.hasOwnProperty("rollbackEstimatedDtNanos"))
|
||||
if (typeof message.rollbackEstimatedDtNanos === "number")
|
||||
object.rollbackEstimatedDtNanos = options.longs === String ? String(message.rollbackEstimatedDtNanos) : message.rollbackEstimatedDtNanos;
|
||||
else
|
||||
object.rollbackEstimatedDtNanos = options.longs === String ? $util.Long.prototype.toString.call(message.rollbackEstimatedDtNanos) : options.longs === Number ? new $util.LongBits(message.rollbackEstimatedDtNanos.low >>> 0, message.rollbackEstimatedDtNanos.high >>> 0).toNumber() : message.rollbackEstimatedDtNanos;
|
||||
return object;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user