code: public static Bag getAllObjects(ShanksSimulation simulation,
              PercipientShanksAgent agent) {
          Location agentLocation = agent.getCurrentLocation();
          if (agentLocation.is3DLocation()) {
              try {
                  ContinuousPortrayal3D devicesPortrayal = (ContinuousPortrayal3D) simulation
                          .getScenarioPortrayal().getPortrayals()
                          .get(Scenario3DPortrayal.MAIN_DISPLAY_ID)
                          .get(ScenarioPortrayal.DEVICES_PORTRAYAL);
                  Continuous3D devicesField = (Continuous3D) devicesPortrayal
                          .getField();
                  Bag objects = devicesField.getAllObjects();
                  return objects;
              } catch (DuplicatedPortrayalIDException e) {
                  e.printStackTrace();
              } catch (ScenarioNotFoundException e) {
                  e.printStackTrace();
              } catch (ShanksException e) {
                  e.printStackTrace();
              }
          } else if (agentLocation.is2DLocation()) {
              try {
                  ContinuousPortrayal2D devicesPortrayal = (ContinuousPortrayal2D) simulation
                          .getScenarioPortrayal().getPortrayals()
                          .get(Scenario2DPortrayal.MAIN_DISPLAY_ID)
                          .get(ScenarioPortrayal.DEVICES_PORTRAYAL);
                  Continuous2D devicesField = (Continuous2D) devicesPortrayal
                          .getField();
                  Bag objects = devicesField.getAllObjects();
                  return objects;
              } catch (DuplicatedPortrayalIDException e) {
                  e.printStackTrace();
              } catch (ScenarioNotFoundException e) {
                  e.printStackTrace();
              } catch (ShanksException e) {
                  e.printStackTrace();
              }
          }
          return null;
      }
docs: To obtain all objects in the simulation
  
  @param simulation
  @param agent
  @return the objects that are in the simulation