mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
refactor(unit): moved data update code from initialize to update; made initialize and update final
This commit is contained in:
@@ -19,12 +19,12 @@ public:
|
|||||||
~Unit();
|
~Unit();
|
||||||
|
|
||||||
/********** Methods **********/
|
/********** Methods **********/
|
||||||
void initialize(json::value json);
|
virtual void initialize(json::value json) final;
|
||||||
virtual void setDefaults(bool force = false);
|
virtual void setDefaults(bool force = false);
|
||||||
|
|
||||||
void runAILoop();
|
void runAILoop();
|
||||||
|
|
||||||
void update(json::value json, double dt);
|
virtual void update(json::value json, double dt) final;
|
||||||
void refreshLeaderData(unsigned long long time);
|
void refreshLeaderData(unsigned long long time);
|
||||||
|
|
||||||
unsigned int getID() { return ID; }
|
unsigned int getID() { return ID; }
|
||||||
|
|||||||
@@ -28,28 +28,6 @@ Unit::~Unit()
|
|||||||
|
|
||||||
void Unit::initialize(json::value json)
|
void Unit::initialize(json::value json)
|
||||||
{
|
{
|
||||||
if (json.has_string_field(L"name"))
|
|
||||||
setName(to_string(json[L"name"]));
|
|
||||||
|
|
||||||
if (json.has_string_field(L"unitName"))
|
|
||||||
setUnitName(to_string(json[L"unitName"]));
|
|
||||||
|
|
||||||
if (json.has_string_field(L"groupName"))
|
|
||||||
setGroupName(to_string(json[L"groupName"]));
|
|
||||||
|
|
||||||
if (json.has_string_field(L"callsign"))
|
|
||||||
setCallsign(to_string(json[L"callsign"]));
|
|
||||||
|
|
||||||
if (json.has_number_field(L"coalitionID"))
|
|
||||||
setCoalition(json[L"coalitionID"].as_number().to_int32());
|
|
||||||
|
|
||||||
//if (json.has_number_field(L"Country"))
|
|
||||||
// setCountry(json[L"Country"].as_number().to_int32());
|
|
||||||
|
|
||||||
/* All units which contain the name "Olympus" are automatically under AI control */
|
|
||||||
if (getUnitName().find("Olympus") != string::npos)
|
|
||||||
setControlled(true);
|
|
||||||
|
|
||||||
update(json, 0);
|
update(json, 0);
|
||||||
setDefaults();
|
setDefaults();
|
||||||
}
|
}
|
||||||
@@ -71,6 +49,12 @@ void Unit::update(json::value json, double dt)
|
|||||||
|
|
||||||
if (json.has_number_field(L"coalitionID"))
|
if (json.has_number_field(L"coalitionID"))
|
||||||
setCoalition(json[L"coalitionID"].as_number().to_int32());
|
setCoalition(json[L"coalitionID"].as_number().to_int32());
|
||||||
|
//if (json.has_number_field(L"Country"))
|
||||||
|
// setCountry(json[L"Country"].as_number().to_int32());
|
||||||
|
|
||||||
|
/* All units which contain the name "Olympus" are automatically under AI control */
|
||||||
|
if (getUnitName().find("Olympus") != string::npos)
|
||||||
|
setControlled(true);
|
||||||
|
|
||||||
if (json.has_object_field(L"position"))
|
if (json.has_object_field(L"position"))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user