Ticket #599: fogging_scripted.patch
File fogging_scripted.patch, 30.5 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/gui/session/selection_details.js
172 172 Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; 173 173 Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translate("Number of builders.\nTasking another to this foundation would speed construction up by %(numb)s%%"), { numb : Math.round((Math.pow((entState.foundation.numBuilders+1)/entState.foundation.numBuilders, 0.7) - 1.0)*100) }); 174 174 } 175 else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) )175 else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && !entState.mirage) 176 176 { 177 177 Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; 178 178 Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; -
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/Fogging.js
1 const VIS_HIDDEN = 0; 2 const VIS_FOGGED = 1; 3 const VIS_VISIBLE = 2; 4 5 function Fogging() {} 6 7 Fogging.prototype.Schema = 8 "<a:help>Allows this entity to be replaced by mirages entities in the fog-of-war.</a:help>" + 9 "<empty/>"; 10 11 Fogging.prototype.Init = function() 12 { 13 this.mirages = []; 14 this.seen = []; 15 16 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 17 for (var i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i) 18 { 19 this.mirages.push(INVALID_ENTITY); 20 this.seen.push(false); 21 } 22 }; 23 24 Fogging.prototype.LoadMirage = function(player) 25 { 26 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 27 var templateName = "mirage|" + cmpTemplateManager.GetCurrentTemplateName(this.entity); 28 29 // If this is an entity without visibility (e.g. a foundation), it should be 30 // marked as seen for its owner 31 var cmpParentOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 32 if (cmpParentOwnership && cmpParentOwnership.GetOwner() == player) 33 this.seen[player] = true; 34 35 if (!this.seen[player] || this.mirages[player] != INVALID_ENTITY) 36 return; 37 38 this.mirages[player] = Engine.AddEntity(templateName); 39 var cmpMirage = Engine.QueryInterface(this.mirages[player], IID_Mirage); 40 if (!cmpMirage) 41 { 42 error("Failed to load mirage entity for template " + templateName); 43 this.mirages[player] = INVALID_ENTITY; 44 return; 45 } 46 // Setup basic mirage properties 47 cmpMirage.SetPlayer(player); 48 cmpMirage.SetParent(this.entity); 49 50 // Copy cmpOwnership data 51 var cmpMirageOwnership = Engine.QueryInterface(this.mirages[player], IID_Ownership); 52 if (!cmpParentOwnership || !cmpMirageOwnership) 53 { 54 error("Failed to setup the ownership data of the fogged entity " + templateName); 55 return; 56 } 57 cmpMirageOwnership.SetOwner(cmpParentOwnership.GetOwner()); 58 59 // Copy cmpPosition data 60 var cmpParentPosition = Engine.QueryInterface(this.entity, IID_Position); 61 var cmpMiragePosition = Engine.QueryInterface(this.mirages[player], IID_Position); 62 if (!cmpParentPosition || !cmpMiragePosition) 63 { 64 error("Failed to setup the position data of the fogged entity " + templateName); 65 return; 66 } 67 if (!cmpParentPosition.IsInWorld()) 68 return; 69 var pos = cmpParentPosition.GetPosition(); 70 cmpMiragePosition.JumpTo(pos.x, pos.z); 71 var rot = cmpParentPosition.GetRotation(); 72 cmpMiragePosition.SetYRotation(rot.y); 73 cmpMiragePosition.SetXZRotation(rot.x, rot.z); 74 75 // Copy cmpVisualActor data 76 var cmpParentVisualActor = Engine.QueryInterface(this.entity, IID_Visual); 77 var cmpMirageVisualActor = Engine.QueryInterface(this.mirages[player], IID_Visual); 78 if (!cmpParentVisualActor || !cmpMirageVisualActor) 79 { 80 error("Failed to setup the visual data of the fogged entity " + templateName); 81 return; 82 } 83 cmpMirageVisualActor.SetActorSeed(cmpParentVisualActor.GetActorSeed()); 84 85 // Store valuable information into the mirage component (especially for the GUI) 86 var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 87 if (cmpHealth) 88 cmpMirage.AddHealth(cmpHealth.GetMaxHitpoints(), cmpHealth.GetHitpoints()); 89 90 var cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply); 91 if (cmpResourceSupply) 92 cmpMirage.AddResourceSupply(cmpResourceSupply.GetMaxAmount(), cmpResourceSupply.GetCurrentAmount(), cmpResourceSupply.GetType()); 93 }; 94 95 Fogging.prototype.IsMiraged = function(player) 96 { 97 if (player >= this.mirages.length) 98 return false; 99 100 return this.mirages[player] != INVALID_ENTITY; 101 }; 102 103 Fogging.prototype.WasSeen = function(player) 104 { 105 if (player >= this.seen.length) 106 return false; 107 108 return this.seen[player]; 109 }; 110 111 Fogging.prototype.OnVisibilityChanged = function(msg) 112 { 113 if (msg.player >= this.mirages.length) 114 return; 115 116 if (msg.newVisibility == VIS_VISIBLE) 117 { 118 this.seen[msg.player] = true; 119 120 // Destroy mirages when we get back into LoS 121 if (this.mirages[msg.player] != INVALID_ENTITY) 122 { 123 Engine.DestroyEntity(this.mirages[msg.player]); 124 this.mirages[msg.player] = INVALID_ENTITY; 125 } 126 } 127 128 // Intermediate LoS state, meaning we must create a mirage 129 if (msg.newVisibility == VIS_FOGGED) 130 this.LoadMirage(msg.player); 131 }; 132 133 Fogging.prototype.OnDestroy = function(msg) 134 { 135 for each (var mirage in this.mirages) 136 { 137 var cmpMirage = Engine.QueryInterface(mirage, IID_Mirage); 138 if (cmpMirage) 139 cmpMirage.SetParent(INVALID_ENTITY); 140 } 141 }; 142 143 Engine.RegisterComponentType(IID_Fogging, "Fogging", Fogging); -
binaries/data/mods/public/simulation/components/GuiInterface.js
179 179 "garrisonHolder": null, 180 180 "gate": null, 181 181 "guard": null, 182 "mirage": null, 182 183 "pack": null, 183 184 "player": -1, 184 185 "position": null, … … 190 191 "visibility": null, 191 192 }; 192 193 194 var cmpMirage = Engine.QueryInterface(ent, IID_Mirage); 195 193 196 var cmpIdentity = Engine.QueryInterface(ent, IID_Identity); 194 197 if (cmpIdentity) 195 198 { … … 216 219 ret.needsRepair = cmpHealth.IsRepairable() && (cmpHealth.GetHitpoints() < cmpHealth.GetMaxHitpoints()); 217 220 ret.needsHeal = !cmpHealth.IsUnhealable(); 218 221 } 222 if (cmpMirage && cmpMirage.Health()) 223 { 224 ret.hitpoints = cmpMirage.GetHitpoints(); 225 ret.maxHitpoints = cmpMirage.GetMaxHitpoints(); 226 } 219 227 220 228 var cmpBuilder = Engine.QueryInterface(ent, IID_Builder); 221 229 if (cmpBuilder) … … 351 359 "resourceSupply": null, 352 360 }; 353 361 362 var cmpMirage = Engine.QueryInterface(ent, IID_Mirage); 363 if (cmpMirage) 364 ret.mirage = true; 365 354 366 var cmpIdentity = Engine.QueryInterface(ent, IID_Identity); 355 367 356 368 var cmpAttack = Engine.QueryInterface(ent, IID_Attack); … … 445 457 "gatherers": cmpResourceSupply.GetGatherers() 446 458 }; 447 459 } 460 if (cmpMirage && cmpMirage.ResourceSupply()) 461 { 462 ret.resourceSupply = { 463 "max": cmpMirage.GetMaxAmount(), 464 "amount": cmpMirage.GetAmount(), 465 "type": cmpMirage.GetType() 466 }; 467 } 448 468 449 469 var cmpResourceGatherer = Engine.QueryInterface(ent, IID_ResourceGatherer); 450 470 if (cmpResourceGatherer) -
binaries/data/mods/public/simulation/components/interfaces/Messages.js
1 1 /** 2 2 * Broadcast message 3 3 * sent when one entity is changed to other: 4 * from Foundation component when building constuction is done 5 * and from Promotion component when unit is promoted 4 * - from Foundation component when building construction is done 5 * - from Promotion component when unit is promoted 6 * - from Mirage component when a fogged entity is re-discovered 6 7 * Data: { entity: <integer>, newentity: <integer> } 7 8 */ 8 9 Engine.RegisterMessageType("EntityRenamed"); -
binaries/data/mods/public/simulation/components/Mirage.js
1 const VIS_HIDDEN = 0; 2 const VIS_FOGGED = 1; 3 const VIS_VISIBLE = 2; 4 5 function Mirage() {} 6 7 Mirage.prototype.Schema = 8 "<a:help>Mirage entities replace real entities in the fog-of-war.</a:help>" + 9 "<empty/>"; 10 11 Mirage.prototype.Init = function() 12 { 13 this.player = undefined; 14 this.parent = INVALID_ENTITY; 15 16 this.health = false; 17 this.maxHitpoints = undefined; 18 this.hitpoints = undefined; 19 20 this.resourceSupply = false; 21 this.maxAmount = undefined; 22 this.amount = undefined; 23 this.type = undefined; 24 }; 25 26 Mirage.prototype.SetParent = function(ent) 27 { 28 this.parent = ent; 29 }; 30 31 Mirage.prototype.GetPlayer = function() 32 { 33 return this.player; 34 }; 35 36 Mirage.prototype.SetPlayer = function(player) 37 { 38 this.player = player; 39 }; 40 41 //// Parent entity data 42 43 //// 44 // Health data 45 //// 46 Mirage.prototype.AddHealth = function(maxHitpoints, hitpoints) 47 { 48 this.health = true; 49 this.maxHitpoints = maxHitpoints; 50 this.hitpoints = Math.ceil(hitpoints); 51 }; 52 53 Mirage.prototype.Health = function() 54 { 55 return this.health; 56 }; 57 58 Mirage.prototype.GetMaxHitpoints = function() 59 { 60 return this.maxHitpoints; 61 }; 62 63 Mirage.prototype.GetHitpoints = function() 64 { 65 return this.hitpoints; 66 }; 67 68 //// 69 // ResourceSupply data 70 //// 71 Mirage.prototype.AddResourceSupply = function(maxAmount, amount, type) 72 { 73 this.resourceSupply = true; 74 this.maxAmount = maxAmount; 75 this.amount = amount; 76 this.type = type; 77 }; 78 79 Mirage.prototype.ResourceSupply = function() 80 { 81 return this.resourceSupply; 82 }; 83 84 Mirage.prototype.GetMaxAmount = function() 85 { 86 return this.maxAmount; 87 }; 88 89 Mirage.prototype.GetAmount = function() 90 { 91 return this.amount; 92 }; 93 94 Mirage.prototype.GetType = function() 95 { 96 return this.type; 97 }; 98 99 //// 100 101 Mirage.prototype.OnVisibilityChanged = function(msg) 102 { 103 if (msg.player == this.player && msg.newVisibility == VIS_VISIBLE && this.parent == INVALID_ENTITY) 104 Engine.DestroyEntity(this.entity); 105 }; 106 107 Mirage.prototype.OnDestroy = function(msg) 108 { 109 if (this.parent == INVALID_ENTITY) 110 return; 111 112 Engine.BroadcastMessage(MT_EntityRenamed, { entity: this.entity, newentity: this.parent }); 113 }; 114 115 Engine.RegisterComponentType(IID_Mirage, "Mirage", Mirage); -
binaries/data/mods/public/simulation/components/ResourceGatherer.js
243 243 { 244 244 var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); 245 245 246 var type; 246 247 var cmpResourceSupply = Engine.QueryInterface(target, IID_ResourceSupply); 247 if (!cmpResourceSupply) 248 var cmpMirage = Engine.QueryInterface(target, IID_Mirage); 249 if (cmpResourceSupply) 250 type = cmpResourceSupply.GetType(); 251 else if (cmpMirage && cmpMirage.ResourceSupply()) 252 type = cmpMirage.GetType(); 253 else 248 254 return 0; 249 255 250 var type = cmpResourceSupply.GetType();251 252 256 var rates = this.GetGatherRates(); 253 257 254 258 var rate; … … 261 265 rate = rates[type.generic] / cmpPlayer.GetCheatTimeMultiplier(); 262 266 } 263 267 268 if (cmpMirage) 269 return rate || 0; 270 264 271 // Apply diminishing returns with more gatherers, for e.g. infinite farms. For most resources this has no effect. (GetDiminishingReturns will return null.) 272 // We can assume that for resources that are miraged this is the case. (else just add the diminishing returns data to the mirage data and remove the 273 // early return above) 265 274 // Note to people looking to change <DiminishingReturns> in a template: This is a bit complicated. Basically, the lower that number is 266 275 // the steeper diminishing returns will be. I suggest playing around with Wolfram Alpha or a graphing calculator a bit. 267 276 // In each of the following links, replace 0.65 with the gather rate of your worker for the resource with diminishing returns and -
binaries/data/mods/public/simulation/components/UnitAI.js
1987 1987 // check that we can gather from the resource we're supposed to gather from. 1988 1988 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 1989 1989 var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); 1990 if (!cmpSupply || !cmpSupply.AddGatherer(cmpOwnership.GetOwner(), this.entity)) 1990 var cmpMirage = Engine.QueryInterface(this.gatheringTarget, IID_Mirage); 1991 if ((!cmpMirage || !cmpMirage.ResourceSupply()) && 1992 (!cmpSupply || !cmpSupply.AddGatherer(cmpOwnership.GetOwner(), this.entity))) 1991 1993 { 1992 1994 // Save the current order's data in case we need it later 1993 1995 var oldType = this.order.data.type; … … 3896 3898 if (cmpFormation) 3897 3899 return true; 3898 3900 3901 var cmpMirage = Engine.QueryInterface(ent, IID_Mirage); 3902 if (cmpMirage) 3903 return true; 3904 3899 3905 var cmpHealth = Engine.QueryInterface(ent, IID_Health); 3900 3906 if (!cmpHealth) 3901 3907 return false; … … 4386 4392 if (!cmpRangeManager) 4387 4393 return false; 4388 4394 4395 // Entities that are hidden and miraged are considered visible 4396 var cmpFogging = Engine.QueryInterface(target, IID_Fogging); 4397 if (cmpFogging && cmpFogging.IsMiraged(cmpOwnership.GetOwner())) 4398 return true; 4399 4389 4400 if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner(), false) == "hidden") 4390 4401 return false; 4391 4402 … … 5007 5018 // Save the resource type now, so if the resource gets destroyed 5008 5019 // before we process the order then we still know what resource 5009 5020 // type to look for more of 5021 var type; 5010 5022 var cmpResourceSupply = Engine.QueryInterface(target, IID_ResourceSupply); 5011 var type = cmpResourceSupply.GetType(); 5023 var cmpMirage = Engine.QueryInterface(target, IID_Mirage); 5024 if (cmpResourceSupply) 5025 type = cmpResourceSupply.GetType(); 5026 else if (cmpMirage && cmpMirage.ResourceSupply()) 5027 type = cmpMirage.GetType(); 5028 else 5029 error("CanGather allowed gathering from invalid entity"); 5012 5030 5013 5031 // Also save the target entity's template, so that if it's an animal, 5014 5032 // we won't go from hunting slow safe animals to dangerous fast ones … … 5552 5570 { 5553 5571 if (this.IsTurret()) 5554 5572 return false; 5555 // The target must be a valid resource supply .5573 // The target must be a valid resource supply, or the mirage of one. 5556 5574 var cmpResourceSupply = Engine.QueryInterface(target, IID_ResourceSupply); 5557 if (!cmpResourceSupply) 5575 var cmpMirage = Engine.QueryInterface(target, IID_Mirage); 5576 if (!cmpResourceSupply && !(cmpMirage && cmpMirage.ResourceSupply()) ) 5558 5577 return false; 5559 5578 5560 5579 // Formation controllers should always respond to commands -
binaries/data/mods/public/simulation/helpers/Commands.js
980 980 "queued": cmd.queued 981 981 }); 982 982 } 983 984 // Load a mirage for the owner of this new entity 985 var cmpFogging = Engine.QueryInterface(ent, IID_Fogging) 986 if (cmpFogging) 987 cmpFogging.LoadMirage(player); 983 988 984 989 return ent; 985 990 } -
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 { … … 380 395 } 381 396 } 382 397 398 void CTemplateLoader::CopyMirageSubset(CParamNode& out, const CParamNode& in) 399 { 400 // Currently used for mirage entities replacing real ones in fog-of-war 401 402 std::set<std::string> permittedComponentTypes; 403 permittedComponentTypes.insert("Footprint"); 404 permittedComponentTypes.insert("Minimap"); 405 permittedComponentTypes.insert("Ownership"); 406 permittedComponentTypes.insert("Position"); 407 permittedComponentTypes.insert("Selectable"); 408 permittedComponentTypes.insert("VisualActor"); 409 410 CParamNode::LoadXMLString(out, "<Entity/>"); 411 out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes); 412 413 // Select a subset of identity data. We don't want to have, for example, a CC mirage 414 // that has also the CC class and then prevents construction of other CCs 415 std::set<std::string> identitySubset; 416 identitySubset.insert("Civ"); 417 identitySubset.insert("GenericName"); 418 identitySubset.insert("SpecificName"); 419 identitySubset.insert("Tooltip"); 420 identitySubset.insert("History"); 421 identitySubset.insert("Icon"); 422 CParamNode identity; 423 CParamNode::LoadXMLString(identity, "<Identity/>"); 424 identity.CopyFilteredChildrenOfChild(in.GetChild("Entity"), "Identity", identitySubset); 425 CParamNode::LoadXMLString(out, ("<Entity>"+utf8_from_wstring(identity.ToXML())+"</Entity>").c_str()); 426 427 // Set the entity as mirage entity 428 CParamNode::LoadXMLString(out, "<Entity><Mirage/></Entity>"); 429 CParamNode::LoadXMLString(out, "<Entity><Vision><Range>0</Range><RetainInFog>true</RetainInFog><AlwaysVisible>false</AlwaysVisible></Vision></Entity>"); 430 } 431 383 432 void CTemplateLoader::CopyFoundationSubset(CParamNode& out, const CParamNode& in) 384 433 { 385 434 // TODO: this is all kind of yucky and hard-coded; it'd be nice to have a more generic … … 394 443 permittedComponentTypes.insert("Obstruction"); 395 444 permittedComponentTypes.insert("Selectable"); 396 445 permittedComponentTypes.insert("Footprint"); 446 permittedComponentTypes.insert("Fogging"); 397 447 permittedComponentTypes.insert("Armour"); 398 448 permittedComponentTypes.insert("Health"); 399 449 permittedComponentTypes.insert("StatusBars"); -
source/ps/TemplateLoader.h
79 79 void CopyPreviewSubset(CParamNode& out, const CParamNode& in, bool corpse); 80 80 81 81 /** 82 * Copy the components of an entity template necessary for a fogged "mirage" 83 * entity (position, actor) into a new entity template 84 */ 85 void CopyMirageSubset(CParamNode& out, const CParamNode& in); 86 87 /** 82 88 * Copy the components of an entity template necessary for a construction foundation 83 89 * (position, actor, armour, health, etc) into a new entity template 84 90 */ -
source/simulation2/components/CCmpRangeManager.cpp
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" … … 1410 1413 { 1411 1414 CmpPtr<ICmpVision> cmpVision(ent); 1412 1415 if (forceRetainInFog || (cmpVision && cmpVision->GetRetainInFog())) 1413 return VIS_FOGGED; 1416 { 1417 // Mirage entities are visible for one specific player 1418 CmpPtr<ICmpMirage> cmpMirage(ent); 1419 if (cmpMirage) 1420 { 1421 if (cmpMirage->GetPlayer() == player) 1422 return VIS_FOGGED; 1423 else 1424 return VIS_HIDDEN; 1425 } 1426 1427 // Real entities visibility depends on ownership 1428 CmpPtr<ICmpOwnership> cmpOwnership(ent); 1429 if (cmpOwnership) 1430 { 1431 if (cmpOwnership->GetOwner() == player) 1432 { 1433 CmpPtr<ICmpFogging> cmpFogging(ent); 1434 if (!cmpFogging) 1435 return VIS_VISIBLE; 1436 1437 // Fogged entities must not disappear while the mirage is not ready 1438 if (!cmpFogging->IsMiraged(player)) 1439 return VIS_FOGGED; 1440 1441 return VIS_HIDDEN; 1442 } 1443 else 1444 { 1445 // Fogged entities must not disappear while the mirage is not ready 1446 CmpPtr<ICmpFogging> cmpFogging(ent); 1447 if (cmpFogging && cmpFogging->WasSeen(player) && !cmpFogging->IsMiraged(player)) 1448 return VIS_FOGGED; 1449 1450 return VIS_HIDDEN; 1451 } 1452 } 1453 1454 return VIS_VISIBLE; 1455 } 1414 1456 } 1415 1457 1416 1458 // Otherwise not visible -
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 #include "simulation2/scripting/ScriptComponent.h" 24 25 BEGIN_INTERFACE_WRAPPER(Fogging) 26 END_INTERFACE_WRAPPER(Fogging) 27 28 class CCmpFoggingScripted : public ICmpFogging 29 { 30 public: 31 DEFAULT_SCRIPT_WRAPPER(FoggingScripted) 32 33 virtual bool WasSeen(player_id_t player) 34 { 35 return m_Script.Call<bool> ("WasSeen", player); 36 } 37 38 virtual bool IsMiraged(player_id_t player) 39 { 40 return m_Script.Call<bool> ("IsMiraged", player); 41 } 42 }; 43 44 REGISTER_COMPONENT_SCRIPT_WRAPPER(FoggingScripted) -
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 bool WasSeen(player_id_t player) = 0; 35 virtual bool IsMiraged(player_id_t player) = 0; 36 DECLARE_INTERFACE_TYPE(Fogging) 37 }; 38 39 #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 #include "simulation2/scripting/ScriptComponent.h" 24 25 BEGIN_INTERFACE_WRAPPER(Mirage) 26 END_INTERFACE_WRAPPER(Mirage) 27 28 class CCmpMirageScripted : public ICmpMirage 29 { 30 public: 31 DEFAULT_SCRIPT_WRAPPER(MirageScripted) 32 33 virtual player_id_t GetPlayer() 34 { 35 return m_Script.Call<player_id_t> ("GetPlayer"); 36 } 37 }; 38 39 REGISTER_COMPONENT_SCRIPT_WRAPPER(MirageScripted) -
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 player_id_t GetPlayer() = 0; 33 34 DECLARE_INTERFACE_TYPE(Mirage) 35 }; 36 37 #endif // INCLUDED_ICMPMIRAGE -
source/simulation2/TypeList.h
81 81 INTERFACE(Decay) 82 82 COMPONENT(Decay) 83 83 84 INTERFACE(Fogging) 85 COMPONENT(FoggingScripted) 86 84 87 // Note: The VisualActor component relies on this component being initialized before itself, in order to support using 85 88 // an entity's footprint shape for the selection boxes. This dependency is not strictly necessary, but it does avoid 86 89 // some extra plumbing code to set up on-demand initialization. If you find yourself forced to break this dependency, … … 97 100 INTERFACE(Minimap) 98 101 COMPONENT(Minimap) 99 102 103 INTERFACE(Mirage) 104 COMPONENT(MirageScripted) 105 100 106 INTERFACE(Motion) 101 107 COMPONENT(MotionBall) 102 108 COMPONENT(MotionScripted)