Skip to content

Instantly share code, notes, and snippets.

@psuong
Last active February 23, 2019 20:08
Show Gist options
  • Save psuong/40bc8b3b29bd28fe92a3d99c328668d0 to your computer and use it in GitHub Desktop.
Save psuong/40bc8b3b29bd28fe92a3d99c328668d0 to your computer and use it in GitHub Desktop.
ChargeFXIndicatorTests
private ChargeFXIndicatorSystem indicatorSystem;
private Entity playerEntity;
private ComponentGroup particleGroup, playerGroup;
private GameObject particles, player;
[SetUp]
public override void SetUp() {
base.SetUp();
indicatorSystem = currentWorld.GetOrCreateManager<ChargeFXIndicatorSystem>();
particles = GetInstantiatedAsset<GameObject>("ChargeEffect", "Assets/Prefabs");
player = GetInstantiatedAsset<GameObject>("Base Player", "Assets/Prefabs");
playerGroup = RetrievalSystem.GetComponentGroup(typeof(ID), typeof(ChargeShotTimer));
particleGroup = RetrievalSystem.GetComponentGroup(typeof(ParticleSystemPair));
playerEntity = playerGroup.GetEntityArray()[0];
}
[TearDown]
public override void TearDown() {
Object.DestroyImmediate(particles);
Object.DestroyImmediate(player);
base.TearDown();
}
[Test]
public void ChargingAttackShowsChildIndicator() {
entityManager.SetComponentData(playerEntity, new ChargeShotTimer {
Current = 1f,
Wait = 2f
});
indicatorSystem.Update();
var particles = particleGroup.GetEntityArray();
AreEqual(1, particles.Length, "Only 1 ParticleSystemPair entity allowed!");
var particle = entityManager.GetSharedComponentData<ParticleSystemPair>(particles[0]);
IsTrue(particle.Child.isPlaying, "The child particle should be playing!");
IsFalse(particle.Parent.isPlaying, "The parent particle should not be playing!");
}
[Test]
public void FullyChargedAttackShowsBothIndicators() {
entityManager.SetComponentData(playerEntity, new ChargeShotTimer {
Current = 2f,
Wait = 2f
});
indicatorSystem.Update();
var particles = particleGroup.GetEntityArray();
AreEqual(1, particles.Length, "Only 1 ParticleSystemPair entity allowed!");
var particle = entityManager.GetSharedComponentData<ParticleSystemPair>(particles[0]);
IsTrue(particle.Child.isPlaying, "The child particle should be playing!");
IsTrue(particle.Parent.isPlaying, "The parent particle should be playing!");
}
[Test]
public void ReleasedChargedAttackShowsNoIndicator() {
entityManager.SetComponentData(playerEntity, new ChargeShotTimer {
Current = 0f,
Wait = 2f
});
indicatorSystem.Update();
var particles = particleGroup.GetEntityArray();
AreEqual(1, particles.Length, "Only 1 ParticleSystemPair entity allowed!");
var particle = entityManager.GetSharedComponentData<ParticleSystemPair>(particles[0]);
IsFalse(particle.Child.isPlaying, "The child particle should not be playing!");
IsFalse(particle.Parent.isPlaying, "The parent particle should be not playing!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment