Skip to content

Commit

Permalink
catch up on the newest version of AssetStudio
Browse files Browse the repository at this point in the history
  • Loading branch information
Deficuet authored and Deficuet committed Dec 24, 2022
1 parent 762de17 commit 695cb19
Show file tree
Hide file tree
Showing 39 changed files with 991 additions and 915 deletions.
2 changes: 1 addition & 1 deletion TextureDecoderNative/header.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
javac -h ./ D:\UnityKt\src\main\java\io\github\deficuet\unitykt\extension\TextureDecoder.java
javac -h ./ ../src/main/java/io/github/deficuet/unitykt/extension/TextureDecoder.java
pause
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.5.31'
id 'org.jetbrains.kotlin.jvm' version '1.7.20'
id 'maven-publish'
}

Expand All @@ -14,11 +14,11 @@ repositories {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7'
implementation 'org.json:json:20220320'
implementation 'org.json:json:20220924'
implementation 'org.lz4:lz4-java:1.8.0'
implementation 'com.nixxcode.jvmbrotli:jvmbrotli:0.2.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
}

test {
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/io/github/deficuet/unitykt/ImportContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@ class ImportContext: AssetBundleFile {
override val name: String

/**
* The [AssetManager] which loads this file.
* The [UnityAssetManager] which loads this file.
*/
val manager: AssetManager
val manager: UnityAssetManager

/**
* All [Object] loaded from this file.
*/
val objects = mutableListOf<Object>()

internal constructor(
filePath: String, manager: AssetManager,
filePath: String, manager: UnityAssetManager,
offsetMode: OffsetMode = OffsetMode.MANUAL,
manualIgnoredOffset: Long = 0
manualOffset: Long = 0
) {
val file = File(filePath)
directory = file.parentFile.canonicalPath
name = file.name
this.manager = manager
files = mapOf(name to init(EndianFileStreamReader(
filePath, offsetMode = offsetMode, manualIgnoredOffset = manualIgnoredOffset
filePath, offsetMode = offsetMode, manualOffset = manualOffset
)))
}

internal constructor(
data: ByteArray, name: String, manager: AssetManager,
data: ByteArray, name: String, manager: UnityAssetManager,
offsetMode: OffsetMode = OffsetMode.MANUAL,
manualIgnoredOffset: Long = 0
manualOffset: Long = 0
) {
directory = ""
this.name = name
this.manager = manager
files = mapOf(this.name to init(EndianByteArrayReader(
data, offsetMode = offsetMode, manualIgnoredOffset = manualIgnoredOffset
data, offsetMode = offsetMode, manualOffset = manualOffset
)))
}

Expand Down
11 changes: 8 additions & 3 deletions src/main/kotlin/io/github/deficuet/unitykt/PPtrUtils.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.deficuet.unitykt

import io.github.deficuet.unitykt.data.*
import io.github.deficuet.unitykt.data.Object
import io.github.deficuet.unitykt.data.PPtr

inline fun <reified O: Object> PPtr<O>.getObj(): O? {
if (obj != null) return obj
Expand All @@ -18,11 +19,15 @@ inline fun <reified O: Object> PPtr<O>.getObj(): O? {
return null
}

inline fun <reified T: Object> Array<out PPtr<*>>.getAllInstanceOf(): List<T> {
inline fun <reified T: Object> PPtr<*>.getObjAs(): T? {
return getObj() as? T
}

inline fun <reified T: Object> Array<out PPtr<*>>.allObjectsOf(): List<T> {
return map { it.getObj() }.filterIsInstance<T>()
}

inline fun <reified T: Object> List<PPtr<*>>.getAllInstanceOf(): List<T> {
inline fun <reified T: Object> List<PPtr<*>>.allObjectsOf(): List<T> {
return map { it.getObj() }.filterIsInstance<T>()
}

Expand Down
Loading

0 comments on commit 695cb19

Please sign in to comment.