Entitas
Entitas copied to clipboard
Can I feel free to use my class in component?
Ask AI, it says "Your component-embedded class leads to multiple pointer jumps, further reducing CPU cache hit rate.". It's that ture? Should I care about that? What if my class in component has function in it? Different answer?
public struct HealthComponent : IComponent {
public int CurrentHP;
public int MaxHP;
}
From ↑ to ↓
public class HealthComponent : IComponent {
public HealthData Health;
}
public class HealthData {
public int CurrentHP;
public int MaxHP;
}
Hi!
True, each ref to another class is a jump, but you can use classes in components. In your case I think the following makes sense, also avoiding an additional class:
public sealed class HealthComponent : IComponent
{
public int CurrentHealth;
public int MaxHealth;
}