Esempio n. 1
0
        // Execute dispel skill
        private void executeDispel(int entityId, ExecuteDispelSkill executeSkill)
        {
            AffectedBySpellEntitiesComponent affectedBySpellEntities = EntityManager.getAffectedBySpellEntitiesComponent(executeSkill.targetId);

            foreach (int spellId in affectedBySpellEntities.spellEntities)
            {
                DispellableComponent dispellableComponent = EntityManager.getDispellableComponent(spellId);

                // Skip if no dispellable component
                if (dispellableComponent == null)
                {
                    continue;
                }

                EntityManager.destroyEntity(spellId);
            }

            EntityManager.removeComponent(entityId, ComponentType.PositionTarget);
            resetCooldown(entityId, SkillType.Dispel);
            removeExecutedSkill(entityId, executeSkill);
        }
Esempio n. 2
0
        // Perform dispel skill
        public void performDispelSkill(int entityId, DispelSkill skill, int targetEntityId)
        {
            PerformingSkillsComponent performingSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId);
            CharacterComponent characterComponent = EntityManager.getCharacterComponent(entityId);
            bool inRangeAtleastOnce = false;
            ExecuteDispelSkill executeSkill = new ExecuteDispelSkill(
                skill,
                targetEntityId,
                () =>
                {
                    if (inRangeAtleastOnce)
                    {
                        return true;
                    }
                    else
                    {
                        PositionComponent callbackPositionComponent = EntityManager.getPositionComponent(entityId);
                        PositionTargetComponent positionTargetComponent = EntityManager.getPositionTargetComponent(entityId);
                        float distance = Math.Abs(positionTargetComponent.position - callbackPositionComponent.position.X);
                        bool inRange = distance <= positionTargetComponent.tolerance + SKILL_RANGE_TOLERANCE;

                        if (inRange)
                        {
                            inRangeAtleastOnce = true;
                        }

                        return inRange;
                    }
                });

            EntityManager.addComponent(entityId, new PositionTargetComponent(entityId, characterComponent.body, skill.range));
            performingSkillsComponent.executingSkills.Add(executeSkill);
        }