Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Fix some breaks after the GUID update #480

Merged
merged 2 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions packages/sdk/src/adapters/multipeer/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ export const Rules: { [id in Payloads.PayloadType]: Rule } = {
undefined;
if (client.authoritative || client.userId && client.userId === exclusiveUser) {
// Create no-op creation message. Implicit sync from initialization until they're updated
for (const spawned of message.payload.actors) {
for (const spawned of message.payload.actors || []) {
session.cacheInitializeActorMessage({
payload: {
type: 'actor-update',
Expand All @@ -745,7 +745,7 @@ export const Rules: { [id in Payloads.PayloadType]: Rule } = {
});
}
// create somewhere to store anim updates
for (const newAnim of message.payload.animations) {
for (const newAnim of message.payload.animations || []) {
session.cacheAnimationCreation(newAnim.id, message.replyToId, newAnim.duration);
}
// Allow the message to propagate to the app.
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/types/internal/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ export class InternalContext {
this.prevGeneration = this.generation;

const syncObjects = [
...Object.values(this.actorSet),
...this.actorSet.values(),
...this.assetsIterable(),
...Object.values(this.userSet),
...this.userSet.values(),
...this.animationSet.values()
] as Array<Patchable<any>>;

Expand Down Expand Up @@ -641,7 +641,7 @@ export class InternalContext {
public getStats(): PerformanceStats {
const networkStats = this.protocol.conn.statsReport;
const stats: PerformanceStats = {
actorCount: Object.keys(this.actorSet).length,
actorCount: this.actorSet.size,
actorWithMeshCount: 0,
prefabCount: 0,
materialCount: 0,
Expand Down Expand Up @@ -676,7 +676,7 @@ export class InternalContext {
}
stats.texturePixelsAverage = stats.texturePixelsTotal / (stats.textureCount || 1);

for (const actor of Object.values(this.actorSet)) {
for (const actor of this.actorSet.values()) {
if (actor.appearance.activeAndEnabled && actor.appearance.mesh) {
stats.actorWithMeshCount += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/runtime/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class Appearance implements AppearanceLike {

/** @returns A shared reference to this actor's mesh, or null if this actor has no mesh */
public get mesh() {
return this.actor.context.internal.lookupAsset(this._meshId).mesh;
return this.actor.context.internal.lookupAsset(this._meshId)?.mesh;
}
public set mesh(value) {
this.meshId = value?.id ?? ZeroGuid;
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/runtime/assets/assetContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AssetContainer {
/** A mapping of asset IDs to assets in this container */
public get assetsById() { return this._assets as ReadonlyMap<Guid, Asset>; }
/** A list of all assets in this container */
public get assets() { return Object.values(this._assets); }
public get assets() { return [...this._assets.values()]; }
/** A list of all materials in this container */
public get materials() { return this.assets.filter(a => a instanceof Material) as Material[]; }
/** A list of all meshes in this container */
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/runtime/assets/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class Material extends Asset implements MaterialLike, Patchable<AssetLike

/** @returns A shared reference to this material's texture asset */
public get mainTexture() {
return this.container.context.internal.lookupAsset(this._mainTextureId).texture;
return this.container.context.internal.lookupAsset(this._mainTextureId)?.texture;
}
public set mainTexture(value) {
this.mainTextureId = value?.id ?? ZeroGuid;
Expand Down