public void SetSoftBoundary(SoftBoundary boundary) { this.CurrentSoftBoundary = boundary; this.LastSoftBoundaryComponent = boundary ? boundary.GetFirstComponent() : null; this.IsOutsideSoftBounds = true; }
private void CreateIsolatedSoftBoundary() { SoftBoundary isolatedSoftBoundary = Instantiate <SoftBoundary>(FishManager.Instance.IsolatedSoftBoundaryPrefab); this.SetSoftBoundary(isolatedSoftBoundary); this.IsolatedSoftBoundary = isolatedSoftBoundary; isolatedSoftBoundary.transform.position = this.transform.position; isolatedSoftBoundary.GetComponent <SphereCollider>().radius = this.IsolatedSoftBoundaryRadius; }
public void OutsideSoftBounds(SoftBoundaryComponent boundaryComponent) { if (this.CurrentExternalSoftBoundary == boundaryComponent.SoftBoundary) { this.CurrentExternalSoftBoundary = null; } this.SoftBoundaryComponents.Remove(boundaryComponent); if (this.SoftBoundaryComponents.Count <= 0) { this.IsOutsideSoftBounds = true; } }
// Automatically assign the parent softboundary as the associated boundary. If non-existent, show a warning and destroy void Reset() { if (!this.SoftBoundary) { SoftBoundary parentBoundary = null; if (transform.parent) { parentBoundary = transform.parent.GetComponent <SoftBoundary>(); } if (parentBoundary) { this.SoftBoundary = parentBoundary; } else { EditorUtility.DisplayDialog("Invalid Soft Boundary Component Context", "A soft boundary component may only exist as a child of a soft boundary", "I understand"); DestroyImmediate(this); } } }
public void InsideSoftBounds(SoftBoundaryComponent boundaryComponent) { this.CurrentExternalSoftBoundary = boundaryComponent.SoftBoundary; // For fish that don't have a current soft boundary assigned, do nothing if (this.CurrentSoftBoundary == null) { return; } if (this.CurrentSoftBoundary.Contains(boundaryComponent)) { this.CurrentExternalSoftBoundary = null; this.SoftBoundaryComponents.Add(boundaryComponent); this.LastSoftBoundaryComponent = boundaryComponent; if (this.IsOutsideSoftBounds) { this.IsOutsideSoftBounds = false; } } }