// distanceThreshold: Ship will stop moving once within certain distance to destination public MoveCommand(Ship ship, Vector2 destination, float distanceThreshold = 0.1f) { this._ship = ship; this._thruster = ship.CmpThruster; this._destination = new Vector3(destination.x, destination.y, 0.0f); this._distanceThreshold = distanceThreshold; this._sqrDistanceThreshold = Mathf.Pow(distanceThreshold, 2); }
void InitCmpThruster(Ship ship) { CmpThruster cmp = ship.gameObject.GetComponent <CmpThruster>(); if (!cmp) { return; } cmp.Init(ship); }
// Add Thruster void AddThruster(Ship ship, ShipThruster thruster) { GameObject shipObject = ship.gameObject; CmpThruster cmp = shipObject.GetComponent <CmpThruster>(); if (!cmp) { cmp = shipObject.AddComponent <CmpThruster>() as CmpThruster; } cmp.Add(thruster); }