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); } }
public virtual MyObjectBuilder_EntityStatRegenEffect GetObjectBuilder() { MyObjectBuilder_EntityStatRegenEffect effect1 = new MyObjectBuilder_EntityStatRegenEffect(); effect1.TickAmount = this.m_amount; effect1.Interval = this.m_interval; effect1.MaxRegenRatio = this.m_maxRegenRatio; effect1.MinRegenRatio = this.m_minRegenRatio; effect1.Duration = this.m_duration; effect1.AliveTime = this.AliveTime; return effect1; }
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)); }
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); }
public int AddEffect(float amount, float interval, float duration = -1f, float minRegenRatio = 0f, float maxRegenRatio = 1f) { MyObjectBuilder_EntityStatRegenEffect effect1 = new MyObjectBuilder_EntityStatRegenEffect(); effect1.TickAmount = amount; effect1.Interval = interval; effect1.Duration = duration; effect1.MinRegenRatio = minRegenRatio; effect1.MaxRegenRatio = maxRegenRatio; MyObjectBuilder_EntityStatRegenEffect objectBuilder = effect1; return(this.AddEffect(objectBuilder)); }
public virtual void Init(MyObjectBuilder_Base objectBuilder, MyEntityStat parentStat) { this.m_parentStat = parentStat; MyObjectBuilder_EntityStatRegenEffect effect = objectBuilder as MyObjectBuilder_EntityStatRegenEffect; if ((effect != null) && (effect.Interval > 0f)) { this.m_amount = effect.TickAmount; this.m_interval = effect.Interval; this.m_maxRegenRatio = effect.MaxRegenRatio; this.m_minRegenRatio = effect.MinRegenRatio; this.m_duration = effect.Duration - (effect.AliveTime / 1000f); this.ResetRegenTime(); } }
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); }
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); } }
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); }
public void Consume(MyFixedPoint amount, MyConsumableItemDefinition definition) { if (definition != null) { MyObjectBuilder_EntityStatRegenEffect objectBuilder = new MyObjectBuilder_EntityStatRegenEffect { Interval = 1f, MaxRegenRatio = 1f, MinRegenRatio = 0f }; foreach (MyConsumableItemDefinition.StatValue value2 in definition.Stats) { MyEntityStat stat; DictionaryValuesReader <MyStringHash, MyEntityStat> stats = base.Stats; if (stats.TryGetValue(MyStringHash.GetOrCompute(value2.Name), out stat)) { objectBuilder.TickAmount = value2.Value * ((float)amount); objectBuilder.Duration = value2.Time; stat.AddEffect(objectBuilder); } } } }
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 static MyEntityStatRegenEffect CreateInstance(MyObjectBuilder_EntityStatRegenEffect builder) { var obj = m_objectFactory.CreateInstance(builder.TypeId); return(obj); }
public static MyEntityStatRegenEffect CreateInstance(MyObjectBuilder_EntityStatRegenEffect builder) => m_objectFactory.CreateInstance(builder.TypeId);