检查自NodeJS的上一个间隔以来已更改的属性

时间:2019-05-23 12:38:57

标签: javascript node.js object

在nodeJS中,假设我有一点In instantiation of 'struct std::atomic<std::pair<int, int> >': error: static assertion failed: std::atomic requires a trivially copyable type static_assert(__is_trivially_copyable(_Tp),

setInterval

它发送给客户实体:

setInterval(() => {
   // ...
}, 50)

实体看起来像这样:

setInterval(() => {
   socket.emit("entities", { ... })
}, 50)

我如何在每个时间间隔仅发送所有实体的更新属性,并且如果所有实体均未更改,则仅发送{ "0": { "collisionRadius": 40, "entityClass": "Prop", "health": 100, "maxHealth": 100, "model": "Tree", "position": { "x": 1970, "y": 1477 }, "uid": 0, "damage": 10, "dead": 0, "height": 32, "hits": [], "interpolatedYaw": 0, "slowed": 0, "stunned": 0, "timeDead": 0, "width": 32, "yaw": 0 }, "1": { "collisionRadius": 40, "entityClass": "Prop", "health": 100, "maxHealth": 100, "model": "Tree", "position": { "x": 1240, "y": 1866 }, "uid": 1, "damage": 10, "dead": 0, "height": 32, "hits": [], "interpolatedYaw": 0, "slowed": 0, "stunned": 0, "timeDead": 0, "width": 32, "yaw": 0 }, "2": { "collisionRadius": 40, "entityClass": "Prop", "health": 100, "maxHealth": 100, "model": "Tree", "position": { "x": 2195, "y": 2034 }, "uid": 2, "damage": 10, "dead": 0, "height": 32, "hits": [], "interpolatedYaw": 0, "slowed": 0, "stunned": 0, "timeDead": 0, "width": 32, "yaw": 0 } }

接收到的实体应如下所示:

true

0 个答案:

没有答案