Пример #1
0
        private static void HashComponent <T>(BitHashBuilder hashBuilder, Component <T> component, IDictionary <string, T> componentAssortiment) where T : AComponentType
        {
            var indices = componentAssortiment.Keys.OrderBy(x => x).ToList();
            var index   = component != null?indices.IndexOf(component.TypeInfo.IdCode) : componentAssortiment.Count;

            hashBuilder.Add(index, componentAssortiment.Count + 1);
            if (component != null)
            {
                hashBuilder.Add(component.Level, component.TypeInfo.MaxLevel + 1);
            }
        }
Пример #2
0
        public void CalcHash(StaticsDB statics)
        {
            var hashBuilder = new BitHashBuilder();

            HashComponent(hashBuilder, this.Armor, statics.Armors);
            HashComponent(hashBuilder, this.Reactor, statics.Reactors);
            HashComponent(hashBuilder, this.Sensors, statics.Sensors);
            HashComponent(hashBuilder, this.Thrusters, statics.Thrusters);

            HashComponent(hashBuilder, this.Hull, statics.Hulls);
            hashBuilder.Add(this.SpecialEquipment.Count, statics.SpecialEquipment.Count);

            if (this.IsDrive != null)
            {
                hashBuilder.Add(1, 2);
                HashComponent(hashBuilder, this.IsDrive, statics.IsDrives);
            }
            else
            {
                hashBuilder.Add(0, 2);
            }

            HashComponent(hashBuilder, this.Shield, statics.Shields);

            int maxEquips = this.SpecialEquipment.Count > 0 ? (this.SpecialEquipment.Max(x => x.Quantity) + 1) : 0;

            foreach (var equip in this.SpecialEquipment.OrderBy(x => x.TypeInfo.IdCode))
            {
                HashComponent(hashBuilder, equip, statics.SpecialEquipment);
                hashBuilder.Add(equip.Quantity, maxEquips);
            }

            maxEquips = this.MissionEquipment.Count > 0 ? (this.MissionEquipment.Max(x => x.Quantity) + 1) : 0;
            foreach (var equip in this.MissionEquipment.OrderBy(x => x.TypeInfo.IdCode))
            {
                HashComponent(hashBuilder, equip, statics.MissionEquipment);
                hashBuilder.Add(equip.Quantity, maxEquips);
            }

            this.hash = hashBuilder.Create();
        }