using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ServerCore; using ServerBase; using ServerCommon; namespace GameServer { public static class OwnedBuildingHelper { public static async Task<(Result, OwnedBuilding)> createOwnedBuilding(Player player, int buildingMetaId, OwnedType ownedType) { var result = new Result(); var err_msg = string.Empty; var owned_building = new OwnedBuilding(player); result = await owned_building.onInit(); if (result.isFail()) { err_msg = $"Failed to OwnedBuilding.onInit() !!! : {result.toBasicString()}"; Log.getLogger().error(err_msg); return (result, owned_building); } var owned_building_attribute = owned_building.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(owned_building_attribute, () => $"owned_building_attribute is null !!!"); owned_building_attribute.BuildingMetaId = (uint)buildingMetaId; owned_building_attribute.OwnedType = ownedType; owned_building_attribute.newEntityAttribute(); return (result, owned_building); } public static int getBuildingMetaId(this OwnedBuilding ownedBuilding) { var owned_building_attribute = ownedBuilding.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(owned_building_attribute, () => $"owned_building_attribute is null !!!"); return (int)owned_building_attribute.BuildingMetaId; } } }