Initial migration commit to .NET 7

Menu, sync and other stuff except resource system should be working.
We're far from finished
This commit is contained in:
Sardelka9515
2023-01-28 20:51:29 +08:00
parent 0112140f0e
commit cac2385c35
107 changed files with 36610 additions and 267320 deletions

View File

@ -12,22 +12,22 @@ namespace RageCoop.Client
if (speaking)
{
Function.Call(Hash.PLAY_FACIAL_ANIM, MainPed.Handle, "mic_chatter", "mp_facial");
Call(PLAY_FACIAL_ANIM, MainPed.Handle, "mic_chatter", "mp_facial");
return;
}
switch (MainPed.Gender)
{
case Gender.Male:
Function.Call(Hash.PLAY_FACIAL_ANIM, MainPed.Handle, "mood_normal_1",
Call(PLAY_FACIAL_ANIM, MainPed.Handle, "mood_normal_1",
"facials@gen_male@variations@normal");
break;
case Gender.Female:
Function.Call(Hash.PLAY_FACIAL_ANIM, MainPed.Handle, "mood_normal_1",
Call(PLAY_FACIAL_ANIM, MainPed.Handle, "mood_normal_1",
"facials@gen_female@variations@normal");
break;
default:
Function.Call(Hash.PLAY_FACIAL_ANIM, MainPed.Handle, "mood_normal_1",
Call(PLAY_FACIAL_ANIM, MainPed.Handle, "mood_normal_1",
"facials@mime@variations@normal");
break;
}
@ -41,12 +41,12 @@ namespace RageCoop.Client
if (ourAnim != null && animDict != null)
{
var flag = AnimationFlags.Loop;
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed, animDict, ourAnim, 3))
if (!Call<bool>(IS_ENTITY_PLAYING_ANIM, MainPed, animDict, ourAnim, 3))
{
if (LoadAnim(animDict) == null) return;
MainPed.Task.ClearAll();
Function.Call(Hash.TASK_PLAY_ANIM, MainPed, animDict, ourAnim, 8f, 10f, -1, flag, -8f, 1, 1, 1);
Call(TASK_PLAY_ANIM, MainPed, animDict, ourAnim, 8f, 10f, -1, flag, -8f, 1, 1, 1);
}
}
}
@ -149,9 +149,9 @@ namespace RageCoop.Client
private string LoadAnim(string anim)
{
if (!Function.Call<bool>(Hash.HAS_ANIM_DICT_LOADED, anim))
if (!Call<bool>(HAS_ANIM_DICT_LOADED, anim))
{
Function.Call(Hash.REQUEST_ANIM_DICT, anim);
Call(REQUEST_ANIM_DICT, anim);
return null;
}

View File

@ -208,13 +208,13 @@ namespace RageCoop.Client
MainPed.IsFireProof = false;
MainPed.IsExplosionProof = false;
Function.Call(Hash.SET_PED_DROPS_WEAPONS_WHEN_DEAD, MainPed.Handle, false);
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, MainPed.Handle, true);
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED_BY_PLAYER, MainPed.Handle, Game.Player, true);
Function.Call(Hash.SET_PED_GET_OUT_UPSIDE_DOWN_VEHICLE, MainPed.Handle, false);
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, MainPed.Handle, true, true);
// Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
Call(SET_PED_DROPS_WEAPONS_WHEN_DEAD, MainPed.Handle, false);
Call(SET_PED_CAN_BE_TARGETTED, MainPed.Handle, true);
Call(SET_PED_CAN_BE_TARGETTED_BY_PLAYER, MainPed.Handle, Game.Player, true);
Call(SET_PED_GET_OUT_UPSIDE_DOWN_VEHICLE, MainPed.Handle, false);
Call(SET_CAN_ATTACK_FRIENDLY, MainPed.Handle, true, true);
// Call(_SET_PED_CAN_PLAY_INJURED_ANIMS, false);
Call(SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater, false);
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
@ -244,7 +244,7 @@ namespace RageCoop.Client
private void SetClothes()
{
for (byte i = 0; i < 12; i++)
Function.Call(Hash.SET_PED_COMPONENT_VARIATION, MainPed.Handle, i, (int)Clothes[i],
Call(SET_PED_COMPONENT_VARIATION, MainPed.Handle, i, (int)Clothes[i],
(int)Clothes[i + 12], (int)Clothes[i + 24]);
_lastClothes = Clothes;
}
@ -257,12 +257,12 @@ namespace RageCoop.Client
MainPed.PositionNoOffset = Vector3.Lerp(MainPed.ReadPosition(), Position + Velocity, 0.5f);
MainPed.Quaternion = Rotation.ToQuaternion();
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "skydive@base", "free_idle", 3))
if (!Call<bool>(IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "skydive@base", "free_idle", 3))
{
// Skip update if animation is not loaded
var dict = LoadAnim("skydive@base");
if (dict == null) return;
Function.Call(Hash.TASK_PLAY_ANIM, MainPed.Handle, dict, "free_idle", 8f, 10f, -1, 0, -8f, 1, 1, 1);
Call(TASK_PLAY_ANIM, MainPed.Handle, dict, "free_idle", 8f, 10f, -1, 0, -8f, 1, 1, 1);
}
return;
@ -293,12 +293,12 @@ namespace RageCoop.Client
MainPed.PositionNoOffset = Vector3.Lerp(MainPed.ReadPosition(), Position + Velocity, 0.5f);
MainPed.Quaternion = Rotation.ToQuaternion();
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "skydive@parachute@first_person",
if (!Call<bool>(IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "skydive@parachute@first_person",
"chute_idle_right", 3))
{
var dict = LoadAnim("skydive@parachute@first_person");
if (dict == null) return;
Function.Call(Hash.TASK_PLAY_ANIM, MainPed, dict, "chute_idle_right", 8f, 10f, -1, 0, -8f, 1, 1, 1);
Call(TASK_PLAY_ANIM, MainPed, dict, "chute_idle_right", 8f, 10f, -1, 0, -8f, 1, 1, 1);
}
return;
@ -321,7 +321,7 @@ namespace RageCoop.Client
_currentAnimation[1] = anim;
}
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", anim, 3))
if (!Call<bool>(IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", anim, 3))
MainPed.Task.PlayAnimation("laddersbase", anim, 8f, -1, AnimationFlags.Loop);
}
else
@ -334,7 +334,7 @@ namespace RageCoop.Client
_currentAnimation[1] = "base_left_hand_up";
}
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase",
if (!Call<bool>(IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase",
"base_left_hand_up", 3))
MainPed.Task.PlayAnimation("laddersbase", "base_left_hand_up", 8f, -1, AnimationFlags.Loop);
}
@ -346,7 +346,7 @@ namespace RageCoop.Client
_currentAnimation[1] = "climb_up";
}
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", "climb_up",
if (!Call<bool>(IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", "climb_up",
3)) MainPed.Task.PlayAnimation("laddersbase", "climb_up", 8f, -1, AnimationFlags.Loop);
}
}
@ -373,8 +373,8 @@ namespace RageCoop.Client
if (!IsVaulting && MainPed.IsVaulting) MainPed.Task.ClearAllImmediately();
if (IsOnFire && !MainPed.IsOnFire)
Function.Call(Hash.START_ENTITY_FIRE, MainPed);
else if (!IsOnFire && MainPed.IsOnFire) Function.Call(Hash.STOP_ENTITY_FIRE, MainPed);
Call(START_ENTITY_FIRE, MainPed);
else if (!IsOnFire && MainPed.IsOnFire) Call(STOP_ENTITY_FIRE, MainPed);
if (IsJumping)
{
@ -432,7 +432,7 @@ namespace RageCoop.Client
}
else if (IsInCover)
{
if (!_lastInCover) Function.Call(Hash.TASK_STAY_IN_COVER, MainPed.Handle);
if (!_lastInCover) Call(TASK_STAY_IN_COVER, MainPed.Handle);
_lastInCover = true;
if (IsAiming)
@ -476,16 +476,16 @@ namespace RageCoop.Client
}
else
{
var model = Function.Call<uint>(Hash.GET_WEAPONTYPE_MODEL, CurrentWeapon);
if (!Function.Call<bool>(Hash.HAS_MODEL_LOADED, model))
var model = Call<uint>(GET_WEAPONTYPE_MODEL, CurrentWeapon);
if (!Call<bool>(HAS_MODEL_LOADED, model))
{
Function.Call(Hash.REQUEST_MODEL, model);
Call(REQUEST_MODEL, model);
return;
}
if (WeaponObj?.Exists() == true)
WeaponObj.Delete();
MainPed.Weapons.RemoveAll();
WeaponObj = Entity.FromHandle(Function.Call<int>(Hash.CREATE_WEAPON_OBJECT, CurrentWeapon, -1, Position.X, Position.Y, Position.Z, true, 0, 0));
WeaponObj = Entity.FromHandle(Call<int>(CREATE_WEAPON_OBJECT, CurrentWeapon, -1, Position.X, Position.Y, Position.Z, true, 0, 0));
}
if (compChanged)
@ -494,17 +494,17 @@ namespace RageCoop.Client
{
if (comp.Value)
{
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, WeaponObj.Handle, comp.Key);
Call(GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, WeaponObj.Handle, comp.Key);
}
}
_lastWeaponComponents = WeaponComponents;
}
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, WeaponObj.Handle, MainPed.Handle);
Call(GIVE_WEAPON_OBJECT_TO_PED, WeaponObj.Handle, MainPed.Handle);
_lastWeaponHash = CurrentWeapon;
}
if (Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeapon) != WeaponTint)
Function.Call<int>(Hash.SET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeapon, WeaponTint);
if (Call<int>(GET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeapon) != WeaponTint)
Call<int>(SET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeapon, WeaponTint);
}
private void DisplayAiming()
@ -512,7 +512,7 @@ namespace RageCoop.Client
if (Velocity == default)
MainPed.Task.AimAt(AimCoords, 1000);
else
Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, MainPed.Handle,
Call(TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, MainPed.Handle,
Position.X + Velocity.X, Position.Y + Velocity.Y, Position.Z + Velocity.Z,
AimCoords.X, AimCoords.Y, AimCoords.Z, 3f, false, 0x3F000000, 0x40800000, false, 512, false, 0);
SmoothTransition();
@ -520,7 +520,7 @@ namespace RageCoop.Client
private void WalkTo()
{
Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, MainPed, IsInStealthMode, 0);
Call(SET_PED_STEALTH_MOVEMENT, MainPed, IsInStealthMode, 0);
var predictPosition = Predict(Position) + Velocity;
var range = predictPosition.DistanceToSquared(MainPed.ReadPosition());
@ -533,7 +533,7 @@ namespace RageCoop.Client
if (nrange > 1.0f) nrange = 1.0f;
MainPed.Task.GoStraightTo(predictPosition);
Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, nrange);
Call(SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, nrange);
}
_lastMoving = true;
@ -542,7 +542,7 @@ namespace RageCoop.Client
if (!MainPed.IsRunning || range > 0.50f)
{
MainPed.Task.RunTo(predictPosition, true);
Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, 1.0f);
Call(SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, 1.0f);
}
_lastMoving = true;
@ -550,10 +550,10 @@ namespace RageCoop.Client
case 3:
if (!MainPed.IsSprinting || range > 0.75f)
{
Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, MainPed.Handle, predictPosition.X,
Call(TASK_GO_STRAIGHT_TO_COORD, MainPed.Handle, predictPosition.X,
predictPosition.Y, predictPosition.Z, 3.0f, -1, 0.0f, 0.0f);
Function.Call(Hash.SET_RUN_SPRINT_MULTIPLIER_FOR_PLAYER, MainPed.Handle, 1.49f);
Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, 1.0f);
Call(SET_RUN_SPRINT_MULTIPLIER_FOR_PLAYER, MainPed.Handle, 1.49f);
Call(SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, 1.0f);
}
_lastMoving = true;
@ -655,7 +655,7 @@ namespace RageCoop.Client
(!MainPed.IsSittingInVehicle() && !MainPed.IsBeingJacked))
MainPed.SetIntoVehicle(CurrentVehicle.MainVehicle, Seat);
if (MainPed.IsOnTurretSeat())
Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y,
Call(TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y,
AimCoords.Z);
// Drive-by
@ -663,12 +663,12 @@ namespace RageCoop.Client
{
if (IsAiming)
{
Function.Call(Hash.SET_DRIVEBY_TASK_TARGET, MainPed, 0, 0, AimCoords.X, AimCoords.Y,
Call(SET_DRIVEBY_TASK_TARGET, MainPed, 0, 0, AimCoords.X, AimCoords.Y,
AimCoords.Z);
if (!_lastDriveBy)
{
_lastDriveBy = true;
Function.Call(Hash.TASK_DRIVE_BY, MainPed, 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z,
Call(TASK_DRIVE_BY, MainPed, 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z,
1, 100, 1, FiringPattern.SingleShot);
}
}

View File

@ -125,7 +125,7 @@ namespace RageCoop.Client
Position = (Owner.PacketTravelTime + 0.001f * LastSyncedStopWatch.ElapsedMilliseconds) * Shooter.Velocity +
Position;
var end = Position + Velocity;
Function.Call(Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS_IGNORE_ENTITY, Position.X, Position.Y, Position.Z,
Call(SHOOT_SINGLE_BULLET_BETWEEN_COORDS_IGNORE_ENTITY, Position.X, Position.Y, Position.Z,
end.X, end.Y, end.Z, 0, 1, WeaponHash, owner?.Handle ?? 0, 1, 0, -1);
var ps = World.GetAllProjectiles();
MainProjectile = ps[ps.Length - 1];

View File

@ -48,11 +48,11 @@ namespace RageCoop.Client
if (MainVehicle.IsOnFire)
{
if (!Flags.HasVehFlag(VehicleDataFlags.IsOnFire)) Function.Call(Hash.STOP_ENTITY_FIRE, MainVehicle);
if (!Flags.HasVehFlag(VehicleDataFlags.IsOnFire)) Call(STOP_ENTITY_FIRE, MainVehicle);
}
else if (Flags.HasVehFlag(VehicleDataFlags.IsOnFire))
{
Function.Call(Hash.START_ENTITY_FIRE, MainVehicle);
Call(START_ENTITY_FIRE, MainVehicle);
}
if (EngineRunning != MainVehicle.IsEngineRunning) MainVehicle.IsEngineRunning = EngineRunning;
@ -100,13 +100,13 @@ namespace RageCoop.Client
if (!_lastTransformed)
{
_lastTransformed = true;
Function.Call(Hash.TRANSFORM_TO_SUBMARINE, MainVehicle.Handle, false);
Call(TRANSFORM_TO_SUBMARINE, MainVehicle.Handle, false);
}
}
else if (_lastTransformed)
{
_lastTransformed = false;
Function.Call(Hash.TRANSFORM_TO_CAR, MainVehicle.Handle, false);
Call(TRANSFORM_TO_CAR, MainVehicle.Handle, false);
}
}
else if (IsDeluxo)
@ -115,7 +115,7 @@ namespace RageCoop.Client
if (IsDeluxoHovering) MainVehicle.SetDeluxoWingRatio(DeluxoWingRatio);
}
Function.Call(Hash.SET_VEHICLE_BRAKE_LIGHTS, MainVehicle.Handle, BrakeLightsOn);
Call(SET_VEHICLE_BRAKE_LIGHTS, MainVehicle.Handle, BrakeLightsOn);
}
MainVehicle.LockStatus = LockStatus;
@ -125,7 +125,7 @@ namespace RageCoop.Client
if (Flags.HasVehFlag(VehicleDataFlags.Repaired)) MainVehicle.Repair();
if (Colors != null && Colors != _lastVehicleColors)
{
Function.Call(Hash.SET_VEHICLE_COLOURS, MainVehicle, Colors[0], Colors[1]);
Call(SET_VEHICLE_COLOURS, MainVehicle, Colors[0], Colors[1]);
_lastVehicleColors = Colors;
}
@ -133,19 +133,19 @@ namespace RageCoop.Client
MainVehicle.EngineHealth = EngineHealth;
if (Mods != null && !Mods.Compare(_lastVehicleMods))
{
Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle, 0);
Call(SET_VEHICLE_MOD_KIT, MainVehicle, 0);
foreach (var mod in Mods) MainVehicle.Mods[(VehicleModType)mod.Key].Index = mod.Value;
_lastVehicleMods = Mods;
}
if (Function.Call<string>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle) != LicensePlate)
Function.Call(Hash.SET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle, LicensePlate);
if (Call<string>(GET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle) != LicensePlate)
Call(SET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle, LicensePlate);
if (_lastLivery != Livery)
{
Function.Call(Hash.SET_VEHICLE_LIVERY, MainVehicle, Livery);
Call(SET_VEHICLE_LIVERY, MainVehicle, Livery);
_lastLivery = Livery;
}
@ -295,7 +295,7 @@ namespace RageCoop.Client
private void StartPedalingAnim(bool fast)
{
MainVehicle.Driver?.Task.PlayAnimation(PedalingAnimDict(), PedalingAnimName(fast), 8.0f, -8.0f, -1,
AnimationFlags.Loop | AnimationFlags.AllowRotation, 1.0f);
AnimationFlags.Loop | AnimationFlags.Secondary, 1.0f);
}
private void StopPedalingAnim(bool fast)

