Index: binaries/data/mods/public/simulation/components/Identity.js
===================================================================
--- binaries/data/mods/public/simulation/components/Identity.js
+++ binaries/data/mods/public/simulation/components/Identity.js
@@ -85,7 +85,12 @@
"" +
"" +
"" +
- "";
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "";
Identity.prototype.Init = function()
{
@@ -97,6 +102,7 @@
this.phenotype = "default";
this.controllable = this.template.Controllable ? this.template.Controllable == "true" : true;
+ this.isGaia = this.template.IsGaia ? this.template.IsGaia == "true" : false;
};
Identity.prototype.GetCiv = function()
@@ -198,6 +204,11 @@
return this.name || this.template.GenericName;
};
+Identity.prototype.IsGaia = function()
+{
+ return this.isGaia;
+};
+
function IdentityMirage() {}
IdentityMirage.prototype.Init = function(cmpIdentity)
{
Index: binaries/data/mods/public/simulation/templates/special/players/gaia.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/special/players/gaia.xml
+++ binaries/data/mods/public/simulation/templates/special/players/gaia.xml
@@ -5,6 +5,7 @@
Gaia
emblems/emblem_gaia.png
true
+ true
Index: binaries/data/mods/public/simulation/templates/template_gaia.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_gaia.xml
+++ binaries/data/mods/public/simulation/templates/template_gaia.xml
@@ -6,6 +6,7 @@
gaia
Gaia
true
+ true
true
Index: source/simulation2/components/ICmpIdentity.h
===================================================================
--- source/simulation2/components/ICmpIdentity.h
+++ source/simulation2/components/ICmpIdentity.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Wildfire Games.
+/* Copyright (C) 2023 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -33,6 +33,8 @@
virtual std::wstring GetCiv() = 0;
+ virtual bool IsGaia() = 0;
+
DECLARE_INTERFACE_TYPE(Identity)
};
Index: source/simulation2/components/ICmpIdentity.cpp
===================================================================
--- source/simulation2/components/ICmpIdentity.cpp
+++ source/simulation2/components/ICmpIdentity.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Wildfire Games.
+/* Copyright (C) 2023 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -45,6 +45,11 @@
{
return m_Script.Call("GetCiv");
}
+
+ bool IsGaia() override
+ {
+ return m_Script.Call("IsGaia");
+ }
};
REGISTER_COMPONENT_SCRIPT_WRAPPER(IdentityScripted)
Index: source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
===================================================================
--- source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
+++ source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2023 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -41,6 +41,7 @@
#include "renderer/Renderer.h"
#include "renderer/WaterManager.h"
#include "simulation2/Simulation2.h"
+#include "simulation2/components/ICmpIdentity.h"
#include "simulation2/components/ICmpObstruction.h"
#include "simulation2/components/ICmpOwnership.h"
#include "simulation2/components/ICmpPosition.h"
@@ -355,9 +356,12 @@
AtlasView* view = AtlasView::GetView(msg->view);
CSimulation2* simulation = view->GetSimulation2();
+ //get identity
+ CmpPtr cmpIdentity(*g_Game->GetSimulation2(), view->GetEntityId(msg->id));
+
CmpPtr cmpOwnership(*simulation, view->GetEntityId(msg->id));
if (cmpOwnership)
- cmpOwnership->SetOwner(player);
+ cmpOwnership->SetOwner(cmpIdentity && cmpIdentity->IsGaia() ? 0 : player);
// TODO: selections
// unit->SetActorSelections(selections);
@@ -439,11 +443,17 @@
cmpPositionNew->SetYRotation(rotation.Y);
}
+ //get identity
+ CmpPtr cmpIdentity(*g_Game->GetSimulation2(), ent);
+
//get owner
CmpPtr cmpOwnershipNew(*g_Game->GetSimulation2(), new_ent);
CmpPtr cmpOwnershipOld(*g_Game->GetSimulation2(), ent);
- if (cmpOwnershipNew && cmpOwnershipOld)
- cmpOwnershipNew->SetOwner(cmpOwnershipOld->GetOwner());
+ if (cmpOwnershipNew)
+ if (cmpIdentity && cmpIdentity->IsGaia())
+ cmpOwnershipNew->SetOwner(0);
+ else if (cmpOwnershipOld)
+ cmpOwnershipNew->SetOwner(cmpOwnershipOld->GetOwner());
//getVisual
CmpPtr cmpVisualNew(*g_Game->GetSimulation2(), new_ent);
@@ -563,9 +573,12 @@
if (cmpVisual)
cmpVisual->SetActorSeed(msg->actorseed);
+ //get identity
+ CmpPtr cmpIdentity(*g_Game->GetSimulation2(), g_PreviewEntityID);
+
CmpPtr cmpOwnership(*g_Game->GetSimulation2(), g_PreviewEntityID);
if (cmpOwnership)
- cmpOwnership->SetOwner((player_id_t)msg->settings->player);
+ cmpOwnership->SetOwner(cmpIdentity && cmpIdentity->IsGaia() ? 0 : (player_id_t)msg->settings->player);
CheckObstructionAndUpdateVisual(g_PreviewEntityID);
}
@@ -616,9 +629,12 @@
cmpPosition->SetYRotation(entity_angle_t::FromFloat(m_Angle));
}
+ //get identity
+ CmpPtr cmpIdentity(*g_Game->GetSimulation2(), m_EntityID);
+
CmpPtr cmpOwnership(*g_Game->GetSimulation2(), m_EntityID);
if (cmpOwnership)
- cmpOwnership->SetOwner(m_Player);
+ cmpOwnership->SetOwner(cmpIdentity && cmpIdentity->IsGaia() ? 0 : m_Player);
CmpPtr cmpVisual(*g_Game->GetSimulation2(), m_EntityID);
if (cmpVisual)
@@ -1072,10 +1088,13 @@
cmpPosition->SetXZRotation(oldObjects[i].rot.X, oldObjects[i].rot.Z);
cmpPosition->SetYRotation(oldObjects[i].rot.Y);
}
+
+ //get identity
+ CmpPtr cmpIdentity(sim, oldObjects[i].entityID);
CmpPtr cmpOwnership(sim, oldObjects[i].entityID);
if (cmpOwnership)
- cmpOwnership->SetOwner(oldObjects[i].owner);
+ cmpOwnership->SetOwner(cmpIdentity && cmpIdentity->IsGaia() ? 0 : oldObjects[i].owner);
CmpPtr cmpVisual(sim, oldObjects[i].entityID);
if (cmpVisual)