Refilling would be easy...Just copy the Fountain of Mana ability, if you want it to be completely restored instantly set the mana regeneration amount to like, 9999999999.
If you want a cost to it...Just make it a fully-restore Mana Potion.
But, if you still want it to be directly from the building, You could make it a purchasable dummy unit that's invisible and has Spirit Touch, as Spirit Touch is Auto-Cast, make it only affect Player-Units and not Friends, otherwise it'll replenish allies too. Once the unit has performed it's function, remove the unit via trigger.
EX:
-
Untitled Trigger 001
-
Events
-
Unit - A unit Sells a unit
-
Conditions
-
(Selling unit) Equal to Unit That the Dummy Unit is being bought from
-
Actions
-
Unit Group - Pick every unit in (Units of type Your Dummy Mana Replenishing Unit) and do (Actions)
-
Loop - Actions
-
Unit - Add a 5.00 second Generic expiration timer to (Picked unit)
For the Dummy unit, do this:
Art - Animation - Blend Time (Seconds)
Art - Animation - Cast Backswing
Art - Animation - Cast Point
Set all of those Object values to 0.
Base the spell off of Spirit Touch from the Obsidian Statue and do this:
Mana Points Gained - 999999999
Maximum Units Affected - 1
Maximum Units Charged To Caster - 1
Mana Cost - 0
But then again, this only works if that's your only unit. I assumed it was, since it looks like you are just one unit based on what you said... If you have more then one unit, the ability could possibly be cast on a different unit instead of the one you want.
-
Untitled Trigger 001
-
Events
-
Unit - A unit Is attacked
-
Conditions
-
(Unit-type of (Attacking unit)) Equal to Your Unit
-
Actions
-
Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) - 5.00)
Also, do this instead. All units that are this unit will have their mana drained, and it doesn't matter what player owns them.