string type; //catalog or product // the query static IQueryable <Page> GetProductsWithCatalogAncestor(IQueryable <Page> pages) { return(FixPoint <bool, IQueryable <Page>, IQueryable <Page> > (processChildPages => (hasCatalogAncestor, thePages) => thePages.SelectMany(p => (hasCatalogAncestor && p.type == "product") ? new[] { p }.AsQueryable() : processChildPages(hasCatalogAncestor || p.type == "catalog", p.ChildPages))) (false, pages)); }
public override bool SetVariable(int id, FixPoint value) { switch (id) { case VID_X: m_current_position.x = value; return(true); case VID_Y: m_current_position.y = value; return(true); case VID_Z: m_current_position.z = value; return(true); case VID_BaseAngle: m_base_angle = value; return(true); case VID_Radius: m_radius = value; return(true); case VID_Height: m_height = value; return(true); default: return(false); } }
public override void Reset() { m_entity_id = -1; m_effect_cfgid = 0; m_play_time = FixPoint.Zero; m_play = false; }
public override void Reset() { m_entity_id = -1; m_mana_type = 0; m_delta_mana = FixPoint.Zero; m_current_mana = FixPoint.Zero; }
public TakeSilverEvent(Dictionary <byte, object> parameters) : base(parameters) { ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); try { if (parameters.ContainsKey(0)) { ObjectId = parameters[0].ObjectToLong(); } if (parameters.ContainsKey(1)) { TimeStamp = parameters[1].ObjectToLong() ?? 0; } if (parameters.ContainsKey(2)) { TargetEntityId = parameters[2].ObjectToLong(); } if (parameters.ContainsKey(3)) { var yieldPreTax = parameters[3].ObjectToLong(); YieldPreTax = FixPoint.FromInternalValue(yieldPreTax ?? 0); } if (parameters.ContainsKey(5)) { var guildTax = parameters[5].ObjectToLong(); GuildTax = FixPoint.FromInternalValue(guildTax ?? 0); } if (parameters.ContainsKey(6)) { var clusterTax = parameters[6].ObjectToLong(); ClusterTax = FixPoint.FromInternalValue(clusterTax ?? 0); } if (parameters.ContainsKey(7)) { IsPremiumBonus = parameters[7] as bool? ?? false; } if (parameters.ContainsKey(8)) { var multiplier = parameters[8].ObjectToLong(); Multiplier = FixPoint.FromInternalValue(multiplier ?? 0); } YieldAfterTax = YieldPreTax - GuildTax; ClusterYieldPreTax = FixPoint.FromFloatingPointValue(YieldPreTax.DoubleValue - (YieldPreTax.DoubleValue / Multiplier.DoubleValue)); PremiumAfterTax = ClusterYieldPreTax - ClusterTax; ClusterYieldAfterTax = FixPoint.FromFloatingPointValue((ClusterYieldPreTax.DoubleValue / Multiplier.DoubleValue) - ClusterTax.DoubleValue); } catch (Exception e) { ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod().DeclaringType, e); } }
public override void InitializeComponent() { if (m_current_health < 0) { m_current_health = m_current_max_health; } }
public void FeedSectionStartFixPoint_OnSnapped(FixPoint fixpoint, FixPoint.SnapEventArgs e) { PreviousConveyor = fixpoint.Parent as IRouteStatus; PreviousLoadWaiting = PreviousConveyor.GetLoadWaitingStatus(fixpoint); PreviousLoadWaiting.OnLoadWaitingChanged += PreviousLoadWaiting_OnLoadWaitingChanged; feedSection.Speed = PreviousConveyor.Speed; }
public bool Run(int entrty_id = 0) { int new_index = EntryID2Index(entrty_id); if (new_index == -1) { return(false); } if (new_index == m_current_running_entry_index) { return(true); } m_context.GetActionBuffer().ExitAllAction(); if (m_current_running_entry_index >= 0) { m_children[m_current_running_entry_index].ClearRunningTrace(); } m_current_running_entry_index = new_index; m_task.Cancel(); FixPoint update_interval = UpdateInterval; if (update_interval > FixPoint.Zero) { LogicWorld logic_world = m_context.GetLogicWorld(); var schedeler = logic_world.GetTaskScheduler(); schedeler.Schedule(m_task, logic_world.GetCurrentTime(), update_interval, update_interval); } OnUpdate(FixPoint.Zero); return(true); }
public override void InitializeVariable(Dictionary <string, string> variables) { string value; if (variables.TryGetValue("object_type_id", out value)) { m_object_type_id = int.Parse(value); } if (variables.TryGetValue("object_proto_id", out value)) { m_object_proto_id = int.Parse(value); } if (variables.TryGetValue("object_life_time", out value)) { m_object_life_time = FixPoint.Parse(value); } if (variables.TryGetValue("generator_id", out value)) { m_generator_cfgid = int.Parse(value); } if (variables.TryGetValue("offset_x", out value)) { m_offset.x = FixPoint.Parse(value); } if (variables.TryGetValue("offset_y", out value)) { m_offset.y = FixPoint.Parse(value); } if (variables.TryGetValue("offset_z", out value)) { m_offset.z = FixPoint.Parse(value); } }
public override void InitializeVariable(Dictionary <string, string> variables) { string value; if (variables.TryGetValue("config_int", out value)) { m_int = int.Parse(value); } if (variables.TryGetValue("config_fp", out value)) { m_fp = FixPoint.Parse(value); } if (variables.TryGetValue("config_string", out value)) { m_string = value; } if (variables.TryGetValue("config_bool", out value)) { m_bool = bool.Parse(value); } if (variables.TryGetValue("config_crc", out value)) { m_crcint = (int)CRC.Calculate(value); } if (variables.TryGetValue("config_formula", out value)) { m_formula.Compile(value); } }
public Vector3FP GetAimingLineFP() { float angle = 0; if (m_is_aiming_line_state) { if (m_aiming_line_trans == null) { return(Vector3FP.Zero); } angle = m_aiming_line_trans.eulerAngles.y - 90; } else { if (m_rotate_turret_trans == null) { return(Vector3FP.Zero); } angle = m_rotate_angle; } if (angle < 0) { angle = 360 + angle; } FixPoint radian = FixPoint.Degree2Radian(-FixPoint.CreateFromFloat(angle)); return(new Vector3FP(FixPoint.Cos(radian), FixPoint.Zero, FixPoint.Sin(radian))); }
public void Update(FixPoint delta_time) { if (m_cur_way_point == INVALID_WAYPOINT_INDEX) { return; } if (delta_time > m_remain_time) { Vector3FP new_position = m_position_component.CurrentPosition + m_direction * m_max_speed * m_remain_time; delta_time -= m_remain_time; AdvanceWayPoint(); if (m_cur_way_point != INVALID_WAYPOINT_INDEX) { new_position += m_direction * m_max_speed * delta_time; m_remain_time -= delta_time; } m_position_component.CurrentPosition = new_position; } else { Vector3FP new_position = m_position_component.CurrentPosition + m_direction * m_max_speed * delta_time; m_remain_time -= delta_time; m_position_component.CurrentPosition = new_position; } if (m_target != null) { FixPoint distance = m_position_component.CurrentPosition.FastDistance(m_target.CurrentPosition) - m_position_component.Radius - m_target.Radius; //ZZWTODO 多处距离计算 if (distance < m_range) { m_callback.MovementFinished(); } } }
public void Update(FixPoint current_time) { while (true) { Task <TContext> task = m_queue.Peek(); if (task == null || task.NextExecutionTime > current_time) { break; } FixPoint delta_time; if (task.Period.RawValue > 0) { delta_time = task.NextExecutionTime - task.ScheduleTime; task.ScheduleTime = task.NextExecutionTime; task.NextExecutionTime = task.NextExecutionTime + task.Period; m_queue.UpdatePriorityByIndex(0); } else { delta_time = current_time - task.ScheduleTime; m_queue.Dequeue(); } task.Run(m_context, current_time, delta_time); } }
public virtual void Schedule(FixPoint current_time, FixPoint delay = default(FixPoint), FixPoint period = default(FixPoint)) { if (m_scheduler != null) { m_scheduler.Schedule(this, current_time, delay, period); } }
public override void InitializeVariable(Dictionary <string, string> variables) { string value; if (variables.TryGetValue("object_type_id", out value)) { m_object_type_id = int.Parse(value); } if (variables.TryGetValue("object_proto_id", out value)) { m_object_proto_id = int.Parse(value); } if (variables.TryGetValue("object_distance", out value)) { m_object_distance = FixPoint.Parse(value); } if (variables.TryGetValue("init_count", out value)) { m_init_count = int.Parse(value); } if (variables.TryGetValue("max_count", out value)) { m_max_count = int.Parse(value); } if (variables.TryGetValue("update_interval", out value)) { m_update_interval = FixPoint.Parse(value); } }
void LongToFixPointAndBack_Internal(long source, long expected) { FixPoint fp = (FixPoint)source; long back = (long)fp; Assert.Equal(back, expected); }
public override void InitializeVariable(Dictionary <string, string> variables) { string value; if (variables.TryGetValue("gathering_type", out value)) { m_target_gathering_param.m_type = (int)CRC.Calculate(value); } if (variables.TryGetValue("gathering_param1", out value)) { m_target_gathering_param.m_param1 = FixPoint.Parse(value); } if (variables.TryGetValue("gathering_param2", out value)) { m_target_gathering_param.m_param2 = FixPoint.Parse(value); } if (variables.TryGetValue("gathering_faction", out value)) { m_target_gathering_param.m_faction = (int)CRC.Calculate(value); } if (variables.TryGetValue("gathering_category", out value)) { m_target_gathering_param.m_category = (int)CRC.Calculate(value); } }
public override void StartFixPoint_OnUnSnapped(FixPoint stranger) { PreviousConveyor = null; PreviousLoadWaitingStatus.OnLoadWaitingChanged -= PreviousLoadWaitingStatus_OnLoadWaitingChanged; PreviousLoadWaitingStatus = null; Reset(); }
public override void Inflict(FixPoint start_time) { if (m_generator == null) { return; } if (m_delay_time == FixPoint.Zero) { Impact(); } else { if (m_delay_task == null) { m_delay_task = LogicTask.Create <ComponentCommonTask>(); m_delay_task.Construct(this); } var schedeler = GetLogicWorld().GetTaskScheduler(); schedeler.Schedule(m_delay_task, GetCurrentTime(), m_delay_time); } #if COMBAT_CLIENT if (m_render_effect_cfgid > 0 && m_render_delay_time > FixPoint.Zero) { if (m_render_delay_task == null) { m_render_delay_task = LogicTask.Create <PlayRenderEffectTask>(); m_render_delay_task.Construct(this); } var schedeler = GetLogicWorld().GetTaskScheduler(); schedeler.Schedule(m_render_delay_task, GetCurrentTime(), m_render_delay_time); } #endif }
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; }
void ChangeHealth(FixPoint delta_health, int source_id) { if (delta_health > 0) { if (m_current_health + delta_health > m_current_max_health) { delta_health = m_current_max_health - m_current_health; } } else { if (-delta_health > m_current_health) { delta_health = -m_current_health; } } if (delta_health == 0) { return; } m_current_health += delta_health; #if COMBAT_CLIENT ChangeHealthRenderMessage msg = RenderMessage.Create <ChangeHealthRenderMessage>(); msg.Construct(ParentObject.ID, delta_health, m_current_health); GetLogicWorld().AddRenderMessage(msg); #endif if (m_current_health <= 0) { EntityUtil.KillEntity(ParentObject as Entity, source_id); } }
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); }
public void Reset() { m_callback = null; m_position_component = null; m_max_speed = FixPoint.Zero; m_direction.MakeZero(); }
public Vector3FP YRotate(FixPoint radian) { FixPoint sin_v = FixPoint.Sin(radian); FixPoint cos_v = FixPoint.Cos(radian); return(new Vector3FP(cos_v * x - sin_v * z, y, sin_v * x + cos_v * z)); }
public void Construct(int entity_id, int mana_type, FixPoint delta_mana, FixPoint current_mana) { m_entity_id = entity_id; m_mana_type = mana_type; m_delta_mana = delta_mana; m_current_mana = current_mana; }
public void ReleaseSectionStartFixPoint_OnSnapped(FixPoint fixpoint, FixPoint.SnapEventArgs e) { NextConveyor = fixpoint.Parent as IRouteStatus; NextRouteStatus = NextConveyor.GetRouteStatus(fixpoint); NextRouteStatus.OnRouteStatusChanged += NextRouteStatus_OnRouteStatusChanged; releaseSection.Speed = NextConveyor.Speed; }
public void ConstructAsPlay(int entity_id, int effect_cfgid, FixPoint play_time) { m_entity_id = entity_id; m_effect_cfgid = effect_cfgid; m_play_time = play_time; m_play = true; }
private void StartFixPoint_Snapped(FixPoint fixpoint, FixPoint.SnapEventArgs e) { if (fixpoint.UserData is SorterElementFixPoint) { e.Cancel = true; } }
public void UpdateSpurt(FixPoint delta_time) { Skill skill = GetOwnerSkill(); Entity owner_entity = skill.GetOwnerEntity(); PositionComponent position_component = owner_entity.GetComponent(PositionComponent.ID) as PositionComponent; Vector3FP offset = position_component.Facing3D * (m_distance * delta_time / m_time); if (m_backward) { offset = -offset; } Vector3FP new_position = position_component.CurrentPosition + offset; GridGraph grid_graph = position_component.GetGridGraph(); if (grid_graph != null) { GridNode node = grid_graph.Position2Node(new_position); if (node == null || !node.Walkable) { StopSpurt(); return; } } position_component.CurrentPosition = new_position; if (m_collision_target_generator != null) { DetectCollision(position_component.GetSpacePartition(), new_position, position_component.Radius); } }
public override bool GetVariable(int id, out FixPoint value) { switch (id) { case VID_X: value = m_current_position.x; return(true); case VID_Y: value = m_current_position.y; return(true); case VID_Z: value = m_current_position.z; return(true); case VID_BaseAngle: value = m_base_angle; return(true); case VID_Radius: value = m_radius; return(true); case VID_Height: value = m_height; return(true); default: value = FixPoint.Zero; return(false); } }