|
|
|
@ -140,13 +140,14 @@ namespace ET
|
|
|
|
|
return ErrorCode.ERR_Success; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Building ConstructFinish(Unit unit, long constructId, long buildingId = 0) |
|
|
|
|
public static (Building,long) ConstructFinish(Unit unit, long constructId, long buildingId = 0, long childId = 0) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
var construct = unit.GetComponent<ConstructComponent>().GetChild<Construct>(constructId); |
|
|
|
|
Building build; |
|
|
|
|
if (construct == null) |
|
|
|
|
{ |
|
|
|
|
return null; |
|
|
|
|
return (null,0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (construct.IsUpgrade) |
|
|
|
@ -157,19 +158,13 @@ namespace ET
|
|
|
|
|
{ |
|
|
|
|
Log.Error($"Can't find building:{construct.BuildingId} for construct:{construct.Id}"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
build.IsUpgrade = 0; |
|
|
|
|
build.ConfigId = construct.Config.MixtureID; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (buildingId > 0) |
|
|
|
|
{ |
|
|
|
|
build = unit.GetOrAddComponent<BuildingComponent>().AddChildWithId<Building>(buildingId); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
build = unit.GetOrAddComponent<BuildingComponent>().AddChild<Building>(); |
|
|
|
|
} |
|
|
|
|
build = unit.GetOrAddComponent<BuildingComponent>().AddChildWithNotZeroId<Building>(buildingId); |
|
|
|
|
|
|
|
|
|
build.Position.x = construct.X; |
|
|
|
|
build.Position.y = construct.Y; |
|
|
|
@ -177,18 +172,17 @@ namespace ET
|
|
|
|
|
switch (build.Config.Special) |
|
|
|
|
{ |
|
|
|
|
case (int) StructureSpecialEnum.FARMLAND: //如果是农场 |
|
|
|
|
var farmland = build.AddChild<Farmland>(); |
|
|
|
|
var farmland = build.AddChildWithNotZeroId<Farmland>(childId); |
|
|
|
|
farmland.SetFarmlandState(FarmlandState.FARMLAND_STATE_FREE); |
|
|
|
|
childId = farmland.Id; |
|
|
|
|
unit.AddGrandChild(farmland); |
|
|
|
|
break; |
|
|
|
|
case (int) StructureSpecialEnum.FARM_CABIN: |
|
|
|
|
var cabin = build.AddChild<Cabin>(); |
|
|
|
|
var cabin = build.AddChildWithNotZeroId<Cabin>(childId); |
|
|
|
|
childId = cabin.Id; |
|
|
|
|
unit.AddGrandChild(cabin); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
StructureConfig structureConfig = StructureConfigCategory.Instance.Get(build.ConfigId); |
|
|
|
@ -206,7 +200,7 @@ namespace ET
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
construct.Dispose(); |
|
|
|
|
return build; |
|
|
|
|
return (build,childId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static bool CheckOutBuildingByIds(Unit unit, int[] StructureID) |
|
|
|
|