feat: Transform Recalculation Conditions Updated
This commit is contained in:
parent
4607955d55
commit
ac09b78edd
|
@ -39,13 +39,15 @@ public abstract class Collider2DBehaviourBase : BehaviourOverride, ICollider2D
|
||||||
BehaviourController.OnBehaviourAdded += OnBehaviourAddedToController;
|
BehaviourController.OnBehaviourAdded += OnBehaviourAddedToController;
|
||||||
BehaviourController.OnBehaviourRemoved += OnBehaviourRemovedFromController;
|
BehaviourController.OnBehaviourRemoved += OnBehaviourRemovedFromController;
|
||||||
|
|
||||||
Transform.OnPositionChanged += OnPositionChanged;
|
Transform.OnPositionChanged += SetNeedsRecalculation;
|
||||||
|
Transform.OnRotationChanged += SetNeedsRecalculation;
|
||||||
|
Transform.OnScaleChanged += SetNeedsRecalculation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBehaviourAddedToController(IBehaviourController _, IBehaviour behaviour)
|
private void OnBehaviourAddedToController(IBehaviourController _, IBehaviour behaviour)
|
||||||
{
|
{
|
||||||
if (behaviour is IRigidBody2D rigidbody)
|
if (behaviour is IRigidBody2D rigidBody)
|
||||||
_rigidBody2D = rigidbody;
|
_rigidBody2D = rigidBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBehaviourRemovedFromController(IBehaviourController _, IBehaviour behaviour)
|
private void OnBehaviourRemovedFromController(IBehaviourController _, IBehaviour behaviour)
|
||||||
|
@ -54,13 +56,15 @@ public abstract class Collider2DBehaviourBase : BehaviourOverride, ICollider2D
|
||||||
_rigidBody2D = null;
|
_rigidBody2D = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPositionChanged(ITransform transform) => NeedsRecalculation = true;
|
private void SetNeedsRecalculation(ITransform transform) => NeedsRecalculation = true;
|
||||||
|
|
||||||
protected override void OnFinalize()
|
protected override void OnFinalize()
|
||||||
{
|
{
|
||||||
BehaviourController.OnBehaviourAdded -= OnBehaviourAddedToController;
|
BehaviourController.OnBehaviourAdded -= OnBehaviourAddedToController;
|
||||||
BehaviourController.OnBehaviourRemoved -= OnBehaviourRemovedFromController;
|
BehaviourController.OnBehaviourRemoved -= OnBehaviourRemovedFromController;
|
||||||
|
Transform.OnScaleChanged -= SetNeedsRecalculation;
|
||||||
|
|
||||||
Transform.OnPositionChanged -= OnPositionChanged;
|
Transform.OnPositionChanged -= SetNeedsRecalculation;
|
||||||
|
Transform.OnRotationChanged -= SetNeedsRecalculation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue