how would i make a candle?

i want to make a brushed based candle. with a dynamic flickering light. and it goes out in water, but can be re lit if placed in a fire pit. how would i make this?

env_fire with triggers underwater set to use the extinguish input of the env_fire, then the fire pit with a trigger to set the env_fire with the StartFire input.

ah, thanks.