Buff.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Common.Base;
  2. using Common.Helper;
  3. using MongoDB.Bson;
  4. using MongoDB.Bson.Serialization.Attributes;
  5. namespace Model
  6. {
  7. public class Buff: Entity<Buff>
  8. {
  9. [BsonElement]
  10. private int configId { get; set; }
  11. [BsonElement]
  12. private long expiration;
  13. [BsonIgnore]
  14. private ObjectId timerId;
  15. [BsonIgnore]
  16. public long Expiration
  17. {
  18. get
  19. {
  20. return this.expiration;
  21. }
  22. set
  23. {
  24. this.expiration = value;
  25. }
  26. }
  27. [BsonIgnore]
  28. public ObjectId TimerId
  29. {
  30. get
  31. {
  32. return this.timerId;
  33. }
  34. set
  35. {
  36. this.timerId = value;
  37. }
  38. }
  39. public Buff(int configId)
  40. {
  41. this.configId = configId;
  42. if (this.Config.Duration != 0)
  43. {
  44. this.Expiration = TimeHelper.Now() + this.Config.Duration;
  45. }
  46. }
  47. [BsonIgnore]
  48. public BuffConfig Config
  49. {
  50. get
  51. {
  52. return World.Instance.GetComponent<ConfigComponent>().Get<BuffConfig>(this.configId);
  53. }
  54. }
  55. }
  56. }