Author Topic: Differences between SimSets and SimGroups?  (Read 1302 times)

as far as I can tell they are identical. am i missing something?

apparently not
Code: [Select]
class  SimSet : public SimObject {
  public:
   virtual void listObjects() {}
   virtual void add(obj1,...) {}
   virtual void remove(obj1,...) {}
   virtual void clear() {}
   virtual int getCount() {}
   virtual int getObject(objIndex) {}
   virtual bool isMember(object) {}
   virtual void bringToFront(object) {}
   virtual void pushToBack(object) {}
   virtual void clientDeleteAll() {}
   virtual void deleteAll() {}
};

class  SimGroup : public SimSet {
  public:
   virtual Script addPotentialTrust() {}
   virtual Script chainDeleteAll() {}
   virtual Script chainBlink() {}
   virtual Script dumpSpawnPoints() {}
   virtual Script getBrickSpawnPoint() {}
   virtual Script removeSpawnBrick() {}
   virtual Script addSpawnBrick() {}
   virtual Script hasUser() {}
   virtual Script getClient() {}
   virtual Script ClearAllNTNames() {}
   virtual Script DumpNTNames() {}
   virtual Script removeNTName() {}
   virtual Script addNTName() {}
};
SimGroup inherits from SimSet

so a sim set is like a hand of cards that was dealt and has a specific order, but a sim group is like a shuffled deck of cards?

disregarding the differences in size

also what are these:  virtual Script ClearAllNTNames() {}
   virtual Script DumpNTNames() {}
   virtual Script removeNTName() {}
   virtual Script addNTName() {}

and initializeEvent or somethign, I keep seeing it in ::dump();

Quote
A group of SimObjects.
A SimGroup is a stricter form of SimSet. SimObjects may only be a member of a single SimGroup at a time.

The SimGroup will automatically enforce the single-group-membership rule.
Code: [Select]
     // From engine/sim/simPath.cc - getting a pointer to a SimGroup
      SimGroup* pMissionGroup = dynamic_cast<SimGroup*>(Sim::findObject("MissionGroup"));

      // From game/trigger.cc:46 - iterating over a SimObject's group.
      SimObject* trigger = ...;
      SimGroup* pGroup = trigger->getGroup();
      for (SimGroup::iterator itr = pGroup->begin(); itr != pGroup->end(); itr++)
      {
         // do something with *itr
      }

edit:
Most, or all, of those functions seem to be related to brick groups, so they shouldn't be included in the differences as far as what they originally do.
« Last Edit: July 06, 2012, 12:47:59 AM by otto-san »

i presume they are manipulated similarly to each other though?

i presume they are manipulated similarly to each other though?
As far as I know any 'group' sort of objects in Torque are manipulated the same ways. (with add and remove and stuff like that)

Those are just functions made for the base game.

Here's the real difference:

Adding an object to a SimGroup will remove it from it's current group.
Adding an object to a SimSet will not remove it from it's current group.

so when working with bricks, it would be advisable to have them in a simSet so they aren't removed from the brickgroup?


Adding an object to a SimGroup will remove it from it's current group.
Adding an object to a SimSet will not remove it from it's current group.

Said more specifically, a SimSet simply contains objects. When the set is deleted, nothing special happens.
However for a SimGroup, adding an object will automatically remove that object from any SimGroup it was previously in. In addition, deleting the set will delete all members.

Also, pretty much all objects have a getGroup method which returns the SimGroup it is currently in, if any.

Objects aren't always stored in simgroups though. There's other group-like objects, such as GUI elements and GameConnections.

it's worth noting getGroup() returns simGroups not simSets, but as said above an object can be in an infinite number of simSets but only one simGroup.