//Private Functions private void _FullTypeAbsorb(MatterChunk m) { if (this.IsElementEmpty() && this.IsRemoved) throw new Exception("Unhandled empty state"); this.ElementUnits += m.ElementUnits; m.ElementUnits = 0; this._myHeatE.Absorb(m.MyHeat); this._myChargeE.Absorb(m.MyCharge); //if (m.MyMixedContents.Count > 0) // throw new Exception("Unhan//ddled mixture contents"); //if (m._owner != null) // throw new Exception("Unhandled m owner"); }
private Matter _AddMixedContent(MatterChunk m) { if (this.IsElementEmpty() && this.IsRemoved) throw new Exception("Unhandled empty state"); var nm = new Matter(m); this._myMixedContents.Add(nm); nm._owner = this; this.MixMass += nm.TotalMass; return nm; }
public Matter AbsorbChunk(MatterChunk m) { //Check for Stackable Exact Match if (m.MyType.IsStackable && this.TypeMatches(m)) { this._FullTypeAbsorb(m); return this; } //If Permeable, allow entry itno mixed contents if (this._myType.IsPermeable) { for (int i = 0; i < this._myMixedContents.Count; i++) { if (m.MyType.IsStackable && this._myMixedContents[i].TypeMatches(m)) { this._myMixedContents[i]._FullTypeAbsorb(m); return this._myMixedContents[i]; } } return this._AddMixedContent(m); } //Send Absorbtion to parent if (this._owner != null) { return this._owner.AbsorbChunk(m); } //SEnd Absorbtion to environment if (this._mySimulator != null) { var nm = new Matter(m); this._mySimulator.AddAgent(nm); return nm; } //Throw uhandled throw new Exception("Uhandled region"); }
public bool TypeMatches(MatterChunk m) { if (this._myType.MyName == m.MyType.MyName) return true; return false; }
public Matter(MatterChunk mc) : this(mc.MyType, mc.ElementUnits) { this._myChargeE = mc.MyCharge; this._myHeatE = mc.MyHeat; }