thhggfg
@@ -156,11 +156,10 @@ class GameObject
156
156
{
157
157
if (!this.destroyed)
158
158
{
159
this.destroyed = true;
160
161
159
this.onDestroy && this.onDestroy();
162
160
163
161
this.scene.removeObject(this);
162
this.destroyed = true;
164
163
}
165
164
}
166
165
@@ -384,9 +383,10 @@ class Collider
384
383
{
385
384
if (this.enabled && !this.gameObject.destroyed)
386
385
{
387
for (var i = 0; i < this.gameObject.scene.activeObjects.length; i++)
388
{
386
let offset = this.gameObject.scene.activeObjects.indexOf(this) + 1;
389
387
388
for (var i = offset; i < this.gameObject.scene.activeObjects.length; i++)
389
{
390
390
if (this.gameObject.scene.activeObjects[i] != this && this.gameObject.scene.activeObjects[i].collider.enabled)
391
391
{
392
392
if (this.widestDiagonal + this.gameObject.scene.activeObjects[i].collider.widestDiagonal < this.gameObject.transform.position.distanceTo(this.gameObject.scene.activeObjects[i].transform.position))
@@ -723,6 +723,8 @@ class Scene
723
723
parentScene = null;
724
724
renderBackground = true;
725
725
726
pendingRemoval = [];
727
726
728
g_primary = false;
727
729
728
730
static DisplayModes = { absolute: 0, relativeToParent: 1 };
@@ -817,9 +819,11 @@ class Scene
817
819
818
820
removeObject (obj)
819
821
{
820
if (this.activeObjects.contains(obj))
822
let index = this.activeObjects.indexOf(obj);
823
if (index >= 0 && !obj.destroyed)
821
824
{
822
this.activeObjects.remove(obj);
825
if (!this.pendingRemoval.contains(index))
826
this.pendingRemoval.push(index);
823
827
}
824
828
}
825
829
@@ -829,6 +833,19 @@ class Scene
829
833
{
830
834
this.activeObjects[i].update(deltaTime);
831
835
}
836
837
if (this.pendingRemoval.length)
838
{
839
this.pendingRemoval.sort();
840
841
for (let i = this.pendingRemoval.length - 1; i >= 0; i--)
842
{
843
if (this.activeObjects[this.pendingRemoval[i]].destroyed)
844
this.activeObjects.removeAt(this.pendingRemoval[i]);
845
846
this.pendingRemoval.splice(i, 1);
847
}
848
}
832
849
}
833
850
834
851
draw ()
@@ -156,11 +156,10 @@ class GameObject156
{156
{157
if (!this.destroyed)157
if (!this.destroyed)158
{158
{159
this.destroyed = true;160
161
this.onDestroy && this.onDestroy();159
this.onDestroy && this.onDestroy();162
160
163
this.scene.removeObject(this);161
this.scene.removeObject(this);162
this.destroyed = true;164
}163
}165
}164
}166
165
@@ -384,9 +383,10 @@ class Collider384
{383
{385
if (this.enabled && !this.gameObject.destroyed)384
if (this.enabled && !this.gameObject.destroyed)386
{385
{387
for (var i = 0; i < this.gameObject.scene.activeObjects.length; i++)386
let offset = this.gameObject.scene.activeObjects.indexOf(this) + 1;388
{389
387
388
for (var i = offset; i < this.gameObject.scene.activeObjects.length; i++)389
{390
if (this.gameObject.scene.activeObjects[i] != this && this.gameObject.scene.activeObjects[i].collider.enabled)390
if (this.gameObject.scene.activeObjects[i] != this && this.gameObject.scene.activeObjects[i].collider.enabled)391
{391
{392
if (this.widestDiagonal + this.gameObject.scene.activeObjects[i].collider.widestDiagonal < this.gameObject.transform.position.distanceTo(this.gameObject.scene.activeObjects[i].transform.position))392
if (this.widestDiagonal + this.gameObject.scene.activeObjects[i].collider.widestDiagonal < this.gameObject.transform.position.distanceTo(this.gameObject.scene.activeObjects[i].transform.position))@@ -723,6 +723,8 @@ class Scene723
parentScene = null;723
parentScene = null;724
renderBackground = true;724
renderBackground = true;725
725
726
pendingRemoval = [];727
726
g_primary = false;728
g_primary = false;727
729
728
static DisplayModes = { absolute: 0, relativeToParent: 1 };730
static DisplayModes = { absolute: 0, relativeToParent: 1 };@@ -817,9 +819,11 @@ class Scene817
819
818
removeObject (obj)820
removeObject (obj)819
{821
{820
if (this.activeObjects.contains(obj))822
let index = this.activeObjects.indexOf(obj);823
if (index >= 0 && !obj.destroyed)821
{824
{822
this.activeObjects.remove(obj);825
if (!this.pendingRemoval.contains(index))826
this.pendingRemoval.push(index);823
}827
}824
}828
}825
829
@@ -829,6 +833,19 @@ class Scene829
{833
{830
this.activeObjects[i].update(deltaTime);834
this.activeObjects[i].update(deltaTime);831
}835
}836
837
if (this.pendingRemoval.length)838
{839
this.pendingRemoval.sort();840
841
for (let i = this.pendingRemoval.length - 1; i >= 0; i--) 842
{843
if (this.activeObjects[this.pendingRemoval[i]].destroyed)844
this.activeObjects.removeAt(this.pendingRemoval[i]);845
846
this.pendingRemoval.splice(i, 1);847
}848
}832
}849
}833
850
834
draw ()851
draw ()