mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
refactor: adding back country, group id and original unit id to the unit data for future uses
This commit is contained in:
parent
edc3529b67
commit
5237dc688a
@ -16,6 +16,8 @@ namespace DataIndex {
|
||||
name,
|
||||
unitName,
|
||||
callsign,
|
||||
unitID,
|
||||
groupID,
|
||||
groupName,
|
||||
state,
|
||||
task,
|
||||
|
||||
@ -75,6 +75,8 @@ public:
|
||||
virtual void setName(string newValue) { updateValue(name, newValue, DataIndex::name); }
|
||||
virtual void setUnitName(string newValue) { updateValue(unitName, newValue, DataIndex::unitName); }
|
||||
virtual void setCallsign(string newValue) { updateValue(callsign, newValue, DataIndex::callsign); }
|
||||
virtual void setUnitID(unsigned char newValue) { updateValue(unitID, newValue, DataIndex::unitID); }
|
||||
virtual void setGroupID(unsigned char newValue) { updateValue(groupID, newValue, DataIndex::groupID); }
|
||||
virtual void setGroupName(string newValue) { updateValue(groupName, newValue, DataIndex::groupName); }
|
||||
virtual void setState(unsigned char newValue) { updateValue(state, newValue, DataIndex::state); };
|
||||
virtual void setTask(string newValue) { updateValue(task, newValue, DataIndex::task); }
|
||||
@ -141,6 +143,8 @@ public:
|
||||
virtual string getCallsign() { return callsign; }
|
||||
virtual string getUnitName() { return unitName; }
|
||||
virtual string getGroupName() { return groupName; }
|
||||
virtual unsigned char getUnitID() { return unitID; }
|
||||
virtual unsigned char getGroupID() { return groupID; }
|
||||
virtual unsigned char getState() { return state; }
|
||||
virtual string getTask() { return task; }
|
||||
virtual bool getHasTask() { return hasTask; }
|
||||
@ -206,6 +210,8 @@ protected:
|
||||
string name = "";
|
||||
string unitName = "";
|
||||
string callsign = "";
|
||||
unsigned char unitID = NULL;
|
||||
unsigned char groupID = NULL;
|
||||
string groupName = "";
|
||||
unsigned char state = State::NONE;
|
||||
unsigned char alarmState = AlarmState::AUTO;
|
||||
|
||||
@ -41,6 +41,11 @@ void Unit::update(json::value json, double dt)
|
||||
if (json.has_string_field(L"unitName"))
|
||||
setUnitName(to_string(json[L"unitName"]));
|
||||
|
||||
if (json.has_number_field(L"groupID"))
|
||||
setGroupID(json[L"groupID"].as_number().to_int32());
|
||||
if (json.has_number_field(L"unitID"))
|
||||
setUnitID(json[L"unitID"].as_number().to_int32());
|
||||
|
||||
if (json.has_string_field(L"groupName"))
|
||||
setGroupName(to_string(json[L"groupName"]));
|
||||
|
||||
@ -49,8 +54,8 @@ void Unit::update(json::value json, double dt)
|
||||
|
||||
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());
|
||||
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)
|
||||
@ -267,6 +272,8 @@ void Unit::getData(stringstream& ss, unsigned long long time)
|
||||
case DataIndex::name: appendString(ss, datumIndex, name); break;
|
||||
case DataIndex::unitName: appendString(ss, datumIndex, unitName); break;
|
||||
case DataIndex::callsign: appendString(ss, datumIndex, callsign); break;
|
||||
case DataIndex::unitID: appendNumeric(ss, datumIndex, unitID); break;
|
||||
case DataIndex::groupID: appendNumeric(ss, datumIndex, groupID); break;
|
||||
case DataIndex::groupName: appendString(ss, datumIndex, groupName); break;
|
||||
case DataIndex::state: appendNumeric(ss, datumIndex, state); break;
|
||||
case DataIndex::task: appendString(ss, datumIndex, task); break;
|
||||
|
||||
@ -462,6 +462,8 @@ export enum DataIndexes {
|
||||
name,
|
||||
unitName,
|
||||
callsign,
|
||||
unitID,
|
||||
groupID,
|
||||
groupName,
|
||||
state,
|
||||
task,
|
||||
|
||||
@ -232,6 +232,8 @@ export interface UnitData {
|
||||
name: string;
|
||||
unitName: string;
|
||||
callsign: string;
|
||||
unitID: number;
|
||||
groupID: number;
|
||||
groupName: string;
|
||||
state: string;
|
||||
task: string;
|
||||
|
||||
@ -97,6 +97,8 @@ export abstract class Unit extends CustomMarker {
|
||||
#name: string = "";
|
||||
#unitName: string = "";
|
||||
#callsign: string = "";
|
||||
#unitID: number = 0;
|
||||
#groupID: number = 0;
|
||||
#groupName: string = "";
|
||||
#state: string = states[0];
|
||||
#task: string = "";
|
||||
@ -236,6 +238,12 @@ export abstract class Unit extends CustomMarker {
|
||||
getCallsign() {
|
||||
return this.#callsign;
|
||||
}
|
||||
getUnitID() {
|
||||
return this.#unitID;
|
||||
}
|
||||
getGroupID() {
|
||||
return this.#groupID;
|
||||
}
|
||||
getGroupName() {
|
||||
return this.#groupName;
|
||||
}
|
||||
@ -611,6 +619,14 @@ export abstract class Unit extends CustomMarker {
|
||||
case DataIndexes.callsign:
|
||||
this.#callsign = dataExtractor.extractString();
|
||||
break;
|
||||
case DataIndexes.unitID:
|
||||
this.#unitID = dataExtractor.extractUInt8();
|
||||
updateMarker = true;
|
||||
break;
|
||||
case DataIndexes.groupID:
|
||||
this.#groupID = dataExtractor.extractUInt8();
|
||||
updateMarker = true;
|
||||
break;
|
||||
case DataIndexes.groupName:
|
||||
this.#groupName = dataExtractor.extractString();
|
||||
updateMarker = true;
|
||||
@ -851,6 +867,8 @@ export abstract class Unit extends CustomMarker {
|
||||
name: this.#name,
|
||||
unitName: this.#unitName,
|
||||
callsign: this.#callsign,
|
||||
unitID: this.#unitID,
|
||||
groupID: this.#groupID,
|
||||
groupName: this.#groupName,
|
||||
state: this.#state,
|
||||
task: this.#task,
|
||||
@ -1624,9 +1642,6 @@ export abstract class Unit extends CustomMarker {
|
||||
|
||||
/** Show temporary engagement ring when unit is selected */
|
||||
showTemporaryEngagementRing() {
|
||||
console.log(`Show temporary engagement ring for ${this.getUnitName()}, engagement range: ${this.#engagementRange}`);
|
||||
|
||||
|
||||
if (!getApp().getMap().getOptions().showUnitsEngagementRings
|
||||
&& !getApp().getMap().getOptions().showUnitsAcquisitionRings
|
||||
&& this.#engagementRange > 0) {
|
||||
@ -1717,8 +1732,6 @@ export abstract class Unit extends CustomMarker {
|
||||
|
||||
if (this.#debounceTimeout) window.clearTimeout(this.#debounceTimeout);
|
||||
this.#debounceTimeout = window.setTimeout(() => {
|
||||
console.log(`Left short click on ${this.getUnitName()}`);
|
||||
|
||||
if (getApp().getState() === OlympusState.UNIT_CONTROL && getApp().getMap().getContextAction()) {
|
||||
if (getApp().getMap().getContextAction()?.getTarget() === ContextActionTarget.UNIT) getApp().getMap().executeContextAction(this, null, e.originalEvent);
|
||||
else getApp().getMap().executeContextAction(null, this.getPosition(), e.originalEvent);
|
||||
@ -1730,8 +1743,6 @@ export abstract class Unit extends CustomMarker {
|
||||
}
|
||||
|
||||
#onLeftLongClick(e: any) {
|
||||
console.log(`Left long click on ${this.getUnitName()}`);
|
||||
|
||||
if (getApp().getState() === OlympusState.IDLE) {
|
||||
this.setSelected(!this.getSelected());
|
||||
|
||||
@ -1756,8 +1767,6 @@ export abstract class Unit extends CustomMarker {
|
||||
}
|
||||
|
||||
#onRightShortClick(e: any) {
|
||||
console.log(`Right short click on ${this.getUnitName()}`);
|
||||
|
||||
window.clearTimeout(this.#rightMouseDownTimeout);
|
||||
if (
|
||||
getApp().getState() === OlympusState.UNIT_CONTROL &&
|
||||
@ -1768,7 +1777,7 @@ export abstract class Unit extends CustomMarker {
|
||||
}
|
||||
|
||||
#onRightLongClick(e: any) {
|
||||
console.log(`Right long click on ${this.getUnitName()}`);
|
||||
// console.log(`Right long click on ${this.getUnitName()}`);
|
||||
}
|
||||
|
||||
#onDoubleClick(e: any) {
|
||||
@ -1776,8 +1785,6 @@ export abstract class Unit extends CustomMarker {
|
||||
DomEvent.preventDefault(e);
|
||||
e.originalEvent.stopImmediatePropagation();
|
||||
|
||||
console.log(`Double click on ${this.getUnitName()}`);
|
||||
|
||||
if (this.#debounceTimeout) window.clearTimeout(this.#debounceTimeout);
|
||||
|
||||
/* Select all matching units in the viewport */
|
||||
|
||||
@ -1249,6 +1249,7 @@ function Olympus.setUnitsData(arg, time)
|
||||
local airborne = unit:inAir()
|
||||
|
||||
-- Fill the data table
|
||||
table["unitID"] = unit:getID()
|
||||
table["name"] = unit:getTypeName()
|
||||
table["coalitionID"] = unit:getCoalition()
|
||||
table["position"] = {}
|
||||
@ -1276,13 +1277,14 @@ function Olympus.setUnitsData(arg, time)
|
||||
|
||||
table["isAlive"] = unit:isExist() and unit:isActive() and unit:getLife() >= 1
|
||||
|
||||
if unit:isActive() and unit:hasSensors(Unit.SensorType.RADAR) then
|
||||
--[[ COMMENTING OUT BECAUSE OF CRASHES -- TO BE INVESTIGATED LATER ON ]]--
|
||||
--[[ if unit:isActive() and unit:hasSensors(Unit.SensorType.RADAR) then
|
||||
if unit:getRadar() then
|
||||
table["radarState"] = true
|
||||
else
|
||||
table["radarState"] = false
|
||||
end
|
||||
end
|
||||
end ]]
|
||||
|
||||
local group = unit:getGroup()
|
||||
if group ~= nil then
|
||||
@ -1322,6 +1324,7 @@ function Olympus.setUnitsData(arg, time)
|
||||
end
|
||||
-- In case of AI units the callSign and the unitName will be the same
|
||||
table["callsign"] = unit:getName()
|
||||
table["groupID"] = group:getID()
|
||||
table["groupName"] = group:getName()
|
||||
table["isHuman"] = (unit:getPlayerName() ~= nil)
|
||||
table["hasTask"] = controller:hasTask()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user