class A4ObjectFactory { constructor() { this.baseClasses = ["item","container","vehicle","character","obstacle","obstacle-container","door","key","pushable-wall","food","spade","object"]; } addDefinitions(xml:Element, game:A4Game, baseClassName:string) { let o:Ontology = game.ontology; let classes_xml:Element[] = getElementChildrenByTag(xml, baseClassName); for(let i:number = 0;i 0) { let current:string = open[0]; //console.log("considering: " + current); open.splice(0,1); let loadContent:boolean = true; let current2:string = current; if (current.charAt(0) == '*') { // loadContent = false; current2 = current.substring(1); if (ontology.getSort(current2).is_a_string("dead")) dead = true; //closed.push(current2); continue; } else { if (ontology.getSort(current2).is_a_string("dead")) dead = true; //closed.push(current2); } let current_xml:Element = this.getObjectType(current2); let found:number = this.baseClasses.indexOf(current2); if (current_xml == null && found >= 0) { if (baseClassName == null) { baseClassName = current; } else if (baseClassName != current) { console.error("A4ObjectFactory::createObject: baseClassName was '"+baseClassName+"' and now it's attempted to set to '"+current+"'!!!"); return null; } } else { if (current_xml != null) { if (loadContent) classes.unshift(current_xml); // push at the front of the array let superString:string = current_xml.getAttribute("super"); let superClasses:string[] = superString.split(','); for(let className of superClasses) { open.push(className); } } } } } if (baseClassName == null) { console.error("A4ObjectFactory::createObject: baseClassName null to create '" + xml.getAttribute("class") + "'!!!"); return null; } let o_ID:string = xml.getAttribute("id"); let o_name:string = xml.getAttribute("name"); if (o_name == null) { for(let xml2 of classes) { o_name = xml2.getAttribute("name"); if (o_name != null) break; } } let classStr:string = xml.getAttribute("class"); if (classStr == null) classStr = xml.getAttribute("type"); o = this.createObjectFromBaseClass(baseClassName, ontology.getSort(classStr), o_name, isPlayer, dead); if (o_ID != null) { o.ID = o_ID; if (!isNaN(Number(o_ID)) && Number(o_ID) >= A4Object.s_nextID) A4Object.s_nextID = Number(o_ID)+1; } if (!completeRedefinition) { for(let xml2 of classes) { o.loadObjectAdditionalContent(xml2, game, this, [], []); } } return o; } objectTypes:Element[] = []; baseClasses:string[] = []; };