void pawsFrameDrawable::LoadPiece(csRef<iDocumentNode> node, FRAME_DRAWABLE_PIECE piece) { bool tiled = node->GetAttributeValueAsBool("tile"); csRect textureRect; textureRect.SetPos(node->GetAttributeValueAsInt("tx"), node->GetAttributeValueAsInt("ty")); textureRect.SetSize(node->GetAttributeValueAsInt("tw"), node->GetAttributeValueAsInt("th")); pieces[piece].drawable.AttachNew(new pawsImageDrawable(imageFileLocation, resourceName, tiled, textureRect, defaultAlphaValue, defaultTransparentColourRed, defaultTransparentColourGreen, defaultTransparentColourBlue)); pieces[piece].offsetx = node->GetAttributeValueAsInt("offsetx"); pieces[piece].offsety = node->GetAttributeValueAsInt("offsety"); }
bool psEntity::DefineState(csRef<iDocumentNode> stateNode) { int stateID; EntityState* entityState; csRef<iDocumentNodeIterator> resourceItr; // checking if the state ID is legal stateID = stateNode->GetAttributeValueAsInt("ID", -1); Debug4(LOG_SOUND, 0, "psEntity::DefineState %s state %d meshid %u",entityName.GetData(),stateID,id); if(stateID < 0) { return false; } // initializing the EntityState entityState = states.Get(stateID, 0); if(entityState != 0) // already defined { return false; } entityState = new EntityState(); // initializing resources resourceItr = stateNode->GetNodes("RESOURCE"); while(resourceItr->HasNext()) { const char* resourceName = resourceItr->Next()->GetAttributeValue("NAME", 0); if(resourceName == 0) { continue; } entityState->resources.PushSmart(resourceName); } // checking if there is at least one resource if(entityState->resources.IsEmpty()) { delete entityState; return false; } // setting all the other parameters entityState->probability = stateNode->GetAttributeValueAsFloat("PROBABILITY", 1.0); entityState->volume = stateNode->GetAttributeValueAsFloat("VOLUME", VOLUME_NORM); entityState->delay = stateNode->GetAttributeValueAsInt("DELAY", 0); entityState->timeOfDayStart = stateNode->GetAttributeValueAsInt("TIME_START", 0); entityState->timeOfDayEnd = stateNode->GetAttributeValueAsInt("TIME_END", 24); entityState->fallbackState = stateNode->GetAttributeValueAsInt("FALLBACK_STATE", UNDEFINED_ENTITY_STATE); entityState->fallbackProbability = stateNode->GetAttributeValueAsFloat("FALLBACK_PROBABILITY", 0.0); entityState->references = 1; // adjusting the probabilities on the update time if(entityState->probability < 1.0) { entityState->probability *= SoundManager::updateTime / 1000.0; } if(entityState->fallbackProbability < 1.0) { entityState->fallbackProbability *= SoundManager::updateTime / 1000.0; } // in XML delay is given in seconds, converting delay into milliseconds entityState->delay = entityState->delay * 1000; states.Put(stateID, entityState); return true; }