-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add opacity, removing entities from map
- Loading branch information
1 parent
da11ae9
commit 499e8be
Showing
9 changed files
with
138 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
local ignored_entities = require("modules/gridworld/map/ignored_entities") | ||
|
||
local function on_entity_added(_, entity) | ||
if ignored_entities[entity.type] then | ||
return | ||
end | ||
if global.gridworld.map.added_entities_to_update == nil then | ||
global.gridworld.map.added_entities_to_update = {} | ||
end | ||
table.insert(global.gridworld.map.added_entities_to_update, entity) | ||
local registration = script.register_on_entity_destroyed(entity) | ||
global.gridworld.map.entity_registrations[registration] = { | ||
position = entity.position, | ||
bounding_box = entity.bounding_box, | ||
deleted = true, | ||
} | ||
end | ||
|
||
return on_entity_added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
-- TODO: Add batching of updates with on_nth_tick | ||
local function on_entity_removed(_event) | ||
-- dump_entities({event.entity}) | ||
local function on_entity_removed(event) | ||
if global.gridworld.map.removed_entities_to_update == nil then | ||
global.gridworld.map.removed_entities_to_update = {} | ||
end | ||
local entity = global.gridworld.map.entity_registrations[event.registration_number] | ||
table.insert(global.gridworld.map.removed_entities_to_update, entity) | ||
global.gridworld.map.entity_registrations[event.registration_number] = nil | ||
end | ||
|
||
return on_entity_removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local ignored_entities = require("modules/gridworld/map/ignored_entities") | ||
|
||
local function on_entity_removed(event) | ||
local entity = event.entity or event.cliff | ||
if ignored_entities[entity.type] then | ||
return | ||
end | ||
if global.gridworld.map.removed_entities_to_update == nil then | ||
global.gridworld.map.removed_entities_to_update = {} | ||
end | ||
table.insert(global.gridworld.map.removed_entities_to_update, { | ||
position = entity.position, | ||
bounding_box = entity.bounding_box, | ||
deleted = true, | ||
}) | ||
end | ||
|
||
return on_entity_removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
local ignored_entities = { | ||
-- "entity-ghost", -- Should be rendered as transparent purple | ||
"locomotive", | ||
"cargo-wagon", | ||
"fluid-wagon", | ||
"artillery-wagon", | ||
"car", | ||
"spider-vehicle", | ||
"character", | ||
"character-corpse", | ||
} | ||
|
||
return ignored_entities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters