Skip to content

Commit 864b0a1

Browse files
tweaks
1 parent cef5c67 commit 864b0a1

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

src/Native/Camera.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class ClientCamera extends CameraEntity {
123123
/** Client interface. */
124124
public client: Client;
125125
/** All entities in the view of the camera. Represented by id. */
126-
public view: Entity[] = [];
126+
private view: Entity[] = [];
127127

128128
public static VISION_BUFFER: number = 200;
129129

src/Native/Manager.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ export default class EntityManager {
175175
}
176176
}
177177
}
178-
178+
179179
public hibernateEntities() {
180-
let entitySleepCount = 0; // remove this, just for testing
181180
for (let id = 1; id <= this.lastId; ++id) {
182181
const entity = this.inner[id] as ObjectEntity;
183182
if (!entity || entity.hash === 0 || !entity.isPhysical || !entity.canSleep) continue;
@@ -186,35 +185,15 @@ export default class EntityManager {
186185
const camera = client.camera;
187186
if (!camera) continue;
188187

189-
const cameraData = camera.cameraData.values;
190-
191-
const fov = cameraData.FOV;
192-
const width = (1920 / fov) + ClientCamera.VISION_BUFFER;
193-
const height = (1080 / fov) + ClientCamera.VISION_BUFFER;
194-
195-
const l = cameraData.cameraX - width;
196-
const r = cameraData.cameraX + width;
197-
const t = cameraData.cameraY - height;
198-
const b = cameraData.cameraY + height;
199-
200-
const entityWidth = entity.physicsData.values.sides === 2 ? entity.physicsData.values.size / 2 : entity.physicsData.values.size;
201-
const entitySize = entity.physicsData.values.sides === 2 ? entity.physicsData.values.width / 2 : entity.physicsData.values.size;
202-
203-
if (entity.positionData.values.x - entityWidth < r &&
204-
entity.positionData.values.y + entitySize > t &&
205-
entity.positionData.values.x + entityWidth > l &&
206-
entity.positionData.values.y - entitySize < b
207-
) {
188+
if (camera["view"].includes(entity)) {
208189
entity.isSleeping = false;
209190
continue;
210191
}
211192

212193
entity.setVelocity(0, 0);
213194
entity.isSleeping = true;
214-
entitySleepCount++; // remove this, just for testing
215195
}
216196
}
217-
console.log(entitySleepCount, "entities going to sleep"); // remove this, just for testing
218197
}
219198

220199
/** Ticks all entities in the game. */

0 commit comments

Comments
 (0)