You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
3 years ago
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[FriendClass(typeof(Construct))]
|
||
|
public static class ConstructComponentSystem
|
||
|
{
|
||
|
public static Construct CreateConstruct( this ConstructComponent self,int configId, float x, float y,long id=0,long buildingId =0)
|
||
|
{
|
||
|
Construct construct ;
|
||
|
if (id == 0)
|
||
|
{
|
||
|
construct = self.AddChild<Construct>();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
construct = self.AddChildWithId<Construct>(id);
|
||
|
}
|
||
|
|
||
|
construct.ConfigId = configId;
|
||
|
construct.X = x;
|
||
|
construct.Y = y;
|
||
|
construct.BuildingId = buildingId;
|
||
|
return construct;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#if SERVER
|
||
|
public static void Update(this ConstructComponent self,Unit unit, int tick)
|
||
|
{
|
||
|
if (self.Children.Count == 0)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
List<Construct> finishConstructs = new List<Construct>();
|
||
|
foreach (var v in self.Children.Values)
|
||
|
{
|
||
|
var construct = ((Construct) v);
|
||
|
construct.Update(unit, tick);
|
||
|
if (construct.Progress >= construct.Config.BodyVolume)
|
||
|
{
|
||
|
finishConstructs.Add(construct);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ConstructHelper.NtfUpdateConstructProgress(unit, self);
|
||
|
foreach (var v in finishConstructs)
|
||
|
{
|
||
|
ConstructOperate.ConstructFinish(unit, v.Id);
|
||
|
ConstructHelper.NofityConstructFinish(unit,v.Id);
|
||
|
}
|
||
|
|
||
|
if (finishConstructs.Count > 0)
|
||
|
{
|
||
|
UnitOperate.InitProsperity(unit);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|