using System.Collections.Generic; using Common.Base; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; namespace Model { public class BuffComponent: Component { [BsonElement] public HashSet buffs; [BsonIgnore] public Dictionary idBuff; [BsonIgnore] public MultiMap typeBuff; public BuffComponent() { this.buffs = new HashSet(); this.idBuff = new Dictionary(); this.typeBuff = new MultiMap(); } public override void BeginInit() { base.BeginInit(); this.buffs = new HashSet(); this.idBuff = new Dictionary(); this.typeBuff = new MultiMap(); } public override void EndInit() { base.EndInit(); foreach (var buff in this.buffs) { this.idBuff.Add(buff.Id, buff); this.typeBuff.Add(buff.Config.Type, buff); } } } }