Beispiel #1
0
inline scene::Node& node_for_eclass (EntityClass* eclass)
{
	scene::Node& node = entity_for_eclass(eclass);
	Node_getEntity(node)->setKeyValue("classname", eclass->name());

	Namespaced* namespaced = Node_getNamespaced(node);
	if (namespaced != 0) {
		namespaced->setNamespace(GlobalNamespace());
	}

	return node;
}
Beispiel #2
0
inline scene::Node& node_for_eclass(EntityClass* eclass)
{
  scene::Node& node = entity_for_eclass(eclass);
  Node_getEntity(node)->setKeyValue("classname", eclass->name());

  if(g_gameType == eGameTypeDoom3
    && string_not_empty(eclass->name())
    && !string_equal(eclass->name(), "worldspawn")
    && !string_equal(eclass->name(), "UNKNOWN_CLASS"))
  {
    char buffer[1024];
    strcpy(buffer, eclass->name());
    strcat(buffer, "_1");
    GlobalNamespace().makeUnique(buffer, EntitySetNameCaller(*Node_getEntity(node)));
  }

  Namespaced* namespaced = Node_getNamespaced(node);
  if(namespaced != 0)
  {
    namespaced->setNamespace(GlobalNamespace());
  }

  return node;
}
Beispiel #3
0
		void connectEntities (const scene::Path& path, const scene::Path& targetPath)
		{
			Entity* e1 = ScenePath_getEntity(path);
			Entity* e2 = ScenePath_getEntity(targetPath);

			if (e1 == 0 || e2 == 0) {
				globalErrorStream() << "entityConnectSelected: both of the selected instances must be an entity\n";
				return;
			}

			if (e1 == e2) {
				globalErrorStream()
						<< "entityConnectSelected: the selected instances must not both be from the same entity\n";
				return;
			}

			UndoableCommand undo("entityConnectSelected");

			ConnectEntities connector(e1, e2);
			std::string value = e2->getKeyValue("targetname");
			if (value.empty()) {
				value = e1->getKeyValue("target");
			}
			if (!value.empty()) {
				connector.connect(value);
			} else {
				std::string type = e2->getKeyValue("classname");
				if (type.empty()) {
					type = "t";
				}
				std::string key = type + "1";
				GlobalNamespace().makeUnique(key, ConnectEntities::ConnectCaller(connector));
			}

			SceneChangeNotify();
		}
Beispiel #4
0
  void connectEntities(const scene::Path& path, const scene::Path& targetPath, int index)
  {
    Entity* e1 = ScenePath_getEntity(path);
    Entity* e2 = ScenePath_getEntity(targetPath);

    if(e1 == 0 || e2 == 0)
    {
      globalErrorStream() << "entityConnectSelected: both of the selected instances must be an entity\n";
      return;
    }

    if(e1 == e2)
    {
      globalErrorStream() << "entityConnectSelected: the selected instances must not both be from the same entity\n";
      return;
    }


    UndoableCommand undo("entityConnectSelected");

    if(g_gameType == eGameTypeDoom3)
    {
      StringOutputStream key(16);
      if(index >= 0)
      {
	  key << "target";
	  if(index != 0)
	  {
	    key << index;
	  }
	  e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
	  key.clear();
      }
      else
      {
	for(unsigned int i = 0; ; ++i)
	{
	  key << "target";
	  if(i != 0)
	  {
	    key << i;
	  }
	  const char* value = e1->getKeyValue(key.c_str());
	  if(string_empty(value))
	  {
	    e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
	    break;
	  }
	  key.clear();
	}
      }
    }
    else
    {
      ConnectEntities connector(e1, e2, index);
      const char* value = e2->getKeyValue("targetname");
      if(!string_empty(value))
      {
        connector.connect(value);
      }
      else
      {
        const char* type = e2->getKeyValue("classname");
        if(string_empty(type))
        {
          type = "t";
        }
        StringOutputStream key(64);
        key << type << "1";
        GlobalNamespace().makeUnique(key.c_str(), ConnectEntities::ConnectCaller(connector));
      }
    }

    SceneChangeNotify();
  }