public Vector2D Calculate() { Vector2D sum = new Vector2D(0, 0); #region NormalBehaviours if (_instanceExists(_arrive)) { Vector2D v = _arrive.Calculate().Multiply(_dArrive); sum.Add(v); } if (_instanceExists(_flee)) { Vector2D v = _flee.Calculate().Multiply(_dFlee); sum.Add(v); } if (_instanceExists(_seek)) { Vector2D v = _seek.Calculate().Multiply(_dSeek); sum.Add(v); } if (_instanceExists(_wander)) { Vector2D v = _wander.Calculate().Multiply(_dWander); sum.Add(v); } if (_instanceExists(_followPath)) { Vector2D v = _followPath.Calculate().Multiply(_dFollowPath); sum.Add(v); } #endregion #region AdvancedBehaviours if (_instanceExists(_obstacleAvoidance)) { Vector2D v = _obstacleAvoidance.Calculate().Multiply(_dObstacleAvoidance); sum.Add(v); } #endregion Vector2D a = sum.Truncate(_movingEntity.DMaxForce); return(a); }