Package org.nlogo.prim.etc

Source Code of org.nlogo.prim.etc._subject

// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo

package org.nlogo.prim.etc;

import org.nlogo.api.Agent;
import org.nlogo.api.PerspectiveJ;
import org.nlogo.api.Syntax;
import org.nlogo.nvm.Reporter;

public final strictfp class _subject
    extends Reporter {
  @Override
  public Object report(final org.nlogo.nvm.Context context) {
    if (world.observer().perspective() == PerspectiveJ.OBSERVE()) {
      return org.nlogo.api.Nobody$.MODULE$;
    }
    Agent subject = world.observer().targetAgent();
    // not actually sure if the null check here is necessary - ST 6/28/05
    if (subject == null || subject.id() == -1) {
      return org.nlogo.api.Nobody$.MODULE$;
    }
    return subject;
  }

  @Override
  public Syntax syntax() {
    return Syntax.reporterSyntax(Syntax.AgentType());
  }
}
TOP

Related Classes of org.nlogo.prim.etc._subject

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.