mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-23 04:27:25 +08:00
refactor: Rework Persist Car Service (#2394)
This commit is contained in:
parent
e102d6ca2c
commit
2eec32b747
@ -186,6 +186,7 @@ static const std::map<std::string, std::vector<int>> lsc_tire_smoke_rgb = {
|
||||
{"Red", {TIRESMOKE_COLOR_RED}},
|
||||
{"Pink", {TIRESMOKE_COLOR_PINK}},
|
||||
{"Brown", {TIRESMOKE_COLOR_BROWN}},
|
||||
{"Patriot", {TIRESMOKE_COLOR_PATRIOT}},
|
||||
};
|
||||
|
||||
static const std::map<std::string, std::vector<int>> lsc_neon_rgb = {
|
||||
|
@ -11,7 +11,6 @@ namespace big
|
||||
Vector3 rotation;
|
||||
bool has_collision;
|
||||
bool is_visible;
|
||||
bool is_invincible;
|
||||
};
|
||||
|
||||
static void to_json(nlohmann::json& j, const model_attachment& attachment)
|
||||
@ -25,8 +24,6 @@ namespace big
|
||||
{"rotation_z", attachment.rotation.z},
|
||||
{"has_collision", attachment.has_collision},
|
||||
{"is_visible", attachment.is_visible},
|
||||
{"is_invincible", attachment.is_invincible}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@ -44,6 +41,5 @@ namespace big
|
||||
|
||||
set_from_key_or_default(j, "has_collision", attachment.has_collision);
|
||||
set_from_key_or_default(j, "is_visible", attachment.is_visible, true);
|
||||
set_from_key_or_default(j, "is_invincible", attachment.is_invincible);
|
||||
}
|
||||
};
|
||||
|
@ -154,7 +154,6 @@ namespace big
|
||||
|
||||
ENTITY::SET_ENTITY_VISIBLE(object, attachment.is_visible, 0);
|
||||
ENTITY::SET_ENTITY_COLLISION(object, attachment.has_collision, true);
|
||||
ENTITY::SET_ENTITY_INVINCIBLE(object, attachment.is_invincible);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +182,6 @@ namespace big
|
||||
|
||||
ENTITY::SET_ENTITY_VISIBLE(vehicle_to_attach, attachment.is_visible, 0);
|
||||
ENTITY::SET_ENTITY_COLLISION(vehicle_to_attach, attachment.has_collision, true);
|
||||
ENTITY::SET_ENTITY_INVINCIBLE(vehicle_to_attach, attachment.is_invincible);
|
||||
VEHICLE::SET_VEHICLE_IS_CONSIDERED_BY_PLAYER(vehicle_to_attach, false);
|
||||
}
|
||||
|
||||
@ -203,7 +201,15 @@ namespace big
|
||||
|
||||
VEHICLE::SET_VEHICLE_DIRT_LEVEL(vehicle, 0.0f);
|
||||
VEHICLE::SET_VEHICLE_MOD_KIT(vehicle, 0);
|
||||
VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(vehicle, false);
|
||||
|
||||
if (!vehicle_json[tire_can_burst].is_null())
|
||||
VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(vehicle, vehicle_json[tire_can_burst]);
|
||||
else
|
||||
VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(vehicle, false);
|
||||
|
||||
if (!vehicle_json[drift_tires].is_null())
|
||||
VEHICLE::SET_DRIFT_TYRES(vehicle, vehicle_json[drift_tires]);
|
||||
|
||||
VEHICLE::SET_VEHICLE_COLOURS(vehicle, vehicle_json[primary_color_key], vehicle_json[secondary_color_key]);
|
||||
|
||||
if (!vehicle_json[custom_primary_color_key].is_null())
|
||||
@ -224,12 +230,6 @@ namespace big
|
||||
ENTITY::SET_ENTITY_COLLISION(vehicle, has_collision, true);
|
||||
}
|
||||
|
||||
if (!vehicle_json[is_invincible_key].is_null())
|
||||
{
|
||||
bool is_invincible = vehicle_json[is_invincible_key];
|
||||
ENTITY::SET_ENTITY_INVINCIBLE(vehicle, is_invincible);
|
||||
}
|
||||
|
||||
if (!vehicle_json[custom_secondary_color_key].is_null())
|
||||
{
|
||||
std::vector<int> secondary_custom_color = vehicle_json[custom_secondary_color_key];
|
||||
@ -355,14 +355,13 @@ namespace big
|
||||
bool has_collision = ENTITY::GET_ENTITY_COLLISION_DISABLED(object);
|
||||
bool is_visible = ENTITY::IS_ENTITY_VISIBLE(object);
|
||||
CObject* cobject = (CObject*)g_pointers->m_gta.m_handle_to_ptr(vehicle);
|
||||
bool is_invincible = misc::has_bit_set(&(int&)cobject->m_damage_bits, 8);
|
||||
|
||||
Vector3 rotation;
|
||||
rotation.x = (object_rotation.x - vehicle_rotation.x);
|
||||
rotation.y = (object_rotation.y - vehicle_rotation.y);
|
||||
rotation.z = (object_rotation.z - vehicle_rotation.z);
|
||||
|
||||
model_attachment attachment = {ENTITY::GET_ENTITY_MODEL(object), location, rotation, !has_collision, is_visible, is_invincible};
|
||||
model_attachment attachment = {ENTITY::GET_ENTITY_MODEL(object), location, rotation, !has_collision, is_visible};
|
||||
|
||||
return attachment;
|
||||
}
|
||||
@ -465,11 +464,11 @@ namespace big
|
||||
bool has_collision = ENTITY::GET_ENTITY_COLLISION_DISABLED(vehicle);
|
||||
bool is_visible = ENTITY::IS_ENTITY_VISIBLE(vehicle);
|
||||
CVehicle* cvehicle = (CVehicle*)g_pointers->m_gta.m_handle_to_ptr(vehicle);
|
||||
bool is_invincible = misc::has_bit_set(&(int&)cvehicle->m_damage_bits, 8);
|
||||
vehicle_json[has_collision_key] = !has_collision;
|
||||
vehicle_json[is_visible_key] = is_visible;
|
||||
vehicle_json[is_invincible_key] = is_invincible;
|
||||
vehicle_json[wheel_color_key] = wheel_color;
|
||||
vehicle_json[tire_can_burst] = VEHICLE::GET_VEHICLE_TYRES_CAN_BURST(vehicle);
|
||||
vehicle_json[drift_tires] = VEHICLE::GET_DRIFT_TYRES_SET(vehicle);
|
||||
|
||||
std::map<int, bool> vehicle_extras;
|
||||
for (int extra_iterator = 0; extra_iterator <= 14; extra_iterator++)
|
||||
|
@ -20,9 +20,8 @@ namespace big
|
||||
static constexpr auto model_attachments_key = "model_attachments";
|
||||
|
||||
static constexpr auto vehicle_attachments_key = "vehicle_attachments";
|
||||
static constexpr auto is_invincible_key = "is_invincible";
|
||||
static constexpr auto is_visible_key = "is_visible";
|
||||
static constexpr auto has_collision_key = "has_collision";
|
||||
static constexpr auto is_visible_key = "is_visible";
|
||||
static constexpr auto has_collision_key = "has_collision";
|
||||
|
||||
static constexpr auto vehicle_model_hash_key = "vehicle_model_hash";
|
||||
|
||||
@ -43,6 +42,8 @@ namespace big
|
||||
static constexpr auto wheel_type_key = "wheel_type";
|
||||
static constexpr auto wheel_color_key = "wheel_color";
|
||||
static constexpr auto tire_smoke_color_key = "tire_smoke_color";
|
||||
static constexpr auto tire_can_burst = "tire_can_burst";
|
||||
static constexpr auto drift_tires = "drift_tires";
|
||||
|
||||
static constexpr auto convertable_state_key = "convertable_state";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user