Example #1
0
        protected override void process(Entity entity)
        {
            Health health = (Health)h_HealthMapper.get(entity);

            if (health.CurrentHealth <= 0)
            {
                Life life = (Life)h_LifeMapper.get(entity);

                if (life.IsAlive)
                {
                    UtilFactory.createSound("audio\\effects\\death", true, 1f);

                    //issue victory
                    Aggrivation aggro = (Aggrivation)h_AggroMapper.get(entity);

                    if (aggro != null)
                    {
                        foreach (Entity receiver in aggro.HateList)
                        {
                            Interactable interactor = (Interactable)h_InteractionMapper.get(entity);
                            Interactable interactee = (Interactable)h_InteractionMapper.get(receiver);

                            if (interactor == null || interactee == null)
                            {
                                continue;
                            }

                            if (interactor.SupportedInteractions.AWARDS_VICTORY &&
                                interactee.SupportedInteractions.MAY_RECEIVE_VICTORY)
                            {
                                UtilFactory.createVictoryAward(entity, receiver, GameConfig.AwardDefs.VictoryMinimum);
                            }
                        }
                    }
                }

                life.IsAlive = false;


                return;
            }

            health.TimeSinceLastRecover += ecs_instance.ElapsedTime;

            if (health.TimeSinceLastRecover > health.RecoveryRate)
            {
                health.TimeSinceLastRecover = 0;

                health.CurrentHealth += health.RecoveryAmmount;

                if (health.CurrentHealth > health.MaxHealth)
                {
                    health.CurrentHealth = health.MaxHealth;
                }
            }
        }