Offload vehicle purchase logic to clientside
This commit is contained in:
@@ -94,6 +94,7 @@ function onProcess(event, deltaTime) {
|
|||||||
processWantedLevelReset();
|
processWantedLevelReset();
|
||||||
processGameSpecifics();
|
processGameSpecifics();
|
||||||
processNearbyPickups();
|
processNearbyPickups();
|
||||||
|
processVehiclePurchasing();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ let mouseCameraEnabled = false;
|
|||||||
|
|
||||||
let currentPickup = false;
|
let currentPickup = false;
|
||||||
|
|
||||||
|
let vehiclePurchaseState = VRR_VEHBUYSTATE_NONE;
|
||||||
|
let vehiclePurchasing = null;
|
||||||
|
let vehiclePurchasePosition = null;
|
||||||
|
|
||||||
// Pre-cache all allowed skins
|
// Pre-cache all allowed skins
|
||||||
let allowedSkins = getAllowedSkins(getGame());
|
let allowedSkins = getAllowedSkins(getGame());
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ function addAllNetworkHandlers() {
|
|||||||
addNetworkHandler("vrr.elementPosition", setElementPosition);
|
addNetworkHandler("vrr.elementPosition", setElementPosition);
|
||||||
addNetworkHandler("vrr.elementCollisions", setElementCollisionsEnabled);
|
addNetworkHandler("vrr.elementCollisions", setElementCollisionsEnabled);
|
||||||
|
|
||||||
|
addNetworkHandler("vrr.vehBuyState", setVehiclePurchaseState);
|
||||||
|
|
||||||
addNetworkHandler("vrr.showRegistration", showRegistrationGUI);
|
addNetworkHandler("vrr.showRegistration", showRegistrationGUI);
|
||||||
addNetworkHandler("vrr.showNewCharacter", showNewCharacterGUI);
|
addNetworkHandler("vrr.showNewCharacter", showNewCharacterGUI);
|
||||||
addNetworkHandler("vrr.showLogin", showLoginGUI);
|
addNetworkHandler("vrr.showLogin", showLoginGUI);
|
||||||
|
|||||||
@@ -819,4 +819,34 @@ function processGameSpecifics() {
|
|||||||
destroyAutoCreatedPickups();
|
destroyAutoCreatedPickups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function processVehiclePurchasing() {
|
||||||
|
if(vehiclePurchaseState == VRR_VEHBUYSTATE_TESTDRIVE) {
|
||||||
|
if(inVehicle == false) {
|
||||||
|
vehiclePurchaseState = VRR_VEHBUYSTATE_EXITEDVEH;
|
||||||
|
triggerNetworkEvent("vrr.vehBuyState", VRR_VEHBUYSTATE_EXITEDVEH);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if(vehiclePurchasing.id == inVehicle) {
|
||||||
|
if(getDistance(inVehicle.position, vehiclePurchasePosition) >= 25) {
|
||||||
|
vehiclePurchaseState = VRR_VEHBUYSTATE_FARENOUGH;
|
||||||
|
triggerNetworkEvent("vrr.vehBuyState", VRR_VEHBUYSTATE_FARENOUGH);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vehiclePurchaseState = VRR_VEHBUYSTATE_WRONGVEH;
|
||||||
|
triggerNetworkEvent("vrr.vehBuyState", VRR_VEHBUYSTATE_WRONGVEH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setVehiclePurchaseState(state, vehicle, position) {
|
||||||
|
vehiclePurchaseState = state;
|
||||||
|
vehiclePurchasePosition = position;
|
||||||
|
vehiclePurchasing = vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user