Editor Crash when subtract.
It is ok for add.
Am i wrong?
struct DamageWork : IJobParallelFor
{
[ReadOnly] public EntityCommandBuffer CommandBuffer;
[ReadOnly] public NativeArray<Entity> entities;
[ReadOnly] public ComponentDataFromEntity<DamageTag> damageTag;
// [ReadOnly] public ComponentDataFromEntity<Damage> otherDamage;
[ReadOnly] public ComponentDataFromEntity<Tag> tag;
[NativeDisableParallelForRestriction]
public ComponentDataFromEntity<CircleCollision> collision;
[NativeDisableParallelForRestriction]
public ComponentDataFromEntity<HealthPoint> healthPoint;
[NativeDisableParallelForRestriction] public ComponentDataFromEntity<Damage> otherDamage;
public void Execute(int index)
{
CircleCollision receiverCol = collision[entities[index]];
if (collision[entities[index]].hit)
{
Enum_Tag otherTag = tag[receiverCol.hitEntity].Value;
Enum_Tag damagableFromTag = damageTag[entities[index]].DamagableFromTag;
bool match = false;
if (damagableFromTag == otherTag)
{
match = true;
}
//--------------------------------------------------------------------------------------------------
//Look Here
//--------------------------------------------------------------------------------------------------
if (match)
{
//NOT CRASH when add
healthPoint[entities[index]] = new HealthPoint(healthPoint[entities[index]].Value + 1);
//CRASH when subsract
healthPoint[entities[index]] = new HealthPoint(healthPoint[entities[index]].Value - 1);
receiverCol.hitEntity = Entity.Null;
}
//--------------------------------------------------------------------------------------------------
}
}
}