Closed ChaosSaber closed 1 year ago
I'm pretty sure a place item was a requirement for an entity to be blueprintable in the first place which is the main reason I only create dummys for place results. So how are the diffrent modi BPable in the first placce. If I can figure that out it may be possible to turn this into a more generalized fix for any entries that are blueprintable without having an item that places it.
Also instead of hardcoding the roboports a better way would be to loop trough every roboprot in Data.raw["roboport"] and apply it to all roboports, that way it works for any arbitrary mod that adds new types of rob port.
Anyways I'll merge it if you change it to work for all rob ports (after I've tested if it works).
It uses the placeable_by member variable. So maybe it is enough to create an dummy entity on each entity where that variable is set. Since this variable is used by blueprints to determine the items needed, I would assume that this should work.
I did an approach with a loop. Not pretty but works. I also found some more issues while testing, mostly related to space eploration but probably not unique to it.
Short explanation for line 343 to 353 382 to 392 with the latest commit. I found at least one entity, where the placeable_by item did not exist as a ghost on water dummy. Therefore I just skipped over them for now.
If you are interested, I tried my hand here at an completely generic approach with the placeable_by entry, but got some errors that some item dummies don't have an entity dummy. Since I have no idea how i could debug that except printf-debugging, I stopped there for now.
I actually made another change which should now cover all entities which can be placed by a different item.
In Space Exploration are some items which can be placed on different surfaces and depending on which surface they are placed on, a different entity is placed.
But there is still an issue with muti-entities (a single entity which actually consists of multiple entities.) I will create a separate issue for this.
You're still checking data.raw.roboport[dummyName] to see if the dummy entitles already exists, so that wouldn't work for non rob port entities, you'd either have to get all entities again (the same way Entity Table is created, which can't be used for this check since it wouldn't be up to day and check that or add a table to keep track of generated water ghost entities). It's also missing the check to see if the original entity is already water placeable (entityCollidesWithMask). Other then those two things this looks good and I'll check to see if it works and merge as soon as I've got the time.
I now properly check if a dummy entity was already created and added the check if it is already placeable on water.
I'll look at it and test it as soon as I've got the time, if it works I'll merge and release an update
This is a workaround for the roboport modi added by Krastorio 2. Issue was, that the current script only adds items and their place results as dummies. But the new roboport modi do not have an item and only exist as entities. I manually added all roboport variations added by Krastorio, but there is probably a cleaner way to automatically find these.