mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 11:09:19 +02:00
tmj merge
This commit is contained in:
63
MemCell.cpp
63
MemCell.cpp
@@ -16,26 +16,23 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "MemCell.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "simulation.h"
|
||||
#include "Logs.h"
|
||||
#include "usefull.h"
|
||||
#include "Driver.h"
|
||||
#include "Event.h"
|
||||
#include "parser.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// legacy constructor
|
||||
TMemCell::TMemCell(vector3 *p)
|
||||
{
|
||||
fValue1 = fValue2 = 0;
|
||||
vPosition =
|
||||
p ? *p : vector3(0, 0, 0); // ustawienie współrzędnych, bo do TGroundNode nie ma dostępu
|
||||
location(
|
||||
p ? *p : vector3() ); // ustawienie współrzędnych, bo do TGroundNode nie ma dostępu
|
||||
bCommand = false; // komenda wysłana
|
||||
OnSent = NULL;
|
||||
}
|
||||
void TMemCell::Init()
|
||||
{
|
||||
}
|
||||
|
||||
TMemCell::TMemCell( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
|
||||
|
||||
void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask )
|
||||
{
|
||||
if (CheckMask & update_memadd)
|
||||
@@ -103,10 +100,12 @@ TCommandType TMemCell::CommandCheck()
|
||||
bool TMemCell::Load(cParser *parser)
|
||||
{
|
||||
std::string token;
|
||||
parser->getTokens(1, false); // case sensitive
|
||||
*parser >> szText;
|
||||
parser->getTokens( 2, false );
|
||||
parser->getTokens( 6, false );
|
||||
*parser
|
||||
>> m_area.center.x
|
||||
>> m_area.center.y
|
||||
>> m_area.center.z
|
||||
>> szText
|
||||
>> fValue1
|
||||
>> fValue2;
|
||||
parser->getTokens();
|
||||
@@ -121,7 +120,7 @@ bool TMemCell::Load(cParser *parser)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMemCell::PutCommand(TController *Mech, vector3 *Loc)
|
||||
void TMemCell::PutCommand( TController *Mech, glm::dvec3 const *Loc )
|
||||
{ // wysłanie zawartości komórki do AI
|
||||
if (Mech)
|
||||
Mech->PutCommand(szText, fValue1, fValue2, Loc);
|
||||
@@ -150,11 +149,6 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
|
||||
&& ( !TestFlag( CheckMask, conditional_memval2 ) || ( fValue2 == fTestValue2 ) ) );
|
||||
};
|
||||
|
||||
bool TMemCell::Render()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMemCell::IsVelocity()
|
||||
{ // sprawdzenie, czy event odczytu tej komórki ma być do skanowania, czy do kolejkowania
|
||||
if (eCommand == cm_SetVelocity)
|
||||
@@ -169,11 +163,38 @@ void TMemCell::StopCommandSent()
|
||||
if (!bCommand)
|
||||
return;
|
||||
bCommand = false;
|
||||
if (OnSent) // jeśli jest event
|
||||
Global::AddToQuery(OnSent, NULL);
|
||||
if( OnSent ) {
|
||||
// jeśli jest event
|
||||
simulation::Events.AddToQuery( OnSent, nullptr );
|
||||
}
|
||||
};
|
||||
|
||||
void TMemCell::AssignEvents(TEvent *e)
|
||||
{ // powiązanie eventu
|
||||
OnSent = e;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// legacy method, initializes traction after deserialization from scenario file
|
||||
void
|
||||
memory_table::InitCells() {
|
||||
|
||||
for( auto *cell : m_items ) {
|
||||
// Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu
|
||||
cell->AssignEvents( simulation::Events.FindEvent( cell->name() + ":sent" ) );
|
||||
}
|
||||
}
|
||||
|
||||
// legacy method, sends content of all cells to the log
|
||||
void
|
||||
memory_table::log_all() {
|
||||
|
||||
for( auto *cell : m_items ) {
|
||||
|
||||
WriteLog( "Memcell \"" + cell->name() + "\": ["
|
||||
+ cell->Text() + "] ["
|
||||
+ to_string( cell->Value1(), 2 ) + "] ["
|
||||
+ to_string( cell->Value2(), 2 ) + "]" );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user