//a method called when the resource object is to be locally destroyed public void DestroyResourceLocal(Unit source) { amount = 0; //empty the resource CustomEvents.OnResourceEmpty(this); //trigger custom event if (destroyOnEmpty == false) //if the resource is not supposed to be destroyed { return; } if (TreasureComp) //if this has a treasure component { TreasureComp.Trigger(source.FactionID, gameMgr); //trigger the treasure for the collector's faction } gameMgr.ResourceMgr.RemoveResource(this); //remove resource from all resources list selection.DisableMinimapIcon(); //remove resource's minimap icon from the minimap Destroy(gameObject); CustomEvents.OnResourceDestroyed(this); }