if (type (Require) ~= 'function') then loadstring(exports['nc_libraries']:extend('Extend'), 'Require')() end local MapLib = { map_size = 2048, } function MapLib:Render(x, y, w, h, px, py, zoom, blip, style, blipW, blipH, Alpha, target, shader) local px = Animation('MAP_POS_X', {value = 0, target = px or 0, speed = 500, animType = 'InOutSine', ForceInt = false, onProgress = MapLib:ForceUpdate()}) or 0 local py = Animation('MAP_POS_Y', {value = 0, target = py or 0, speed = 1000, animType = 'InOutSine', ForceInt = false, onProgress = MapLib:ForceUpdate()}) or 0 local scale = 6000 / self.map_size local mapX = (px + 3000) / scale local mapY = (-py + 3000) / scale if not target then dxSetBlendMode("modulate_add") Draw:ImageSection( x, y, w, h, mapX - (w / zoom) / 2, mapY - (h / zoom) / 2, w / zoom, h / zoom, AsyncElements:Icon(self.map_size, self.map_size, false, "assets/Svg/"..style..".svg", "clamp", 2), 0, 0, 0, tocolor(255, 255, 255, Alpha) ) dxSetBlendMode("blend") local sizeW, sizeH = 40, 46 Draw:Image( x + (w / 2) - (sizeW / 2), y + (h / 2) - (sizeH / 2), sizeW, sizeH, AsyncElements:Icon(sizeW, sizeH, false, "assets/Svg/"..blip..".svg", "clamp", 2), 0, 0, 0, tocolor(255, 255, 255, Alpha) ) else if not MapLib.RenderTarget then MapLib.RenderTarget = dxCreateRenderTarget(w, h, true) if shader then MapLib.MapShader = Shader:Create(shader) if MapLib.MapShader then Shader:setValue(MapLib.MapShader, "SourceTexture", MapLib.RenderTarget) end end end if MapLib.updateTarget and MapLib.updateTarget > getTickCount() then if MapLib.ignoreUpdate then MapLib.ignoreUpdate = false else if shader and MapLib.MapShader and isElement(MapLib.MapShader) then Draw:Image(x, y, w, h, MapLib.MapShader, 0, 0, 0, tocolor(255, 255, 255, Alpha)) return true else Draw:Image(x, y, w, h, MapLib.RenderTarget, 0, 0, 0, tocolor(255, 255, 255, Alpha)) return true end end end Draw:SetRenderTarget(MapLib.RenderTarget, true) dxSetBlendMode("modulate_add") local scale = 6000 / self.map_size local mapX = (px + 3000) / scale local mapY = (-py + 3000) / scale Draw:Image( x - (mapX - (w / zoom) / 2), y - (mapY - (h / zoom) / 2), self.map_size / zoom, self.map_size / zoom, AsyncElements:Icon(self.map_size, self.map_size, false, "assets/Svg/"..style..".svg", "clamp", 2), 0, 0, 0, tocolor(255, 255, 255, Alpha)) dxSetBlendMode("blend") local sizeW, sizeH = 40, 46 Draw:Image( 0 + (w / 2) - (sizeW / 2), 0 + (h / 2) - (sizeH / 2), sizeW, sizeH, AsyncElements:Icon(sizeW, sizeH, false, "assets/Svg/"..blip..".svg", "clamp", 2), 0, 0, 0, tocolor(255, 255, 255, Alpha) ) Draw:SetRenderTarget() MapLib.updateTarget = getTickCount() + 500 if shader and MapLib.MapShader and isElement(MapLib.MapShader) then Draw:Image(x, y, w, h, MapLib.MapShader, 0, 0, 0, tocolor(255, 255, 255, Alpha)) return true end Draw:Image(x, y, w, h, MapLib.RenderTarget, 0, 0, 0, tocolor(255, 255, 255, Alpha)) return true end end function MapLib:ForceUpdate() MapLib.ignoreUpdate = true end function MapLib:Destroy() if MapLib.RenderTarget and isElement(MapLib.RenderTarget) then destroyElement(MapLib.RenderTarget) MapLib.RenderTarget = nil end if MapLib.MapShader and isElement(MapLib.MapShader) then destroyElement(MapLib.MapShader) MapLib.MapShader = nil end end return MapLib