MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / LoadPrefabDescriptionFromXML

Function LoadPrefabDescriptionFromXML

Source/Game/EntityDescription.cpp:874–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

872}
873
874void LoadPrefabDescriptionFromXML(EntityDescription& desc, const TiXmlElement* el) {
875 desc.AddEntityType(EDF_ENTITY_TYPE, _prefab);
876 desc.AddBool(EDF_PREFAB_LOCKED, SAYS_TRUE == saysTrue(el->Attribute("prefab_locked")));
877 desc.AddString(EDF_PREFAB_PATH, nullAsEmpty(el->Attribute("prefab_path")));
878
879 const char* ename = el->Attribute("name");
880 if (ename) {
881 desc.AddString(EDF_NAME, ename);
882 }
883 GetTSRIinfo(desc, el);
884
885 double os0, os1, os2;
886 bool success = (el->QueryDoubleAttribute("os0", &os0) == TIXML_SUCCESS) && (el->QueryDoubleAttribute("os1", &os1) == TIXML_SUCCESS) && (el->QueryDoubleAttribute("os2", &os2) == TIXML_SUCCESS);
887 if (success) {
888 vec3 original_scale((float)os0, (float)os1, (float)os2);
889 desc.AddVec3(EDF_ORIGINAL_SCALE, original_scale);
890 }
891
892 int ival;
893 int using_imposter = 0;
894 if (el->QueryIntAttribute("uses_imposter", &ival) == TIXML_SUCCESS) {
895 using_imposter = ival != 0;
896 }
897 desc.AddInt(EDF_USING_IMPOSTER, using_imposter);
898
899 if (el->QueryIntAttribute("version", &ival) == TIXML_SUCCESS) {
900 desc.AddInt(EDF_VERSION, ival);
901 }
902
903 vec3 dims;
904 char name[3];
905 double dval;
906 for (int i = 0; i < 3; i++) {
907 name[0] = 'd';
908 name[1] = '0' + i;
909 name[2] = '\0';
910 if (el->QueryDoubleAttribute(name, &dval) == TIXML_SUCCESS) {
911 dims[i] = (float)dval;
912 } else {
913 dims[i] = 1;
914 }
915 }
916 desc.AddVec3(EDF_DIMENSIONS, dims);
917
918 vec3 color;
919 for (int i = 0; i < 3; i++) {
920 name[0] = 'c';
921 name[1] = '0' + i;
922 name[2] = '\0';
923 if (el->QueryDoubleAttribute(name, &dval) == TIXML_SUCCESS) {
924 color[i] = (float)dval;
925 } else {
926 color[i] = 0;
927 }
928 }
929 desc.AddVec3(EDF_COLOR, color);
930
931 LoadEntityDescriptionListFromXML(desc.children, el);

Callers 1

Calls 12

saysTrueFunction · 0.85
nullAsEmptyFunction · 0.85
GetTSRIinfoFunction · 0.85
AddEntityTypeMethod · 0.80
AddBoolMethod · 0.80
QueryDoubleAttributeMethod · 0.80
AddVec3Method · 0.80
QueryIntAttributeMethod · 0.80
AddIntMethod · 0.80
AttributeMethod · 0.45
AddStringMethod · 0.45

Tested by

no test coverage detected