public static Door Create(AuroraUTD utd, AuroraGIT.ADoor gitData) { GameObject gameObject; //get the resource reference for this object, which we'll use as it's in-engine name string name = utd.TemplateResRef; //get the appearance row number in genericdoors.2da int appearance = utd.GenericType; //get the model name for this door id string modelRef = Resources.Load2DA("genericdoors")[appearance, "modelname"]; //create a new game object and load the model into the scene gameObject = Resources.LoadModel(modelRef); gameObject.name = name; //add the template component to the new object Door door = gameObject.AddComponent <Door>(); door.template = utd; door.gitData = gitData; LookAtHook hook = gameObject.GetComponentInChildren <LookAtHook>(); if (hook != null) { hook.obj = door; } return(door); }
public static Placeable Create(AuroraUTP utp, AuroraGIT.APlaceable gitData) { if (guiSystem == null) { guiSystem = GameObject.Find("GUI System").GetComponent <GUISystem>(); } GameObject gameObject; //get the resource reference for this object, which we'll use as it's in-engine name string name = utp.TemplateResRef; //get the appearance row number in placeables.2da int appearance = (int)utp.Appearance; //get the model name for this appearance id string modelRef = Resources.Load2DA("placeables")[appearance, "modelname"]; if (modelRef == "PLC_Invis") { gameObject = new GameObject(name); } else { gameObject = Resources.LoadModel(modelRef); gameObject.name = name; } //add the template component to the new object Placeable placeable = gameObject.AddComponent <Placeable>(); placeable.template = utp; placeable.gitData = gitData; LookAtHook hook = gameObject.GetComponentInChildren <LookAtHook>(); if (hook != null) { hook.obj = placeable; } return(placeable); }
public static Creature Create(AuroraUTC utc, AuroraGIT.ACreature gitData) { //GameObject gameObject; //get the resource reference for this object, which we'll use as it's in-engine name string name = utc.TemplateResRef; //get the appearance row number in appearance.2da int appearance = utc.Appearance_Type; string modelType = Resources.From2DA("appearance", appearance, "modeltype"); //get the model name for this appearance id string modelRef = Resources.Load2DA("appearance")[appearance, "modela"]; if (modelRef == null) { // This should only happen if we didn't find the row in appearance modelRef = Resources.Load2DA("appearance")[appearance, "race"]; } string texRef = Resources.Load2DA("appearance")[appearance, "texa"]; string cubemapRef = Resources.From2DA("appearance", appearance, "envmap"); if (Resources.data.GetStream(modelRef, ResourceType.MDL) == null) { modelRef = Resources.Load2DA("appearance")[appearance, "modelb"]; texRef = Resources.Load2DA("appearance")[appearance, "texb"]; } if (cubemapRef == "" || cubemapRef == "DEFAULT") { cubemapRef = null; } //create a new game object and load the model into the scene GameObject gameObject = Resources.LoadModel(modelRef, null, null, cubemapRef); gameObject.name = name; GameObject headObj = null; switch (modelType.ToLower()) { case "b": // Model requires a head int headID = int.Parse(Resources.From2DA("appearance", appearance, "normalhead")); string headName = Resources.From2DA("heads", headID, "head"); headObj = Resources.LoadModel(headName, null, gameObject, cubemapRef); break; case "f": default: // Model includes head break; } // Add a character controller for movement NavMeshAgent agent = gameObject.AddComponent <NavMeshAgent>(); // Make the creature commandable by default utc.Commandable = 1; //add the template component to the new object Creature creature = gameObject.AddComponent <Creature>(); creature.template = utc; creature.gitData = gitData; creature.head = headObj; LookAtHook hook = gameObject.GetComponentInChildren <LookAtHook>(); if (hook != null) { hook.obj = creature; } //if (headObj != null) //{ // Transform headPosition = gameObject.transform.Find("cutscenedummy/rootdummy/torso_g/torsoupr_g/headhook"); // character.head.transform.localPosition = headPosition.position - character.head.transform.position; // character.head.transform.localRotation = Quaternion.identity; //} return(creature); }