Skip to content

Commit 75ca7ad

Browse files
committed
TPK - impl TpkUnityClass.to_dict
1 parent 422db65 commit 75ca7ad

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

UnityPy/helpers/Tpk.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,28 @@ def __init__(self, stream: BytesIO) -> None:
352352
if self.Flags & TpkUnityClassFlags.HasReleaseRootNode:
353353
(self.ReleaseRootNode,) = UINT16.unpack(stream.read(UINT16.size))
354354

355+
def to_dict(self) -> Dict[str, Any]:
356+
return {
357+
"Name": self.Name,
358+
"Base": self.Base,
359+
"Flags": self.Flags,
360+
"EditorRootNode": self.EditorRootNode,
361+
"ReleaseRootNode": self.ReleaseRootNode,
362+
}
363+
355364
def __eq__(self, other: TpkUnityClass) -> bool:
356-
return self.__dict__ == other.__dict__
365+
return self.to_dict() == other.to_dict()
357366

358367
def __hash__(self) -> int:
359-
# TODO
360-
return hash(self.__dict__)
368+
return hash(
369+
(
370+
self.Name,
371+
self.Base,
372+
self.Flags,
373+
self.EditorRootNode,
374+
self.ReleaseRootNode,
375+
)
376+
)
361377

362378

363379
class TpkClassInformation:

0 commit comments

Comments
 (0)