View File

@ -100,7 +100,7 @@ namespace RageCoop.Client
{
var p = Game.Player.Character;
// var clipset=p.Gender==Gender.Male? "MOVE_M@TOUGH_GUY@" : "MOVE_F@TOUGH_GUY@";
// Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET,p,clipset,1f);
// Call(SET_PED_MOVEMENT_CLIPSET,p,clipset,1f);
var player = GetPedByID(Main.LocalPlayerID);
if (player == null)
{
@ -297,19 +297,23 @@ namespace RageCoop.Client
public static void DoSync()
{
UpdateTargets();
#if BENCHMARK
PerfCounter.Restart();
Debug.TimeStamps[TimeStamp.CheckProjectiles] = PerfCounter.ElapsedTicks;
#endif
var allPeds = World.GetAllPeds();
var allVehicles = World.GetAllVehicles();
var allProjectiles = World.GetAllProjectiles();
vehStatesPerFrame = allVehicles.Length * 2 / (int)Game.FPS + 1;
pedStatesPerFrame = allPeds.Length * 2 / (int)Game.FPS + 1;
vehStatesPerFrame = allVehicles.Length * 2 / (int)Main.FPS + 1;
pedStatesPerFrame = allPeds.Length * 2 / (int)Main.FPS + 1;
#if BENCHMARK
Debug.TimeStamps[TimeStamp.GetAllEntities] = PerfCounter.ElapsedTicks;
#endif
lock (ProjectilesLock)
{
foreach (var p in allProjectiles)
@ -338,6 +342,7 @@ namespace RageCoop.Client
}
}
i = -1;
lock (PedsLock)
@ -514,8 +519,8 @@ namespace RageCoop.Client
private static void SetBudget(int b)
{
Function.Call(Hash.SET_PED_POPULATION_BUDGET, b); // 0 - 3
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, b); // 0 - 3
Call(SET_PED_POPULATION_BUDGET, b); // 0 - 3
Call(SET_VEHICLE_POPULATION_BUDGET, b); // 0 - 3
}
public static string DumpDebug()

View File

@ -5,6 +5,7 @@ namespace RageCoop.Client
{
internal static class Voice
{
private static bool _stopping = false;
private static WaveInEvent _waveIn;
private static readonly BufferedWaveProvider _waveProvider =
@ -30,7 +31,8 @@ namespace RageCoop.Client
if (_thread != null && _thread.IsAlive)
{
_thread.Abort();
_stopping = true;
_thread.Join();
_thread = null;
}
}
@ -51,9 +53,9 @@ namespace RageCoop.Client
return;
// I tried without thread but the game will lag without
_thread = new Thread(() =>
_thread = ThreadManager.CreateThread(() =>
{
while (true)
while (!_stopping && !Main.IsUnloading)
using (var wo = new WaveOutEvent())
{
wo.Init(_waveProvider);
@ -61,8 +63,7 @@ namespace RageCoop.Client
while (wo.PlaybackState == PlaybackState.Playing) Thread.Sleep(100);
}
});
_thread.Start();
},"Voice");
}
public static void StartRecording()