Ticket #599: fogging.patch
File fogging.patch, 33.3 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/simulation/components/BuildingAI.js
335 335 336 336 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 337 337 338 // Entities that are hidden and miraged are considered visible 339 var cmpFogging = Engine.QueryInterface(target, IID_Fogging); 340 if (cmpFogging && cmpFogging.IsMiraged(cmpOwnership.GetOwner())) 341 return true; 342 338 343 if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner(), false) == "hidden") 339 344 return false; 340 345 -
binaries/data/mods/public/simulation/components/BuildRestrictions.js
102 102 if (!cmpRangeManager || !cmpOwnership) 103 103 return result; // Fail 104 104 105 var cmpFogging = Engine.QueryInterface(this.entity, IID_Fogging); 105 106 var explored = (cmpRangeManager.GetLosVisibility(this.entity, cmpOwnership.GetOwner(), true) != "hidden"); 106 if (!explored )107 if (!explored && !(cmpFogging && cmpFogging.IsMiraged(cmpOwnership.GetOwner()))) 107 108 { 108 109 result.message = markForTranslation("%(name)s cannot be built in unexplored area"); 109 110 return result; // Fail -
binaries/data/mods/public/simulation/components/GuiInterface.js
175 175 "garrisonHolder": null, 176 176 "gate": null, 177 177 "guard": null, 178 "mirage": null, 178 179 "pack": null, 179 180 "player": -1, 180 181 "position": null, … … 303 304 }; 304 305 } 305 306 307 var cmpMirage = Engine.QueryInterface(ent, IID_Mirage); 308 if (cmpMirage) 309 { 310 ret.mirage = { 311 "parent": cmpMirage.GetParent(), 312 }; 313 } 314 306 315 var cmpGate = Engine.QueryInterface(ent, IID_Gate); 307 316 if (cmpGate) 308 317 { -
binaries/data/mods/public/simulation/components/interfaces/Messages.js
1 /**2 * Broadcast message3 * sent when one entity is changed to other:4 * from Foundation component when building constuction is done5 * and from Promotion component when unit is promoted6 * Data: { entity: <integer>, newentity: <integer> }7 */8 Engine.RegisterMessageType("EntityRenamed");9 10 1 Engine.RegisterMessageType("DiplomacyChanged"); -
binaries/data/mods/public/simulation/components/UnitAI.js
3896 3896 if (cmpFormation) 3897 3897 return true; 3898 3898 3899 var cmpMirage = Engine.QueryInterface(ent, IID_Mirage); 3900 if (cmpMirage) 3901 return true; 3902 3899 3903 var cmpHealth = Engine.QueryInterface(ent, IID_Health); 3900 3904 if (!cmpHealth) 3901 3905 return false; … … 4386 4390 if (!cmpRangeManager) 4387 4391 return false; 4388 4392 4393 // Entities that are hidden and miraged are considered visible 4394 var cmpFogging = Engine.QueryInterface(target, IID_Fogging); 4395 if (cmpFogging && cmpFogging.IsMiraged(cmpOwnership.GetOwner())) 4396 return true; 4397 4389 4398 if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner(), false) == "hidden") 4390 4399 return false; 4391 4400 -
binaries/data/mods/public/simulation/templates/template_gaia.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_entity_quasi"> 3 <Fogging/> 3 4 <Identity> 4 5 <Civ>gaia</Civ> 5 6 <GenericName>Gaia</GenericName> -
binaries/data/mods/public/simulation/templates/template_structure.xml
37 37 <SinkRate>3.0</SinkRate> 38 38 <SinkAccel>9.8</SinkAccel> 39 39 </Decay> 40 <Fogging/> 40 41 <Health> 41 42 <DeathType>corpse</DeathType> 42 43 <RegenRate>0</RegenRate> -
source/ps/TemplateLoader.cpp
80 80 return true; 81 81 } 82 82 83 // Handle special case "mirage|foo" 84 if (templateName.find("mirage|") == 0) 85 { 86 // Load the base entity template, if it wasn't already loaded 87 std::string baseName = templateName.substr(7); 88 if (!LoadTemplateFile(baseName, depth+1)) 89 { 90 LOGERROR(L"Failed to load entity template '%hs'", baseName.c_str()); 91 return false; 92 } 93 // Copy a subset to the requested template 94 CopyMirageSubset(m_TemplateFileData[templateName], m_TemplateFileData[baseName]); 95 return true; 96 } 97 83 98 // Handle special case "foundation|foo" 84 99 if (templateName.find("foundation|") == 0) 85 100 { … … 319 334 } 320 335 } 321 336 337 void CTemplateLoader::CopyMirageSubset(CParamNode& out, const CParamNode& in) 338 { 339 // Currently used for mirage entities replacing real ones in fog-of-war 340 341 std::set<std::string> permittedComponentTypes; 342 permittedComponentTypes.insert("Footprint"); 343 permittedComponentTypes.insert("Health"); 344 permittedComponentTypes.insert("Minimap"); 345 permittedComponentTypes.insert("Ownership"); 346 permittedComponentTypes.insert("Position"); 347 permittedComponentTypes.insert("ResourceSupply"); 348 permittedComponentTypes.insert("Selectable"); 349 permittedComponentTypes.insert("VisualActor"); 350 351 CParamNode::LoadXMLString(out, "<Entity/>"); 352 out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes); 353 354 // Select a subset of identity data. We don't want to have, for example, a CC mirage 355 // that has also the CC class and then prevents construction of other CCs 356 std::set<std::string> identitySubset; 357 identitySubset.insert("Civ"); 358 identitySubset.insert("GenericName"); 359 identitySubset.insert("SpecificName"); 360 identitySubset.insert("Tooltip"); 361 identitySubset.insert("History"); 362 identitySubset.insert("Icon"); 363 CParamNode identity; 364 CParamNode::LoadXMLString(identity, "<Identity/>"); 365 identity.CopyFilteredChildrenOfChild(in.GetChild("Entity"), "Identity", identitySubset); 366 CParamNode::LoadXMLString(out, ("<Entity>"+utf8_from_wstring(identity.ToXML())+"</Entity>").c_str()); 367 368 // Set the entity as mirage entity 369 CParamNode::LoadXMLString(out, "<Entity><Mirage/></Entity>"); 370 CParamNode::LoadXMLString(out, "<Entity><Vision><Range>0</Range><RetainInFog>true</RetainInFog><AlwaysVisible>false</AlwaysVisible></Vision></Entity>"); 371 } 372 322 373 void CTemplateLoader::CopyFoundationSubset(CParamNode& out, const CParamNode& in) 323 374 { 324 375 // TODO: this is all kind of yucky and hard-coded; it'd be nice to have a more generic … … 333 384 permittedComponentTypes.insert("Obstruction"); 334 385 permittedComponentTypes.insert("Selectable"); 335 386 permittedComponentTypes.insert("Footprint"); 387 permittedComponentTypes.insert("Fogging"); 336 388 permittedComponentTypes.insert("Armour"); 337 389 permittedComponentTypes.insert("Health"); 338 390 permittedComponentTypes.insert("StatusBars"); -
source/ps/TemplateLoader.h
76 76 void CopyPreviewSubset(CParamNode& out, const CParamNode& in, bool corpse); 77 77 78 78 /** 79 * Copy the components of an entity template necessary for a fogged "mirage" 80 * entity (position, actor) into a new entity template 81 */ 82 void CopyMirageSubset(CParamNode& out, const CParamNode& in); 83 84 /** 79 85 * Copy the components of an entity template necessary for a construction foundation 80 86 * (position, actor, armour, health, etc) into a new entity template 81 87 */ -
source/simulation2/components/CCmpFogging.cpp
1 /* Copyright (C) 2014 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "simulation2/system/Component.h" 21 #include "ICmpFogging.h" 22 23 #include "lib/utf8.h" 24 25 #include "ICmpOwnership.h" 26 #include "ICmpPlayerManager.h" 27 #include "ICmpRangeManager.h" 28 #include "ICmpTemplateManager.h" 29 #include "ICmpVisual.h" 30 31 #include "ICmpMirage.h" 32 #include "ICmpPosition.h" 33 34 class CCmpFogging : public ICmpFogging 35 { 36 public: 37 static void ClassInit(CComponentManager& componentManager) 38 { 39 componentManager.SubscribeToMessageType(MT_Update); 40 componentManager.SubscribeToMessageType(MT_Destroy); 41 } 42 43 DEFAULT_COMPONENT_ALLOCATOR(Fogging) 44 45 static std::string GetSchema() 46 { 47 return "<a:help>Allows this entity to be replaced by mirages entities in the fog-of-war.</a:help>" 48 "<empty/>"; 49 } 50 51 virtual void Init(const CParamNode& UNUSED(paramNode)) 52 { 53 CmpPtr<ICmpPlayerManager> cmpPlayerManager(GetSystemEntity()); 54 size_t numPlayers = cmpPlayerManager->GetNumPlayers(); 55 56 for (size_t i = 0; i < numPlayers; ++i) 57 { 58 m_Mirages.push_back(INVALID_ENTITY); 59 m_Miraged.push_back(false); 60 } 61 } 62 63 virtual void Deinit() 64 { 65 } 66 67 virtual void Serialize(ISerializer& serialize) 68 { 69 serialize.NumberU32_Unbounded("num players", m_Mirages.size()); 70 71 for (size_t i = 0; i < m_Mirages.size(); ++i) 72 { 73 serialize.NumberU32_Unbounded("mirage entity id", m_Mirages[i]); 74 serialize.Bool("miraging enabled", m_Miraged[i]); 75 } 76 } 77 78 virtual void Deserialize(const CParamNode& UNUSED(paramNode), IDeserializer& deserialize) 79 { 80 uint32_t numPlayers; 81 deserialize.NumberU32_Unbounded("num players", numPlayers); 82 83 entity_id_t ent; 84 bool enabled; 85 for (size_t i = 0; i < numPlayers; ++i) 86 { 87 deserialize.NumberU32_Unbounded("mirage entity id", ent); 88 m_Mirages.push_back(ent); 89 90 deserialize.Bool("miraging enabled", enabled); 91 m_Miraged.push_back(enabled); 92 } 93 } 94 95 virtual void HandleMessage(const CMessage& msg, bool UNUSED(global)) 96 { 97 switch (msg.GetType()) 98 { 99 case MT_Update: 100 UpdateMirages(); 101 break; 102 case MT_Destroy: 103 for (std::vector<entity_id_t>::iterator it = m_Mirages.begin(); it < m_Mirages.end(); ++it) 104 { 105 CmpPtr<ICmpMirage> cmpMirage(GetSimContext(), *it); 106 if (cmpMirage) 107 cmpMirage->SetParent(INVALID_ENTITY); 108 } 109 break; 110 } 111 } 112 113 virtual void UpdateMirages() 114 { 115 CComponentManager& componentManager = GetSimContext().GetComponentManager(); 116 CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); 117 CmpPtr<ICmpTemplateManager> cmpTemplateManager(GetSystemEntity()); 118 119 std::string templateName = "mirage|" + cmpTemplateManager->GetCurrentTemplateName(GetEntityId()); 120 121 for (size_t player = 0; player < m_Mirages.size(); ++player) 122 { 123 ICmpRangeManager::ELosVisibility visibility = cmpRangeManager->GetLosVisibility(GetEntityHandle(), player); 124 125 // Nothing to update 126 if (visibility == ICmpRangeManager::VIS_FOGGED) 127 continue; 128 129 // Destroy mirages when we get back into LoS 130 if (visibility == ICmpRangeManager::VIS_VISIBLE) 131 { 132 if (m_Mirages[player] != INVALID_ENTITY) 133 { 134 componentManager.DestroyComponentsSoon(m_Mirages[player]); 135 m_Mirages[player] = INVALID_ENTITY; 136 } 137 continue; 138 } 139 140 // Else, we are hidden and we should consider miraging 141 if (!m_Miraged[player] || m_Mirages[player] != INVALID_ENTITY) 142 continue; 143 144 m_Mirages[player] = componentManager.AllocateNewEntity(); 145 componentManager.AddEntity(wstring_from_utf8(templateName), m_Mirages[player]); 146 147 CmpPtr<ICmpMirage> cmpMirage(GetSimContext(), m_Mirages[player]); 148 if (!cmpMirage) 149 { 150 LOGERROR(L"Failed to load mirage entity for template %hs", templateName.c_str()); 151 m_Mirages[player] = INVALID_ENTITY; 152 continue; 153 } 154 155 // Setup basic mirage properties 156 cmpMirage->SetPlayer(player); 157 cmpMirage->SetParent(GetEntityId()); 158 159 // Copy cmpOwnership data 160 CmpPtr<ICmpOwnership> cmpParentOwnership(GetEntityHandle()); 161 if (!cmpParentOwnership) 162 { 163 LOGERROR(L"Failed to access the ownership data of the fogged entity %hs", templateName.c_str()); 164 continue; 165 } 166 CmpPtr<ICmpOwnership> cmpMirageOwnership(GetSimContext(), m_Mirages[player]); 167 if (!cmpMirageOwnership) 168 { 169 LOGERROR(L"No valid Ownership in template %hs", templateName.c_str()); 170 continue; 171 } 172 player_id_t parentOwner = cmpParentOwnership->GetOwner(); 173 cmpMirageOwnership->SetOwner(parentOwner); 174 175 // Copy cmpPosition data 176 CmpPtr<ICmpPosition> cmpParentPosition(GetEntityHandle()); 177 if (!cmpParentPosition) 178 { 179 LOGERROR(L"Failed to access the position data of the fogged entity %hs", templateName.c_str()); 180 continue; 181 } 182 CmpPtr<ICmpPosition> cmpMiragePosition(GetSimContext(), m_Mirages[player]); 183 if (!cmpMiragePosition) 184 { 185 LOGERROR(L"No valid Position component in template %hs", templateName.c_str()); 186 continue; 187 } 188 // The entity may not have been moved in-world yet, if we are e.g. placing a new building 189 if (!cmpParentPosition->IsInWorld()) 190 continue; 191 CFixedVector3D pos = cmpParentPosition->GetPosition(); 192 cmpMiragePosition->JumpTo(pos.X, pos.Z); 193 CFixedVector3D rot = cmpParentPosition->GetRotation(); 194 cmpMiragePosition->SetXZRotation(rot.X, rot.Z); 195 cmpMiragePosition->SetYRotation(rot.Y); 196 197 // Copy cmpVisualActor data 198 CmpPtr<ICmpVisual> cmpParentVisualActor(GetEntityHandle()); 199 if (!cmpParentVisualActor) 200 { 201 LOGERROR(L"Failed to access the visual actor of the fogged entity %hs", templateName.c_str()); 202 continue; 203 } 204 CmpPtr<ICmpVisual> cmpMirageVisualActor(GetSimContext(), m_Mirages[player]); 205 if (!cmpMirageVisualActor) 206 { 207 LOGERROR(L"No valid Visual actor in template %hs", templateName.c_str()); 208 continue; 209 } 210 u32 parentSeed = cmpParentVisualActor->GetActorSeed(); 211 cmpMirageVisualActor->SetActorSeed(parentSeed); 212 } 213 } 214 215 virtual bool IsMiraged(player_id_t player) 216 { 217 if (player > m_Miraged.size()) 218 { 219 LOGERROR(L"Tried to query miraging info for invalid player"); 220 return false; 221 } 222 223 return m_Miraged[player]; 224 } 225 226 virtual void SetMiraged(player_id_t player, bool enable) 227 { 228 if (player > m_Miraged.size()) 229 { 230 LOGERROR(L"Tried to enable/disable a mirage for invalid player"); 231 return; 232 } 233 234 m_Miraged[player] = enable; 235 } 236 237 private: 238 /// Vector of mirages, one for each player 239 std::vector<entity_id_t> m_Mirages; 240 241 /// For each player, remember if the entity must be mirage'd 242 /// (i.e. has already been seen) or not. 243 std::vector<bool> m_Miraged; 244 }; 245 246 REGISTER_COMPONENT_TYPE(Fogging) -
source/simulation2/components/CCmpMirage.cpp
Property changes on: source/simulation2/components/CCmpFogging.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 /* Copyright (C) 2014 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "simulation2/system/Component.h" 21 #include "simulation2/MessageTypes.h" 22 #include "ICmpMirage.h" 23 #include "ICmpRangeManager.h" 24 25 class CCmpMirage : public ICmpMirage 26 { 27 public: 28 static void ClassInit(CComponentManager& componentManager) 29 { 30 componentManager.SubscribeToMessageType(MT_Update); 31 componentManager.SubscribeToMessageType(MT_Destroy); 32 } 33 34 DEFAULT_COMPONENT_ALLOCATOR(Mirage) 35 36 static std::string GetSchema() 37 { 38 return "<a:help>Mirage entities replace real entities in the fog-of-war.</a:help>" 39 "<empty/>"; 40 } 41 42 virtual void Init(const CParamNode& UNUSED(paramNode)) 43 { 44 } 45 46 virtual void Deinit() 47 { 48 } 49 50 template<typename S> 51 void SerializeCommon(S& serialize) 52 { 53 serialize.NumberI32_Unbounded("player", m_Player); 54 serialize.NumberU32_Unbounded("parent", m_Parent); 55 } 56 57 virtual void Serialize(ISerializer& serialize) 58 { 59 SerializeCommon(serialize); 60 } 61 62 virtual void Deserialize(const CParamNode& UNUSED(paramNode), IDeserializer& deserialize) 63 { 64 SerializeCommon(deserialize); 65 } 66 67 virtual void HandleMessage(const CMessage& msg, bool UNUSED(global)) 68 { 69 switch (msg.GetType()) 70 { 71 case MT_Update: 72 { 73 CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); 74 ICmpRangeManager::ELosVisibility visibility = cmpRangeManager->GetLosVisibility(GetEntityHandle(), m_Player); 75 if (visibility == ICmpRangeManager::VIS_VISIBLE && m_Parent == INVALID_ENTITY) 76 GetSimContext().GetComponentManager().DestroyComponentsSoon(GetEntityId()); 77 break; 78 } 79 case MT_Destroy: 80 { 81 if (GetParent() == INVALID_ENTITY) 82 break; 83 84 CMessageEntityRenamed msg(GetEntityId(), GetParent()); 85 GetSimContext().GetComponentManager().BroadcastMessage(msg); 86 break; 87 } 88 } 89 } 90 91 virtual void SetPlayer(player_id_t player) 92 { 93 m_Player = player; 94 } 95 96 virtual player_id_t GetPlayer() 97 { 98 return m_Player; 99 } 100 101 virtual void SetParent(entity_id_t ent) 102 { 103 m_Parent = ent; 104 } 105 106 virtual entity_id_t GetParent() 107 { 108 return m_Parent; 109 } 110 111 private: 112 player_id_t m_Player; 113 entity_id_t m_Parent; 114 }; 115 116 REGISTER_COMPONENT_TYPE(Mirage) -
source/simulation2/components/CCmpRangeManager.cpp
Property changes on: source/simulation2/components/CCmpMirage.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2014 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 23 23 #include "ICmpTerrain.h" 24 24 #include "simulation2/system/EntityMap.h" 25 25 #include "simulation2/MessageTypes.h" 26 #include "simulation2/components/ICmpFogging.h" 27 #include "simulation2/components/ICmpMirage.h" 28 #include "simulation2/components/ICmpOwnership.h" 26 29 #include "simulation2/components/ICmpPosition.h" 27 30 #include "simulation2/components/ICmpTerritoryManager.h" 28 31 #include "simulation2/components/ICmpVision.h" … … 1364 1367 CLosQuerier los(GetSharedLosMask(player), m_LosState, m_TerrainVerticesPerSide); 1365 1368 1366 1369 if (los.IsVisible(i, j)) 1370 { 1371 // If we see an entity, we should mirage it as soon as it falls into fog-of-war 1372 CmpPtr<ICmpFogging> cmpFogging(ent); 1373 if (cmpFogging) 1374 cmpFogging->SetMiraged(player, true); 1375 1367 1376 return VIS_VISIBLE; 1377 } 1368 1378 1369 1379 // Fogged if the 'retain in fog' flag is set, and in a non-visible explored region 1370 1380 if (los.IsExplored(i, j)) … … 1371 1381 { 1372 1382 CmpPtr<ICmpVision> cmpVision(ent); 1373 1383 if (forceRetainInFog || (cmpVision && cmpVision->GetRetainInFog())) 1374 return VIS_FOGGED; 1384 { 1385 // Mirage entities are visible for one specific player 1386 CmpPtr<ICmpMirage> cmpMirage(ent); 1387 if (cmpMirage) 1388 { 1389 if (cmpMirage->GetPlayer() == player) 1390 return VIS_FOGGED; 1391 else 1392 return VIS_HIDDEN; 1393 } 1394 1395 // Normal entities should be visible only for their owner 1396 CmpPtr<ICmpOwnership> cmpOwnership(ent); 1397 if (cmpOwnership) 1398 { 1399 if (cmpOwnership->GetOwner() == player) 1400 return VIS_FOGGED; 1401 else 1402 return VIS_HIDDEN; 1403 } 1404 1405 return VIS_VISIBLE; 1406 } 1375 1407 } 1376 1408 1377 1409 // Otherwise not visible -
source/simulation2/components/CCmpUnitRenderer.cpp
374 374 CmpPtr<ICmpVision> cmpVision(unit.entity); 375 375 if (cmpVision && cmpVision->GetAlwaysVisible()) 376 376 unit.visibility = ICmpRangeManager::VIS_VISIBLE; 377 378 // Uncomment the following two lines to prevent the models from popping into existence 379 // near the LOS boundary. Is rather resource intensive. 380 //else if (cmpVision && cmpVision->GetRetainInFog()) 381 // unit.visibility = ICmpRangeManager::VIS_VISIBLE; 382 377 383 else 378 384 { 379 385 CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); 380 // Uncomment the following lines to prevent the models from popping into existence 381 // near the LOS boundary. Is rather resource intensive. 382 //if (cmpVision->GetRetainInFog()) 383 // unit.visibility = ICmpRangeManager::VIS_VISIBLE; 384 //else 385 unit.visibility = cmpRangeManager->GetLosVisibility(unit.entity, 386 GetSimContext().GetCurrentDisplayedPlayer()); 386 unit.visibility = cmpRangeManager->GetLosVisibility(unit.entity, 387 GetSimContext().GetCurrentDisplayedPlayer()); 387 388 } 388 389 } 389 390 else -
source/simulation2/components/CCmpVisualActor.cpp
532 532 void ReloadActor(); 533 533 534 534 void Update(fixed turnLength); 535 void UpdateVisibility();536 535 }; 537 536 538 537 REGISTER_COMPONENT_TYPE(VisualActor) -
source/simulation2/components/ICmpFogging.cpp
1 /* Copyright (C) 2014 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "ICmpFogging.h" 21 22 #include "simulation2/system/InterfaceScripted.h" 23 24 BEGIN_INTERFACE_WRAPPER(Fogging) 25 DEFINE_INTERFACE_METHOD_0("UpdateMirages", void, ICmpFogging, UpdateMirages) 26 DEFINE_INTERFACE_METHOD_1("IsMiraged", bool, ICmpFogging, IsMiraged, player_id_t) 27 DEFINE_INTERFACE_METHOD_2("SetMiraged", void, ICmpFogging, SetMiraged, player_id_t, bool) 28 END_INTERFACE_WRAPPER(Fogging) -
source/simulation2/components/ICmpFogging.h
Property changes on: source/simulation2/components/ICmpFogging.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 /* Copyright (C) 2014 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef INCLUDED_ICMPFOGGING 19 #define INCLUDED_ICMPFOGGING 20 21 #include "simulation2/system/Interface.h" 22 23 #include "simulation2/helpers/Player.h" 24 25 26 /** 27 * Handles the fogging of out-of-sight enemy entities, by creating mirage 28 * entities. 29 * This allows hiding changes, especially destruction status or health. 30 */ 31 class ICmpFogging : public IComponent 32 { 33 public: 34 virtual void UpdateMirages() = 0; 35 virtual bool IsMiraged(player_id_t player) = 0; 36 virtual void SetMiraged(player_id_t player, bool enable) = 0; 37 DECLARE_INTERFACE_TYPE(Fogging) 38 }; 39 40 #endif // INCLUDED_ICMPFOGGING -
source/simulation2/components/ICmpMirage.cpp
Property changes on: source/simulation2/components/ICmpFogging.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 /* Copyright (C) 2014 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "ICmpMirage.h" 21 22 #include "simulation2/system/InterfaceScripted.h" 23 24 BEGIN_INTERFACE_WRAPPER(Mirage) 25 DEFINE_INTERFACE_METHOD_1("SetPlayer", void, ICmpMirage, SetPlayer, player_id_t) 26 DEFINE_INTERFACE_METHOD_0("GetPlayer", player_id_t, ICmpMirage, GetPlayer) 27 DEFINE_INTERFACE_METHOD_1("SetParent", void, ICmpMirage, SetParent, entity_id_t) 28 DEFINE_INTERFACE_METHOD_0("GetParent", entity_id_t, ICmpMirage, GetParent) 29 END_INTERFACE_WRAPPER(Mirage) -
source/simulation2/components/ICmpMirage.h
Property changes on: source/simulation2/components/ICmpMirage.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 /* Copyright (C) 2014 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef INCLUDED_ICMPMIRAGE 19 #define INCLUDED_ICMPMIRAGE 20 21 #include "simulation2/system/Interface.h" 22 23 #include "simulation2/helpers/Player.h" 24 25 /** 26 * Component allowing mirage entities to communicate with their parent entity. 27 * See ICmpFogging. 28 */ 29 class ICmpMirage : public IComponent 30 { 31 public: 32 virtual void SetPlayer(player_id_t player) = 0; 33 virtual player_id_t GetPlayer() = 0; 34 virtual void SetParent(entity_id_t ent) = 0; 35 virtual entity_id_t GetParent() = 0; 36 DECLARE_INTERFACE_TYPE(Mirage) 37 }; 38 39 #endif // INCLUDED_ICMPMIRAGE -
source/simulation2/MessageTypes.h
Property changes on: source/simulation2/components/ICmpMirage.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2014 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 241 241 entity_id_t entity; 242 242 }; 243 243 244 /** 245 * This is sent when one entity is changed to other: from Foundation component when building 246 * constuction is done, from Promotion component, from Fogging component etc. 247 */ 248 class CMessageEntityRenamed : public CMessage 249 { 250 public: 251 DEFAULT_MESSAGE_IMPL(EntityRenamed) 252 253 CMessageEntityRenamed(entity_id_t entity, entity_id_t newentity) : 254 entity(entity), newentity(newentity) 255 { 256 } 257 258 entity_id_t entity; 259 entity_id_t newentity; 260 }; 261 244 262 class CMessageOwnershipChanged : public CMessage 245 263 { 246 264 public: -
source/simulation2/scripting/MessageTypeConversions.cpp
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2014 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 194 194 195 195 //////////////////////////////// 196 196 197 jsval CMessageEntityRenamed::ToJSVal(ScriptInterface& scriptInterface) const 198 { 199 TOJSVAL_SETUP(); 200 SET_MSG_PROPERTY(entity); 201 SET_MSG_PROPERTY(newentity); 202 return OBJECT_TO_JSVAL(obj); 203 } 204 205 CMessage* CMessageEntityRenamed::FromJSVal(ScriptInterface& scriptInterface, jsval val) 206 { 207 FROMJSVAL_SETUP(); 208 GET_MSG_PROPERTY(entity_id_t, entity); 209 GET_MSG_PROPERTY(entity_id_t, newentity); 210 return new CMessageEntityRenamed(entity, newentity); 211 } 212 213 //////////////////////////////// 214 197 215 jsval CMessageOwnershipChanged::ToJSVal(ScriptInterface& scriptInterface) const 198 216 { 199 217 TOJSVAL_SETUP(); -
source/simulation2/TypeList.h
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2014 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 41 41 MESSAGE(Deserialized) // non-deterministic (use with caution) 42 42 MESSAGE(Create) 43 43 MESSAGE(Destroy) 44 MESSAGE(EntityRenamed) 44 45 MESSAGE(OwnershipChanged) 45 46 MESSAGE(PositionChanged) 46 47 MESSAGE(InterpolatedPositionChanged) … … 80 81 INTERFACE(Decay) 81 82 COMPONENT(Decay) 82 83 84 INTERFACE(Fogging) 85 COMPONENT(Fogging) 86 83 87 // Note: The VisualActor component relies on this component being initialized before itself, in order to support using 84 88 // an entity's footprint shape for the selection boxes. This dependency is not strictly necessary, but it does avoid 85 89 // some extra plumbing code to set up on-demand initialization. If you find yourself forced to break this dependency, … … 96 100 INTERFACE(Minimap) 97 101 COMPONENT(Minimap) 98 102 103 INTERFACE(Mirage) 104 COMPONENT(Mirage) 105 99 106 INTERFACE(Motion) 100 107 COMPONENT(MotionBall) 101 108 COMPONENT(MotionScripted)