(7ee8dbc11) v0.9.8.0

This commit is contained in:
Joonas Rikkonen
2020-03-31 15:11:41 +03:00
parent 3e99a49383
commit b647059b93
147 changed files with 2299 additions and 1297 deletions
@@ -1,17 +1,27 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Extensions;
using Microsoft.Xna.Framework;
namespace Barotrauma
{
class DelayedListElement
{
public DelayedEffect Parent;
public Entity Entity;
public Vector2? WorldPosition;
public List<ISerializableEntity> Targets;
public readonly DelayedEffect Parent;
public readonly Entity Entity;
public readonly Vector2? WorldPosition;
public readonly List<ISerializableEntity> Targets;
public float StartTimer;
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;
}
}
class DelayedEffect : StatusEffect
{
@@ -27,28 +37,18 @@ namespace Barotrauma
public override void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target, Vector2? worldPosition = null)
{
if (this.type != type || !HasRequiredItems(entity)) return;
if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.FirstOrDefault() == target)) return;
if (targetIdentifiers != null && !IsValidTarget(target)) return;
if (!HasRequiredConditions(new List<ISerializableEntity>() { target })) return;
if (this.type != type || !HasRequiredItems(entity)) { return; }
if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.FirstOrDefault() == target)) { return; }
if (targetIdentifiers != null && !IsValidTarget(target)) { return; }
if (!HasRequiredConditions(target.ToEnumerable())) { return; }
DelayedListElement element = new DelayedListElement
{
Parent = this,
StartTimer = delay,
Entity = entity,
WorldPosition = worldPosition,
Targets = new List<ISerializableEntity>() { target }
};
DelayList.Add(element);
DelayList.Add(new DelayedListElement(this, entity, target.ToEnumerable(), delay, worldPosition));
}
public override void Apply(ActionType type, float deltaTime, Entity entity, IEnumerable<ISerializableEntity> targets, Vector2? worldPosition = null)
{
if (this.type != type || !HasRequiredItems(entity)) return;
if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.SequenceEqual(targets))) return;
if (this.type != type || !HasRequiredItems(entity)) { return; }
if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.SequenceEqual(targets))) { return; }
currentTargets.Clear();
foreach (ISerializableEntity target in targets)
@@ -61,18 +61,9 @@ namespace Barotrauma
currentTargets.Add(target);
}
if (!HasRequiredConditions(currentTargets)) return;
if (!HasRequiredConditions(currentTargets)) { return; }
DelayedListElement element = new DelayedListElement
{
Parent = this,
StartTimer = delay,
Entity = entity,
WorldPosition = worldPosition,
Targets = currentTargets
};
DelayList.Add(element);
DelayList.Add(new DelayedListElement(this, entity, currentTargets, delay, worldPosition));
}
public static void Update(float deltaTime)
@@ -88,7 +79,7 @@ namespace Barotrauma
element.StartTimer -= deltaTime;
if (element.StartTimer > 0.0f) continue;
if (element.StartTimer > 0.0f) { continue; }
element.Parent.Apply(1.0f, element.Entity, element.Targets, element.WorldPosition);
DelayList.Remove(element);