// Perform infusion skill public void performInfusionSkill(int entityId, InfusionSkill infusionSkill, int targetEntityId) { PerformingSkillsComponent performingSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId); CharacterComponent characterComponent = EntityManager.getCharacterComponent(targetEntityId); bool inRangeAtleastOnce = false; ExecuteInfusionSkill executeSkill = new ExecuteInfusionSkill(infusionSkill, targetEntityId, () => { if (inRangeAtleastOnce) { return true; } else { PositionComponent positionComponent = EntityManager.getPositionComponent(entityId); PositionTargetComponent positionTargetComponent = EntityManager.getPositionTargetComponent(entityId); float distance = Math.Abs(positionTargetComponent.position - positionComponent.position.X); bool inRange = distance <= positionTargetComponent.tolerance + SKILL_RANGE_TOLERANCE; if (inRange) { inRangeAtleastOnce = true; } return inRange; } }); EntityManager.addComponent(entityId, new PositionTargetComponent(entityId, characterComponent.body, infusionSkill.range - 2f)); performingSkillsComponent.executingSkills.Add(executeSkill); }
// Execute infusion skill private void executeInfusion(int entityId, ExecuteInfusionSkill executeSkill) { InfusionSkill skill = executeSkill.skill as InfusionSkill; EntityFactory.createInfusionSpell(executeSkill.targetEntityId, skill.maxHpMod, skill.strengthMod, skill.armorClassMod, skill.timeToLive); EntityManager.removeComponent(entityId, ComponentType.PositionTarget); resetCooldown(entityId, SkillType.Infusion); removeExecutedSkill(entityId, executeSkill); }