CanadianMachines / MachineLib / Machine.cpp
Machine.cpp
Raw
/**
 * @file Machine.cpp
 * @author sriram
 */

#include "pch.h"
#include "Machine.h"
#include "Component.h"

/**
 * constructor
 * @param num
 */
Machine::Machine(const int num): mNumber(num)
{

}


void Machine::Draw(std::shared_ptr<wxGraphicsContext> graphics,double x, double y)
{
	if (this!=nullptr)
	{
		for(auto component : mComponents)
		{
			component->Draw(graphics, x, y);
		}
	}
}
void Machine::AddComponent(std::shared_ptr<Component> component)
{
	component->SetMachine(this);
	mComponents.push_back(component);
}

void Machine::ClearMachine()
{
	mComponents.clear();
}

void Machine::Update()
{
	if (this!=nullptr)
	{
		for(auto component : mComponents)
		{
			component->SetTime(mTime);
		}
	}

}
void Machine::SetTime(double time)
{
	mTime = time;
	Update();
}