void OnDisable() { CUE cue = CUE.GetInstance(); // Remove molecule form MoleculeManager cue.Molecules.Remove(this); }
void OnEnable() { CUE cue = CUE.GetInstance(); // Register molecule to MoleculeManager cue.Molecules.Add(this); }
void FixedUpdate() { // // When in reaction, add attraction force to the location of the reaction // ReactionPrep r = ReactionPrep; if (r != null && r.Active) { Vector3 destination = r.GetExpectedReactionLocation(); Vector3 force = Vector3.Normalize(destination - Position); rigidbody.AddForce(force, ForceMode.Acceleration); //Debug.Log(force); } // // Collide with compartment wall // CUE cue = CUE.GetInstance(); cue.CheckCompartmentCollision(this); }
/// <summary> /// Assigns a reaction prep, that indicates that the molecule is involved in a reaction. /// The MoleculeManager is updated. /// </summary> /// <param name="reactionPrep">Reaction prep.</param> public void AssignReactionPrep(ReactionPrep reactionPrep) { this.reactionPrep = reactionPrep; CUE cue = CUE.GetInstance(); cue.Molecules.AssignReactionPrep(this); }
void OnMouseDown() { // select molecule CUE cue = CUE.GetInstance(); cue.ReactionManager.SelectedMolecule = this; cue.ScriptManager.GetOrAddScript <CellUnity.View.MoleculeSelectScript> ().enabled = true; }
/// <summary> /// Releases the reaction prep. Called when a planned reaction is not performed (e.g. when /// not enough molecules available or an reaction occurs). ReactionPrep is set to null again. /// </summary> public void ReleaseReactionPrep() { if (this.reactionPrep != null) { this.reactionPrep = null; CUE cue = CUE.GetInstance(); cue.Molecules.ReleaseReactionPrep(this); } }
/// <summary> /// Clears the reaction prep after the reaction was performed. The molecule is /// removed from the MoleculeManager. Molecule must be deleted after calling this method /// </summary> public void ClearReactionPrep() { if (this.reactionPrep != null) { CUE cue = CUE.GetInstance(); cue.Molecules.ClearReactionPrep(this); this.reactionPrep = null; } }
/// <summary> /// Delete this species. /// All molecules associated with this species are removed. The prefab is also deleted. /// </summary> public void Delete() { CUE cue = CUE.GetInstance(); cue.RemoveMolecules(this); if (PrefabPath != null) { AssetDatabase.DeleteAsset(PrefabPath); } }
void OnCollisionStay(Collision collision) { Molecule otherMolecule = collision.gameObject.GetComponent <Molecule> (); // Detect if collision is with molecule if (otherMolecule != null) { CUE cue = CUE.GetInstance(); // let the reaction manager handle the collision cue.ReactionManager.Collision(this, otherMolecule); } }