protected override void ShowVisuals(IPowerable g1, IPowerable g2) { if (g1 is RoverStation && g2 is RoverInput) { station = g1 as RoverStation; station.OnRoverAttachedChange(g2 as RoverInput); } else if (g2 is RoverStation && g1 is RoverInput) { station = g2 as RoverStation; station.OnRoverAttachedChange(g1 as RoverInput); } fromCap = CreateCap(Data.fromPos, Data.fromRot, Data.fromScale); toCap = CreateCap(Data.toPos, Data.toRot, Data.toScale); Vector3 fromPos = fromCap.position, toPos = toCap.position; float distanceBetween = Vector3.Distance(fromPos, toPos); numLinks = Mathf.RoundToInt(distanceBetween / linkSeparation) + LinkNumberAdjustment; rootLink = GameObject.Instantiate <Transform>(UmbilicalLinkPrefab); rootLink.SetParent(this.transform); rootLink.position = fromPos; rootLink.rotation = Data.fromRot; Transform parent = rootLink; for (int i = 0; i < numLinks - 1; i++) { Transform link = GameObject.Instantiate <Transform>(UmbilicalLinkPrefab); link.position = parent.position + Vector3.forward * linkSeparation; link.SetParent(parent); link.SetAsFirstSibling(); parent = link; } lastLink = parent; solver = rootLink.gameObject.AddComponent <FABRIK>(); solver.Constrain = true; solver.ConstrainAngle = FABRIKAngleConstraint; solver.initialTarget = toCap; StartCoroutine(StopSolver(solver)); }
protected override void HideVisuals() { station.OnRoverAttachedChange(null); }