Refactor behaviors functions to a single function called applyBehaviors

This commit is contained in:
Siklos 2022-08-18 10:15:12 +02:00
parent f34ba64f7e
commit e831f95d20
2 changed files with 25 additions and 12 deletions

View file

@ -0,0 +1,21 @@
import { IContainerModel } from '../../../Interfaces/IContainerModel';
import { ImposePosition } from './AnchorBehaviors';
import { RecalculatePhysics } from './RigidBodyBehaviors';
/**
* Recalculate the position of the container and its neighbors
* Mutate and returns the updated container
* @param container Container to recalculate its positions
* @returns Updated container
*/
export function applyBehaviors(container: IContainerModel): IContainerModel {
if (container.properties.isAnchor) {
ImposePosition(container);
}
if (container.properties.isRigidBody) {
RecalculatePhysics(container);
}
return container;
}