int MathFunction::SetPiecewiseFromFile2(const char* filename, int column1, int column2, int interp, mystr comment) { int rv = 0; // OK CMatrixFile cf(filename, (TFileMode)TFMread); if(!cf.IsGood()) { return 1; // error } cf.ReadSpecifiedColumns(IntVec2(column1,column2)); SetPiecewise(Vector(cf.Column(column1)), Vector(cf.Column(column2)), interp); return rv; }
void from_json(json const& j, MapMemory& obj) { obj.m_size = IntVec2(0, 0); obj.m_chunks.clear(); JSONUtils::doIfPresent(j, "size", [&](auto& value) { obj.m_size = value; }); JSONUtils::doIfPresent(j, "chunks", [&](auto& value) { for (auto citer = value.cbegin(); citer != value.cend(); ++citer) { obj.m_chunks[std::stoul(citer.key())] = citer.value(); } }); }
inline IntVec2 Map::GetRandomMapPosition(){ return IntVec2(GetRandomIntInRange(0, m_size.x-1), GetRandomIntInRange(0, m_size.y-1)); }
//------------------------------------------------------------------------------ IntVec2 IntVec2::operator-()const { return IntVec2(-x, -y); }
#include "Engine/Map/TileState.hpp" #include "Engine/Components/RenderComponent.hpp" const int TILE_X_WIDTH = 64; const int TILE_Y_HEIGHT = 32; const int NUMBER_OF_TILE_NODES = TILE_X_WIDTH * TILE_Y_HEIGHT;// +TILE_X_WIDTH; const float TILE_SCALE_2D = 32.0f; const float ONE_OVER_TILE_NODE_SCALE = 1.0f / TILE_SCALE_2D; const float TILE_RADIUS_2D = TILE_SCALE_2D * 0.5f; const Vector2 TILE_SCALE_2D_RADIUS_VEC2 = Vector2(TILE_RADIUS_2D, TILE_RADIUS_2D); const Vector2 TILE_START_OFFSET = Vector2(TILE_SCALE_2D, TILE_SCALE_2D * 5.0f); const Vector2 TILE_SCALE_2D_VEC2 = Vector2(TILE_SCALE_2D, TILE_SCALE_2D); const IntVec2 TILE_SCALE_2D_INTVEC2 = IntVec2((int)TILE_SCALE_2D, (int)TILE_SCALE_2D); const int TILE_SCALE_2D_OFFSET = (int)(TILE_SCALE_2D * 1.0f); struct MeshRenderer; class OpenGLRenderer; enum TileType{ TILE_TYPE_AIR = 0, TILE_TYPE_SOLID = 1, NUMBER_OF_TILE_TYPES, TILE_TYPE_INVALID = -1 }; inline TileType GetRandomTileType(){ return (TileType)GetRandomIntInRange(0, NUMBER_OF_TILE_TYPES - 1); }
///===================================================== /// ///===================================================== Item::Item(const XMLNode& itemNode, OpenGLRenderer* renderer) : Entity(itemNode, renderer), m_type(Undefined), m_equippedSlot(Unequippable), m_damageReductionPercent(0.0f), m_numUses(1), m_healing(0), m_damage(0, 0){ m_name = GetStringAttribute(itemNode, "name"); std::string itemType = GetStringAttribute(itemNode, "type"); m_damageReductionPercent = GetFloatAttribute(itemNode, "damageReductionPercent", m_damageReductionPercent); m_numUses = GetIntAttribute(itemNode, "numUses", m_numUses); m_healing = GetIntAttribute(itemNode, "healing", m_healing); m_damage = IntVec2(GetIntAttribute(itemNode, "minDamage", m_damage.x), GetIntAttribute(itemNode, "maxDamage", m_damage.y)); RGBAchars defaultColor = RGBAchars::WHITE; char defaultGlyph = ':'; if (itemType == "Weapon"){ m_type = ItemType::Weapon; } else if (itemType == "Armor"){ m_type = ItemType::Armor; } else if (itemType == "Consumable"){ m_type = ItemType::Consumable; } else{ //unknown item assert(false); } if (m_type != ItemType::Undefined){ defaultColor = ITEM_COLOR_TABLE[m_type]; defaultGlyph = ITEM_SYMBOL_TABLE[m_type]; } std::string itemEquipSlot = GetStringAttribute(itemNode, "equip"); if (itemEquipSlot == "Weapon"){ m_equippedSlot = EquipmentSlot::WeaponSlot; } else if (itemEquipSlot == "Chest"){ m_equippedSlot = EquipmentSlot::Chest; } else if (itemEquipSlot == "Head"){ m_equippedSlot = EquipmentSlot::Head; } else if (itemEquipSlot == "Ring"){ m_equippedSlot = EquipmentSlot::Ring; } else if (itemEquipSlot == "Hands"){ m_equippedSlot = EquipmentSlot::Hands; } else if (itemEquipSlot == "Feet"){ m_equippedSlot = EquipmentSlot::Feet; } else if (itemEquipSlot == "Legs"){ m_equippedSlot = EquipmentSlot::Legs; } m_glyph = GetCharAttribute(itemNode, "glyph", defaultGlyph); m_color = GetColorAttribute(itemNode, "color", defaultColor); m_textRenderer.SetInputString(std::string(1, m_glyph)); m_textRenderer.SetInputStringColor(m_color); }