Take this with a grain of salt. According to KCD mods documentation here on nexus (which is more like a leaked in-house Q&A) for newly placed brushes\entities\<you_name_it> "RainOccluder" flag is set to false, resulting in environmental effects like rain to ignore collisions with such objects. When editing a level from within an editor one just have to select a brush they're interested in and set "RainOccluder" flag to true. That will enable this object to be registered by rain (unless collisions are unloaded\disabled or simply not existing). As for changing this flag from within a LUA script, there's a function you can call on entity named "SetFlags" with "ENTITY_FLAG_RAIN_OCCLUDER" parameter, setting it to 0 or 1 like that:
local spawnedEntity = System.SpawnEntity(<...>)
spawnedEntity:SetFlags(ENTITY_FLAG_RAIN_OCCLUDER, 1)
But that's in theory. In practice I was unable to make it work, so more investigation is needed. Link to KCD mods documentation page: https://wiki.nexusmods.com/index.php/Weather_Documentation#Rain_occluders A list of what I believe are entity flags:
ENTITY_FLAG_WRITE_ONLY
ENTITY_FLAG_NOT_REGISTER_IN_SECTORS
ENTITY_FLAG_CALC_PHYSICS
ENTITY_FLAG_CLIENT_ONLY
ENTITY_FLAG_SERVER_ONLY
ENTITY_FLAG_CALCBBOX_USEALL
ENTITY_FLAG_IGNORE_PHYSICS_UPDATE
ENTITY_FLAG_TRIGGER_AREAS
ENTITY_FLAG_NO_SAVE
ENTITY_FLAG_NO_PROXIMITY
ENTITY_FLAG_VOLUME_SOUND
ENTITY_FLAG_AI_HIDEABLE
ENTITY_FLAG_MODIFIED_BY_PHYSICS
ENTITY_FLAG_UPDATE_HIDDEN
ENTITY_FLAG_EXTENDED_NEEDS_MOVEINSIDE
ENTITY_FLAG_EXTENDED_CAN_COLLIDE_WITH_MERGED_MESHES
ENTITY_FLAG_EXTENDED_FORCE_UPDATE
ENTITY_FLAG_CASTSHADOW
ENTITY_FLAG_RAIN_OCCLUDER
ENTITY_FLAG_GOOD_OCCLUDER
P.s. "EXTENDED" flags are probably used with "SetFlagsExtended(<...>)".