protected override void OnActionUpdate(FixPoint delta_time) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); Skill owner_skill = skill_component.GetOwnerSkill(); owner_skill.BuildSkillTargets(m_target_gathering_param); }
bool Deactivate(bool force) { if (!m_is_active) { return(false); } m_definition_component.ClearTimer(SkillTimer.CastingTimer); m_definition_component.ClearTimer(SkillTimer.InflictingTimer); m_definition_component.ClearTimer(SkillTimer.ExpirationTimer); var enumerator = m_components.GetEnumerator(); while (enumerator.MoveNext()) { SkillComponent cmp = enumerator.Current.Value as SkillComponent; if (cmp != null) { cmp.Deactivate(force); } } SetSkillActive(false); #if COMBAT_CLIENT int render_effect_cfgid = m_definition_component.GetMainRenderEffectConfigID(); if (render_effect_cfgid > 0) { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsStop(GetOwnerEntityID(), render_effect_cfgid); GetLogicWorld().AddRenderMessage(msg); } #endif return(true); }
protected override void OnActionUpdate(FixPoint delta_time) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); Skill skill = skill_component.GetOwnerSkill(); Entity attacker = skill.GetOwnerEntity(); List <Target> targets = skill.GetTargets(); LogicWorld logic_world = skill.GetLogicWorld(); for (int i = 0; i < targets.Count; ++i) { Entity current_target = targets[i].GetEntity(logic_world); if (current_target == null) { continue; } skill_component.CurrentTarget = current_target; DamagableComponent damageable_component = current_target.GetComponent(DamagableComponent.ID) as DamagableComponent; if (damageable_component == null) { continue; } Damage damage = RecyclableObject.Create <Damage>(); damage.m_attacker_id = attacker.ID; damage.m_defender_id = current_target.ID; damage.m_damage_type = m_damage_type_id; damage.m_damage_amount = m_damage_amount.Evaluate(this); damage.m_damage_amount = DamageSystem.Instance.CalculateDamageAmount(m_damage_type_id, damage.m_damage_amount, attacker, current_target); damage.m_render_effect_cfgid = m_damage_render_effect_cfgid; damage.m_sound_cfgid = m_damage_sound_cfgid; damageable_component.TakeDamage(damage); } skill_component.CurrentTarget = null; }
protected override void OnActionEnter() { if (m_generator == null) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); m_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_generator_cfgid, skill_component.GetOwnerEntity()); } }
protected override void ResetRuntimeData() { if (m_generator != null) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); GetLogicWorld().GetEffectManager().DestroyGenerator(m_generator.ID, skill_component.GetOwnerEntityID()); m_generator = null; } }
protected override void OnActionUpdate(FixPoint delta_time) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); Skill owner_skill = skill_component.GetOwnerSkill(); Entity owner_entity = owner_skill.GetOwnerEntity(); Target projectile_target = owner_skill.GetMajorTarget(); EntityUtil.CreateEntityForSkillAndEffect(skill_component, owner_entity, projectile_target, m_offset, m_angle_offset, m_object_type_id, m_object_proto_id, m_object_life_time, m_generator); }
public Skill GetOwnerSkill() { if (m_context == null) { return(null); } SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); if (skill_component == null) { return(null); } return(skill_component.GetOwnerSkill()); }
public bool Activate(FixPoint start_time) { if (!CanActivate(false)) { return(false); } Deactivate(false); AdjustDirection(); SetSkillActive(true); var enumerator = m_components.GetEnumerator(); while (enumerator.MoveNext()) { SkillComponent cmp = enumerator.Current.Value as SkillComponent; if (cmp != null) { cmp.Activate(start_time); } } m_definition_component.ClearTimer(SkillTimer.ExpirationTimer); if (m_definition_component.CastingTime > FixPoint.Zero) { m_definition_component.StartCastingTimer(start_time, m_owner_component); } else { PostActivate(start_time); } ScheduleTimers(); #if COMBAT_CLIENT if (m_definition_component.m_casting_animation != null) { PlayAnimationRenderMessage msg = RenderMessage.Create <PlayAnimationRenderMessage>(); FixPoint speed = m_definition_component.NormalAttack ? m_owner_component.AttackSpeedRate : FixPoint.One; msg.Construct(GetOwnerEntityID(), m_definition_component.m_casting_animation, null, true, speed); GetLogicWorld().AddRenderMessage(msg); } #endif return(true); }
protected override void OnActionEnter() { if (m_collision_target_generator_cfgid > 0 && m_collision_target_generator == null) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); m_collision_target_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_collision_target_generator_cfgid, skill_component.GetOwnerEntity()); if (m_collision_target_generator != null && m_collided_targets == null) { m_collided_targets = new List <int>(); } } if (m_task == null) { m_task = LogicTask.Create <ComponentCommonTask>(); m_task.Construct(this); } }
protected override void ResetRuntimeData() { if (m_collision_target_generator != null) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); GetLogicWorld().GetEffectManager().DestroyGenerator(m_collision_target_generator.ID, skill_component.GetOwnerEntityID()); m_collision_target_generator = null; } if (m_collided_targets != null) { m_collided_targets.Clear(); } if (m_task != null) { m_task.Cancel(); LogicTask.Recycle(m_task); m_task = null; } m_remain_time = FixPoint.Zero; }
protected override void OnActionUpdate(FixPoint delta_time) { SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); Skill skill = skill_component.GetOwnerSkill(); List <Target> targets = skill.GetTargets(); LogicWorld logic_world = GetLogicWorld(); for (int i = 0; i < targets.Count; ++i) { Entity current_target = targets[i].GetEntity(logic_world); if (current_target == null) { continue; } skill_component.CurrentTarget = current_target; EntityUtil.KillEntity(current_target, skill.GetOwnerEntityID()); } skill_component.CurrentTarget = null; }
void DetectCollision(ISpacePartition partition, Vector3FP position, FixPoint radius) { if (partition == null) { return; } SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); Skill skill = skill_component.GetOwnerSkill(); List <PositionComponent> list = partition.CollectEntity_SurroundingRing(position, radius, FixPoint.Zero, skill.GetOwnerEntityID()); if (list.Count == 0) { return; } for (int i = 0; i < list.Count; ++i) { PositionComponent position_component = list[i]; Entity entity = position_component.GetOwnerEntity(); if (m_collided_targets.Contains(entity.ID)) { continue; } m_collided_targets.Add(entity.ID); if (position_component.Height <= FixPoint.Zero) //ZZWTODO { continue; } if (!FactionRelation.IsFactionSatisfied(skill.GetOwnerPlayer().GetFaction(entity.GetOwnerPlayerID()), FactionRelation.NotAlly)) { continue; } Entity current_target = entity; skill_component.CurrentTarget = current_target; EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>(); app_data.m_original_entity_id = skill.GetOwnerEntityID(); app_data.m_source_entity_id = app_data.m_original_entity_id; m_collision_target_generator.Activate(app_data, entity); RecyclableObject.Recycle(app_data); } skill_component.CurrentTarget = null; }
protected override void OnActionUpdate(FixPoint delta_time) { if (m_generator == null) { return; } SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent); Skill skill = skill_component.GetOwnerSkill(); List <Target> targets = skill.GetTargets(); if (targets.Count == 0) { return; } Entity caster = skill.GetOwnerEntity(); EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>(); app_data.m_original_entity_id = caster.ID; app_data.m_source_entity_id = caster.ID; m_generator.Activate(app_data, targets); RecyclableObject.Recycle(app_data); }
bool Inflict(FixPoint start_time) { var enumerator = m_components.GetEnumerator(); while (enumerator.MoveNext()) { SkillComponent cmp = enumerator.Current.Value as SkillComponent; if (cmp != null) { cmp.Inflict(start_time); } } if (m_definition_component.ExpirationTime > FixPoint.Zero) { m_definition_component.StartExpirationTimer(start_time, m_owner_component); } else { Deactivate(false); } return(true); }
bool PostActivate(FixPoint start_time) { if (m_definition_component.NeedGatherTargets) { BuildSkillTargets(); if (!CheckTargetRange()) { Deactivate(false); return(false); } } FixPoint mana_cost = m_definition_component.ManaCost; if (mana_cost > FixPoint.Zero) { if (!m_mana_component.ChangeMana(m_definition_component.ManaType, -mana_cost)) { Deactivate(false); return(false); } } var enumerator = m_components.GetEnumerator(); while (enumerator.MoveNext()) { SkillComponent cmp = enumerator.Current.Value as SkillComponent; if (cmp != null) { cmp.PostActivate(start_time); } } m_definition_component.StartCooldownTimer(start_time, m_owner_component); if (m_definition_component.InflictTime > FixPoint.Zero) { m_definition_component.StartInflictingTimer(start_time, m_owner_component); } else { Inflict(start_time); } if (m_definition_component.NormalAttack) { GetOwnerEntity().SendSignal(SignalType.CastNormalAttack); } else if (!m_definition_component.StartsActive) { GetOwnerEntity().SendSignal(SignalType.CastSkill); } string main_animation = m_definition_component.GenerateMainActionNameLogicly(); #if COMBAT_CLIENT if (main_animation != null) { PlayAnimationRenderMessage msg = RenderMessage.Create <PlayAnimationRenderMessage>(); FixPoint speed = m_definition_component.NormalAttack ? m_owner_component.AttackSpeedRate : FixPoint.One; if (m_definition_component.m_expiration_animation == null) { msg.Construct(GetOwnerEntityID(), main_animation, AnimationName.IDLE, true, speed); } else { msg.Construct(GetOwnerEntityID(), main_animation, m_definition_component.m_expiration_animation, true, speed); } GetLogicWorld().AddRenderMessage(msg); } int render_effect_cfgid = m_definition_component.GetMainRenderEffectConfigID(); if (render_effect_cfgid > 0) { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsPlay(GetOwnerEntityID(), render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); } if (m_definition_component.m_main_sound > 0) { PlaySoundMessage msg = RenderMessage.Create <PlaySoundMessage>(); msg.Construct(GetOwnerEntityID(), m_definition_component.m_main_sound, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); } #endif return(true); }
public static Entity CreateEntityForSkillAndEffect(Component caller_component, Entity owner_entity, Target projectile_target, Vector3FP position_offset, FixPoint angle_offset, int object_type_id, int object_proto_id, FixPoint object_life_time, EffectGenerator attached_generator) { LogicWorld logic_world = owner_entity.GetLogicWorld(); IConfigProvider config = logic_world.GetConfigProvider(); ObjectTypeData type_data = config.GetObjectTypeData(object_type_id); if (type_data == null) { return(null); } PositionComponent owner_position_cmp = owner_entity.GetComponent(PositionComponent.ID) as PositionComponent; Vector3FP source_pos = owner_position_cmp.CurrentPosition; Vector2FP xz_facing; FixPoint angle; Vector3FP facing; if (projectile_target == null) { xz_facing = owner_position_cmp.Facing2D; angle = owner_position_cmp.FacingAngle; facing.x = xz_facing.x; facing.y = FixPoint.Zero; facing.z = xz_facing.z; } else { Vector3FP target_pos = projectile_target.GetPosition(logic_world); xz_facing.x = target_pos.x - source_pos.x; xz_facing.z = target_pos.z - source_pos.z; xz_facing.Normalize(); angle = xz_facing.ToDegree(); facing = target_pos - source_pos; facing.Normalize(); } Vector2FP side = xz_facing.Perpendicular(); Vector2FP xz_offset = xz_facing * position_offset.z + side * position_offset.x; if (angle_offset != FixPoint.Zero) { angle += angle_offset; FixPoint radian = FixPoint.Degree2Radian(-angle); facing.x = FixPoint.Cos(radian); facing.z = FixPoint.Sin(radian); } Vector3FP birth_position = new Vector3FP(source_pos.x + xz_offset.x, source_pos.y + position_offset.y, source_pos.z + xz_offset.z); BirthPositionInfo birth_info = new BirthPositionInfo(birth_position.x, birth_position.y, birth_position.z, angle, owner_position_cmp.GetCurrentSceneSpace()); ProjectileComponent owner_entity_projectile_component = owner_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent; if (owner_entity_projectile_component != null) { Entity original_owner = logic_world.GetEntityManager().GetObject(owner_entity_projectile_component.SourceEntityID); if (original_owner != null) { owner_entity = original_owner; } } Player owner_player = owner_entity.GetOwnerPlayer(); ObjectCreationContext object_context = new ObjectCreationContext(); object_context.m_object_proxy_id = owner_player.ProxyID; object_context.m_object_type_id = object_type_id; object_context.m_object_proto_id = object_proto_id; object_context.m_birth_info = birth_info; object_context.m_type_data = type_data; object_context.m_proto_data = config.GetObjectProtoData(object_proto_id); object_context.m_logic_world = logic_world; object_context.m_owner_id = owner_player.ID; object_context.m_is_ai = true; object_context.m_is_local = owner_player.IsLocal; Entity created_entity = logic_world.GetEntityManager().CreateObject(object_context); DeathComponent death_component = created_entity.GetComponent(DeathComponent.ID) as DeathComponent; if (death_component != null && object_life_time > FixPoint.Zero) { death_component.SetLifeTime(object_life_time); } SummonedEntityComponent summoned_component = created_entity.GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent; if (summoned_component != null) { summoned_component.SetMaster(owner_entity); } ProjectileComponent projectile_component = created_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent; if (projectile_component != null) { ProjectileParameters param = RecyclableObject.Create <ProjectileParameters>(); param.m_start_time = logic_world.GetCurrentTime(); param.m_life_time = object_life_time; param.m_source_entity_id = owner_entity.ID; param.m_start_position = birth_position; param.m_fixed_facing = facing; if (projectile_target != null) { param.m_target_entity_id = projectile_target.GetEntityID(); param.m_target_position = projectile_target.GetPosition(logic_world); } else { Skill owner_skill = null; SkillComponent skill_componnet = caller_component as SkillComponent; if (skill_componnet != null) { owner_skill = skill_componnet.GetOwnerSkill(); } if (owner_skill != null && owner_skill.GetDefinitionComponent().ExternalDataType == SkillDefinitionComponent.NeedExternalTarget) { param.m_target_entity_id = 0; FixPoint range = owner_skill.GetDefinitionComponent().MaxRange; if (range <= 0) { range = FixPoint.Ten; //ZZWTODO } if (projectile_component.Speed > FixPoint.Zero) { param.m_life_time = range / projectile_component.Speed; } param.m_target_position = param.m_start_position + param.m_fixed_facing * range; } } param.m_generator_id = attached_generator == null ? 0 : attached_generator.ID; projectile_component.InitParam(param); } else if (attached_generator != null) { EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>(); app_data.m_original_entity_id = owner_entity.ID; app_data.m_source_entity_id = owner_entity.ID; attached_generator.Activate(app_data, created_entity); RecyclableObject.Recycle(app_data); } return(created_entity); }
CastSkillResult CheckActivate(bool just_test) { if (!IsReady()) { return(CastSkillResult.InCooldown); } if (!m_owner_component.CanActivateSkill()) { if (!m_definition_component.CanActivateWhenDisabled) { return(CastSkillResult.SkillDisabled); } } FixPoint mana_cost = m_definition_component.ManaCost; if (mana_cost > FixPoint.Zero) { if (m_mana_component.GetCurrentManaPoint(m_definition_component.ManaType) < mana_cost) { return(CastSkillResult.NotEnoughMana); } } bool built_targets = false; LocomotorComponent locomotor_cmp = m_owner_component.GetLocomotorComponent(); if (locomotor_cmp != null && locomotor_cmp.IsMoving) { if (!m_definition_component.CanActivateWhileMoving) { return(CastSkillResult.ObjectIsMoving); } if (just_test && m_definition_component.MovingActivatingMustHaveTarget) { if (!built_targets) { BuildSkillTargets(); built_targets = true; } if (m_skill_targets.Count == 0) { return(CastSkillResult.NotEnoughTargets); } } } if (m_definition_component.ExternalDataType == SkillDefinitionComponent.NeedExternalOffset) { if (m_definition_component.ExternalVector.Length() > m_definition_component.AimParam1) { return(CastSkillResult.CheatedExternalData); } } if (m_definition_component.TargetsMinCountForActivate > 0) { if (!built_targets) { BuildSkillTargets(); built_targets = true; } if (m_skill_targets.Count < m_definition_component.TargetsMinCountForActivate) { return(CastSkillResult.NotEnoughTargets); } } var enumerator = m_components.GetEnumerator(); while (enumerator.MoveNext()) { SkillComponent cmp = enumerator.Current.Value as SkillComponent; if (cmp != null && !cmp.CanActivate()) { return(CastSkillResult.ComponnetUnavailable); } } return(CastSkillResult.Success); }