Пример #1
0
        //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");
        }
Пример #2
0
        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;
        }
Пример #3
0
        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");
        }
Пример #4
0
        public bool TypeMatches(MatterChunk m)
        {
            if (this._myType.MyName == m.MyType.MyName)
                return true;

            return false;
        }
Пример #5
0
 public Matter(MatterChunk mc)
     : this(mc.MyType, mc.ElementUnits)
 {
     this._myChargeE = mc.MyCharge;
     this._myHeatE = mc.MyHeat;
 }