rngine 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -25
- package/android/CMakeLists.txt +45 -2
- package/android/build.gradle +1 -3
- package/android/kls_database.db +0 -0
- package/android/src/main/cpp/game-view.cpp +29 -0
- package/android/src/main/java/com/margelo/nitro/rngine/GameEngine.kt +1 -28
- package/android/src/main/java/com/margelo/nitro/rngine/GameView.kt +22 -166
- package/android/src/main/java/com/margelo/nitro/rngine/SvgLoaderHelper.kt +24 -0
- package/lib/module/GameMethods.js +44 -0
- package/lib/module/GameMethods.js.map +1 -1
- package/lib/module/GameMethods.nitro.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/GameMethods.d.ts +1 -0
- package/lib/typescript/src/GameMethods.d.ts.map +1 -1
- package/lib/typescript/src/GameMethods.nitro.d.ts +3 -0
- package/lib/typescript/src/GameMethods.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/nativeTypes.d.ts +6 -0
- package/lib/typescript/src/nativeTypes.d.ts.map +1 -1
- package/nitro.json +0 -10
- package/nitrogen/generated/android/rngine+autolinking.cmake +0 -2
- package/nitrogen/generated/android/rngineOnLoad.cpp +0 -16
- package/nitrogen/generated/ios/Rngine-Swift-Cxx-Bridge.cpp +0 -33
- package/nitrogen/generated/ios/Rngine-Swift-Cxx-Bridge.hpp +0 -96
- package/nitrogen/generated/ios/Rngine-Swift-Cxx-Umbrella.hpp +0 -9
- package/nitrogen/generated/ios/RngineAutolinking.mm +0 -8
- package/nitrogen/generated/ios/RngineAutolinking.swift +0 -12
- package/nitrogen/generated/shared/c++/Entity.hpp +13 -1
- package/nitrogen/generated/shared/c++/EntityUpdate.hpp +13 -1
- package/nitrogen/generated/shared/c++/HybridGameMethodsSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridGameMethodsSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/Screen.hpp +14 -2
- package/package.json +4 -1
- package/shared/CollisionUtils.hpp +1 -6
- package/{android/src/main/cpp/ColorUtils.hpp → shared/ColorUtils.cpp} +8 -12
- package/shared/ColorUtils.hpp +7 -0
- package/shared/GameLoop.cpp +45 -27
- package/shared/GameLoop.hpp +1 -11
- package/shared/GameMethods.cpp +103 -6
- package/shared/GameMethods.hpp +17 -0
- package/shared/GameRenderer.cpp +431 -0
- package/shared/GameRenderer.hpp +65 -0
- package/shared/GameStats.hpp +3 -3
- package/shared/Overlap.hpp +9 -0
- package/shared/skia/include/android/AHardwareBufferUtils.h +26 -0
- package/shared/skia/include/android/GrAHardwareBufferUtils.h +97 -0
- package/shared/skia/include/android/SkAndroidFrameworkUtils.h +83 -0
- package/shared/skia/include/android/SkAnimatedImage.h +193 -0
- package/shared/skia/include/android/SkCanvasAndroid.h +20 -0
- package/shared/skia/include/android/SkImageAndroid.h +100 -0
- package/shared/skia/include/android/SkSurfaceAndroid.h +50 -0
- package/shared/skia/include/android/graphite/SurfaceAndroid.h +59 -0
- package/shared/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
- package/shared/skia/include/codec/SkAndroidCodec.h +302 -0
- package/shared/skia/include/codec/SkAvifDecoder.h +80 -0
- package/shared/skia/include/codec/SkBmpDecoder.h +44 -0
- package/shared/skia/include/codec/SkBmpRustDecoder.h +42 -0
- package/shared/skia/include/codec/SkCodec.h +1178 -0
- package/shared/skia/include/codec/SkCodecAnimation.h +61 -0
- package/shared/skia/include/codec/SkEncodedImageFormat.h +33 -0
- package/shared/skia/include/codec/SkEncodedOrigin.h +71 -0
- package/shared/skia/include/codec/SkGifDecoder.h +44 -0
- package/shared/skia/include/codec/SkIcoDecoder.h +44 -0
- package/shared/skia/include/codec/SkJpegDecoder.h +51 -0
- package/shared/skia/include/codec/SkJpegxlDecoder.h +44 -0
- package/shared/skia/include/codec/SkPixmapUtils.h +31 -0
- package/shared/skia/include/codec/SkPngChunkReader.h +45 -0
- package/shared/skia/include/codec/SkPngDecoder.h +51 -0
- package/shared/skia/include/codec/SkPngRustDecoder.h +30 -0
- package/shared/skia/include/codec/SkRawDecoder.h +50 -0
- package/shared/skia/include/codec/SkWbmpDecoder.h +44 -0
- package/shared/skia/include/codec/SkWebpDecoder.h +51 -0
- package/shared/skia/include/config/SkUserConfig.h +141 -0
- package/shared/skia/include/core/SkAlphaType.h +45 -0
- package/shared/skia/include/core/SkAnnotation.h +52 -0
- package/shared/skia/include/core/SkArc.h +69 -0
- package/shared/skia/include/core/SkBBHFactory.h +67 -0
- package/shared/skia/include/core/SkBitmap.h +1264 -0
- package/shared/skia/include/core/SkBlendMode.h +112 -0
- package/shared/skia/include/core/SkBlender.h +30 -0
- package/shared/skia/include/core/SkBlurTypes.h +20 -0
- package/shared/skia/include/core/SkCPUContext.h +31 -0
- package/shared/skia/include/core/SkCPURecorder.h +76 -0
- package/shared/skia/include/core/SkCanvas.h +2770 -0
- package/shared/skia/include/core/SkCanvasVirtualEnforcer.h +61 -0
- package/shared/skia/include/core/SkCapabilities.h +35 -0
- package/shared/skia/include/core/SkClipOp.h +19 -0
- package/shared/skia/include/core/SkColor.h +469 -0
- package/shared/skia/include/core/SkColorFilter.h +150 -0
- package/shared/skia/include/core/SkColorSpace.h +432 -0
- package/shared/skia/include/core/SkColorTable.h +62 -0
- package/shared/skia/include/core/SkColorType.h +159 -0
- package/shared/skia/include/core/SkContourMeasure.h +215 -0
- package/shared/skia/include/core/SkCoverageMode.h +28 -0
- package/shared/skia/include/core/SkCubicMap.h +47 -0
- package/shared/skia/include/core/SkData.h +225 -0
- package/shared/skia/include/core/SkDataTable.h +122 -0
- package/shared/skia/include/core/SkDocument.h +93 -0
- package/shared/skia/include/core/SkDrawable.h +178 -0
- package/shared/skia/include/core/SkExecutor.h +59 -0
- package/shared/skia/include/core/SkFlattenable.h +115 -0
- package/shared/skia/include/core/SkFont.h +536 -0
- package/shared/skia/include/core/SkFontArguments.h +116 -0
- package/shared/skia/include/core/SkFontMetrics.h +139 -0
- package/shared/skia/include/core/SkFontMgr.h +178 -0
- package/shared/skia/include/core/SkFontParameters.h +43 -0
- package/shared/skia/include/core/SkFontScanner.h +45 -0
- package/shared/skia/include/core/SkFontStyle.h +84 -0
- package/shared/skia/include/core/SkFontTypes.h +25 -0
- package/shared/skia/include/core/SkFourByteTag.h +19 -0
- package/shared/skia/include/core/SkGraphics.h +169 -0
- package/shared/skia/include/core/SkImage.h +918 -0
- package/shared/skia/include/core/SkImageFilter.h +119 -0
- package/shared/skia/include/core/SkImageGenerator.h +140 -0
- package/shared/skia/include/core/SkImageInfo.h +634 -0
- package/shared/skia/include/core/SkM44.h +442 -0
- package/shared/skia/include/core/SkMallocPixelRef.h +45 -0
- package/shared/skia/include/core/SkMaskFilter.h +45 -0
- package/shared/skia/include/core/SkMatrix.h +1887 -0
- package/shared/skia/include/core/SkMesh.h +429 -0
- package/shared/skia/include/core/SkMilestone.h +9 -0
- package/shared/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
- package/shared/skia/include/core/SkOverdrawCanvas.h +94 -0
- package/shared/skia/include/core/SkPaint.h +698 -0
- package/shared/skia/include/core/SkPath.h +1145 -0
- package/shared/skia/include/core/SkPathBuilder.h +1052 -0
- package/shared/skia/include/core/SkPathEffect.h +88 -0
- package/shared/skia/include/core/SkPathIter.h +90 -0
- package/shared/skia/include/core/SkPathMeasure.h +96 -0
- package/shared/skia/include/core/SkPathTypes.h +71 -0
- package/shared/skia/include/core/SkPathUtils.h +39 -0
- package/shared/skia/include/core/SkPicture.h +291 -0
- package/shared/skia/include/core/SkPictureRecorder.h +115 -0
- package/shared/skia/include/core/SkPixelRef.h +120 -0
- package/shared/skia/include/core/SkPixmap.h +736 -0
- package/shared/skia/include/core/SkPoint.h +560 -0
- package/shared/skia/include/core/SkPoint3.h +149 -0
- package/shared/skia/include/core/SkRRect.h +548 -0
- package/shared/skia/include/core/SkRSXform.h +71 -0
- package/shared/skia/include/core/SkRasterHandleAllocator.h +94 -0
- package/shared/skia/include/core/SkRecorder.h +49 -0
- package/shared/skia/include/core/SkRect.h +1419 -0
- package/shared/skia/include/core/SkRefCnt.h +391 -0
- package/shared/skia/include/core/SkRegion.h +701 -0
- package/shared/skia/include/core/SkSamplingOptions.h +107 -0
- package/shared/skia/include/core/SkScalar.h +148 -0
- package/shared/skia/include/core/SkSerialProcs.h +127 -0
- package/shared/skia/include/core/SkShader.h +123 -0
- package/shared/skia/include/core/SkSize.h +93 -0
- package/shared/skia/include/core/SkSpan.h +174 -0
- package/shared/skia/include/core/SkStream.h +524 -0
- package/shared/skia/include/core/SkStrikeRef.h +96 -0
- package/shared/skia/include/core/SkString.h +297 -0
- package/shared/skia/include/core/SkStrokeRec.h +160 -0
- package/shared/skia/include/core/SkSurface.h +689 -0
- package/shared/skia/include/core/SkSurfaceProps.h +122 -0
- package/shared/skia/include/core/SkSwizzle.h +21 -0
- package/shared/skia/include/core/SkTextBlob.h +541 -0
- package/shared/skia/include/core/SkTextureCompressionType.h +30 -0
- package/shared/skia/include/core/SkTileMode.h +41 -0
- package/shared/skia/include/core/SkTiledImageUtils.h +125 -0
- package/shared/skia/include/core/SkTraceMemoryDump.h +121 -0
- package/shared/skia/include/core/SkTypeface.h +468 -0
- package/shared/skia/include/core/SkTypes.h +193 -0
- package/shared/skia/include/core/SkUnPreMultiply.h +55 -0
- package/shared/skia/include/core/SkVertices.h +136 -0
- package/shared/skia/include/core/SkYUVAInfo.h +311 -0
- package/shared/skia/include/core/SkYUVAPixmaps.h +335 -0
- package/shared/skia/include/docs/SkMultiPictureDocument.h +53 -0
- package/shared/skia/include/docs/SkPDFDocument.h +277 -0
- package/shared/skia/include/docs/SkPDFJpegHelpers.h +41 -0
- package/shared/skia/include/docs/SkXPSDocument.h +43 -0
- package/shared/skia/include/effects/Sk1DPathEffect.h +40 -0
- package/shared/skia/include/effects/Sk2DPathEffect.h +33 -0
- package/shared/skia/include/effects/SkBlenders.h +27 -0
- package/shared/skia/include/effects/SkBlurMaskFilter.h +35 -0
- package/shared/skia/include/effects/SkColorMatrix.h +57 -0
- package/shared/skia/include/effects/SkColorMatrixFilter.h +22 -0
- package/shared/skia/include/effects/SkCornerPathEffect.h +32 -0
- package/shared/skia/include/effects/SkDashPathEffect.h +43 -0
- package/shared/skia/include/effects/SkDiscretePathEffect.h +37 -0
- package/shared/skia/include/effects/SkGradient.h +206 -0
- package/shared/skia/include/effects/SkHighContrastFilter.h +84 -0
- package/shared/skia/include/effects/SkImageFilters.h +641 -0
- package/shared/skia/include/effects/SkLumaColorFilter.h +37 -0
- package/shared/skia/include/effects/SkOverdrawColorFilter.h +33 -0
- package/shared/skia/include/effects/SkPerlinNoiseShader.h +53 -0
- package/shared/skia/include/effects/SkRuntimeEffect.h +503 -0
- package/shared/skia/include/effects/SkShaderMaskFilter.h +28 -0
- package/shared/skia/include/effects/SkTableMaskFilter.h +47 -0
- package/shared/skia/include/effects/SkTrimPathEffect.h +45 -0
- package/shared/skia/include/encode/SkEncoder.h +63 -0
- package/shared/skia/include/encode/SkICC.h +36 -0
- package/shared/skia/include/encode/SkJpegEncoder.h +127 -0
- package/shared/skia/include/encode/SkPngEncoder.h +132 -0
- package/shared/skia/include/encode/SkPngRustEncoder.h +121 -0
- package/shared/skia/include/encode/SkWebpEncoder.h +87 -0
- package/shared/skia/include/gpu/GpuTypes.h +98 -0
- package/shared/skia/include/gpu/MutableTextureState.h +68 -0
- package/shared/skia/include/gpu/ShaderErrorHandler.h +46 -0
- package/shared/skia/include/gpu/ganesh/GrBackendSemaphore.h +50 -0
- package/shared/skia/include/gpu/ganesh/GrBackendSurface.h +257 -0
- package/shared/skia/include/gpu/ganesh/GrContextOptions.h +384 -0
- package/shared/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h +175 -0
- package/shared/skia/include/gpu/ganesh/GrDirectContext.h +1027 -0
- package/shared/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +53 -0
- package/shared/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +49 -0
- package/shared/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +54 -0
- package/shared/skia/include/gpu/ganesh/GrRecordingContext.h +300 -0
- package/shared/skia/include/gpu/ganesh/GrTypes.h +193 -0
- package/shared/skia/include/gpu/ganesh/GrYUVABackendTextures.h +130 -0
- package/shared/skia/include/gpu/ganesh/SkImageGanesh.h +361 -0
- package/shared/skia/include/gpu/ganesh/SkMeshGanesh.h +57 -0
- package/shared/skia/include/gpu/ganesh/SkSurfaceGanesh.h +218 -0
- package/shared/skia/include/gpu/ganesh/d3d/GrD3DBackendContext.h +35 -0
- package/shared/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
- package/shared/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
- package/shared/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
- package/shared/skia/include/gpu/ganesh/d3d/GrD3DTypes.h +248 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLAssembleHelpers.h +17 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLAssembleInterface.h +45 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h +64 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLConfig.h +69 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +30 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLExtensions.h +79 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLFunctions.h +313 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLInterface.h +337 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLMakeWebGLInterface.h +19 -0
- package/shared/skia/include/gpu/ganesh/gl/GrGLTypes.h +219 -0
- package/shared/skia/include/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.h +23 -0
- package/shared/skia/include/gpu/ganesh/gl/epoxy/GrGLMakeEpoxyEGLInterface.h +20 -0
- package/shared/skia/include/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.h +23 -0
- package/shared/skia/include/gpu/ganesh/gl/ios/GrGLMakeIOSInterface.h +20 -0
- package/shared/skia/include/gpu/ganesh/gl/mac/GrGLMakeMacInterface.h +20 -0
- package/shared/skia/include/gpu/ganesh/gl/win/GrGLMakeWinInterface.h +20 -0
- package/shared/skia/include/gpu/ganesh/mock/GrMockBackendSurface.h +59 -0
- package/shared/skia/include/gpu/ganesh/mock/GrMockTypes.h +166 -0
- package/shared/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h +21 -0
- package/shared/skia/include/gpu/ganesh/mtl/GrMtlBackendSemaphore.h +23 -0
- package/shared/skia/include/gpu/ganesh/mtl/GrMtlBackendSurface.h +44 -0
- package/shared/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +30 -0
- package/shared/skia/include/gpu/ganesh/mtl/GrMtlTypes.h +61 -0
- package/shared/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +73 -0
- package/shared/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +44 -0
- package/shared/skia/include/gpu/ganesh/vk/GrVkBackendSemaphore.h +20 -0
- package/shared/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h +71 -0
- package/shared/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +33 -0
- package/shared/skia/include/gpu/ganesh/vk/GrVkTypes.h +101 -0
- package/shared/skia/include/gpu/graphite/BackendSemaphore.h +60 -0
- package/shared/skia/include/gpu/graphite/BackendTexture.h +65 -0
- package/shared/skia/include/gpu/graphite/Context.h +440 -0
- package/shared/skia/include/gpu/graphite/ContextOptions.h +239 -0
- package/shared/skia/include/gpu/graphite/GraphiteTypes.h +315 -0
- package/shared/skia/include/gpu/graphite/Image.h +428 -0
- package/shared/skia/include/gpu/graphite/ImageProvider.h +68 -0
- package/shared/skia/include/gpu/graphite/PersistentPipelineStorage.h +45 -0
- package/shared/skia/include/gpu/graphite/PrecompileContext.h +109 -0
- package/shared/skia/include/gpu/graphite/Recorder.h +355 -0
- package/shared/skia/include/gpu/graphite/Recording.h +100 -0
- package/shared/skia/include/gpu/graphite/Surface.h +121 -0
- package/shared/skia/include/gpu/graphite/TextureInfo.h +133 -0
- package/shared/skia/include/gpu/graphite/YUVABackendTextures.h +148 -0
- package/shared/skia/include/gpu/graphite/dawn/DawnBackendContext.h +77 -0
- package/shared/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +163 -0
- package/shared/skia/include/gpu/graphite/dawn/DawnTypes.h +9 -0
- package/shared/skia/include/gpu/graphite/dawn/DawnUtils.h +9 -0
- package/shared/skia/include/gpu/graphite/mtl/MtlBackendContext.h +34 -0
- package/shared/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +73 -0
- package/shared/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +10 -0
- package/shared/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
- package/shared/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +9 -0
- package/shared/skia/include/gpu/graphite/precompile/PaintOptions.h +211 -0
- package/shared/skia/include/gpu/graphite/precompile/Precompile.h +59 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileBase.h +76 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileBlender.h +56 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileColorFilter.h +95 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileImageFilter.h +116 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileMaskFilter.h +49 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileRuntimeEffect.h +47 -0
- package/shared/skia/include/gpu/graphite/precompile/PrecompileShader.h +268 -0
- package/shared/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
- package/shared/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +104 -0
- package/shared/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +39 -0
- package/shared/skia/include/gpu/mtl/MtlMemoryAllocator.h +41 -0
- package/shared/skia/include/gpu/vk/VulkanBackendContext.h +57 -0
- package/shared/skia/include/gpu/vk/VulkanExtensions.h +73 -0
- package/shared/skia/include/gpu/vk/VulkanMemoryAllocator.h +117 -0
- package/shared/skia/include/gpu/vk/VulkanMutableTextureState.h +26 -0
- package/shared/skia/include/gpu/vk/VulkanPreferredFeatures.h +225 -0
- package/shared/skia/include/gpu/vk/VulkanTypes.h +245 -0
- package/shared/skia/include/pathops/SkPathOps.h +150 -0
- package/shared/skia/include/ports/SkCFObject.h +180 -0
- package/shared/skia/include/ports/SkFontConfigInterface.h +112 -0
- package/shared/skia/include/ports/SkFontMgr_FontConfigInterface.h +24 -0
- package/shared/skia/include/ports/SkFontMgr_Fontations.h +20 -0
- package/shared/skia/include/ports/SkFontMgr_android.h +48 -0
- package/shared/skia/include/ports/SkFontMgr_android_ndk.h +27 -0
- package/shared/skia/include/ports/SkFontMgr_data.h +22 -0
- package/shared/skia/include/ports/SkFontMgr_directory.h +21 -0
- package/shared/skia/include/ports/SkFontMgr_empty.h +21 -0
- package/shared/skia/include/ports/SkFontMgr_fontconfig.h +24 -0
- package/shared/skia/include/ports/SkFontMgr_fuchsia.h +21 -0
- package/shared/skia/include/ports/SkFontMgr_mac_ct.h +27 -0
- package/shared/skia/include/ports/SkFontScanner_Fontations.h +15 -0
- package/shared/skia/include/ports/SkFontScanner_FreeType.h +15 -0
- package/shared/skia/include/ports/SkImageGeneratorCG.h +28 -0
- package/shared/skia/include/ports/SkImageGeneratorNDK.h +40 -0
- package/shared/skia/include/ports/SkImageGeneratorWIC.h +41 -0
- package/shared/skia/include/ports/SkTypeface_fontations.h +24 -0
- package/shared/skia/include/ports/SkTypeface_mac.h +44 -0
- package/shared/skia/include/ports/SkTypeface_win.h +63 -0
- package/shared/skia/include/private/SingleOwner.h +75 -0
- package/shared/skia/include/private/SkAPI.h +52 -0
- package/shared/skia/include/private/SkASAN.h +56 -0
- package/shared/skia/include/private/SkAlign.h +51 -0
- package/shared/skia/include/private/SkAlignedStorage.h +32 -0
- package/shared/skia/include/private/SkAnySubclass.h +79 -0
- package/shared/skia/include/private/SkAssert.h +203 -0
- package/shared/skia/include/private/SkAttributes.h +96 -0
- package/shared/skia/include/private/SkCPUTypes.h +25 -0
- package/shared/skia/include/private/SkContainers.h +54 -0
- package/shared/skia/include/private/SkDebug.h +27 -0
- package/shared/skia/include/private/SkDeque.h +138 -0
- package/shared/skia/include/private/SkEncodedInfo.h +249 -0
- package/shared/skia/include/private/SkEnumBitMask.h +92 -0
- package/shared/skia/include/private/SkExif.h +69 -0
- package/shared/skia/include/private/SkFeatures.h +173 -0
- package/shared/skia/include/private/SkFixed.h +143 -0
- package/shared/skia/include/private/SkFloatingPoint.h +183 -0
- package/shared/skia/include/private/SkGainmapInfo.h +140 -0
- package/shared/skia/include/private/SkGainmapShader.h +60 -0
- package/shared/skia/include/private/SkHdrMetadata.h +357 -0
- package/shared/skia/include/private/SkIDChangeListener.h +76 -0
- package/shared/skia/include/private/SkJpegGainmapEncoder.h +48 -0
- package/shared/skia/include/private/SkJpegMetadataDecoder.h +103 -0
- package/shared/skia/include/private/SkLoadUserConfig.h +64 -0
- package/shared/skia/include/private/SkLog.h +62 -0
- package/shared/skia/include/private/SkLogPriority.h +34 -0
- package/shared/skia/include/private/SkMacros.h +170 -0
- package/shared/skia/include/private/SkMalloc.h +152 -0
- package/shared/skia/include/private/SkMath.h +77 -0
- package/shared/skia/include/private/SkMutex.h +72 -0
- package/shared/skia/include/private/SkNoncopyable.h +30 -0
- package/shared/skia/include/private/SkOnce.h +55 -0
- package/shared/skia/include/private/SkPathRef.h +90 -0
- package/shared/skia/include/private/SkPixelStorage.h +52 -0
- package/shared/skia/include/private/SkSLSampleUsage.h +85 -0
- package/shared/skia/include/private/SkSafe32.h +49 -0
- package/shared/skia/include/private/SkSemaphore.h +84 -0
- package/shared/skia/include/private/SkTArray.h +823 -0
- package/shared/skia/include/private/SkTDArray.h +247 -0
- package/shared/skia/include/private/SkTFitsIn.h +92 -0
- package/shared/skia/include/private/SkTLogic.h +56 -0
- package/shared/skia/include/private/SkTPin.h +23 -0
- package/shared/skia/include/private/SkTemplates.h +500 -0
- package/shared/skia/include/private/SkThreadAnnotations.h +104 -0
- package/shared/skia/include/private/SkThreadID.h +23 -0
- package/shared/skia/include/private/SkTo.h +39 -0
- package/shared/skia/include/private/SkTypeTraits.h +53 -0
- package/shared/skia/include/private/SkWeakRefCnt.h +173 -0
- package/shared/skia/include/private/SkXmp.h +62 -0
- package/shared/skia/include/private/chromium/GrDeferredDisplayList.h +120 -0
- package/shared/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +62 -0
- package/shared/skia/include/private/chromium/GrPromiseImageTexture.h +43 -0
- package/shared/skia/include/private/chromium/GrSurfaceCharacterization.h +211 -0
- package/shared/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +131 -0
- package/shared/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +150 -0
- package/shared/skia/include/private/chromium/SkCodecsICCProfileChromium.h +52 -0
- package/shared/skia/include/private/chromium/SkDiscardableMemory.h +70 -0
- package/shared/skia/include/private/chromium/SkExifChromium.h +26 -0
- package/shared/skia/include/private/chromium/SkImageChromium.h +117 -0
- package/shared/skia/include/private/chromium/SkPMColor.h +38 -0
- package/shared/skia/include/private/chromium/Slug.h +72 -0
- package/shared/skia/include/private/gpu/ganesh/GrContext_Base.h +104 -0
- package/shared/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +60 -0
- package/shared/skia/include/private/gpu/ganesh/GrImageContext.h +56 -0
- package/shared/skia/include/private/gpu/ganesh/GrTextureGenerator.h +66 -0
- package/shared/skia/include/private/gpu/ganesh/GrTypesPriv.h +959 -0
- package/shared/skia/include/private/gpu/vk/SkiaVulkan.h +36 -0
- package/shared/skia/include/sksl/SkSLDebugTrace.h +25 -0
- package/shared/skia/include/sksl/SkSLVersion.h +27 -0
- package/shared/skia/include/svg/SkSVGCanvas.h +62 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_icd.h +245 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_layer.h +192 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_platform.h +84 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +394 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +109 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +143 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +312 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +77 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +147 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +446 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +67 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +157 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std.h +151 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_vp9std_decode.h +68 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +36 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan.h +103 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_android.h +159 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +375 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_core.h +25896 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +59 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +282 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +62 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +50 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +50 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +244 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_ohos.h +120 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +114 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +50 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +59 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +372 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +60 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +60 -0
- package/shared/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +50 -0
- package/shared/skia/include/utils/SkCamera.h +109 -0
- package/shared/skia/include/utils/SkCanvasStateUtils.h +81 -0
- package/shared/skia/include/utils/SkCustomTypeface.h +70 -0
- package/shared/skia/include/utils/SkEventTracer.h +93 -0
- package/shared/skia/include/utils/SkNWayCanvas.h +123 -0
- package/shared/skia/include/utils/SkNoDrawCanvas.h +78 -0
- package/shared/skia/include/utils/SkNullCanvas.h +22 -0
- package/shared/skia/include/utils/SkOrderedFontMgr.h +66 -0
- package/shared/skia/include/utils/SkPaintFilterCanvas.h +140 -0
- package/shared/skia/include/utils/SkParse.h +36 -0
- package/shared/skia/include/utils/SkParsePath.h +33 -0
- package/shared/skia/include/utils/SkShadowUtils.h +102 -0
- package/shared/skia/include/utils/SkTextUtils.h +43 -0
- package/shared/skia/include/utils/SkTraceEventPhase.h +19 -0
- package/shared/skia/include/utils/mac/SkCGUtils.h +90 -0
- package/shared/skia/modules/jsonreader/SkJSONReader.cpp +996 -0
- package/shared/skia/modules/jsonreader/SkJSONReader.h +389 -0
- package/shared/skia/modules/skcms/skcms.h +10 -0
- package/shared/skia/modules/skcms/src/Transform_inl.h +1600 -0
- package/shared/skia/modules/skcms/src/skcms_Transform.h +167 -0
- package/shared/skia/modules/skcms/src/skcms_internals.h +157 -0
- package/shared/skia/modules/skcms/src/skcms_public.h +496 -0
- package/shared/skia/modules/skottie/include/ExternalLayer.h +56 -0
- package/shared/skia/modules/skottie/include/Skottie.h +324 -0
- package/shared/skia/modules/skottie/include/SkottieProperty.h +190 -0
- package/shared/skia/modules/skottie/include/SlotManager.h +113 -0
- package/shared/skia/modules/skottie/include/TextShaper.h +197 -0
- package/shared/skia/modules/skottie/src/SkottieValue.h +56 -0
- package/shared/skia/modules/skottie/src/animator/Animator.h +89 -0
- package/shared/skia/modules/skottie/src/text/Font.h +82 -0
- package/shared/skia/modules/skottie/src/text/TextAdapter.h +155 -0
- package/shared/skia/modules/skottie/src/text/TextAnimator.h +122 -0
- package/shared/skia/modules/skottie/src/text/TextValue.h +28 -0
- package/shared/skia/modules/skparagraph/include/DartTypes.h +153 -0
- package/shared/skia/modules/skparagraph/include/FontArguments.h +46 -0
- package/shared/skia/modules/skparagraph/include/FontCollection.h +76 -0
- package/shared/skia/modules/skparagraph/include/Metrics.h +98 -0
- package/shared/skia/modules/skparagraph/include/Paragraph.h +289 -0
- package/shared/skia/modules/skparagraph/include/ParagraphBuilder.h +94 -0
- package/shared/skia/modules/skparagraph/include/ParagraphCache.h +52 -0
- package/shared/skia/modules/skparagraph/include/ParagraphPainter.h +63 -0
- package/shared/skia/modules/skparagraph/include/ParagraphStyle.h +160 -0
- package/shared/skia/modules/skparagraph/include/TextShadow.h +30 -0
- package/shared/skia/modules/skparagraph/include/TextStyle.h +392 -0
- package/shared/skia/modules/skparagraph/include/TypefaceFontProvider.h +78 -0
- package/shared/skia/modules/skresources/include/SkResources.h +291 -0
- package/shared/skia/modules/sksg/include/SkSGClipEffect.h +61 -0
- package/shared/skia/modules/sksg/include/SkSGColorFilter.h +135 -0
- package/shared/skia/modules/sksg/include/SkSGDraw.h +57 -0
- package/shared/skia/modules/sksg/include/SkSGEffectNode.h +50 -0
- package/shared/skia/modules/sksg/include/SkSGGeometryEffect.h +207 -0
- package/shared/skia/modules/sksg/include/SkSGGeometryNode.h +54 -0
- package/shared/skia/modules/sksg/include/SkSGGradient.h +108 -0
- package/shared/skia/modules/sksg/include/SkSGGroup.h +65 -0
- package/shared/skia/modules/sksg/include/SkSGImage.h +59 -0
- package/shared/skia/modules/sksg/include/SkSGInvalidationController.h +46 -0
- package/shared/skia/modules/sksg/include/SkSGMaskEffect.h +65 -0
- package/shared/skia/modules/sksg/include/SkSGMerge.h +74 -0
- package/shared/skia/modules/sksg/include/SkSGNode.h +128 -0
- package/shared/skia/modules/sksg/include/SkSGOpacityEffect.h +54 -0
- package/shared/skia/modules/sksg/include/SkSGPaint.h +112 -0
- package/shared/skia/modules/sksg/include/SkSGPath.h +68 -0
- package/shared/skia/modules/sksg/include/SkSGPlane.h +47 -0
- package/shared/skia/modules/sksg/include/SkSGRect.h +122 -0
- package/shared/skia/modules/sksg/include/SkSGRenderEffect.h +283 -0
- package/shared/skia/modules/sksg/include/SkSGRenderNode.h +157 -0
- package/shared/skia/modules/sksg/include/SkSGScene.h +47 -0
- package/shared/skia/modules/sksg/include/SkSGText.h +82 -0
- package/shared/skia/modules/sksg/include/SkSGTransform.h +127 -0
- package/shared/skia/modules/skshaper/include/SkShaper.h +318 -0
- package/shared/skia/modules/skshaper/include/SkShaper_coretext.h +26 -0
- package/shared/skia/modules/skshaper/include/SkShaper_factory.h +41 -0
- package/shared/skia/modules/skshaper/include/SkShaper_harfbuzz.h +39 -0
- package/shared/skia/modules/skshaper/include/SkShaper_skunicode.h +28 -0
- package/shared/skia/modules/skunicode/include/SkUnicode.h +321 -0
- package/shared/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
- package/shared/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
- package/shared/skia/modules/svg/include/SkSVGAttribute.h +110 -0
- package/shared/skia/modules/svg/include/SkSVGAttributeParser.h +170 -0
- package/shared/skia/modules/svg/include/SkSVGCircle.h +56 -0
- package/shared/skia/modules/svg/include/SkSVGClipPath.h +41 -0
- package/shared/skia/modules/svg/include/SkSVGContainer.h +52 -0
- package/shared/skia/modules/svg/include/SkSVGDOM.h +111 -0
- package/shared/skia/modules/svg/include/SkSVGDefs.h +23 -0
- package/shared/skia/modules/svg/include/SkSVGEllipse.h +51 -0
- package/shared/skia/modules/svg/include/SkSVGFe.h +93 -0
- package/shared/skia/modules/svg/include/SkSVGFeBlend.h +54 -0
- package/shared/skia/modules/svg/include/SkSVGFeColorMatrix.h +55 -0
- package/shared/skia/modules/svg/include/SkSVGFeComponentTransfer.h +82 -0
- package/shared/skia/modules/svg/include/SkSVGFeComposite.h +55 -0
- package/shared/skia/modules/svg/include/SkSVGFeDisplacementMap.h +56 -0
- package/shared/skia/modules/svg/include/SkSVGFeFlood.h +42 -0
- package/shared/skia/modules/svg/include/SkSVGFeGaussianBlur.h +50 -0
- package/shared/skia/modules/svg/include/SkSVGFeImage.h +44 -0
- package/shared/skia/modules/svg/include/SkSVGFeLightSource.h +93 -0
- package/shared/skia/modules/svg/include/SkSVGFeLighting.h +131 -0
- package/shared/skia/modules/svg/include/SkSVGFeMerge.h +63 -0
- package/shared/skia/modules/svg/include/SkSVGFeMorphology.h +55 -0
- package/shared/skia/modules/svg/include/SkSVGFeOffset.h +44 -0
- package/shared/skia/modules/svg/include/SkSVGFeTurbulence.h +49 -0
- package/shared/skia/modules/svg/include/SkSVGFilter.h +48 -0
- package/shared/skia/modules/svg/include/SkSVGFilterContext.h +69 -0
- package/shared/skia/modules/svg/include/SkSVGG.h +23 -0
- package/shared/skia/modules/svg/include/SkSVGGradient.h +56 -0
- package/shared/skia/modules/svg/include/SkSVGHiddenContainer.h +23 -0
- package/shared/skia/modules/svg/include/SkSVGIDMapper.h +19 -0
- package/shared/skia/modules/svg/include/SkSVGImage.h +67 -0
- package/shared/skia/modules/svg/include/SkSVGLine.h +53 -0
- package/shared/skia/modules/svg/include/SkSVGLinearGradient.h +47 -0
- package/shared/skia/modules/svg/include/SkSVGMask.h +49 -0
- package/shared/skia/modules/svg/include/SkSVGNode.h +235 -0
- package/shared/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +37 -0
- package/shared/skia/modules/svg/include/SkSVGPath.h +46 -0
- package/shared/skia/modules/svg/include/SkSVGPattern.h +61 -0
- package/shared/skia/modules/svg/include/SkSVGPoly.h +56 -0
- package/shared/skia/modules/svg/include/SkSVGRadialGradient.h +48 -0
- package/shared/skia/modules/svg/include/SkSVGRect.h +56 -0
- package/shared/skia/modules/svg/include/SkSVGRenderContext.h +229 -0
- package/shared/skia/modules/svg/include/SkSVGSVG.h +60 -0
- package/shared/skia/modules/svg/include/SkSVGShape.h +40 -0
- package/shared/skia/modules/svg/include/SkSVGStop.h +36 -0
- package/shared/skia/modules/svg/include/SkSVGText.h +128 -0
- package/shared/skia/modules/svg/include/SkSVGTransformableNode.h +48 -0
- package/shared/skia/modules/svg/include/SkSVGTypes.h +740 -0
- package/shared/skia/modules/svg/include/SkSVGUse.h +49 -0
- package/shared/skia/modules/svg/include/SkSVGValue.h +85 -0
- package/shared/skia/src/core/SkArenaAlloc.h +371 -0
- package/shared/skia/src/core/SkAutoLocaleSetter.h +94 -0
- package/shared/skia/src/core/SkChecksum.h +118 -0
- package/shared/skia/src/core/SkLRUCache.h +143 -0
- package/shared/skia/src/core/SkMathPriv.h +225 -0
- package/shared/skia/src/core/SkTHash.h +714 -0
- package/shared/skia/src/core/SkTInternalLList.h +304 -0
- package/shared/skia/src/core/SkTLazy.h +216 -0
- package/shared/skia/src/core/SkUTF.h +102 -0
- package/shared/skia/src/gpu/ganesh/gl/GrGLDefines.h +1162 -0
- package/src/GameMethods.nitro.ts +4 -0
- package/src/GameMethods.ts +55 -0
- package/src/index.tsx +0 -1
- package/src/nativeTypes.ts +6 -0
- package/android/src/main/cpp/GameLoopJNI.cpp +0 -132
- package/android/src/main/java/com/margelo/nitro/rngine/Asset.kt +0 -9
- package/android/src/main/java/com/margelo/nitro/rngine/GameAssets.kt +0 -61
- package/android/src/main/java/com/margelo/nitro/rngine/Screen.kt +0 -9
- package/android/src/main/java/com/margelo/nitro/rngine/Shape.kt +0 -26
- package/android/src/main/java/com/margelo/nitro/rngine/Snapshot.kt +0 -3
- package/android/src/main/java/com/margelo/nitro/rngine/SnapshotSerializer.kt +0 -53
- package/lib/module/GameAssets.js +0 -41
- package/lib/module/GameAssets.js.map +0 -1
- package/lib/module/GameAssets.nitro.js +0 -5
- package/lib/module/GameAssets.nitro.js.map +0 -1
- package/lib/typescript/src/GameAssets.d.ts +0 -2
- package/lib/typescript/src/GameAssets.d.ts.map +0 -1
- package/lib/typescript/src/GameAssets.nitro.d.ts +0 -12
- package/lib/typescript/src/GameAssets.nitro.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JHybridGameAssetsSpec.cpp +0 -86
- package/nitrogen/generated/android/c++/JHybridGameAssetsSpec.hpp +0 -65
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngine/HybridGameAssetsSpec.kt +0 -63
- package/nitrogen/generated/ios/c++/HybridGameAssetsSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridGameAssetsSpecSwift.hpp +0 -99
- package/nitrogen/generated/ios/swift/Func_void.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -46
- package/nitrogen/generated/ios/swift/HybridGameAssetsSpec.swift +0 -57
- package/nitrogen/generated/ios/swift/HybridGameAssetsSpec_cxx.swift +0 -176
- package/nitrogen/generated/shared/c++/HybridGameAssetsSpec.cpp +0 -23
- package/nitrogen/generated/shared/c++/HybridGameAssetsSpec.hpp +0 -65
- package/src/GameAssets.nitro.ts +0 -14
- package/src/GameAssets.ts +0 -47
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rngine
|
|
2
2
|
|
|
3
|
-
A React Native game engine for building 2D games, powered by [Nitro Modules](https://nitro.margelo.com/) for high-performance C++ game logic.
|
|
3
|
+
A React Native game engine for building 2D games, powered by [Nitro Modules](https://nitro.margelo.com/) for high-performance C++ game logic and rendered natively with [Skia](https://skia.org/).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -24,19 +24,14 @@ configure({
|
|
|
24
24
|
px: 420,
|
|
25
25
|
py: 420,
|
|
26
26
|
color: '#0f0',
|
|
27
|
-
shape: {
|
|
28
|
-
radius: 20,
|
|
29
|
-
},
|
|
27
|
+
shape: { radius: 20 },
|
|
30
28
|
},
|
|
31
29
|
{
|
|
32
30
|
id: 'enemy_1',
|
|
33
31
|
px: 120,
|
|
34
32
|
py: 120,
|
|
35
33
|
color: '#f00',
|
|
36
|
-
shape: {
|
|
37
|
-
width: 40,
|
|
38
|
-
height: 40,
|
|
39
|
-
},
|
|
34
|
+
shape: { width: 40, height: 40 },
|
|
40
35
|
vx: 1000,
|
|
41
36
|
},
|
|
42
37
|
{
|
|
@@ -44,10 +39,7 @@ configure({
|
|
|
44
39
|
px: 220,
|
|
45
40
|
py: 220,
|
|
46
41
|
color: '#f00',
|
|
47
|
-
shape: {
|
|
48
|
-
width: 40,
|
|
49
|
-
height: 40,
|
|
50
|
-
},
|
|
42
|
+
shape: { width: 40, height: 40 },
|
|
51
43
|
vx: -1000,
|
|
52
44
|
},
|
|
53
45
|
],
|
|
@@ -58,10 +50,8 @@ configure({
|
|
|
58
50
|
onTick: (enemies) => {
|
|
59
51
|
enemies.forEach((enemy) => {
|
|
60
52
|
// reverse direction when reaching screen edges
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
enemy.px + enemy.width / 2 >= 800
|
|
64
|
-
) {
|
|
53
|
+
const halfWidth = enemy.shape.width / 2;
|
|
54
|
+
if (enemy.px - halfWidth <= 0 || enemy.px + halfWidth >= 800) {
|
|
65
55
|
update({ id: enemy.id, vx: -enemy.vx });
|
|
66
56
|
}
|
|
67
57
|
});
|
|
@@ -78,11 +68,25 @@ export default function App() {
|
|
|
78
68
|
|
|
79
69
|
## Concepts
|
|
80
70
|
|
|
81
|
-
**Entities** are the objects in your game world. Each entity has a position, shape,
|
|
71
|
+
**Entities** are the objects in your game world. Each entity has a position, shape, and optional color/asset/velocity/acceleration/mass. See [`Entity`](./src/nativeTypes.ts).
|
|
72
|
+
|
|
73
|
+
**Shapes** describe an entity's collision and rendering geometry: either a rectangle (`{ width, height }`) or a circle (`{ radius }`).
|
|
82
74
|
|
|
83
75
|
**Systems** define your game logic. Each system optionally declares which entities it cares about via `entities`, which collision pairs to watch via `collisions`, or both. Systems run every tick receiving the resolved entities and any active collisions. See [`System`](./src/types.ts).
|
|
84
76
|
|
|
85
|
-
**Screen** defines the viewport dimensions and background color. Entities outside the screen bounds are automatically clipped. See [`Screen`](./src/nativeTypes.ts)
|
|
77
|
+
**Screen** defines the viewport dimensions and optional background: color/asset. Entities outside the screen bounds are automatically clipped. See [`Screen`](./src/nativeTypes.ts)
|
|
78
|
+
|
|
79
|
+
**World** defines global simulation settings: `tickRate` (game logic updates per second) and optional gravity (`gx`/`gy`, in game units per second²). See [`World`](./src/nativeTypes.ts)
|
|
80
|
+
|
|
81
|
+
## Rendering
|
|
82
|
+
|
|
83
|
+
Rngine renders natively with [Skia](https://skia.org/) — every frame is drawn directly in C++ on the game loop thread, with no bridge round-trip per frame. SVG and [Lottie](https://airbnb.io/lottie/) animations are both supported as entity/screen assets, decoded and cached natively.
|
|
84
|
+
|
|
85
|
+
## Physics
|
|
86
|
+
|
|
87
|
+
Entities with a `mass` are affected by the world's gravity (`world.gx`/`gy`) and participate in automatic collision resolution: overlapping entities are pushed apart and have their velocities updated via an impulse response. Entities without a `mass` (or `mass: 0`) are treated as immovable (infinite mass) when involved in a collision — useful for static geometry like a ground or walls.
|
|
88
|
+
|
|
89
|
+
Set `isSensor: true` on an entity to still receive collision events (`Collision.depth`, `Collision.nx`/`ny`) without any physical response — the entity won't be pushed, and other entities won't be pushed by it. This is useful for pickups, triggers, or grid-based games where you want to detect overlap yourself without physics involved.
|
|
86
90
|
|
|
87
91
|
## Entity Querying
|
|
88
92
|
|
|
@@ -104,19 +108,40 @@ This makes it easy to build entity groups naturally through naming. No extra con
|
|
|
104
108
|
{ collisions: [{ a: 'player', b: 'enemy' }], onTick: (_, collisions) => {} }
|
|
105
109
|
```
|
|
106
110
|
|
|
111
|
+
Collision results include a normalized direction vector (`nx`/`ny`) pointing along the minimum separating axis, alongside the penetration `depth` — useful for resolving collisions manually or reacting to a specific direction of impact.
|
|
112
|
+
|
|
113
|
+
## Assets
|
|
114
|
+
|
|
115
|
+
Assets (SVGs and Lottie animations) must be preloaded with `loadAssets` before being referenced by `id`, `px`/`py`, or any `configure`/`spawn`/`update` call. Loading happens off the JS thread and is cached — calling `loadAssets` again with the same source is a no-op.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { loadAssets } from 'rngine';
|
|
119
|
+
|
|
120
|
+
const assets = await loadAssets({
|
|
121
|
+
player: require('./assets/player.svg'),
|
|
122
|
+
explosion: require('./assets/explosion.json'), // Lottie
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// assets.player and assets.explosion are numeric ids, ready to use as `asset` on any entity or the screen
|
|
126
|
+
```
|
|
127
|
+
|
|
107
128
|
## API
|
|
108
129
|
|
|
109
130
|
### `configure(config)`
|
|
110
131
|
|
|
111
132
|
Sets up the game engine. Call this before anything else.
|
|
112
133
|
|
|
113
|
-
| param | required | type | default | description
|
|
114
|
-
| ---------- | -------- | ---------- | ------- |
|
|
115
|
-
| `
|
|
116
|
-
| `screen` | ✓ | `Screen` | - | Screen dimensions
|
|
117
|
-
| `entities` | | `Entity[]` | `[]` | Initial entities to spawn
|
|
118
|
-
| `systems` | | `System[]` | `[]` | Systems to run each tick
|
|
119
|
-
| `paused` | | `boolean` | `true` | Whether to start paused
|
|
134
|
+
| param | required | type | default | description |
|
|
135
|
+
| ---------- | -------- | ---------- | ------- | --------------------------------------------- |
|
|
136
|
+
| `world` | ✓ | `World` | - | Tick rate and optional gravity |
|
|
137
|
+
| `screen` | ✓ | `Screen` | - | Screen dimensions, background color and asset |
|
|
138
|
+
| `entities` | | `Entity[]` | `[]` | Initial entities to spawn |
|
|
139
|
+
| `systems` | | `System[]` | `[]` | Systems to run each tick |
|
|
140
|
+
| `paused` | | `boolean` | `true` | Whether to start paused |
|
|
141
|
+
|
|
142
|
+
### `loadAssets(assets)`
|
|
143
|
+
|
|
144
|
+
Preloads one or more SVG or Lottie assets ahead of time. Takes an object mapping names to `require(...)` sources (SVG) or imported JSON (Lottie), and resolves to an object of the same shape with numeric asset ids.
|
|
120
145
|
|
|
121
146
|
### `spawn(entity | entity[])`
|
|
122
147
|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -4,15 +4,43 @@ cmake_minimum_required(VERSION 3.9.0)
|
|
|
4
4
|
set(PACKAGE_NAME rngine)
|
|
5
5
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
6
|
set(CMAKE_CXX_STANDARD 20)
|
|
7
|
+
set(SKIA_ROOT ${CMAKE_SOURCE_DIR}/../shared/skia)
|
|
8
|
+
set(SKIA_LIBS_ROOT ${CMAKE_SOURCE_DIR}/../node_modules/react-native-skia-android/libs/${ANDROID_ABI})
|
|
9
|
+
|
|
10
|
+
add_library(skia STATIC IMPORTED)
|
|
11
|
+
set_property(TARGET skia PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libskia.a")
|
|
12
|
+
|
|
13
|
+
add_library(skia_svg STATIC IMPORTED)
|
|
14
|
+
set_property(TARGET skia_svg PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libsvg.a")
|
|
15
|
+
|
|
16
|
+
add_library(skia_skottie STATIC IMPORTED)
|
|
17
|
+
set_property(TARGET skia_skottie PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libskottie.a")
|
|
18
|
+
|
|
19
|
+
add_library(skia_sksg STATIC IMPORTED)
|
|
20
|
+
set_property(TARGET skia_sksg PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libsksg.a")
|
|
21
|
+
|
|
22
|
+
add_library(skia_skshaper STATIC IMPORTED)
|
|
23
|
+
set_property(TARGET skia_skshaper PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libskshaper.a")
|
|
24
|
+
|
|
25
|
+
add_library(skia_skunicode_core STATIC IMPORTED)
|
|
26
|
+
set_property(TARGET skia_skunicode_core PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libskunicode_core.a")
|
|
27
|
+
|
|
28
|
+
add_library(skia_skunicode_icu STATIC IMPORTED)
|
|
29
|
+
set_property(TARGET skia_skunicode_icu PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libskunicode_icu.a")
|
|
30
|
+
|
|
31
|
+
add_library(skia_jsonreader STATIC IMPORTED)
|
|
32
|
+
set_property(TARGET skia_jsonreader PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_ROOT}/libjsonreader.a")
|
|
7
33
|
|
|
8
34
|
# Define C++ library and add all sources
|
|
9
35
|
add_library(
|
|
10
36
|
${PACKAGE_NAME}
|
|
11
37
|
SHARED
|
|
12
38
|
src/main/cpp/cpp-adapter.cpp
|
|
13
|
-
src/main/cpp/
|
|
39
|
+
src/main/cpp/game-view.cpp
|
|
14
40
|
../shared/GameLoop.cpp
|
|
41
|
+
../shared/GameRenderer.cpp
|
|
15
42
|
../shared/GameMethods.cpp
|
|
43
|
+
../shared/ColorUtils.cpp
|
|
16
44
|
../shared/CollisionUtils.cpp
|
|
17
45
|
)
|
|
18
46
|
|
|
@@ -20,7 +48,11 @@ add_library(
|
|
|
20
48
|
include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/rngine+autolinking.cmake)
|
|
21
49
|
|
|
22
50
|
# Set up local includes
|
|
23
|
-
include_directories(
|
|
51
|
+
include_directories(
|
|
52
|
+
"src/main/cpp"
|
|
53
|
+
"../shared"
|
|
54
|
+
"${SKIA_ROOT}"
|
|
55
|
+
)
|
|
24
56
|
|
|
25
57
|
find_library(LOG_LIB log)
|
|
26
58
|
|
|
@@ -29,4 +61,15 @@ target_link_libraries(
|
|
|
29
61
|
${PACKAGE_NAME}
|
|
30
62
|
${LOG_LIB}
|
|
31
63
|
android # <-- Android core
|
|
64
|
+
skia_skottie
|
|
65
|
+
skia_sksg
|
|
66
|
+
skia_svg
|
|
67
|
+
skia_skshaper
|
|
68
|
+
skia_skunicode_core
|
|
69
|
+
skia_skunicode_icu
|
|
70
|
+
skia_jsonreader
|
|
71
|
+
skia
|
|
72
|
+
jnigraphics
|
|
73
|
+
EGL
|
|
74
|
+
GLESv3
|
|
32
75
|
)
|
package/android/build.gradle
CHANGED
|
@@ -20,7 +20,7 @@ buildscript {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
dependencies {
|
|
23
|
-
classpath "com.android.tools.build:gradle:
|
|
23
|
+
classpath "com.android.tools.build:gradle:9.1.1"
|
|
24
24
|
// noinspection DifferentKotlinGradleVersion
|
|
25
25
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
26
26
|
}
|
|
@@ -119,6 +119,4 @@ android {
|
|
|
119
119
|
dependencies {
|
|
120
120
|
implementation "com.facebook.react:react-android"
|
|
121
121
|
implementation project(":react-native-nitro-modules")
|
|
122
|
-
implementation 'com.caverock:androidsvg-aar:1.4'
|
|
123
|
-
implementation 'com.airbnb.android:lottie:6.7.1'
|
|
124
122
|
}
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include "GameRenderer.hpp"
|
|
2
|
+
#include <android/native_window_jni.h>
|
|
3
|
+
#include <jni.h>
|
|
4
|
+
|
|
5
|
+
extern "C" JNIEXPORT void JNICALL
|
|
6
|
+
Java_com_margelo_nitro_rngine_GameView_nativeOnSurfaceCreated(JNIEnv *env,
|
|
7
|
+
jobject instance,
|
|
8
|
+
jobject surface) {
|
|
9
|
+
|
|
10
|
+
ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, surface);
|
|
11
|
+
margelo::nitro::rngine::GameRenderer::getInstance().onSurfaceCreated(
|
|
12
|
+
nativeWindow);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
extern "C" JNIEXPORT void JNICALL
|
|
16
|
+
Java_com_margelo_nitro_rngine_GameView_nativeOnSurfaceChanged(JNIEnv *env,
|
|
17
|
+
jobject instance,
|
|
18
|
+
jint width,
|
|
19
|
+
jint height) {
|
|
20
|
+
|
|
21
|
+
margelo::nitro::rngine::GameRenderer::getInstance().onSurfaceChanged(width,
|
|
22
|
+
height);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
extern "C" JNIEXPORT void JNICALL
|
|
26
|
+
Java_com_margelo_nitro_rngine_GameView_nativeOnSurfaceDestroyed(
|
|
27
|
+
JNIEnv *env, jobject instance) {
|
|
28
|
+
margelo::nitro::rngine::GameRenderer::getInstance().onSurfaceDestroyed();
|
|
29
|
+
}
|
|
@@ -1,34 +1,7 @@
|
|
|
1
1
|
package com.margelo.nitro.rngine
|
|
2
2
|
|
|
3
|
-
import android.os.Handler
|
|
4
|
-
import android.os.HandlerThread
|
|
5
|
-
import android.view.Choreographer
|
|
6
3
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
4
|
|
|
8
5
|
class GameEngine(val context: ThemedReactContext) : HybridGameEngineSpec() {
|
|
9
|
-
|
|
10
|
-
private var renderHandler: Handler? = null
|
|
11
|
-
|
|
12
|
-
private val frameCallback = object : Choreographer.FrameCallback {
|
|
13
|
-
override fun doFrame(frameTimeNanos: Long) {
|
|
14
|
-
renderHandler?.post { view.drawFrame() }
|
|
15
|
-
Choreographer.getInstance().postFrameCallback(this)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
override val view: GameView = GameView(
|
|
20
|
-
context
|
|
21
|
-
).apply {
|
|
22
|
-
onAttached = {
|
|
23
|
-
renderThread = HandlerThread("RenderThread").also { it.start() }
|
|
24
|
-
renderHandler = Handler(renderThread!!.looper)
|
|
25
|
-
Choreographer.getInstance().postFrameCallback(frameCallback)
|
|
26
|
-
}
|
|
27
|
-
onDetached = {
|
|
28
|
-
Choreographer.getInstance().removeFrameCallback(frameCallback)
|
|
29
|
-
renderThread?.quitSafely()
|
|
30
|
-
renderThread = null
|
|
31
|
-
renderHandler = null
|
|
32
|
-
}
|
|
33
|
-
}
|
|
6
|
+
override val view: GameView = GameView(context)
|
|
34
7
|
}
|
|
@@ -1,187 +1,43 @@
|
|
|
1
1
|
package com.margelo.nitro.rngine
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import android.
|
|
5
|
-
import android.
|
|
6
|
-
import android.util.AttributeSet
|
|
4
|
+
import android.view.Surface
|
|
5
|
+
import android.view.SurfaceHolder
|
|
7
6
|
import android.view.SurfaceView
|
|
8
|
-
import android.view.View
|
|
9
|
-
import androidx.core.graphics.withTranslation
|
|
10
|
-
import androidx.core.graphics.withClip
|
|
11
7
|
|
|
12
8
|
class GameView(
|
|
13
9
|
context: Context,
|
|
14
|
-
attrs: AttributeSet? = null,
|
|
15
|
-
defStyleAttr: Int = 0,
|
|
16
10
|
) : SurfaceView(
|
|
17
11
|
context,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
private external fun getSnapshot(): ByteArray
|
|
22
|
-
var onAttached: () -> Unit = {}
|
|
23
|
-
var onDetached: () -> Unit = {}
|
|
12
|
+
),
|
|
13
|
+
SurfaceHolder.Callback {
|
|
14
|
+
private external fun nativeOnSurfaceCreated(surface: Surface)
|
|
24
15
|
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
private fun drawAsset(
|
|
30
|
-
canvas: Canvas,
|
|
31
|
-
left: Float,
|
|
32
|
-
top: Float,
|
|
33
|
-
right: Float,
|
|
34
|
-
bottom: Float,
|
|
35
|
-
asset: Int,
|
|
36
|
-
progress: Float?,
|
|
37
|
-
) {
|
|
38
|
-
canvas.withTranslation(left, top) {
|
|
39
|
-
when (val resolvedAsset = GameAssets.getAsset(asset)) {
|
|
40
|
-
is Asset.Svg -> {
|
|
41
|
-
scale(
|
|
42
|
-
(right - left) / resolvedAsset.picture.width,
|
|
43
|
-
(bottom - top) / resolvedAsset.picture.height
|
|
44
|
-
)
|
|
45
|
-
drawPicture(resolvedAsset.picture)
|
|
46
|
-
}
|
|
16
|
+
private external fun nativeOnSurfaceChanged(
|
|
17
|
+
width: Int,
|
|
18
|
+
height: Int,
|
|
19
|
+
)
|
|
47
20
|
|
|
48
|
-
|
|
49
|
-
progress?.let {
|
|
50
|
-
resolvedAsset.drawable.progress = it
|
|
51
|
-
}
|
|
52
|
-
resolvedAsset.drawable.setBounds(0, 0, (right - left).toInt(), (bottom - top).toInt())
|
|
53
|
-
resolvedAsset.drawable.draw(canvas)
|
|
54
|
-
}
|
|
21
|
+
private external fun nativeOnSurfaceDestroyed()
|
|
55
22
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
23
|
+
init {
|
|
24
|
+
holder.addCallback(this)
|
|
59
25
|
}
|
|
60
26
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
left: Float,
|
|
64
|
-
top: Float,
|
|
65
|
-
right: Float,
|
|
66
|
-
bottom: Float,
|
|
67
|
-
color: Int,
|
|
68
|
-
asset: Int,
|
|
69
|
-
progress: Float?,
|
|
70
|
-
) {
|
|
71
|
-
paint.color = color
|
|
72
|
-
canvas.drawRect(left, top, right, bottom, paint)
|
|
73
|
-
|
|
74
|
-
drawAsset(
|
|
75
|
-
canvas,
|
|
76
|
-
left,
|
|
77
|
-
top,
|
|
78
|
-
right,
|
|
79
|
-
bottom,
|
|
80
|
-
asset,
|
|
81
|
-
progress
|
|
82
|
-
)
|
|
27
|
+
override fun surfaceCreated(holder: SurfaceHolder) {
|
|
28
|
+
nativeOnSurfaceCreated(holder.surface)
|
|
83
29
|
}
|
|
84
30
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
color: Int,
|
|
91
|
-
asset: Int,
|
|
92
|
-
progress: Float?,
|
|
31
|
+
override fun surfaceChanged(
|
|
32
|
+
holder: SurfaceHolder,
|
|
33
|
+
format: Int,
|
|
34
|
+
width: Int,
|
|
35
|
+
height: Int,
|
|
93
36
|
) {
|
|
94
|
-
|
|
95
|
-
val top = cy - radius
|
|
96
|
-
val right = cx + radius
|
|
97
|
-
val bottom = cy + radius
|
|
98
|
-
|
|
99
|
-
paint.color = color
|
|
100
|
-
canvas.drawCircle(cx, cy, radius, paint)
|
|
101
|
-
|
|
102
|
-
drawAsset(
|
|
103
|
-
canvas,
|
|
104
|
-
left,
|
|
105
|
-
top,
|
|
106
|
-
right,
|
|
107
|
-
bottom,
|
|
108
|
-
asset,
|
|
109
|
-
progress,
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
init {
|
|
114
|
-
addOnAttachStateChangeListener(
|
|
115
|
-
object : OnAttachStateChangeListener {
|
|
116
|
-
override fun onViewAttachedToWindow(view: View) = onAttached()
|
|
117
|
-
override fun onViewDetachedFromWindow(view: View) = onDetached()
|
|
118
|
-
})
|
|
37
|
+
nativeOnSurfaceChanged(width, height)
|
|
119
38
|
}
|
|
120
39
|
|
|
121
|
-
fun
|
|
122
|
-
|
|
123
|
-
val canvas = holder.lockCanvas() ?: return
|
|
124
|
-
val snapshot = SnapshotSerializer.decode(getSnapshot())
|
|
125
|
-
|
|
126
|
-
val scaleX = canvas.width / snapshot.screen.width
|
|
127
|
-
val scaleY = canvas.height / snapshot.screen.height
|
|
128
|
-
val scale = minOf(scaleX, scaleY)
|
|
129
|
-
|
|
130
|
-
val screenLeft = (canvas.width - snapshot.screen.width * scale) / 2f
|
|
131
|
-
val screenTop = (canvas.height - snapshot.screen.height * scale) / 2f
|
|
132
|
-
val screenRight = screenLeft + snapshot.screen.width * scale
|
|
133
|
-
val screenBottom = screenTop + snapshot.screen.height * scale
|
|
134
|
-
|
|
135
|
-
drawRect(
|
|
136
|
-
canvas,
|
|
137
|
-
screenLeft,
|
|
138
|
-
screenTop,
|
|
139
|
-
screenRight,
|
|
140
|
-
screenBottom,
|
|
141
|
-
snapshot.screen.color,
|
|
142
|
-
snapshot.screen.asset,
|
|
143
|
-
snapshot.screen.progress,
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
canvas.withClip(screenLeft, screenTop, screenRight, screenBottom) {
|
|
147
|
-
snapshot.shapes.forEach { shape ->
|
|
148
|
-
when (shape) {
|
|
149
|
-
is Shape.Rect -> {
|
|
150
|
-
val left = shape.left * scale + screenLeft
|
|
151
|
-
val top = shape.top * scale + screenTop
|
|
152
|
-
val right = shape.right * scale + screenLeft
|
|
153
|
-
val bottom = shape.bottom * scale + screenTop
|
|
154
|
-
|
|
155
|
-
drawRect(
|
|
156
|
-
canvas,
|
|
157
|
-
left,
|
|
158
|
-
top,
|
|
159
|
-
right,
|
|
160
|
-
bottom,
|
|
161
|
-
shape.color,
|
|
162
|
-
shape.asset,
|
|
163
|
-
shape.progress,
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
is Shape.Circle -> {
|
|
168
|
-
val cx = shape.px * scale + screenLeft
|
|
169
|
-
val cy = shape.py * scale + screenTop
|
|
170
|
-
val radius = shape.radius * scale
|
|
171
|
-
|
|
172
|
-
drawCircle(
|
|
173
|
-
canvas,
|
|
174
|
-
cx,
|
|
175
|
-
cy,
|
|
176
|
-
radius,
|
|
177
|
-
shape.color,
|
|
178
|
-
shape.asset,
|
|
179
|
-
shape.progress,
|
|
180
|
-
)
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
holder.unlockCanvasAndPost(canvas)
|
|
40
|
+
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
|
41
|
+
nativeOnSurfaceDestroyed()
|
|
186
42
|
}
|
|
187
43
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.margelo.nitro.rngine
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Keep
|
|
4
|
+
import com.margelo.nitro.NitroModules
|
|
5
|
+
import java.net.URL
|
|
6
|
+
|
|
7
|
+
@Keep
|
|
8
|
+
object SvgLoaderHelper {
|
|
9
|
+
@JvmStatic
|
|
10
|
+
fun loadFromUrl(uri: String): ByteArray {
|
|
11
|
+
return URL(uri).openStream().use { it.readBytes() }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@JvmStatic
|
|
15
|
+
fun loadFromResource(uri: String): ByteArray {
|
|
16
|
+
val context = NitroModules.applicationContext
|
|
17
|
+
?: throw IllegalStateException("No Context available!")
|
|
18
|
+
val resId = context.resources.getIdentifier(uri, "raw", context.packageName)
|
|
19
|
+
if (resId == 0) {
|
|
20
|
+
throw IllegalStateException("Could not resolve raw resource for asset: $uri")
|
|
21
|
+
}
|
|
22
|
+
return context.resources.openRawResource(resId).use { it.readBytes() }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { gameMethods } from "./GameMethods.nitro.js";
|
|
4
|
+
import { Image } from 'react-native';
|
|
5
|
+
|
|
4
6
|
/** Sets up the game engine with the given configuration. Call this before anything else. */
|
|
5
7
|
export const configure = ({
|
|
6
8
|
world,
|
|
@@ -53,4 +55,46 @@ export const update = updates => {
|
|
|
53
55
|
const entityUpdateArray = Array.isArray(updates) ? updates : [updates];
|
|
54
56
|
gameMethods.update(entityUpdateArray);
|
|
55
57
|
};
|
|
58
|
+
const assetCache = new WeakMap();
|
|
59
|
+
let nextId = -1;
|
|
60
|
+
const loadAsset = async asset => {
|
|
61
|
+
switch (typeof asset) {
|
|
62
|
+
case 'object':
|
|
63
|
+
if (asset === null) {
|
|
64
|
+
throw new Error('loadAssets: asset cannot be null');
|
|
65
|
+
}
|
|
66
|
+
if (assetCache.has(asset)) {
|
|
67
|
+
return assetCache.get(asset);
|
|
68
|
+
}
|
|
69
|
+
const assetId = nextId--;
|
|
70
|
+
assetCache.set(asset, assetId);
|
|
71
|
+
const isLottieLoaded = await gameMethods.loadLottie(assetId, JSON.stringify(asset));
|
|
72
|
+
if (!isLottieLoaded) {
|
|
73
|
+
throw new Error('loadAssets: Failed to load lottie asset');
|
|
74
|
+
}
|
|
75
|
+
return assetId;
|
|
76
|
+
case 'number':
|
|
77
|
+
if (gameMethods.isAssetLoaded(asset)) {
|
|
78
|
+
return asset;
|
|
79
|
+
}
|
|
80
|
+
const assetUri = Image.resolveAssetSource(asset)?.uri;
|
|
81
|
+
if (!assetUri) {
|
|
82
|
+
throw new Error(`loadAssets: could not resolve asset URI for ${asset}`);
|
|
83
|
+
}
|
|
84
|
+
const isSvgLoaded = await gameMethods.loadSvg(asset, assetUri);
|
|
85
|
+
if (!isSvgLoaded) {
|
|
86
|
+
throw new Error('loadAssets: Failed to load svg asset');
|
|
87
|
+
}
|
|
88
|
+
return asset;
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`loadAssets: unsupported asset type "${typeof asset}"`);
|
|
91
|
+
};
|
|
92
|
+
export const loadAssets = async assets => {
|
|
93
|
+
const keys = Object.keys(assets);
|
|
94
|
+
const result = {};
|
|
95
|
+
for (const key of keys) {
|
|
96
|
+
result[key] = await loadAsset(assets[key]);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
56
100
|
//# sourceMappingURL=GameMethods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["gameMethods","configure","world","screen","entities","systems","paused","nativeSystems","system","push","collisions","onTick","e","c","start","Date","now","finish","setWorld","setScreen","setEntities","setSystems","pause","resume","spawn","entityArray","Array","isArray","despawn","id","update","updates","entityUpdateArray"],"sourceRoot":"../../src","sources":["GameMethods.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,wBAAqB;
|
|
1
|
+
{"version":3,"names":["gameMethods","Image","configure","world","screen","entities","systems","paused","nativeSystems","system","push","collisions","onTick","e","c","start","Date","now","finish","setWorld","setScreen","setEntities","setSystems","pause","resume","spawn","entityArray","Array","isArray","despawn","id","update","updates","entityUpdateArray","assetCache","WeakMap","nextId","loadAsset","asset","Error","has","get","assetId","set","isLottieLoaded","loadLottie","JSON","stringify","isAssetLoaded","assetUri","resolveAssetSource","uri","isSvgLoaded","loadSvg","loadAssets","assets","keys","Object","result","key"],"sourceRoot":"../../src","sources":["GameMethods.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroModules","gameMethods","createHybridObject"],"sourceRoot":"../../src","sources":["GameMethods.nitro.ts"],"mappings":";;AAQA,SAASA,YAAY,QAAQ,4BAA4B;
|
|
1
|
+
{"version":3,"names":["NitroModules","gameMethods","createHybridObject"],"sourceRoot":"../../src","sources":["GameMethods.nitro.ts"],"mappings":";;AAQA,SAASA,YAAY,QAAQ,4BAA4B;AAqBzD,OAAO,MAAMC,WAAW,GACtBD,YAAY,CAACE,kBAAkB,CAAc,aAAa,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GameEngine"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,UAAU,MAAM,iBAAc;AAErC,cAAc,kBAAe;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"names":["GameEngine"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,UAAU,MAAM,iBAAc;AAErC,cAAc,kBAAe;AAC7B,cAAc,YAAS;AASvB,SAASA,UAAU","ignoreList":[]}
|
|
@@ -12,4 +12,5 @@ export declare const spawn: (entities: Entity | Entity[]) => void;
|
|
|
12
12
|
export declare const despawn: (id: string) => void;
|
|
13
13
|
/** Updates one or more entities. Only the provided fields are changed. */
|
|
14
14
|
export declare const update: (updates: EntityUpdate | EntityUpdate[]) => void;
|
|
15
|
+
export declare const loadAssets: <T extends Record<string, unknown>>(assets: T) => Promise<{ [K in keyof T]: number; }>;
|
|
15
16
|
//# sourceMappingURL=GameMethods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameMethods.d.ts","sourceRoot":"","sources":["../../../src/GameMethods.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAU,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"GameMethods.d.ts","sourceRoot":"","sources":["../../../src/GameMethods.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAU,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,4FAA4F;AAC5F,eAAO,MAAM,SAAS,GAAI,+CAMvB,MAAM,SAyBR,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,KAAK,YAA4B,CAAC;AAE/C,6BAA6B;AAC7B,eAAO,MAAM,MAAM,YAA6B,CAAC;AAEjD,0EAA0E;AAC1E,eAAO,MAAM,KAAK,GAAI,UAAU,MAAM,GAAG,MAAM,EAAE,SAGhD,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,OAAO,GAAI,IAAI,MAAM,SAA4B,CAAC;AAE/D,0EAA0E;AAC1E,eAAO,MAAM,MAAM,GAAI,SAAS,YAAY,GAAG,YAAY,EAAE,SAG5D,CAAC;AA2CF,eAAO,MAAM,UAAU,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,QAAQ,CAAC,KACR,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAE,CASpC,CAAC"}
|
|
@@ -13,6 +13,9 @@ interface GameMethods extends HybridObject<{
|
|
|
13
13
|
spawn(entities: Entity[]): void;
|
|
14
14
|
despawn(id: string): void;
|
|
15
15
|
update(updates: EntityUpdate[]): void;
|
|
16
|
+
isAssetLoaded(id: number): boolean;
|
|
17
|
+
loadLottie(id: number, jsonStr: string): Promise<boolean>;
|
|
18
|
+
loadSvg(id: number, svgUri: string): Promise<boolean>;
|
|
16
19
|
}
|
|
17
20
|
export declare const gameMethods: GameMethods;
|
|
18
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameMethods.nitro.d.ts","sourceRoot":"","sources":["../../../src/GameMethods.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,MAAM,EACN,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAC;AAGvB,UAAU,WAAY,SAAQ,YAAY,CAAC;IACzC,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACtC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"GameMethods.nitro.d.ts","sourceRoot":"","sources":["../../../src/GameMethods.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,MAAM,EACN,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAC;AAGvB,UAAU,WAAY,SAAQ,YAAY,CAAC;IACzC,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACtC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEtC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,WAAW,aACqC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,SAAS,EACT,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,CAAC"}
|