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.
39 lines
1.1 KiB
39 lines
1.1 KiB
using UnityEngine; |
|
|
|
namespace ET |
|
{ |
|
[FriendClass(typeof(Building))] |
|
public static class BuildingSystem |
|
{ |
|
public static void FromMessage(this Building self, BuildingProto buildingProto) |
|
{ |
|
self.Id = buildingProto.Id; |
|
self.Position = new Vector2(buildingProto.X, buildingProto.Y); |
|
self.ConfigId = buildingProto.ConfigId; |
|
self.State = buildingProto.State; |
|
} |
|
|
|
public static BuildingProto ToMessage(this Building self) |
|
{ |
|
return new BuildingProto() { Id = self.Id, ConfigId = self.ConfigId, X = self.Position.x, Y = self.Position.y,State = self.State}; |
|
} |
|
|
|
public static void DurableReduce(this Building self) |
|
{ |
|
if (self.Durable == 0) |
|
{ |
|
return; |
|
} |
|
self.Durable -= self.Config.DurableCoefficient; |
|
if (self.Durable < 0) |
|
{ |
|
self.Durable = 0; |
|
} |
|
} |
|
|
|
public static void Repair(this Building self) |
|
{ |
|
self.Durable = self.Config.Durable; |
|
} |
|
} |
|
} |