Ticket #3997: terrainbonus.diff
File terrainbonus.diff, 8.0 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/art/terrains/biome-alpine/alpine_grass.xml
6 6 <texture name="specTex" file="types/medit_grass_field_spec.png"/> 7 7 </textures> 8 8 <material>terrain_norm_spec.xml</material> 9 </terrain>10 No newline at end of file 9 <props classes="test1, test2"/> 10 </terrain> -
binaries/data/mods/public/art/terrains/terrain_texture.rnc
19 19 }? & 20 20 element props { 21 21 attribute groups { text }? & # comma-separated list of groups 22 attribute classes { text }? & # comma-separated list of classes 22 23 attribute mmap { 23 24 list { 24 25 xsd:integer { minInclusive = "0" }, # R -
binaries/data/mods/public/art/terrains/terrain_texture.rng
34 34 <attribute name="groups"/> 35 35 </optional> 36 36 <optional> 37 <attribute name="classes"/> 38 </optional> 39 <optional> 37 40 <!-- comma-separated list of groups --> 38 41 <attribute name="mmap"> 39 42 <list> -
binaries/data/mods/public/simulation/components/BuildRestrictions.js
314 314 } 315 315 } 316 316 317 var cmpTerrain = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain); 318 if (cmpTerrain.GetTerrainClasses(pos.x, pos.y).indexOf("test1") != -1) 319 { 320 result.message = "Get a terrain bonus here"; 321 result.success = true; 322 result.bonus = 0.4; 323 } 317 324 // Success 318 325 result.success = true; 319 326 result.message = ""; -
binaries/data/mods/public/simulation/components/GuiInterface.js
1041 1041 1042 1042 if (!result.success) 1043 1043 cmpVisual.SetShadingColor(1.4, 0.4, 0.4, 1); 1044 else if (result.bonus) 1045 cmpVisual.SetShadingColor(1 - result.bonus, 1 + result.bonus, 1, 1); 1044 1046 else 1045 1047 cmpVisual.SetShadingColor(1, 1, 1, 1); 1046 1048 } -
source/graphics/Terrain.cpp
112 112 return "default"; 113 113 } 114 114 115 std::vector<std::string> CTerrain::GetClasses(fixed x, fixed z) const 116 { 117 const ssize_t i = clamp((ssize_t)(x / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2); 118 const ssize_t j = clamp((ssize_t)(z / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2); 119 CMiniPatch* tile = GetTile(i, j); 120 if (tile && tile->GetTextureEntry()) 121 return tile->GetTextureEntry()->GetProperties().GetClasses(); 122 return std::vector<std::string>(); 123 } 124 115 125 /////////////////////////////////////////////////////////////////////////////// 116 126 // CalcPosition: calculate the world space position of the vertex at (i,j) 117 127 // If i,j is off the map, it acts as if the edges of the terrain are extended -
source/graphics/Terrain.h
81 81 82 82 CStr8 GetMovementClass(ssize_t i, ssize_t j) const; 83 83 84 std::vector<std::string> GetClasses(fixed x, fixed z) const; 85 84 86 float GetVertexGroundLevel(ssize_t i, ssize_t j) const; 85 87 fixed GetVertexGroundLevelFixed(ssize_t i, ssize_t j) const; 86 88 float GetExactGroundLevel(float x, float z) const; -
source/graphics/TerrainProperties.cpp
96 96 // Terrain Attribs 97 97 ATTR(mmap); 98 98 ATTR(groups); 99 ATTR(classes); 99 100 ATTR(movementclass); 100 101 ATTR(angle); 101 102 ATTR(size); … … 115 116 for(tokenizer::iterator it = tok.begin(); it != tok.end(); ++it) 116 117 m_Groups.push_back(g_TexMan.FindGroup(*it)); 117 118 } 119 else if (attr.Name == attr_classes) 120 { 121 // Parse a comma-separated list of groups, add the new entry to 122 // each of them 123 m_Classes.clear(); 124 boost::char_separator<char> sep(", "); 125 typedef boost::tokenizer<boost::char_separator<char> > tokenizer; 126 tokenizer tok(attr.Value, sep); 127 for (const CStr& cl : tok) 128 m_Classes.push_back(cl); 129 } 118 130 else if (attr.Name == attr_mmap) 119 131 { 120 132 CColor col; -
source/graphics/TerrainProperties.h
66 66 // All terrain type groups we're a member of 67 67 GroupVector m_Groups; 68 68 69 // Classes of this terrain 70 std::vector<std::string> m_Classes; 71 69 72 public: 70 73 CTerrainProperties(CTerrainPropertiesPtr parent); 71 74 … … 112 115 { 113 116 return m_Groups; 114 117 } 118 119 std::vector<std::string> GetClasses() const 120 { 121 return m_Classes; 122 } 115 123 }; 116 124 117 125 #endif -
source/simulation2/components/CCmpTerrain.cpp
109 109 return (u16)vertices; 110 110 } 111 111 112 virtual std::vector<std::string> GetTerrainClasses(entity_pos_t x, entity_pos_t z) 113 { 114 return m_Terrain->GetClasses(x, z); 115 } 116 112 117 virtual CTerrain* GetCTerrain() 113 118 { 114 119 return m_Terrain; -
source/simulation2/components/ICmpTerrain.cpp
24 24 BEGIN_INTERFACE_WRAPPER(Terrain) 25 25 DEFINE_INTERFACE_METHOD_2("GetGroundLevel", entity_pos_t, ICmpTerrain, GetGroundLevel, entity_pos_t, entity_pos_t) 26 26 DEFINE_INTERFACE_METHOD_2("CalcNormal", CFixedVector3D, ICmpTerrain, CalcNormal, entity_pos_t, entity_pos_t) 27 DEFINE_INTERFACE_METHOD_2("GetTerrainClasses", std::vector<std::string>, ICmpTerrain, GetTerrainClasses, entity_pos_t, entity_pos_t) 27 28 DEFINE_INTERFACE_METHOD_0("GetTilesPerSide", u16, ICmpTerrain, GetTilesPerSide) 28 29 END_INTERFACE_WRAPPER(Terrain) -
source/simulation2/components/ICmpTerrain.h
40 41 41 42 virtual float GetExactGroundLevel(float x, float z) = 0; 42 43 44 virtual std::vector<std::string> GetTerrainClasses(entity_pos_t x, entity_pos_t z) = 0; 45 43 46 /** 44 47 * Returns number of tiles per side on the terrain. 45 48 * Return value is always non-zero. -
source/simulation2/system/ComponentTest.h
207 207 return 50.f; 208 208 } 209 209 210 virtual std::vector<std::string> GetTerrainClasses(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) 211 { 212 return std::vector<std::string>(); 213 } 214 210 215 virtual u16 GetTilesPerSide() 211 216 { 212 217 return 16;