/// <summary> /// Extends this quick start with additional components. /// </summary> /// <param name="gameWorld">The game world.</param> protected override void Extend(GameObject gameWorld) { var go = this.gameObject; AddIfMissing<VectorFieldManagerComponent>(gameWorld, true); if (gameWorld.As<IUnitGroupingStrategyFactory>() == null) { gameWorld.AddComponent<SteeringUnitGroupingStrategyFactory>(); } AddIfMissing<SteerForVectorFieldComponent>(go, 5); AddIfMissing<SteerForFormationComponent>(go, 10); AddIfMissing<SteerForBlockedCellRepulsionComponent>(go, 20); AddIfMissing<SteerForContainmentComponent>(go, 20); AddIfMissing<SteeringController>(go, false); }
/// <summary> /// Initializes the Unit Facade. /// </summary> /// <param name="unitObject">The unit game object.</param> public virtual void Initialize(GameObject unitObject) { _props = unitObject.As<IUnitProperties>(false, true); _movable = unitObject.As<IMovable>(false, false); _moving = unitObject.As<IMovingObject>(false, true); _speeder = unitObject.As<IDefineSpeed>(false, true); _pathFinderOptions = unitObject.As<IPathFinderOptions>(false, false) ?? new PathFinderOptions(); _pathNavOptions = unitObject.As<IPathNavigationOptions>(false, false) ?? new PathNavigationOptions(); this.isMovable = _movable != null; if (!this.isMovable) { _movable = new MovableDummy(unitObject.name); } this.gameObject = unitObject; this.transform = unitObject.transform; this.collider = unitObject.GetComponent<Collider>(); this.isAlive = true; this.hasArrivedAtDestination = true; }