Skip to content

Commit

Permalink
Fix a bug that might be caused by a delayed destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Jul 30, 2023
1 parent 78e9692 commit d1a7de0
Show file tree
Hide file tree
Showing 42 changed files with 59 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Assets/Scripts/Pal3/Actor/ActorActionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,19 @@ internal virtual void DeActivate()
if (_shadow != null)
{
Destroy(_shadow);
_shadow = null;
}

if (_rigidbody != null)
{
Destroy(_rigidbody);
_rigidbody = null;
}

if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ internal override void DisposeCurrentAction()
if (_skeletalModelRenderer != null)
{
_skeletalModelRenderer.Dispose();
_skeletalModelRenderer = null;
}

base.DisposeCurrentAction();
Expand All @@ -156,12 +157,6 @@ internal override void DisposeCurrentAction()
internal override void DeActivate()
{
DisposeCurrentAction();

if (_skeletalModelRenderer != null)
{
Destroy(_skeletalModelRenderer);
}

base.DeActivate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ internal override void DisposeCurrentAction()
{
_mv3ModelRenderer.AnimationLoopPointReached -= AnimationLoopPointReached;
_mv3ModelRenderer.Dispose();
_mv3ModelRenderer = null;
}

base.DisposeCurrentAction();
Expand All @@ -229,12 +230,6 @@ internal override void DisposeCurrentAction()
internal override void DeActivate()
{
DisposeCurrentAction();

if (_mv3ModelRenderer != null)
{
Destroy(_mv3ModelRenderer);
}

base.DeActivate();
}

Expand Down
7 changes: 6 additions & 1 deletion Assets/Scripts/Pal3/Scene/SceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ private void DisposeCurrentScene()
{
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneLeavingCurrentSceneNotification());
Object.Destroy(_currentScene);
Object.Destroy(_currentSceneRoot);
_currentScene = null;
}

if (_currentSceneRoot != null)
{
Object.Destroy(_currentSceneRoot);
_currentSceneRoot = null;
}
}

public void Execute(SceneLoadCommand command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public override void Deactivate()
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}

base.Deactivate();
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/CollidableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ public override void Deactivate()
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
_triggerController.OnPlayerActorExited -= OnPlayerActorExited;
Object.Destroy(_triggerController);
_triggerController = null;
}

if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ private void OnDisable()
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private void OnDisable()
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private void OnDisable()
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public override void Deactivate()
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
_platformController.OnPlayerActorExited -= OnPlayerActorExited;
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/ElevatorObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public override void Deactivate()
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public override void Deactivate()
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

if (_triggerController != null)
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public override void Deactivate()
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public override void Deactivate()
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
_triggerController.OnPlayerActorExited -= OnPlayerActorExited;
Object.Destroy(_triggerController);
_triggerController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public override void Deactivate()
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public override void Deactivate()
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public override void Deactivate()
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}

base.Deactivate();
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/PushableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ public override void Deactivate()
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}

if (_standingPlatformController != null)
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/RareChestObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/RotatingWallObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

if (_subObjectMeshCollider != null)
{
Object.Destroy(_subObjectMeshCollider);
_subObjectMeshCollider = null;
}

if (_subObjectGameObject != null)
{
Object.Destroy(_subObjectGameObject);
_subObjectGameObject = null;
}

base.Deactivate();
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/SceneObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ public virtual void Deactivate()
if (_sceneObjectGameObject != null)
{
Object.Destroy(_sceneObjectGameObject);
_sceneObjectGameObject = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public override void Deactivate()
if (_standingPlatformController != null)
{
Object.Destroy(_standingPlatformController);
_standingPlatformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public override void Deactivate()
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private void LateUpdate()
private void OnDisable()
{
Destroy(_effectComponent);
_effectComponent = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/Pal3/Scene/SceneObjects/SwitchObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public override IEnumerator InteractAsync(InteractionContext ctx)
_interactionIndicatorRenderer.Dispose();
Object.Destroy(_interactionIndicatorRenderer);
Object.Destroy(_interactionIndicatorGameObject);
_interactionIndicatorRenderer = null;
_interactionIndicatorGameObject = null;
}

if (ctx.StartedByPlayer &&
Expand Down Expand Up @@ -204,11 +206,13 @@ public override void Deactivate()
{
_interactionIndicatorRenderer.Dispose();
Object.Destroy(_interactionIndicatorRenderer);
_interactionIndicatorRenderer = null;
}

if (_interactionIndicatorGameObject != null)
{
Object.Destroy(_interactionIndicatorGameObject);
_interactionIndicatorGameObject = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public override void Deactivate()
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}

base.Deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public override void Deactivate()
if (_standingPlatformController != null)
{
Object.Destroy(_standingPlatformController);
_standingPlatformController = null;
}

base.Deactivate();
Expand Down
Loading

0 comments on commit d1a7de0

Please sign in to comment.