Exemple #1
0
void CTemplateLoader::CopyMirageSubset(CParamNode& out, const CParamNode& in)
{
	// Currently used for mirage entities replacing real ones in fog-of-war

	std::set<std::string> permittedComponentTypes;
	permittedComponentTypes.insert("Footprint");
	permittedComponentTypes.insert("Minimap");
	permittedComponentTypes.insert("Ownership");
	permittedComponentTypes.insert("OverlayRenderer");
	permittedComponentTypes.insert("Position");
	permittedComponentTypes.insert("Selectable");
	permittedComponentTypes.insert("StatusBars");
	permittedComponentTypes.insert("Visibility");
	permittedComponentTypes.insert("VisualActor");

	CParamNode::LoadXMLString(out, "<Entity/>");
	out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);

	// Select a subset of identity data. We don't want to have, for example, a CC mirage
	// that has also the CC class and then prevents construction of other CCs
	std::set<std::string> identitySubset;
	identitySubset.insert("Civ");
	identitySubset.insert("GenericName");
	identitySubset.insert("SpecificName");
	identitySubset.insert("Tooltip");
	identitySubset.insert("History");
	identitySubset.insert("Icon");
	CParamNode identity;
	CParamNode::LoadXMLString(identity, "<Identity/>");
	identity.CopyFilteredChildrenOfChild(in.GetChild("Entity"), "Identity", identitySubset);
	CParamNode::LoadXMLString(out, ("<Entity>"+utf8_from_wstring(identity.ToXML())+"</Entity>").c_str());

	// Set the entity as mirage entity
	CParamNode::LoadXMLString(out, "<Entity><Mirage/></Entity>");
}
Exemple #2
0
void CTemplateLoader::CopyFoundationSubset(CParamNode& out, const CParamNode& in)
{
	// TODO: this is all kind of yucky and hard-coded; it'd be nice to have a more generic
	// extensible scriptable way to define these subsets

	std::set<std::string> permittedComponentTypes;
	permittedComponentTypes.insert("Ownership");
	permittedComponentTypes.insert("Position");
	permittedComponentTypes.insert("VisualActor");
	permittedComponentTypes.insert("Identity");
	permittedComponentTypes.insert("BuildRestrictions");
	permittedComponentTypes.insert("Obstruction");
	permittedComponentTypes.insert("Selectable");
	permittedComponentTypes.insert("Footprint");
	permittedComponentTypes.insert("Fogging");
	permittedComponentTypes.insert("Armour");
	permittedComponentTypes.insert("Health");
	permittedComponentTypes.insert("StatusBars");
	permittedComponentTypes.insert("OverlayRenderer");
	permittedComponentTypes.insert("Decay");
	permittedComponentTypes.insert("Cost");
	permittedComponentTypes.insert("Sound");
	permittedComponentTypes.insert("Visibility");
	permittedComponentTypes.insert("Vision");
	permittedComponentTypes.insert("AIProxy");
	permittedComponentTypes.insert("RallyPoint");
	permittedComponentTypes.insert("RallyPointRenderer");

	CParamNode::LoadXMLString(out, "<Entity/>");
	out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);

	// Switch the actor to foundation mode
	CParamNode::LoadXMLString(out, "<Entity><VisualActor><Foundation/></VisualActor></Entity>");

	// Add the Foundation component, to deal with the construction process
	CParamNode::LoadXMLString(out, "<Entity><Foundation/></Entity>");

	// Initialise health to 1
	CParamNode::LoadXMLString(out, "<Entity><Health><Initial>1</Initial></Health></Entity>");

	// Foundations shouldn't initially block unit movement
	if (out.GetChild("Entity").GetChild("Obstruction").IsOk())
		CParamNode::LoadXMLString(out, "<Entity><Obstruction><DisableBlockMovement>true</DisableBlockMovement><DisableBlockPathfinding>true</DisableBlockPathfinding></Obstruction></Entity>");

	// Don't provide population bonuses yet (but still do take up population cost)
	if (out.GetChild("Entity").GetChild("Cost").IsOk())
		CParamNode::LoadXMLString(out, "<Entity><Cost><PopulationBonus>0</PopulationBonus></Cost></Entity>");

	// Foundations should be visible themselves in fog-of-war if their base template is,
	// but shouldn't have any vision range
	if (out.GetChild("Entity").GetChild("Vision").IsOk())
	{
		CParamNode::LoadXMLString(out, "<Entity><Vision><Range>0</Range></Vision></Entity>");
		// Foundations should not have special vision capabilities either
		if (out.GetChild("Entity").GetChild("Vision").GetChild("RevealShore").IsOk())
			CParamNode::LoadXMLString(out, "<Entity><Vision><RevealShore>false</RevealShore></Vision></Entity>");
	}
}
Exemple #3
0
void CTemplateLoader::CopyPreviewSubset(CParamNode& out, const CParamNode& in, bool corpse)
{
	// We only want to include components which are necessary (for the visual previewing of an entity)
	// and safe (i.e. won't do anything that affects the synchronised simulation state), so additions
	// to this list should be carefully considered
	std::set<std::string> permittedComponentTypes;
	permittedComponentTypes.insert("Identity");
	permittedComponentTypes.insert("Ownership");
	permittedComponentTypes.insert("Position");
	permittedComponentTypes.insert("Visibility");
	permittedComponentTypes.insert("VisualActor");
	permittedComponentTypes.insert("Footprint");
	permittedComponentTypes.insert("Obstruction");
	permittedComponentTypes.insert("Decay");
	permittedComponentTypes.insert("BuildRestrictions");

	// Need these for the Actor Viewer:
	permittedComponentTypes.insert("Attack");
	permittedComponentTypes.insert("UnitMotion");
	permittedComponentTypes.insert("Sound");

	// (This set could be initialised once and reused, but it's not worth the effort)

	CParamNode::LoadXMLString(out, "<Entity/>");
	out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);

	// Disable the Obstruction component (if there is one) so it doesn't affect pathfinding
	// (but can still be used for testing this entity for collisions against others)
	if (out.GetChild("Entity").GetChild("Obstruction").IsOk())
		CParamNode::LoadXMLString(out, "<Entity><Obstruction><Active>false</Active></Obstruction></Entity>");

	if (!corpse)
	{
		// Previews should not cast shadows
		if (out.GetChild("Entity").GetChild("VisualActor").IsOk())
			CParamNode::LoadXMLString(out, "<Entity><VisualActor><DisableShadows/></VisualActor></Entity>");

		// Previews should always be visible in fog-of-war/etc
		CParamNode::LoadXMLString(out, "<Entity><Visibility><AlwaysVisible>true</AlwaysVisible><Preview>true</Preview></Visibility></Entity>");
	}

	if (corpse)
	{
		// Corpses should include decay components and activate them
		if (out.GetChild("Entity").GetChild("Decay").IsOk())
			CParamNode::LoadXMLString(out, "<Entity><Decay><Active>true</Active></Decay></Entity>");

		// Corpses shouldn't display silhouettes (especially since they're often half underground)
		if (out.GetChild("Entity").GetChild("VisualActor").IsOk())
			CParamNode::LoadXMLString(out, "<Entity><VisualActor><SilhouetteDisplay>false</SilhouetteDisplay></VisualActor></Entity>");

		// Corpses should remain visible in fog-of-war (for the owner only)
		CParamNode::LoadXMLString(out, "<Entity><Visibility><Corpse>true</Corpse></Visibility></Entity>");
	}
}
Exemple #4
0
void CTemplateLoader::CopyConstructionSubset(CParamNode& out, const CParamNode& in)
{
	// Currently used for buildings rising during construction
	// Mostly serves to filter out components like Vision, UnitAI, etc.
	std::set<std::string> permittedComponentTypes;
	permittedComponentTypes.insert("Footprint");
	permittedComponentTypes.insert("Ownership");
	permittedComponentTypes.insert("Position");
	permittedComponentTypes.insert("VisualActor");

	CParamNode::LoadXMLString(out, "<Entity/>");
	out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);
}
Exemple #5
0
void CTemplateLoader::CopyResourceSubset(CParamNode& out, const CParamNode& in)
{
	// Currently used for animals which die and leave a gatherable corpse.
	// Mostly serves to filter out components like Vision, UnitAI, etc.
	std::set<std::string> permittedComponentTypes;
	permittedComponentTypes.insert("Ownership");
	permittedComponentTypes.insert("Position");
	permittedComponentTypes.insert("VisualActor");
	permittedComponentTypes.insert("Identity");
	permittedComponentTypes.insert("Obstruction");
	permittedComponentTypes.insert("Minimap");
	permittedComponentTypes.insert("ResourceSupply");
	permittedComponentTypes.insert("Selectable");
	permittedComponentTypes.insert("Footprint");
	permittedComponentTypes.insert("StatusBars");
	permittedComponentTypes.insert("OverlayRenderer");
	permittedComponentTypes.insert("Sound");
	permittedComponentTypes.insert("AIProxy");

	CParamNode::LoadXMLString(out, "<Entity/>");
	out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);
}