public static bool GetActive(string name) { bool result = false; Form form = Application.OpenForms["Form1"]; if (form == null) { return(false); } CheckBox cb = form.Controls.Find(name, true).FirstOrDefault() as CheckBox; if (cb == null) { return(false); } if (cb.InvokeRequired) { GetBool ph = new GetBool(GetActive); result = (bool)cb.Invoke(ph, name); } else { result = cb.Checked; } return(result); }
public UnitAnimation Init(Animator unit, WeaponAnimator right, WeaponAnimator left, float index, AnimationCallbackCaster callback, GetInt get_id, GetBool rs) { GetIdle = get_id; GetRage = rs; WeaponAnimator_Left = left; WeaponAnimator_Right = right; unit_animator = unit; SetWeaponIndex(index); //No multicast so we dont need to remove listeners callback.OnAbilityTrigger = AbilityCallback; callback.OnWeaponHide = WeaponHide; callback.OnWeaponShow = WeaponShow; return(this); }
public static UnitAnimation MakeUnitAnimations(GameObject unit_mesh, WeaponMesh weapon, int index, AnimationCallbackCaster callbacks, GetBool b) { WeaponAnimator animator_right = new WeaponAnimator(weapon.AttachmentRight, weapon.FX_Right, weapon.MuzzleRight); WeaponAnimator animator_left = new WeaponAnimator(weapon.AttachmentLeft, weapon.FX_Left, weapon.MuzzleLeft); Animator unit_animator = unit_mesh.GetComponent <Animator>(); UnitAnimation_IdleController idle = unit_mesh.GetComponent <UnitAnimation_IdleController>(); return(new UnitAnimation().Init(unit_animator, animator_right, animator_left, index, callbacks, idle.GetId, b)); }
private void RagePresence_Tick(object sender, EventArgs e) { // Wait until the game has loaded while (Function.Call <bool>(Hash.GET_IS_LOADING_SCREEN_ACTIVE)) { Yield(); } // Get the address of the main RagePresence ASI File IntPtr module = GetModuleHandle("RagePresence.asi"); // If is not there, return if (module == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find RagePresence.asi in memory. Please make sure that it was loaded by checking ScriptHookV.log and then restart your game."); Tick -= RagePresence_Tick; return; } // Try to get the addresses of the functions IntPtr set = GetProcAddress(module, "SetCustomMission"); IntPtr get = GetProcAddress(module, "GetCustomMission"); IntPtr check = GetProcAddress(module, "IsCustomMissionSet"); IntPtr clear = GetProcAddress(module, "ClearCustomMission"); // If the functions are not present, return if (set == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find SetCustomMission in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } if (get == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find GetCustomMission in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } else if (check == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find IsCustomMissionSet in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } else if (clear == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find ClearCustomMission in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } // If we got here, is safe to set the delegates for the pointers of the functions setCustomMission = Marshal.GetDelegateForFunctionPointer <SetString>(set); getCustomMission = Marshal.GetDelegateForFunctionPointer <GetString>(get); isCustomMissionSet = Marshal.GetDelegateForFunctionPointer <GetBool>(check); clearCustomMission = Marshal.GetDelegateForFunctionPointer <Void>(clear); // Then do the last steps Tick -= RagePresence_Tick; IsReady = true; }
private void RagePresence_Tick(object sender, EventArgs e) { // Wait until the game has loaded while (Function.Call <bool>(Hash.GET_IS_LOADING_SCREEN_ACTIVE)) { Yield(); } // Get the address of the main RagePresence ASI File IntPtr module = GetModuleHandle("RagePresence.asi"); // If is not there, return if (module == IntPtr.Zero) { Error("Unable to find RagePresence.asi in memory. Please make sure that it was loaded by checking ScriptHookV.log and then restart your game."); return; } // Try to get the addresses of the functions IntPtr missionSet = GetProcAddress(module, "SetCustomMission"); IntPtr missionGet = GetProcAddress(module, "GetCustomMission"); IntPtr missionCheck = GetProcAddress(module, "IsCustomMissionSet"); IntPtr missionClear = GetProcAddress(module, "ClearCustomMission"); IntPtr detailsSet = GetProcAddress(module, "SetCustomDetails"); IntPtr detailsGet = GetProcAddress(module, "GetCustomDetails"); IntPtr detailsCheck = GetProcAddress(module, "AreCustomDetailsSet"); IntPtr detailsClear = GetProcAddress(module, "ClearCustomDetails"); IntPtr stateSet = GetProcAddress(module, "SetCustomState"); IntPtr stateGet = GetProcAddress(module, "GetCustomState"); IntPtr stateCheck = GetProcAddress(module, "IsCustomStateSet"); IntPtr stateClear = GetProcAddress(module, "ClearCustomState"); // If the functions are not present, return if (missionSet == IntPtr.Zero) { PointerError("SetCustomMission"); return; } if (missionGet == IntPtr.Zero) { PointerError("GetCustomMission"); return; } else if (missionCheck == IntPtr.Zero) { PointerError("IsCustomMissionSet"); return; } else if (missionClear == IntPtr.Zero) { PointerError("ClearCustomMission"); return; } else if (detailsSet == IntPtr.Zero) { PointerError("SetCustomDetails"); return; } else if (detailsGet == IntPtr.Zero) { PointerError("GetCustomDetails"); return; } else if (detailsCheck == IntPtr.Zero) { PointerError("AreCustomDetailsSet"); return; } else if (detailsClear == IntPtr.Zero) { PointerError("ClearCustomDetails"); return; } else if (stateSet == IntPtr.Zero) { PointerError("SetCustomState"); return; } else if (stateGet == IntPtr.Zero) { PointerError("GetCustomState"); return; } else if (stateCheck == IntPtr.Zero) { PointerError("IsCustomStateSet"); return; } else if (stateClear == IntPtr.Zero) { PointerError("ClearCustomState"); return; } // If we got here, is safe to set the delegates for the pointers of the functions setCustomMission = Marshal.GetDelegateForFunctionPointer <SetString>(missionSet); getCustomMission = Marshal.GetDelegateForFunctionPointer <GetString>(missionGet); isCustomMissionSet = Marshal.GetDelegateForFunctionPointer <GetBool>(missionCheck); clearCustomMission = Marshal.GetDelegateForFunctionPointer <Void>(missionClear); setCustomDetails = Marshal.GetDelegateForFunctionPointer <SetString>(detailsSet); getCustomDetails = Marshal.GetDelegateForFunctionPointer <GetString>(detailsGet); areCustomDetailsSet = Marshal.GetDelegateForFunctionPointer <GetBool>(detailsCheck); clearCustomDetails = Marshal.GetDelegateForFunctionPointer <Void>(detailsClear); setCustomState = Marshal.GetDelegateForFunctionPointer <SetString>(stateSet); getCustomState = Marshal.GetDelegateForFunctionPointer <GetString>(stateGet); isCustomStateSet = Marshal.GetDelegateForFunctionPointer <GetBool>(stateCheck); clearCustomState = Marshal.GetDelegateForFunctionPointer <Void>(stateClear); // Then do the last steps Tick -= RagePresence_Tick; IsReady = true; }