public DelayedListElement(DelayedEffect parentEffect, Entity parentEntity, IEnumerable <ISerializableEntity> targets, float delay, Vector2?worldPosition) { Parent = parentEffect; Entity = parentEntity; Targets = new List <ISerializableEntity>(targets); StartTimer = delay; WorldPosition = worldPosition; }
public static void UpdateAll(float deltaTime) { DelayedEffect.Update(deltaTime); for (int i = DurationList.Count - 1; i >= 0; i--) { DurationListElement element = DurationList[i]; if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets)) { DurationList.RemoveAt(i); continue; } element.Targets.RemoveAll(t => t is Entity entity && entity.Removed); if (element.Targets.Count == 0) { DurationList.RemoveAt(i); continue; } foreach (ISerializableEntity target in element.Targets) { for (int n = 0; n < element.Parent.propertyNames.Length; n++) { if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(element.Parent.propertyNames[n], out SerializableProperty property)) { continue; } element.Parent.ApplyToProperty(property, element.Parent.propertyEffects[n], CoroutineManager.UnscaledDeltaTime); } } element.Timer -= deltaTime; if (element.Timer > 0.0f) { continue; } DurationList.Remove(element); } }
public static void UpdateAll(float deltaTime) { UpdateAllProjSpecific(deltaTime); DelayedEffect.Update(deltaTime); for (int i = DurationList.Count - 1; i >= 0; i--) { DurationListElement element = DurationList[i]; if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets)) { DurationList.RemoveAt(i); continue; } element.Targets.RemoveAll(t => (t is Entity entity && entity.Removed) || (t is Limb limb && (limb.character == null || limb.character.Removed))); if (element.Targets.Count == 0) { DurationList.RemoveAt(i); continue; } foreach (ISerializableEntity target in element.Targets) { for (int n = 0; n < element.Parent.propertyNames.Length; n++) { if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(element.Parent.propertyNames[n], out SerializableProperty property)) { continue; } element.Parent.ApplyToProperty(target, property, element.Parent.propertyEffects[n], CoroutineManager.UnscaledDeltaTime); } foreach (Affliction affliction in element.Parent.Afflictions) { Affliction multipliedAffliction = affliction; if (!element.Parent.disableDeltaTime) { multipliedAffliction = affliction.CreateMultiplied(deltaTime); } if (target is Character character) { character.AddDamage(character.WorldPosition, new List <Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false); } else if (target is Limb limb) { limb.character.DamageLimb(limb.WorldPosition, limb, new List <Affliction>() { multipliedAffliction }, stun: 0.0f, playSound: false, attackImpulse: 0.0f); } } foreach (Pair <string, float> reduceAffliction in element.Parent.ReduceAffliction) { Limb targetLimb = null; Character targetCharacter = null; if (target is Character character) { targetCharacter = character; } else if (target is Limb limb) { targetLimb = limb; targetCharacter = limb.character; } if (targetCharacter != null) { float prevVitality = targetCharacter.Vitality; targetCharacter.CharacterHealth.ReduceAffliction(targetLimb, reduceAffliction.First, reduceAffliction.Second * deltaTime); #if SERVER GameMain.Server.KarmaManager.OnCharacterHealthChanged(targetCharacter, element.Parent.user, prevVitality - targetCharacter.Vitality); #endif } } } element.Timer -= deltaTime; if (element.Timer > 0.0f) { continue; } DurationList.Remove(element); } }
public static void UpdateAll(float deltaTime) { DelayedEffect.Update(deltaTime); for (int i = DurationList.Count - 1; i >= 0; i--) { DurationListElement element = DurationList[i]; if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets)) { DurationList.RemoveAt(i); continue; } element.Targets.RemoveAll(t => t is Entity entity && entity.Removed); if (element.Targets.Count == 0) { DurationList.RemoveAt(i); continue; } foreach (ISerializableEntity target in element.Targets) { if (target is Character) { for (int n = 0; n < element.Parent.propertyNames.Length; n++) { if (element.CancelledEffects.Contains(n)) { continue; } if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(element.Parent.propertyNames[n], out SerializableProperty property)) { continue; } if (element.Parent.propertyEffects[n].GetType() == typeof(float)) { Character targetcharacter = target as Character; float propertyfloat = Convert.ToSingle(element.Parent.propertyEffects[n]); switch (property.Name.ToLowerInvariant()) { case "health": if (propertyfloat < 0f) { targetcharacter.charRecord.DamageStat("health", -(propertyfloat * CoroutineManager.UnscaledDeltaTime), element.causecharacter, element.identifier); } break; case "bleeding": if (propertyfloat > 0f) { targetcharacter.charRecord.DamageStat("bleeding", (propertyfloat * CoroutineManager.UnscaledDeltaTime), element.causecharacter, element.identifier); } break; case "oxygen": if (propertyfloat < 0f) { targetcharacter.charRecord.DamageStat("oxygen", -(propertyfloat * CoroutineManager.UnscaledDeltaTime), element.causecharacter, element.identifier); } break; default: break; } } element.Parent.ApplyToProperty(property, element.Parent.propertyEffects[n], CoroutineManager.UnscaledDeltaTime); } } else { for (int n = 0; n < element.Parent.propertyNames.Length; n++) { if (element.CancelledEffects.Contains(n)) { continue; } SerializableProperty property; if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(element.Parent.propertyNames[n], out property)) { continue; } element.Parent.ApplyToProperty(property, element.Parent.propertyEffects[n], CoroutineManager.UnscaledDeltaTime); } } } element.Timer -= deltaTime; if (element.Timer > 0.0f) { continue; } DurationList.Remove(element); } }