import polygons from "../polygons";

//Start: Eingang direkt rechts, rechts entlang
const prisonVector1 = new mp.Vector3(1809.99365234375, 2612.373291015625, 40.50623321533203);
const prisonVector2 = new mp.Vector3(1810.377197265625, 2620.338623046875, 40.51300048828125);
const prisonVector3 = new mp.Vector3(1835.8336181640625, 2688.819091796875, 40.4307975769043);
const prisonVector4 = new mp.Vector3(1830.5731201171875, 2703.89990234375, 40.42714309692383);
const prisonVector5 = new mp.Vector3(1776.7342529296875, 2747.79052734375, 40.42777633666992);
const prisonVector6 = new mp.Vector3(1762.360107421875, 2752.788818359375, 40.42710494995117);
const prisonVector7 = new mp.Vector3(1662.0726318359375, 2749.177001953125, 40.444488525390625);
const prisonVector8 = new mp.Vector3(1648.1600341796875, 2742.01611328125, 40.441619873046875);
const prisonVector9 = new mp.Vector3(1584.302978515625, 2679.99072265625, 40.47876739501953);
const prisonVector10 = new mp.Vector3(1575.2301025390625, 2667.2109375, 40.48185729980469);
const prisonVector11 = new mp.Vector3(1547.1693115234375, 2591.489990234375, 40.388912200927734);
const prisonVector12 = new mp.Vector3(1546.39892578125, 2576.266845703125, 40.38877868652344);
const prisonVector13 = new mp.Vector3(1550.493896484375, 2482.98388671875, 40.38750076293945);
const prisonVector14 = new mp.Vector3(1557.9322509765625, 2468.98681640625, 40.387237548828125);
const prisonVector15 = new mp.Vector3(1652.527099609375, 2409.1259765625, 40.40341567993164);
const prisonVector16 = new mp.Vector3(1667.7176513671875, 2407.0595703125, 40.401432037353516);
const prisonVector17 = new mp.Vector3(1749.3123779296875, 2419.23779296875, 40.42228698730469);
const prisonVector18 = new mp.Vector3(1762.95849609375, 2426.209228515625, 40.42059326171875);
const prisonVector19 = new mp.Vector3(1809.08837890625, 2473.969970703125, 40.445960998535156);
const prisonVector20 = new mp.Vector3(1814.2039794921875, 2489.00830078125, 40.44499588012695);
const prisonVector21 = new mp.Vector3(1807.0340576171875, 2535.93212890625, 38.4123420715332);
const prisonVector22 = new mp.Vector3(1809.77587890625, 2590.69775390625, 38.41337966918945);
const prisonVector23 = new mp.Vector3(1819.170654296875, 2597.941650390625, 40.525978088378906);
const prisonVector24 = new mp.Vector3(1819.3084716796875, 2612.3154296875, 40.52067947387695);

const busbaseVector1 = new mp.Vector3(-522.4485, -2138.7021, 7.7564063);
const busbaseVector2 = new mp.Vector3(-584.9822, -2072.467, 5.9921026);
const busbaseVector3 = new mp.Vector3(-669.1689, -2172.7917, 6.009973);
const busbaseVector4 = new mp.Vector3(-600.4804, -2230.3953, 6.213662);

const stadthalleVector1 = new mp.Vector3(-464.26273, -242.73814, 35.946384);
const stadthalleVector2 = new mp.Vector3(-505.32938, -170.14832, 37.859695);
const stadthalleVector3 = new mp.Vector3(-589.5164, -224.41574, 36.648193);
const stadthalleVector4 = new mp.Vector3(-556.6909, -280.71564, 35.163292);

const fahrschuleVector1 = new mp.Vector3(-812.13043, -1406.9983, 4.9805145);
const fahrschuleVector2 = new mp.Vector3(-727.035, -1305.2482, 5.084054);
const fahrschuleVector3 = new mp.Vector3(-757.4177, -1279.31, 5.1093183);
const fahrschuleVector4 = new mp.Vector3(-832.14087, -1268.561, 4.9827914);
const fahrschuleVector5 = new mp.Vector3(-856.8085, -1286.7786, 6.474576);

