mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 06:49:19 +02:00
vehicle heating system tweaks, vehicle destination sign system enhancements
This commit is contained in:
95
DynObj.cpp
95
DynObj.cpp
@@ -919,6 +919,8 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btEndSignalsTab2.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
// destination signs
|
||||
update_destinations();
|
||||
// else btEndSignalsTab2.TurnOff();
|
||||
// McZapkie-181002: krecenie wahaczem (korzysta z kata obrotu silnika)
|
||||
if (iAnimType[ANIM_LEVERS])
|
||||
@@ -1946,6 +1948,10 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
init_sections( mdLowPolyInt, nameprefix );
|
||||
}
|
||||
}
|
||||
// destination sign
|
||||
if( mdModel ) {
|
||||
init_destination( mdModel );
|
||||
}
|
||||
// 'external_load' is an optional special section in the main model, pointing to submodel of external load
|
||||
if( mdModel ) {
|
||||
init_sections( mdModel, "external_load" );
|
||||
@@ -2069,6 +2075,16 @@ TDynamicObject::init_sections( TModel3d const *Model, std::string const &Namepre
|
||||
return sectioncount;
|
||||
}
|
||||
|
||||
bool
|
||||
TDynamicObject::init_destination( TModel3d *Model ) {
|
||||
|
||||
if( Model->GetSMRoot() == nullptr ) { return false; }
|
||||
|
||||
std::tie( DestinationSign.sign, DestinationSign.has_light ) = Model->GetSMRoot()->find_replacable4();
|
||||
|
||||
return DestinationSign.sign != nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
TDynamicObject::create_controller( std::string const Type, bool const Trainset ) {
|
||||
|
||||
@@ -2553,6 +2569,27 @@ na sprzęgach, opóźnienie działania hamulca itp. Oczywiście musi mieć to pe
|
||||
histerezę czasową, aby te tryby pracy nie przełączały się zbyt szybko.
|
||||
*/
|
||||
|
||||
void TDynamicObject::update_destinations() {
|
||||
|
||||
if( DestinationSign.sign == nullptr ) { return; }
|
||||
|
||||
DestinationSign.sign->fLight = (
|
||||
( ( DestinationSign.has_light ) && ( MoverParameters->Battery ) ) ?
|
||||
2.0 :
|
||||
-1.0 );
|
||||
|
||||
// jak są 4 tekstury wymienne, to nie zmieniać rozkładem
|
||||
if( std::abs( m_materialdata.multi_textures ) >= 4 ) { return; }
|
||||
// TODO: dedicated setting to discern electronic signs, instead of fallback on light presence
|
||||
m_materialdata.replacable_skins[ 4 ] = (
|
||||
( ( DestinationSign.destination != null_handle )
|
||||
&& ( ( false == DestinationSign.has_light ) // physical destination signs remain up until manually changed
|
||||
|| ( ( true == MoverParameters->Battery ) // lcd signs are off without power
|
||||
&& ( ctOwner != nullptr ) ) ) ) ? // lcd signs are off for carriages without engine, potentially left on a siding
|
||||
DestinationSign.destination :
|
||||
DestinationSign.destination_off );
|
||||
}
|
||||
|
||||
bool TDynamicObject::Update(double dt, double dt1)
|
||||
{
|
||||
if (dt1 == 0)
|
||||
@@ -4235,7 +4272,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
||||
}
|
||||
|
||||
// potentially set blank destination texture
|
||||
DestinationSet( {}, {} );
|
||||
DestinationSign.destination_off = DestinationFind( "nowhere" );
|
||||
// DestinationSet( {}, {} );
|
||||
|
||||
if( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
||||
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
@@ -6087,45 +6125,60 @@ int TDynamicObject::RouteWish(TTrack *tr)
|
||||
return Mechanik ? Mechanik->CrossRoute(tr) : 0; // wg AI albo prosto
|
||||
};
|
||||
|
||||
void TDynamicObject::DestinationSet(std::string to, std::string numer)
|
||||
{ // ustawienie stacji docelowej oraz wymiennej tekstury 4, jeśli istnieje plik
|
||||
void TDynamicObject::DestinationSet(std::string to, std::string numer) {
|
||||
// ustawienie stacji docelowej oraz wymiennej tekstury 4, jeśli istnieje plik
|
||||
// w zasadzie, to każdy wagon mógłby mieć inną stację docelową
|
||||
// zwłaszcza w towarowych, pod kątem zautomatyzowania maewrów albo pracy górki
|
||||
// ale to jeszcze potrwa, zanim będzie możliwe, na razie można wpisać stację z
|
||||
// rozkładu
|
||||
if( std::abs( m_materialdata.multi_textures ) >= 4 ) {
|
||||
// jak są 4 tekstury wymienne, to nie zmieniać rozkładem
|
||||
return;
|
||||
}
|
||||
numer = Bezogonkow(numer);
|
||||
|
||||
asDestination = to;
|
||||
to = Bezogonkow(to); // do szukania pliku obcinamy ogonki
|
||||
if( true == to.empty() ) {
|
||||
to = "nowhere";
|
||||
|
||||
if( std::abs( m_materialdata.multi_textures ) >= 4 ) { return; } // jak są 4 tekstury wymienne, to nie zmieniać rozkładem
|
||||
if( DestinationSign.sign == nullptr ) { return; } // no sign submodel, no problem
|
||||
|
||||
// now see if we can find any version of the destination texture
|
||||
std::vector<std::string> const destinations = {
|
||||
numer, // try dedicated timetable sign first...
|
||||
to }; // ...then generic destination sign
|
||||
|
||||
for( auto const &destination : destinations ) {
|
||||
|
||||
DestinationSign.destination = DestinationFind( destination );
|
||||
if( DestinationSign.destination != null_handle ) {
|
||||
// got what we wanted, we're done here
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material_handle TDynamicObject::DestinationFind( std::string Destination ) {
|
||||
|
||||
if( Destination.empty() ) { return null_handle; }
|
||||
|
||||
Destination = Bezogonkow( Destination ); // do szukania pliku obcinamy ogonki
|
||||
// destination textures are kept in the vehicle's directory so we point the current texture path there
|
||||
auto const currenttexturepath { Global.asCurrentTexturePath };
|
||||
Global.asCurrentTexturePath = asBaseDir;
|
||||
// now see if we can find any version of the texture
|
||||
std::vector<std::string> destinations = {
|
||||
numer + '@' + MoverParameters->TypeName,
|
||||
numer,
|
||||
to + '@' + MoverParameters->TypeName,
|
||||
to,
|
||||
"nowhere" + '@' + MoverParameters->TypeName,
|
||||
"nowhere" };
|
||||
std::vector<std::string> const destinations {
|
||||
Destination + '@' + MoverParameters->TypeName,
|
||||
Destination };
|
||||
|
||||
auto destinationhandle { null_handle };
|
||||
|
||||
for( auto const &destination : destinations ) {
|
||||
|
||||
auto material = TextureTest( ToLower( destination ) );
|
||||
if( false == material.empty() ) {
|
||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( material );
|
||||
destinationhandle = GfxRenderer.Fetch_Material( material );
|
||||
break;
|
||||
}
|
||||
}
|
||||
// whether we got anything, restore previous texture path
|
||||
Global.asCurrentTexturePath = currenttexturepath;
|
||||
};
|
||||
|
||||
return destinationhandle;
|
||||
}
|
||||
|
||||
void TDynamicObject::OverheadTrack(float o)
|
||||
{ // ewentualne wymuszanie jazdy
|
||||
|
||||
Reference in New Issue
Block a user