//private AudioSource m_audio; private void Start() { try { //ModConsole.Print("Load Trailer"); base.gameObject.name = "trailer"; //base.gameObject.layer = LayerMask.NameToLayer("Object"); //base.gameObject.tag = "OBJECT"; //ModConsole.Print("Find Trailer"); if (transform != null) { m_Connector = transform.FindChild("BodyCollider/ConnectTrigger").GetComponent <Collider>(); centerOfMass = transform.FindChild("CenterOfMass"); } else { // ModConsole.Print("Transform Null"); return; } if (centerOfMass != null) { //ModConsole.Print("Definiu centro de gravidade."); ridgbody = GetComponent <Rigidbody>(); ridgbody.centerOfMass = centerOfMass.localPosition; } this.Load(); // ModConsole.Print("Trailer Loaded"); GameHook.InjectStateHook(GameObject.Find("ITEMS"), "Save game", new Action(this.Save)); }catch (Exception E) { ModConsole.Error("Start Error: " + E.ToString()); } }
public static void InjectStateHook(GameObject gameObject, string stateName, Action hook) { FsmState stateFromGameObject = GameHook.GetStateFromGameObject(gameObject, stateName); if (stateFromGameObject != null) { List <FsmStateAction> list = new List <FsmStateAction>(stateFromGameObject.Actions); list.Insert(0, new GameHook.FsmHookAction { hook = hook }); stateFromGameObject.Actions = list.ToArray(); } }