Page 1 of 1

Workaround for entity destruction on tile change

Posted: Sat Apr 20, 2019 11:57 pm
by Earendel
There may already be a workaround for this, but I can't find one.

The problem occurs when you have a tile, and an entity overlapping that tile. The tile get changed, either by mining the tile, or putting flooring down. The change causes the collision mask to change, the entity gets destroyed.

There are times you'd want this to happen, such as landfill removing fish.

But there are times when you don't: You have space platform with an expensive structure on it. You mine a tile accidentally, the structure disappears.

I can see thee solutions to the problem, but there may be a better one.

Option 1:

Two new events: on_pre_player_changed_tile and on_pre_robot_changed_tile

The event return values could be similar to on_player_built_tile, except that tiles would be an array of 'NewTileAndPosition' (instead of old).

A mod maker could then use these events to search for entities in the affected area, check if they would be destroyed.

Option 2:

The game prevents you from mining tiles that would destroy entities. Some entities could have flags to not block tile changes (fish).

The game prevents you from building tiles where they would destroy entities (unless they are flagged to not block tile changes).

Option 3:

Basically like option 2, but instead of preventing the action, it forces the player or bot to perform a mining action on the conflicting entity if possible.
I.e. you try to mine the tile, and entity is in the way, you automatically start mining the entity first.

Re: Workaround for entity destruction on tile change

Posted: Sun Apr 21, 2019 1:32 am
by mrudat
The platforms mod makes platforms indestructible so long as there is an entity on top to prevent this very thing from happening.

Re: Workaround for entity destruction on tile change

Posted: Sun Apr 21, 2019 9:08 am
by Earendel
mrudat wrote: Sun Apr 21, 2019 1:32 am The platforms mod makes platforms indestructible so long as there is an entity on top to prevent this very thing from happening.
Oh nice. I took a look at the code and the idea is pretty clever. Unfortunately doing it that way requires an additional 'immortal' tile for each tile that might be affected. I have at least 3 tiles that would need this treatment, and I can't justify adding 3 new tile types just for this. With Alien Biomes as a dependency the available tile slots are low and people are already going over the 256 tile limit.