public void Notify(SectionDestroyedMessage message) { foreach (IObservable <SectionDestroyedMessage> observable in GetComponentsInParent <IObservable <SectionDestroyedMessage> >()) { if ((Section)observable != this) { observable.Unsubscribe(this); } } if (health > 0) { sectionDestroyedObservable.Clear(); this.Subscribe <SectionDestroyedMessage>(this); Ship newShip = gameObject.AddComponent <Ship>(); newShip.Copy(myShip); myShip = newShip; } Callback.FireForUpdate(() => { this.transform.SetParent(null, true); if (health <= 0) { Callback.FireForUpdate(() => Destroy(this.gameObject), this); } else { Rigidbody2D rigid = gameObject.AddComponent <Rigidbody2D>(); rigid.gravityScale = 0; rigid.velocity = myShip.GetComponent <Rigidbody2D>().velocity + adriftSpeed * (Vector2)(this.transform.position - message.destroyedSection.transform.position).normalized; rigid.angularVelocity = Random.Range(-adriftRotation, adriftRotation); } }, this, Callback.Mode.FIXEDUPDATE); }
public override void Clear() { base.Clear(); stateSyncObjectsObservable.Clear(); }
public void Clear() { observable.Clear(); }