예제 #1
0
        public float CalculateRegenLeftForLongestEffect()
        {
            MyEntityStatRegenEffect longestTimeLeftEffect = null;

            m_statRegenLeft = 0f;

            foreach (var effect in m_effects)   // Calculate the effect from non-permanent effects
            {
                if (effect.Value.Duration > 0)
                {
                    m_statRegenLeft += effect.Value.AmountLeftOverDuration;
                    if (longestTimeLeftEffect == null || effect.Value.DeathTime > longestTimeLeftEffect.DeathTime)
                    {
                        longestTimeLeftEffect = effect.Value;
                    }
                }
            }

            if (longestTimeLeftEffect == null)
            {
                return(m_statRegenLeft);
            }

            foreach (var effect in m_effects)
            {
                if (effect.Value.Duration < 0)  // Calculate the effect from the permanent effects
                {
                    m_statRegenLeft += effect.Value.Amount * (float)effect.Value.CalculateTicksBetweenTimes(longestTimeLeftEffect.LastRegenTime, longestTimeLeftEffect.DeathTime);
                }
            }

            return(m_statRegenLeft);
        }
예제 #2
0
        public float CalculateRegenLeftForLongestEffect()
        {
            MyEntityStatRegenEffect effect = null;

            this.m_statRegenLeft = 0f;
            foreach (KeyValuePair <int, MyEntityStatRegenEffect> pair in this.m_effects)
            {
                if (pair.Value.Duration <= 0f)
                {
                    continue;
                }
                this.m_statRegenLeft += pair.Value.AmountLeftOverDuration;
                if ((effect == null) || (pair.Value.DeathTime > effect.DeathTime))
                {
                    effect = pair.Value;
                }
            }
            if (effect != null)
            {
                foreach (KeyValuePair <int, MyEntityStatRegenEffect> pair2 in this.m_effects)
                {
                    if (pair2.Value.Duration < 0f)
                    {
                        this.m_statRegenLeft += pair2.Value.Amount * pair2.Value.CalculateTicksBetweenTimes(effect.LastRegenTime, effect.DeathTime);
                    }
                }
            }
            return(this.m_statRegenLeft);
        }
예제 #3
0
        public bool RemoveEffect(int id)
        {
            MyEntityStatRegenEffect effect = null;

            if (m_effects.TryGetValue(id, out effect))
            {
                effect.Closing();
            }
            return(m_effects.Remove(id));
        }
예제 #4
0
        public int AddEffect(MyObjectBuilder_EntityStatRegenEffect objectBuilder)
        {
            MyEntityStatRegenEffect effect = MyEntityStatEffectFactory.CreateInstance(objectBuilder);

            effect.Init(objectBuilder, this);
            int key = 0;

            while ((key < this.m_effects.Count) && this.m_effects.ContainsKey(key))
            {
                key++;
            }
            this.m_effects.Add(key, effect);
            return(key);
        }
예제 #5
0
        public virtual void Update()
        {
            this.m_syncFlag = false;
            this.UpdateRegenAmountMultiplier();
            foreach (KeyValuePair <int, MyEntityStatRegenEffect> pair in this.m_effects)
            {
                MyEntityStatRegenEffect effect = pair.Value;
                if ((effect.Duration >= 0f) && (effect.AliveTime >= (effect.Duration * 1000f)))
                {
                    m_tmpRemoveEffects.Add(pair.Key);
                }
                if (Sync.IsServer && effect.Enabled)
                {
                    if (this.m_regenAmountMultiplierActive)
                    {
                        effect.Update(this.m_regenAmountMultiplier);
                    }
                    else
                    {
                        effect.Update(1f);
                    }
                }
            }
            foreach (int num in m_tmpRemoveEffects)
            {
                this.RemoveEffect(num);
            }
            m_tmpRemoveEffects.Clear();
            int updateCounter = this.m_updateCounter;

            this.m_updateCounter = updateCounter + 1;
            if ((((updateCounter % 10) == 0) || (Math.Abs((float)(this.Value - this.MinValue)) <= 0.001)) && (this.m_lastSyncValue != this.m_currentValue))
            {
                this.m_syncFlag      = true;
                this.m_lastSyncValue = this.m_currentValue;
            }
        }
예제 #6
0
        public MyEntityStatRegenEffect GetEffect(int id)
        {
            MyEntityStatRegenEffect retVal = null;

            return(m_effects.TryGetValue(id, out retVal) ? retVal : null);
        }
예제 #7
0
 public bool TryGetEffect(int id, out MyEntityStatRegenEffect outEffect)
 {
     return(m_effects.TryGetValue(id, out outEffect));
 }
예제 #8
0
 public bool TryGetEffect(int id, out MyEntityStatRegenEffect outEffect)
 {
     return m_effects.TryGetValue(id, out outEffect);
 }
 public static MyObjectBuilder_EntityStatRegenEffect CreateObjectBuilder(MyEntityStatRegenEffect effect)
 {
     return(m_objectFactory.CreateObjectBuilder <MyObjectBuilder_EntityStatRegenEffect>(effect));
 }
예제 #10
0
 public bool TryGetEffect(int id, out MyEntityStatRegenEffect outEffect) =>
 this.m_effects.TryGetValue(id, out outEffect);
예제 #11
0
        public MyEntityStatRegenEffect GetEffect(int id)
        {
            MyEntityStatRegenEffect effect = null;

            return(this.m_effects.TryGetValue(id, out effect) ? effect : null);
        }
		public static MyObjectBuilder_EntityStatRegenEffect CreateObjectBuilder(MyEntityStatRegenEffect effect)
		{
			return m_objectFactory.CreateObjectBuilder<MyObjectBuilder_EntityStatRegenEffect>(effect);
		}