/// <summary> /// If the landblock is loaded, return a reference to the current House object /// else return a copy of the House biota from the latest info in the db /// /// <param name="callback">called when the slumlord inventory is fully loaded</param> public static void GetHouse(uint houseGuid, Action <House> callback) { var landblock = (ushort)((houseGuid >> 12) & 0xFFFF); var landblockId = new LandblockId((uint)(landblock << 16 | 0xFFFF)); var isLoaded = LandblockManager.IsLoaded(landblockId); if (!isLoaded) { // landblock is unloaded // return a copy of the House biota from the latest info in the db var houseBiota = House.Load(houseGuid); RegisterCallback(houseBiota, callback); return; } // landblock is loaded, return a reference to the current House object var loaded = LandblockManager.GetLandblock(landblockId, false); var house = loaded.GetObject(new ObjectGuid(houseGuid)) as House; if (house != null && house.SlumLord != null) { if (!house.SlumLord.InventoryLoaded) { RegisterCallback(house, callback); } else { callback(house); } } else if (!loaded.CreateWorldObjectsCompleted) { var houseBiota = House.Load(houseGuid); RegisterCallback(houseBiota, callback); } else { log.Error($"[HOUSE] HouseManager.GetHouse({houseGuid:X8}): couldn't find house on loaded landblock"); } }