const pilotAnfaengerVector1 = new mp.Vector3(1759.6045, 3305.2988, 41.1526);
const pilotAnfaengerVector2 = new mp.Vector3(1785.29944, 3230.2786, 42.553444);
const pilotAnfaengerVector3 = new mp.Vector3(1655.139, 3198.6257, 42.723602);
const pilotAnfaengerVector4 = new mp.Vector3(1624.4799, 3294.2612, 39.53612);

const pilotProfiVector1 = new mp.Vector3(-1595.5433, -3130.2798, 13.944942);
const pilotProfiVector2 = new mp.Vector3(-1679.6715, -3082.12, 13.948778);
const pilotProfiVector3 = new mp.Vector3(-1728.0858, -3164.9736, 14.055883);
const pilotProfiVector4 = new mp.Vector3(-1640.4034, -3213.0503, 13.8741665);

const muellbaseVector1 = new mp.Vector3(521.6251, -2194.5068, 5.985945);
const muellbaseVector2 = new mp.Vector3(454.88348, -2158.1938, 5.9788494);
const muellbaseVector3 = new mp.Vector3(529.06635, -2088.4097, 8.303088);

const krankenhausVector1 = new mp.Vector3(-508.50705, -351.24368, 34);
//const krankenhausVector2 = new mp.Vector3(-437.00146, -357.10526, 32.735916
const krankenhausVector2 = new mp.Vector3(-442.62323, -356.99185, 33);
const krankenhausVector3 = new mp.Vector3(-448.9346, -297.23972, 33.68);
const krankenhausVector4 = new mp.Vector3(-504.952, -315.21698, 35.04881);

const polygon_busbase = polygons.add([busbaseVector1, busbaseVector2, busbaseVector3, busbaseVector4], 15, false, [255, 155, 0, 255], 0);
const polygon_stadthalle = polygons.add([stadthalleVector1, stadthalleVector2, stadthalleVector3, stadthalleVector4], 15, false, [255, 155, 0, 255], 0);
const polygon_fahrschule = polygons.add([fahrschuleVector1, fahrschuleVector2, fahrschuleVector3, fahrschuleVector4, fahrschuleVector5], 15, false, [255, 155, 0, 255], 0);
const polygon_pilotAnfaenger = polygons.add([pilotAnfaengerVector1, pilotAnfaengerVector2, pilotAnfaengerVector3, pilotAnfaengerVector4], 15, false, [255, 155, 0, 255], 0);
const polygon_pilotProfi = polygons.add([pilotProfiVector1, pilotProfiVector2, pilotProfiVector3, pilotProfiVector4], 15, false, [255, 155, 0, 255], 0);
const polygon_muellbase = polygons.add([muellbaseVector1, muellbaseVector2, muellbaseVector3], 15, false, [255, 155, 0, 255], 0);
const polygon_krankenhaus = polygons.add([krankenhausVector1, krankenhausVector2, krankenhausVector3, krankenhausVector4], 50, false, [255, 155, 0, 255], 0);

const polygon_prison = polygons.add([prisonVector1, prisonVector2, prisonVector3, prisonVector4, prisonVector5, prisonVector6, prisonVector7, prisonVector8,
    prisonVector9, prisonVector10, prisonVector11, prisonVector12, prisonVector13, prisonVector14, prisonVector15, prisonVector16,
    prisonVector17, prisonVector18, prisonVector19, prisonVector20, prisonVector21, prisonVector22, prisonVector23, prisonVector24], 40, false, [255, 155, 0, 255], 0);

export let listNoDMZones = [polygon_busbase, polygon_stadthalle, polygon_fahrschule, polygon_pilotAnfaenger, polygon_pilotProfi, polygon_muellbase, polygon_krankenhaus];
export let isInAnyNoDMPolygon;

export default function polygonHandler() {

    mp.events.add('playerEnterPolygon', (polygon) => {

        if (listNoDMZones.indexOf(polygon) != -1){
            mp.events.call('toggleNoDmZone', true);
            isInAnyNoDMPolygon = true;
        }
    });

    mp.events.add('playerLeavePolygon', (polygon) => {

        if (listNoDMZones.indexOf(polygon) != -1) {
            mp.events.call('toggleNoDmZone', false);
            isInAnyNoDMPolygon = false;
        }

        if (polygon == polygon_prison) {
            mp.events.callRemote("SERVER:BreakOutIfInPrison");
        }
    });
}
