コード例 #1
0
		public virtual MyObjectBuilder_EntityStatRegenEffect GetObjectBuilder()
		{
			var builder = new MyObjectBuilder_EntityStatRegenEffect();

			builder.TickAmount = m_amount;
			builder.Interval = m_interval;
			builder.MaxRegenRatio = m_maxRegenRatio;
			builder.MinRegenRatio = m_minRegenRatio;
			builder.Duration = m_duration;
			builder.AliveTime = AliveTime;

			return builder;
		}
コード例 #2
0
		private void InitPermanentEffects()
		{
			var effectBuilder = new MyObjectBuilder_EntityStatRegenEffect();

			var health = Health;
			if (health != null)
			{
				effectBuilder.TickAmount = SpaceStatEffect.MyEffectConstants.HealthTick;
				effectBuilder.Interval = SpaceStatEffect.MyEffectConstants.HealthInterval;
				effectBuilder.MaxRegenRatio = 0.7f;
				effectBuilder.MinRegenRatio = 0;
				m_healthEffectId = health.AddEffect(effectBuilder);
			}
		}
コード例 #3
0
		public void Consume(MyFixedPoint amount, MyConsumableItemDefinition definition)
		{
			if (definition == null)
				return;

			MyEntityStat stat;
			var regenEffect = new MyObjectBuilder_EntityStatRegenEffect();
			regenEffect.Interval = 1.0f;
			regenEffect.MaxRegenRatio = 1.0f;
			regenEffect.MinRegenRatio = 0.0f;

			foreach (var statValue in definition.Stats)
			{
				if (Stats.TryGetValue(MyStringHash.GetOrCompute(statValue.Name), out stat))
				{
					regenEffect.TickAmount = statValue.Value*(float)amount;
					regenEffect.Duration = statValue.Time;
					stat.AddEffect(regenEffect);
				}
			}
		}
コード例 #4
0
ファイル: MyEntityStat.cs プロジェクト: fluxit/SpaceEngineers
        public int AddEffect(MyObjectBuilder_EntityStatRegenEffect objectBuilder)
        {
            var effect = MyEntityStatEffectFactory.CreateInstance(objectBuilder);
            effect.Init(objectBuilder, this);

            int nextId = 0;

            for (; nextId < m_effects.Count; ++nextId)
            {
                if (!m_effects.ContainsKey(nextId))
                    break;
            }
            m_effects.Add(nextId, effect);

            return nextId;
        }
コード例 #5
0
ファイル: MyEntityStat.cs プロジェクト: fluxit/SpaceEngineers
 public int AddEffect(float amount, float interval, float duration = -1.0f, float minRegenRatio = 0.0f, float maxRegenRatio = 1.0f)
 {
     var builder = new MyObjectBuilder_EntityStatRegenEffect()
     {
         TickAmount = amount,
         Interval = interval,
         Duration = duration,
         MinRegenRatio = minRegenRatio,
         MaxRegenRatio = maxRegenRatio,
     };
     return AddEffect(builder);
 }
コード例 #6
0
		public void Consume(MyFixedPoint amount, MyConsumableItemDefinition definition)
		{
			MyEntityStat stat;
			var regenEffect = new MyObjectBuilder_EntityStatRegenEffect();
			regenEffect.Interval = 1;
			regenEffect.MaxRegenRatio = 1.0f;
			regenEffect.MinRegenRatio = 0.0f;

			foreach (var statValue in definition.Stats)
			{
				if (m_stats.TryGetValue(MyStringHash.GetOrCompute(statValue.Name), out stat))
				{
					regenEffect.TickAmount = statValue.Value;
					regenEffect.Duration = statValue.Time;
					stat.AddEffect(regenEffect);
				}
			}

            // MW:TODO change/remove when there is syncing of consuming items
            if (Entity is MyCharacter)
                (Entity as MyCharacter).StartSecondarySound(definition.EatingSound, true);
		}
コード例 #7
0
		public static MyEntityStatRegenEffect CreateInstance(MyObjectBuilder_EntityStatRegenEffect builder)
		{
			var obj = m_objectFactory.CreateInstance(builder.TypeId);
			return obj;
		}