Job route indicator
This commit is contained in:
@@ -12,6 +12,12 @@ let localPlayerWorking = false;
|
|||||||
let jobRouteLocationBlip = null;
|
let jobRouteLocationBlip = null;
|
||||||
let jobRouteLocationSphere = null;
|
let jobRouteLocationSphere = null;
|
||||||
|
|
||||||
|
let jobRouteLocationIndicatorPosition = toVector3(0.0, 0.0, 0.0);
|
||||||
|
let jobRouteLocationIndicatorSize = [32, 32];
|
||||||
|
let jobRouteLocationIndicatorEnabled = false;
|
||||||
|
let jobRouteLocationIndicatorImagePath = "files/images/objective-icon.png";
|
||||||
|
let jobRouteLocationIndicatorImage = null;
|
||||||
|
|
||||||
let jobBlipBlinkAmount = 0;
|
let jobBlipBlinkAmount = 0;
|
||||||
let jobBlipBlinkTimes = 10;
|
let jobBlipBlinkTimes = 10;
|
||||||
let jobBlipBlinkInterval = 500;
|
let jobBlipBlinkInterval = 500;
|
||||||
@@ -36,11 +42,25 @@ class JobData {
|
|||||||
|
|
||||||
function initJobScript() {
|
function initJobScript() {
|
||||||
logToConsole(LOG_DEBUG, "[V.RP.Job]: Initializing job script ...");
|
logToConsole(LOG_DEBUG, "[V.RP.Job]: Initializing job script ...");
|
||||||
|
jobRouteLocationIndicatorImage = loadJobRouteLocationIndicatorImage();
|
||||||
logToConsole(LOG_DEBUG, "[V.RP.Job]: Job script initialized!");
|
logToConsole(LOG_DEBUG, "[V.RP.Job]: Job script initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
function loadJobRouteLocationIndicatorImage() {
|
||||||
|
let imageStream = openFile(jobRouteLocationIndicatorImagePath);
|
||||||
|
let tempImage = null;
|
||||||
|
if (imageStream != null) {
|
||||||
|
tempImage = graphics.loadPNG(imageStream);
|
||||||
|
imageStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempImage
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
function setLocalPlayerJobType(tempJobType) {
|
function setLocalPlayerJobType(tempJobType) {
|
||||||
logToConsole(LOG_DEBUG, `[V.RP.Job] Set local player job type to ${tempJobType}`);
|
logToConsole(LOG_DEBUG, `[V.RP.Job] Set local player job type to ${tempJobType}`);
|
||||||
localPlayerJobType = tempJobType;
|
localPlayerJobType = tempJobType;
|
||||||
@@ -75,6 +95,11 @@ function showJobRouteLocation(position, colour) {
|
|||||||
blinkJobRouteLocationBlip(10, position, colour);
|
blinkJobRouteLocationBlip(10, position, colour);
|
||||||
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
|
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getGame() == V_GAME_MAFIA_ONE) {
|
||||||
|
jobRouteLocationIndicatorPosition = position;
|
||||||
|
jobRouteLocationIndicatorEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -116,22 +141,30 @@ function blinkJobRouteLocationBlip(times, position, colour) {
|
|||||||
function hideJobRouteLocation() {
|
function hideJobRouteLocation() {
|
||||||
logToConsole(LOG_DEBUG, `[V.RP.Job] Hiding job route location`);
|
logToConsole(LOG_DEBUG, `[V.RP.Job] Hiding job route location`);
|
||||||
|
|
||||||
if (jobRouteLocationBlip != null) {
|
if (isGameFeatureSupported("blip")) {
|
||||||
destroyElement(jobRouteLocationBlip);
|
if (jobRouteLocationBlip != null) {
|
||||||
jobRouteLocationBlip = null;
|
destroyElement(jobRouteLocationBlip);
|
||||||
|
jobRouteLocationBlip = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobRouteLocationSphere != null) {
|
||||||
|
destroyElement(jobRouteLocationSphere);
|
||||||
|
jobRouteLocationSphere = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobBlipBlinkTimer != null) {
|
||||||
|
clearInterval(jobBlipBlinkTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
jobBlipBlinkAmount = 0;
|
||||||
|
jobBlipBlinkTimes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jobRouteLocationSphere != null) {
|
if (getGame() == V_GAME_MAFIA_ONE) {
|
||||||
destroyElement(jobRouteLocationSphere);
|
jobRouteLocationIndicatorPosition = toVector3(0.0, 0.0, 0.0);
|
||||||
jobRouteLocationSphere = null;
|
jobRouteLocationIndicatorEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jobBlipBlinkTimer != null) {
|
|
||||||
clearInterval(jobBlipBlinkTimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobBlipBlinkAmount = 0;
|
|
||||||
jobBlipBlinkTimes = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -237,3 +270,20 @@ function removeJobsFromClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
function processJobLocationIndicatorRendering() {
|
||||||
|
if (jobRouteLocationIndicatorImage == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getGame() != V_GAME_MAFIA_ONE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jobRouteLocationIndicatorEnabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let screenPosition = getScreenFromWorldPosition(jobRouteLocationIndicatorPosition);
|
||||||
|
graphics.drawRectangle(jobRouteLocationIndicatorImage, [screenPosition.x - (jobRouteLocationIndicatorSize[0] / 2), screenPosition.y - (jobRouteLocationIndicatorSize[1] / 2)], [jobRouteLocationIndicatorSize[0], jobRouteLocationIndicatorSize[1]]);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user