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); } } }
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); }