Expose live mod actors and difficulty and support dense event queries
This commit is contained in:
1 parent
287b324e62
commit
93ea7064ba
10 files changed
+302
-11
No files matched your search
+4
-1
@@ -708,7 +708,10 @@ impl ScriptRuntime {
|
||||
.set_max_call_levels(32)
|
||||
.set_max_expr_depths(64, 32)
|
||||
.set_max_array_size(4096)
|
||||
.set_max_map_size(1024)
|
||||
// Rhai counts nested map properties, including host event snapshots.
|
||||
// A 64-enemy event already has 2,886 properties. Keep inputs bounded
|
||||
// without relaxing the separate 64 KiB state or operation limits.
|
||||
.set_max_map_size(16_384)
|
||||
.set_max_string_size(16384)
|
||||
.set_max_modules(0);
|
||||
engine.disable_symbol("eval");
|
||||
|
||||
@@ -2887,6 +2887,15 @@ impl World {
|
||||
if let Some(path) = script {
|
||||
let owner = ®istry.owners[&event.content];
|
||||
let mut e = event.event;
|
||||
e["difficulty"] = self.difficulty.into();
|
||||
let actor_entity = if registry.missions.contains_key(&event.content) {
|
||||
None
|
||||
} else {
|
||||
e.get("entity")
|
||||
.and_then(serde_json::Value::as_u64)
|
||||
.filter(|entity| *entity != 0)
|
||||
};
|
||||
let mut actor = serde_json::Value::Null;
|
||||
e["entities"] = serde_json::to_value(&self.enemies)?;
|
||||
for (snapshot, enemy) in e["entities"]
|
||||
.as_array_mut()
|
||||
@@ -2895,7 +2904,11 @@ impl World {
|
||||
.zip(&self.enemies)
|
||||
{
|
||||
snapshot["ground"] = registry.enemies[&enemy.definition].ground.into();
|
||||
if actor_entity == Some(enemy.entity) {
|
||||
actor = snapshot.clone();
|
||||
}
|
||||
}
|
||||
e["actor"] = actor;
|
||||
e["player"] = serde_json::to_value(&self.player)?;
|
||||
e["objectives"] = serde_json::to_value(&self.objectives)?;
|
||||
e["projectiles"] = serde_json::to_value(&self.projectiles)?;
|
||||
|
||||
Reference in new issue
Block a user