public void AddDemolishable(Demolishable weakPoint) { Debug.Log("Adding weak point " + weakPoint.name + " to demolition controller"); if (DemolitionWeakPoints.SafeAdd(weakPoint)) { weakPoint.OnDemolished += CheckWeakPoints; } }
public void Update( ) { if (DemolitionStarted) { enabled = false; return; } if (WorldClock.AdjustedRealTime < mStartDemolitionTime + State.CheckDelay) { return; } //check each weak point and see if it's null or demolished Debug.Log("Checking all weak points (" + DemolitionWeakPoints.Count.ToString( ) + ") to see if we should demolish structure"); bool allWeakPointsDestroyed = true; for (int i = 0; i < DemolitionWeakPoints.Count; i++) { Demolishable weakPoint = DemolitionWeakPoints [i]; if (weakPoint != null) { if (!weakPoint.worlditem.Get <Damageable> ().IsDead) { allWeakPointsDestroyed = false; break; } } } OnAttempt(); if (allWeakPointsDestroyed) { Debug.Log("All weak points were destroyed, demolishing structure"); DemolitionStarted = true; StartCoroutine(DemolishStructureOverTime()); OnSuccess(); enabled = false; } else { Debug.Log("Not all weak points were destroyed, not demolishing structure"); Finish(); } }