Normally as each object in the game becomes dirty (its dirty commodity fills up) it gains a dirty buff (see the grungy surface and icky plumbing buffs for example). When enough of those contribute, the game kicks in its bad environment buff. If I was making your trait this is how I would do it: set up a proximity buff on the trait that activates whenever you're near one of the dirty object buffs. You would set up each dirty object as its own condition set (any apply to be valid). You'll have to play around with the test target setting so that the game is checking the nearby object question. You can find the dirty object buffs by searching in the handy buff database Zerbu has provided in the program or you can use Sims 4 Studio to extract the xml files and search for all of the yourself (SimsVip has excellent tutorials on xml modding including some for Zerbu's programs). It'll take some work and trial and error but you can do it. Also, I recommend using the game's existing bad environment buffs as opposed to making one of your own so that you don't end up stacking the same effect in certain circumstances. Good luck!