MNoya / BuildingHelper

Library for RTS & TD Dota Custom Games
GNU General Public License v3.0
37 stars 14 forks source link

What is the purpose of the modifier_grid_ ? #14

Open pedrus opened 8 years ago

pedrus commented 8 years ago

I was wondering why is the JS checking if the building has the modifier_grid_blablabla : https://github.com/MNoya/BuildingHelper/blob/master/panorama/scripts/building_helper.js#L688

I'm asking because it seems redundant to add the modifier when there is already the KV defining the custom grid type.

MNoya commented 8 years ago

I added when implementing Blight in DotaCraft because I needed something more dynamic and customizable. The problem is Blight only takes effect after the building finishes construction, unlike the normal KV blocks which are networked only once in lua when the library starts. If you check the blight.lua implementation, it does both BuildingHelper:AddGridType to register the grid types on the server, and the modifier is used to make those changes visible on the clients as long as they have vision of the building.

But you are correct, it seems redundant and could be changed to a net-table with the entity index of the building, checking if that entity has any custom grid types attached to it.

pedrus commented 8 years ago

How about calling BuildingHelper:AddGridType() around this code ?

That way it is created when the construction is done and then you don't have to call BuildingHelper:AddGridType() manually in order to register the custom grid types.

I was a bit confused because I added a grid type "Expand" around my main building (in order to prevent building too far from it) and noticed that it didn't actually generate the custom grid type. Until I realized I had to call AddGridType() with the same size defined in the KV as parameter.

MNoya commented 8 years ago

Yeah I see the issue. Problem with doing it there is, what if you want the custom grid type to be set as soon as it starts building? Or proggressively increase it as it finishes? Would probably need to add a new key for the custom grid behavior, such as "AddGridOn" "Start" and "Finish" at the very least.

Honestly the custom grid types deal is very unfinished, let me know if you find any other problems or suggestions I'd be glad to add them in!

pedrus commented 8 years ago

Ok, I see. Thanks for your explanations :)