public static string MissionBoundsExtents(SimSet group)
        {
            string box   = "0 0 0 0 0 0";
            int    count = group.getCount();

            for (uint i = 0; i < count; i++)
            {
                // Skip LevelInfos. Need a way to detect other non-SceneObjects.
                // Also skip GroundPlanes. They're too big.
                SimObject obj = group.getObject(i);
                //var cls = obj.getClassName();
                var cls = obj.GetType().Name;
                if (cls == "LevelInfo" || cls == "GroundPlane" || cls == "GroundCover")
                {
                    continue;
                }

                // Get world box - might have to recurse into nested SimGroups.
                string wbox = "0 0 0 0 0 0";
                if (cls == "SimGroup" || cls == "SimSet" || cls == "Path")
                {
                    wbox = MissionBoundsExtents((SimSet)obj);
                }
                else if (obj.GetType() == typeof(SceneObject) && ((SceneObject)obj).getType() == omni.iGlobal["$TypeMasks::StaticObjectType"] &&
                         !(((SceneObject)obj).getType() == omni.iGlobal["$TypeMasks::EnvironmentObjectType"]))
                {
                    wbox = ((SceneObject)obj).getWorldBox().AsString();
                }
                else
                {
                    continue;
                }

                // Update min point.
                for (int j = 0; j < 3; j++)
                {
                    if (omni.Util.getWord(box, j).AsInt() > omni.Util.getWord(wbox, j).AsInt())
                    {
                        box = omni.Util.setWord(box, j, omni.Util.getWord(wbox, j));
                    }
                }
                // Update max point.
                for (int j = 3; j < 6; j++)
                {
                    if (omni.Util.getWord(box, j).AsInt() < omni.Util.getWord(wbox, j).AsInt())
                    {
                        box = omni.Util.setWord(box, j, omni.Util.getWord(wbox, j));
                    }
                }
            }
            return(box);
        }
        public static string CallScriptFunction(string pFunctionNamespace, string pFunctionName, object[] args, out bool found)
        {
            if (pFunctionNamespace != null)
            {
                Type      type;
                SimObject obj = SimDictionary.Find(pFunctionNamespace);

                string objectName = pFunctionNamespace;
                if (objectName != null && ClassTypeDictionary.ContainsKey(objectName))
                {
                    type = ClassTypeDictionary[objectName];
                }
                else if (obj != null)
                {
                    type = obj.GetType();
                }
                else
                {
                    //todo throw exception?
                    found = false;
                    return(null);
                }

                return(CallNamespaceMethod(type, obj, pFunctionName, args, out found));
            }
            if (!FunctionDictionary.ContainsKey(pFunctionName))
            {
                found = false;
                return(null);
            }
            found = true;
            MethodInfo methodInfo = FunctionDictionary[pFunctionName];

            return(InvokeMethod(methodInfo, null, args, out found));
        }
        public static string CallScriptMethod(string className, string classNamespace, SimObject objectWrapper, string methodName, object[] args, out bool found)
        {
            if (methodName.Equals("pushDialog"))
            {
                methodName = methodName;
            }
            Type   type;
            string objectName = objectWrapper.getName();

            if (objectName != null && ClassTypeDictionary.ContainsKey(objectName))
            {
                type = ClassTypeDictionary[objectName];
            }
            else if (classNamespace != null && ClassTypeDictionary.ContainsKey(classNamespace))
            {
                type = ClassTypeDictionary[classNamespace];
            }
            else if (ClassTypeDictionary.ContainsKey(className))
            {
                type = ClassTypeDictionary[className];
            }
            else if (SimDictionary.Find(objectWrapper.Name) != null)
            {
                type = SimDictionary.Find(objectWrapper.Name).GetType();
            }
            else if (SimDictionary.Find(objectWrapper.getId()) != null)
            {
                type = SimDictionary.Find(objectWrapper.getId()).GetType();
            }
            else
            {
                if (ClassTypeDictionary.ContainsKey(objectWrapper.GetType().Name))
                {
                    type = ClassTypeDictionary[objectWrapper.GetType().Name];
                }
                else
                {
                    found = false;
                    return(null);
                }
            }
            return(CallNamespaceMethod(type, objectWrapper, methodName, args, out found));
        }
Beispiel #4
0
 public void onSelect(SimObject item)
 {
     if (item.GetType() == typeof(TerrainMaterial))
     {
         setActiveMaterial(item.unSafeCast <TerrainMaterial>());
     }
     else
     {
         setActiveMaterial(0);
     }
 }
	//-----------  SELECTED OBJECT STUFF.

	public void selectObject(SimObject obj) {

		if (obj != null) {
			//do the generic stuff.

			hudView.setObjectName(obj.getName());
			hudView.setObjectDescription(obj.getDesc());


			hud.setSelectedObject(obj);



			//get other object set up stuff.
			if (obj.GetType() == typeof(PlugLoadController)) {
				PlugLoadController pl = (PlugLoadController)obj;

				hudView.plugLoad_setListOfEnergyUsingObjects(pl.getEuoList(), pl);

			}
			else if (obj.GetType() == typeof(EnergyUsingObject)) {
				EnergyUsingObject euo = (EnergyUsingObject)obj;
				hudView.setListOfSelectablePlugLoads(euo);
			}

		}

	}