public void AddEvent(MoveEvent move) { // Reiterate ignores time. move.Time = 0; if (MoveEvents.Count == 0) { this.Name = move.Name; } MoveEvents.Add(move); }
private void UpdateScene(MoveEvent evt, bool simulate_motion) { lock (_scene) { string unit_name = evt.Name; Vector3 current = GetCurrentPosition(unit_name); _scene.SelectPawn(unit_name); if (simulate_motion) { // Place object and put into motion. _scene.MoveSelected(current.X, current.Y); _scene.MoveSelected(evt.X, evt.Y, (EventSpeed(evt) * (1000 / (float)SimSpeed))); } else { _scene.MoveSelected(current.X, current.Y); } _scene.ClearPawnSelection(); } }
public void DoMove(MoveEvent evt, System.Threading.ThreadStart callback) { if (_scene != null) { lock (_scene) { _scene.SelectPawn(evt.Name); if (callback != null) { _scene.MoveSelected(evt.X, evt.Y, (EventSpeed(evt) * (1000 / (float)SimSpeed)), callback); } else { _scene.MoveSelected(evt.X, evt.Y, (EventSpeed(evt) * (1000 / (float)SimSpeed))); } _scene.ClearPawnSelection(); } } }
public AGT_LinearMotion CreateMotionCalculator(MoveEvent evt) { if (_current_positions.ContainsKey(evt.Name) && evt != MoveEvent.Empty) { AGT_LinearMotion motion_calculator = new AGT_LinearMotion(_current_positions[evt.Name].X, _current_positions[evt.Name].Y, _current_positions[evt.Name].Z); motion_calculator.MoveTo(evt.X, evt.Y, evt.Z, EventSpeed(evt)); return motion_calculator; } return null; }
private double GetMoveDuration(MoveEvent evt) { return AGT_LinearMotion.CalculateMoveDuration(_current_positions[evt.Name].X, _current_positions[evt.Name].Y, evt.X, evt.Y, EventSpeed(evt)); }
private float EventSpeed(MoveEvent evt) { if (UnitMaxSpeeds.ContainsKey(evt.Name)) { return (float)((evt.Throttle * (float)UnitMaxSpeeds[evt.Name])/_mapScale); } return 0f; }
private void Xml_ReadMoveEvent(XPathNodeIterator iterator, AbstractPreviewEvent abstract_event) { int last_move_timetick = -1; if (iterator != null) { foreach (XPathNavigator move_node in iterator) { MoveEvent move_event = new MoveEvent(); move_event.MoveDuration = -1; move_event.ID = move_node.GetAttribute("ID", move_node.NamespaceURI); move_event.Name = GetUnitName(Convert.ToInt32(move_event.ID)); XPathNavigator time_node = move_node.SelectSingleNode(MoveEventTime_XPath); try { move_event.Time = (int)Convert.ToDecimal(time_node.GetAttribute("value", time_node.NamespaceURI)); } catch (Exception) { move_event.Time = 0; } XPathNavigator throttle_node = move_node.SelectSingleNode(MoveEventThrottle_XPath); try { move_event.Throttle = (float)(Convert.ToDecimal(throttle_node.GetAttribute("value", throttle_node.NamespaceURI))); } catch (Exception) { move_event.Throttle = 100f; } XPathNavigator x_node = move_node.SelectSingleNode(MoveEventDestX_XPath); try { move_event.X = (float)(Convert.ToDouble(x_node.GetAttribute("value", x_node.NamespaceURI))); move_event.X = UTM_Mapping.HorizontalMetersToPixels(move_event.X); } catch (Exception) { move_event.X = 0f; } XPathNavigator y_node = move_node.SelectSingleNode(MoveEventDestY_XPath); try { move_event.Y = (float)(Convert.ToDouble(y_node.GetAttribute("value", y_node.NamespaceURI))); move_event.Y = UTM_Mapping.VerticalMetersToPixels(move_event.Y); } catch (Exception) { move_event.Y = 0f; } move_event.Z = 0f; if (last_move_timetick >= 0) { MoveEvent mv = _sim.FindMoveEvent(last_move_timetick, move_event.Name); if (mv != MoveEvent.Empty) { mv.MoveDuration = move_event.Time - mv.Time; } } if (abstract_event == null) { _sim.AddEvent(move_event); } else { if (abstract_event is ReiterateEvent) { _sim.AddEvent(move_event, (ReiterateEvent)abstract_event); } } last_move_timetick = move_event.Time; } } }