efro.dataclassio cleanup

This commit is contained in:
Eric Froemling 2021-04-30 21:22:40 -05:00
parent a931a856b2
commit 053a514d0e
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
5 changed files with 52 additions and 18 deletions

View File

@ -3940,18 +3940,18 @@
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/11/c5/e0bf2d2b8f49ca5f37251c92b27d",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e0/14/b977cd5aeebf9911060c7a5e89b4",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e9/fc/7bd6a5e9415a29eb5c05f5ef9330",
"build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/aa/48c51a02a45debc7dba4e08497e4",
"build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/71/ef/8c9ab9836acf77c761e59e82e0e4",
"build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/83/db/c41d3815f8218bc07de270a89976",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2c/a4/427e8fdf20a81d46b0fdb1de8f76",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6c/e5/e3285ac07d2181af33c995181333",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5b/9a/97ecfd01f46e5d60110fce5154e5",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a7/9b/22091a33113871fe9178d4745a2a",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b4/44/3431d4bee306522090f4b3df32c1",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/e1/33/4a76b4caf23ccc7e052f8dbc9319",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f6/d0/7b87d34b13f5cb7950a0ffa45fe9",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8e/ea/7fea64f41eaf54901beae5d35e52",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8d/10/bc0420b13a490468a9b0c17c7bd6",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/34/5f/31c444bae9e4addaf62868e6d544",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/76/61/ac6b5aacb3b4ba410a5730bef602",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/37/a0/396efd9512c58e15776258a6dbaa",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/c1/29/61eaddf05361c973917645544193",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/9c/f4/0841191f3813141c159dda3d11a8",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/47/44/a70f6fbd98ca6f36332182d7617b",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/98/5f/ba5b9b9c7ea867ed5dcbe8e8a0ba",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/27/e2/61a5a5ab4aaa0877412610298de8",
"build/prefab/lib/linux_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/05/1d/03a2b2487e67010afff2a855fa2e",
"build/prefab/lib/linux_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7c/8e/4be856155b5485c6a2ed8a605253",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a6/7d/a267f67eb9c9eecc0c6c5d4381c4",
@ -3960,12 +3960,12 @@
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/98/24/86dfc03d0985b358527f1abbaca5",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/20/82/4544f70ada88097fba6c34c23b77",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/be/05/4767c22c4e4821de606a12a9b2a6",
"build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d7/e1/1dae62eb42fd7b66325278b84dba",
"build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/22/e2/769d0b3e06b73edc6ad712f9a821",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b5/61/43b9fe96846c0ff72598a6f9ab9c",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a4/9d/f30a305efea862cc1b483efc79d3",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ee/bf/ebc6b503082cb03575d2927c0fc6",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/85/d6/6664a0ce02bc4e513ed86ac1d61b",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/38/67/b85a805950491a0bb322be8497b5",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2e/9f/c537ed38c978b7fe030d3f06f421"
"build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/97/e7/74bd85c8f1977f50f50c0efd4f5f",
"build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/13/5c/f439548a629b1b2c8beff79f4802",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/85/94/f58e01484c1ccc9938d0bd30da2c",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/74/da/af32501dee7ae4425a296bbc8227",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e5/b5/afd606774f75262abfdcb8fdcef7",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b7/c9/e3bf9b169734f8e264a47f497044",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4a/bf/34a5673bf1322e4fe5f86db35e1d",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6b/e7/1e0a6a7ff3131835ae3df2ed4f0d"
}

View File

@ -1,4 +1,4 @@
### 1.6.0 (20333)
### 1.6.0 (20353)
- Revamped netcode significantly. We still don't have client-prediction, but things should (hopefully) feel much lower latency now.
- Added network debug graphs accessible by hitting F8.
- Added private parties functionality (cloud hosted parties with associated codes making it easier to play with friends)
@ -20,6 +20,7 @@
- Better randomization for player free-for-all starting locations
- Plugins can now register to be called for pause, resume, and shutdown events in addition to launch
- Added ba.app.state holding the overall state of the app (running, paused, etc)
- renamed the efro.dataclasses module to efro.dataclassio and added significant functionality
### 1.5.29 (20246)
- Exposed ba method/class initing in public C++ layer.

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2021-04-30 for Ballistica version 1.6.0 build 20352</em></h4>
<h4><em>last updated on 2021-04-30 for Ballistica version 1.6.0 build 20353</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr>

View File

@ -8,6 +8,7 @@ from typing import TYPE_CHECKING
from dataclasses import dataclass
from efro import entity
from efro.dataclassio import prepped
if TYPE_CHECKING:
from typing import Optional, Any, List, Dict
@ -32,6 +33,7 @@ class ServerNodeQueryResponse(entity.Entity):
store_default=False)
@prepped
@dataclass
class PrivateHostingState:
"""Combined state of whether we're hosting, whether we can, etc."""
@ -43,6 +45,7 @@ class PrivateHostingState:
free_host_minutes_remaining: Optional[float] = None
@prepped
@dataclass
class PrivateHostingConfig:
"""Config provided when hosting a private party."""
@ -55,6 +58,7 @@ class PrivateHostingConfig:
playlist: Optional[List[Dict[str, Any]]] = None
@prepped
@dataclass
class PrivatePartyConnectResult:
"""Info about a server we get back when connecting."""

View File

@ -64,6 +64,18 @@ def dataclass_to_dict(obj: Any, coerce_to_float: bool = True) -> dict:
return out
def dataclass_to_json(obj: Any, coerce_to_float: bool = True) -> str:
"""Utility function; return a json string from a dataclass instance.
Basically json.dumps(dataclass_to_dict(...)).
"""
import json
return json.dumps(
dataclass_to_dict(obj=obj, coerce_to_float=coerce_to_float),
separators=(',', ':'),
)
def dataclass_from_dict(cls: Type[T],
values: dict,
coerce_to_float: bool = True,
@ -98,6 +110,23 @@ def dataclass_from_dict(cls: Type[T],
discard_unknown_attrs=discard_unknown_attrs).run(values)
def dataclass_from_json(cls: Type[T],
json_str: str,
coerce_to_float: bool = True,
allow_unknown_attrs: bool = True,
discard_unknown_attrs: bool = False) -> T:
"""Utility function; return a dataclass instance given a json string.
Basically dataclass_from_dict(json.loads(...))
"""
import json
return dataclass_from_dict(cls=cls,
values=json.loads(json_str),
coerce_to_float=coerce_to_float,
allow_unknown_attrs=allow_unknown_attrs,
discard_unknown_attrs=discard_unknown_attrs)
def dataclass_validate(obj: Any, coerce_to_float: bool = True) -> None:
"""Ensure that values in a dataclass instance are the correct types."""