|
|
|
@ -6,7 +6,7 @@ namespace ET
|
|
|
|
|
[FriendClass(typeof (Construct))] |
|
|
|
|
[FriendClass(typeof (Building))] |
|
|
|
|
[FriendClass(typeof (Farmland))] |
|
|
|
|
[FriendClass(typeof(Unit))] |
|
|
|
|
[FriendClass(typeof (Unit))] |
|
|
|
|
public static class ConstructOperate |
|
|
|
|
{ |
|
|
|
|
public static Construct CreateConstruct(Unit unit, int configId, float x, float y, long id = 0, long buildingId = 0) |
|
|
|
@ -15,7 +15,7 @@ namespace ET
|
|
|
|
|
// { |
|
|
|
|
// return null; |
|
|
|
|
// } |
|
|
|
|
var construct = unit.GetOrAddComponent<ConstructComponent>().CreateConstruct(unit,configId, x, y, id, buildingId); |
|
|
|
|
var construct = unit.GetOrAddComponent<ConstructComponent>().CreateConstruct(unit, configId, x, y, id, buildingId); |
|
|
|
|
return construct; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -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,40 +158,33 @@ 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; |
|
|
|
|
build.ConfigId = construct.Config.MixtureID; |
|
|
|
|
switch (build.Config.Special) |
|
|
|
|
{ |
|
|
|
|
case (int)StructureSpecialEnum.FARMLAND: //如果是农场 |
|
|
|
|
var farmland = build.AddChild<Farmland>(); |
|
|
|
|
case (int) StructureSpecialEnum.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>(); |
|
|
|
|
case (int) StructureSpecialEnum.FARM_CABIN: |
|
|
|
|
var cabin = build.AddChildWithNotZeroId<Cabin>(childId); |
|
|
|
|
childId = cabin.Id; |
|
|
|
|
unit.AddGrandChild(cabin); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StructureConfig structureConfig = StructureConfigCategory.Instance.Get(build.ConfigId); |
|
|
|
|
if (structureConfig != null) |
|
|
|
|
{ |
|
|
|
@ -206,7 +200,7 @@ namespace ET
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
construct.Dispose(); |
|
|
|
|
return build; |
|
|
|
|
return (build,childId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static bool CheckOutBuildingByIds(Unit unit, int[] StructureID) |
|
|
|
|