public OCObjectMapInfo(UnityEngine.GameObject gameObject) { UnityEngine.Debug.Log("OCObjectMapInfo::OCObjectMapInfo, passed object is of type: " + gameObject.GetType().ToString() + ", and name " + gameObject.name); _id = gameObject.GetInstanceID().ToString(); // // Get id of a game object // _id = gameObject.GetInstanceID ().ToString (); // Get name _name = gameObject.name; // TODO: By default, we are using object type. _type = OCEmbodimentXMLTags.ORDINARY_OBJECT_TYPE; // Convert from unity coordinate to OAC coordinate. this.position = Utility.VectorUtil.ConvertToOpenCogCoord(gameObject.transform.position); // Get rotation _rotation = new Utility.Rotation(gameObject.transform.rotation); // Calculate the velocity later _velocity = UnityEngine.Vector3.zero; // Get size if (gameObject.collider != null) { // Get size information from collider. _width = gameObject.collider.bounds.size.z; _height = gameObject.collider.bounds.size.y; _length = gameObject.collider.bounds.size.x; } else { OCLogger.Warn("No collider for gameobject " + gameObject.name + ", assuming a point."); // Set default value of the size. _width = 0.1f; _height = 0.1f; _length = 0.1f; } if (gameObject.tag == "OCAGI") { // This is an OC avatar, we will use the brain id instead of unity id. OCConnectorSingleton connector = OCConnectorSingleton.Instance; if (connector != null) { _id = connector.BrainID; _type = OCEmbodimentXMLTags.PET_OBJECT_TYPE; } UnityEngine.Debug.Log("Just made an OCObjectMapInfo stating the AGI is at [" + this.position.x + ", " + this.position.y + ", " + this.position.z + "]"); } else if (gameObject.tag == "OCNPC") { // This is a human player avatar. _type = OCEmbodimentXMLTags.AVATAR_OBJECT_TYPE; _length = OCObjectMapInfo.DEFAULT_AVATAR_LENGTH; _width = OCObjectMapInfo.DEFAULT_AVATAR_WIDTH; _height = OCObjectMapInfo.DEFAULT_AVATAR_HEIGHT; } if (gameObject.tag == "OCNPC" || gameObject.tag == "OCAGI" || gameObject.tag == "Player") { if (_height > 1.1f) // just to make sure that the center point of the character will not be in the block where the feet are { this.position = new UnityEngine.Vector3(this.position.x, this.position.y, this.position.z + 1.0f); } } if (gameObject.name == "Hearth") { this.AddProperty("petHome", "TRUE", System.Type.GetType("System.Boolean")); } // Get weight if (gameObject.rigidbody != null) { _weight = gameObject.rigidbody.mass; } else { _weight = 0.0f; } if (gameObject.GetComponent <OpenCog.Extensions.OCConsumableData>() != null) { UnityEngine.Debug.Log("Adding edible and foodbowl tags to '" + gameObject.name + "' with ID " + gameObject.GetInstanceID()); this.AddProperty("edible", "TRUE", System.Type.GetType("System.Boolean")); this.AddProperty("pickupable", "TRUE", System.Type.GetType("System.Boolean")); this.AddProperty("holder", "none", System.Type.GetType("System.String")); } // Get a property manager instance // TODO: may need to re-enable this for other object types. // OCPropertyManager manager = gameObject.GetComponent<OCPropertyManager> () as OCPropertyManager; // if (manager != null) { // // Copy all OC properties from the manager, if any. // foreach (OpenCog.Serialization.OCPropertyField ocp in manager.propertyList) { // this.AddProperty (ocp.Key, ocp.value, ocp.valueType); // } // } this.AddProperty("visibility-status", "visible", System.Type.GetType("System.String")); this.AddProperty("detector", "true", System.Type.GetType("System.Boolean")); string gameObjectName = gameObject.name; if (gameObjectName.Contains("(")) { gameObjectName = gameObjectName.Remove(gameObjectName.IndexOf('(')); } // For Einstein puzzle if (gameObject.name.Contains("_man")) { _id = _name; this.AddProperty("class", "people", System.Type.GetType("System.String")); } else { this.AddProperty("class", gameObjectName, System.Type.GetType("System.String")); } }