public override void Start(IEntityPool entityPool) { var entity = entityPool.GetEntityById(_entityId); if (entity == null) return; _health = entity.GetComponent<HealthComponent>(); if (_health != null) { Set(_health.Health / _health.MaxHealth); _health.HealthChanged += health_HealthChanged; } }
public override Component Clone() { HealthComponent copy = new HealthComponent { StartHealth = this.StartHealth, maxHealth = this.maxHealth, flashtime = this.flashtime, meter = this.meter }; // if it has a meter, it's intended to only have one instance on the screen // so a shallow copy should suffice if (copy.meter != null) copy.meter.Reset(); return copy; }