9 BeamGate::BeamGate(Layout &l):
15 TrackAttachment::layout.add(*this);
20 TrackAttachment::layout.remove(*this);
23 BeamGate *BeamGate::clone(Layout *to_layout) const
25 BeamGate *gate = new BeamGate(to_layout ? *to_layout : TrackAttachment::layout);
26 gate->set_position(position);
27 gate->set_rotation(rotation);
31 const BeamGateType &BeamGate::get_type() const
33 return BeamGateType::instance();
36 void BeamGate::set_position(const Vector &p)
43 void BeamGate::set_rotation(const Angle &r)
50 void BeamGate::update_attachment()
52 attach_to_closest(100);
56 OrientedPoint p = track.point();
57 position = p.position;
58 rotation = p.rotation;
63 Block *BeamGate::get_block() const
66 return &track->get_block();
71 void BeamGate::save(list<DataFile::Statement> &st) const
73 st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));
74 st.push_back((DataFile::Statement("rotation"), rotation.radians()));
76 st.push_back((DataFile::Statement("address"), address));
80 BeamGate::Loader::Loader(BeamGate &g):
81 DataFile::ObjectLoader<BeamGate>(g)
83 add("address", &Loader::address);
84 add("position", &Loader::position);
85 add("rotation", &Loader::rotation);
88 void BeamGate::Loader::address(unsigned a)
93 void BeamGate::Loader::position(float x, float y, float z)
95 obj.set_position(Vector(x, y, z));
98 void BeamGate::Loader::rotation(float r)
100 obj.set_rotation(Angle::from_radians(r));