mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 18:39:18 +02:00
basic power circuits simulation, vehicle device presence definition, automatic coupling tweaks, minor vehicle simulation logic enhancements, minor brake simulation logic fixes, pantograph control enhancements, ai logic enhancements
This commit is contained in:
27
DynObj.h
27
DynObj.h
@@ -679,7 +679,11 @@ private:
|
||||
void update_neighbours();
|
||||
// locates potential collision source within specified range, scanning its route in specified direction
|
||||
auto find_vehicle( int const Direction, double const Range ) const -> std::tuple<TDynamicObject *, int, double, bool>;
|
||||
TDynamicObject * ControlledFind();
|
||||
// locates potential vehicle connected with specific coupling type and satisfying supplied predicate
|
||||
template <typename Predicate_>
|
||||
auto find_vehicle( coupling const Coupling, Predicate_ const Predicate ) -> TDynamicObject *;
|
||||
TDynamicObject * FindPowered();
|
||||
TDynamicObject * FindPantographCarrier();
|
||||
void ParamSet(int what, int into);
|
||||
// zapytanie do AI, po którym segmencie skrzyżowania jechać
|
||||
int RouteWish(TTrack *tr);
|
||||
@@ -754,4 +758,25 @@ private:
|
||||
erase_disabled();
|
||||
};
|
||||
|
||||
|
||||
template <typename Predicate_>
|
||||
auto
|
||||
TDynamicObject::find_vehicle( coupling const Coupling, Predicate_ const Predicate ) -> TDynamicObject * {
|
||||
|
||||
if( Predicate( this ) ) {
|
||||
return this; }
|
||||
// try first to look towards the rear
|
||||
auto *vehicle { this };
|
||||
while( ( vehicle = vehicle->NextC( Coupling ) ) != nullptr ) {
|
||||
if( Predicate( vehicle ) ) {
|
||||
return vehicle; } }
|
||||
// if we didn't yet find a suitable vehicle try in the other direction
|
||||
vehicle = this;
|
||||
while( ( vehicle = vehicle->NextC( Coupling ) ) != nullptr ) {
|
||||
if( Predicate( vehicle ) ) {
|
||||
return vehicle; } }
|
||||
// if we still don't have a match give up
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user