Beispiel #1
0
CSpringUnit* CSpringGame::CreateUnit(int id) {
    if (id < 0) {
        SendToConsole("shard-runtime warning: tried to create unit with id < 0");
        return NULL;
    }
    springai::Unit* unit = springai::WrappUnit::GetInstance(callback->GetSkirmishAIId(), id);
    if (unit) {
        return CreateUnit(unit);
    } else {
        SendToConsole("shard-runtime warning: Could not create unit, WrappUnit returned NULL.");
        return NULL;
    }
}
	void ElementGroup::ProcessComponent(const ComponentPtr& component, bool removable)
	{
		bool added = AddInspector(component, component->GetType(), removable);

		// If there wasn't a specific inspector for the given type, try adding interface inspectors
		if (!added)
		{
			// Make sure the transform inspector is at the top
			const auto& actualInterfaces = component->GetInterfaces();
			auto entry = actualInterfaces.find("ITransform");
			if (entry == actualInterfaces.end())
			{
				for (auto it = actualInterfaces.begin(), end = actualInterfaces.end(); it != end; ++it)
					added |= AddInspector(component, *it, removable);
			}
			else
			{
				AddInspector(component, "ITransform", false);

				std::set<std::string> interfacesMinusTransform = actualInterfaces;
				interfacesMinusTransform.erase("ITransform");
				for (auto it = interfacesMinusTransform.begin(), end = interfacesMinusTransform.end(); it != end; ++it)
					added |= AddInspector(component, *it, removable);
			}
		}
		if (!added)
			SendToConsole("No inspector for component type: " + component->GetType());
	}