コード例 #1
0
ファイル: Nodule.cs プロジェクト: ianzhangtianyi/ApsimX
        protected void OnDoActualPlantGrowth(object sender, EventArgs e)
        {
            if (parentPlant.IsAlive)
            {
                // Do senescence
                double senescedFrac = senescenceRate.Value();
                if (Live.Wt * (1.0 - senescedFrac) < BiomassToleranceValue)
                {
                    senescedFrac = 1.0;  // remaining amount too small, senesce all
                }
                Biomass Loss = Live * senescedFrac;
                Live.Subtract(Loss);
                Dead.Add(Loss);
                Senesced.Add(Loss);

                // Do detachment
                double detachedFrac = detachmentRateFunction.Value();
                if (Dead.Wt * (1.0 - detachedFrac) < BiomassToleranceValue)
                {
                    detachedFrac = 1.0;  // remaining amount too small, detach all
                }
                Biomass detaching = Dead * detachedFrac;
                Dead.Multiply(1.0 - detachedFrac);
                if (detaching.Wt > 0.0)
                {
                    Detached.Add(detaching);
                    surfaceOrganicMatter.Add(detaching.Wt * 10, detaching.N * 10, 0, parentPlant.CropType, Name);
                }

                // Do maintenance respiration
                MaintenanceRespiration  = 0;
                MaintenanceRespiration += Live.MetabolicWt * maintenanceRespirationFunction.Value();
                MaintenanceRespiration += Live.StorageWt * maintenanceRespirationFunction.Value();
            }
        }
コード例 #2
0
ファイル: GridEncounter.cs プロジェクト: thesmallbang/oddmud
        private async Task Combatant_Death(IEntity deadCombatant)
        {
            deadCombatant.Died -= Combatant_Death;

            Dead.Add(deadCombatant);

            Debug.WriteLine("Combatant Died " + deadCombatant.Name);


            // figure out how many are alive per faction

            foreach (var faction in Factions.Keys.ToList())
            {
                // if a faction has no members alive then we are ending
                var aliveCount = Factions[faction].Count(e => !Dead.Contains(e));
                if (aliveCount == 0)
                {
                    _ended = true;
                    foreach (var combatant in Combatants.Keys.ToList())
                    {
                        combatant.Died -= Combatant_Death;
                    }


                    if (Ended != null)
                    {
                        await Ended.Invoke(this, EncounterEndings.Death);
                    }

                    //break;
                    return;
                }
            }
        }
コード例 #3
0
        public void DamageParty(BaseCard playCard, SlayerRecruit member)
        {
            if (playCard.Amount > -1)
            {
                playCard.Amount--;
            }

            // This party member dies :(
            Party.Remove(member);
            Dead.Add(member);
        }
コード例 #4
0
        //Kills an Entity, moving it to the Dead list and removing from it's Alignment list
        public void KillEntity(int in_ID)
        {
            int index = ID.IndexOf(in_ID);

            switch (Behaviour[index][1])
            {
            case "Friendly": Friendlies.RemoveAt(Friendlies.IndexOf(in_ID)); break;

            case "Hostile": Hostiles.RemoveAt(Hostiles.IndexOf(in_ID)); break;

            case "Neutral": Neutrals.RemoveAt(Neutrals.IndexOf(in_ID)); break;
            }

            Alive.Remove(in_ID);
            Dead.Add(in_ID);
        }
コード例 #5
0
        /// <summary>Sets the n allocation.</summary>
        /// <param name="nitrogen">The nitrogen allocation</param>
        public virtual void SetNitrogenAllocation(BiomassAllocationType nitrogen)
        {
            Live.StructuralN += nitrogen.Structural;
            Live.StorageN    += nitrogen.Storage;
            Live.MetabolicN  += nitrogen.Metabolic;

            Allocated.StructuralN += nitrogen.Structural;
            Allocated.StorageN    += nitrogen.Storage;
            Allocated.MetabolicN  += nitrogen.Metabolic;

            RetranslocateNitrogen.Allocate(this, nitrogen);

            // Reallocation
            double senescedFrac = SenescenceRate.Value();

            if (StartLive.Wt * (1.0 - senescedFrac) < BiomassToleranceValue)
            {
                senescedFrac = 1.0;  // remaining amount too small, senesce all
            }
            if (senescedFrac > 0 && StartLive.Wt > 0 && Name == "Shell")
            {
            }

            if (MathUtilities.IsGreaterThan(nitrogen.Reallocation, StartLive.StorageN + StartLive.MetabolicN))
            {
                throw new Exception("N reallocation exceeds storage + metabolic nitrogen in organ: " + Name);
            }
            double StorageNReallocation = Math.Min(nitrogen.Reallocation, StartLive.StorageN * senescedFrac * nReallocationFactor.Value());

            Live.StorageN      -= StorageNReallocation;
            Live.MetabolicN    -= (nitrogen.Reallocation - StorageNReallocation);
            Allocated.StorageN -= nitrogen.Reallocation;

            // now move the remaining senescing material to the dead pool
            Biomass Loss = new Biomass();

            Loss.StructuralN  = StartLive.StructuralN * senescedFrac;
            Loss.StorageN     = StartLive.StorageN * senescedFrac - StorageNReallocation;
            Loss.MetabolicN   = StartLive.MetabolicN * senescedFrac - (nitrogen.Reallocation - StorageNReallocation);
            Loss.StructuralWt = StartLive.StructuralWt * senescedFrac;
            Loss.MetabolicWt  = StartLive.MetabolicWt * senescedFrac;
            Loss.StorageWt    = StartLive.StorageWt * senescedFrac;
            Live.Subtract(Loss);
            Dead.Add(Loss);
            Senesced.Add(Loss);
        }
コード例 #6
0
        public virtual void OnMemberDeath(PlayerMobile pm)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            if (!IsDead(pm))
            {
                Dead.Add(pm, DateTime.UtcNow);
            }
            else
            {
                Dead[pm] = DateTime.UtcNow;
            }

            Battle.OnTeamMemberDeath(this, pm);
            Battle.OnAfterTeamMemberDeath(this, pm);
        }