public void Parse(AssetsReader reader)
        {
            Version      = reader.ReadCStr();
            Platform     = reader.ReadInt32();
            HasTypeTrees = reader.ReadBoolean();
            int numTypes = reader.ReadInt32();

            for (int i = 0; i < numTypes; i++)
            {
                Types.Add(new AssetsType(reader, HasTypeTrees));
            }
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, reader);

                ObjectInfos.Add(obj);
            }
            int numAdds = reader.ReadInt32();

            for (int i = 0; i < numAdds; i++)
            {
                reader.AlignTo(4);
                Adds.Add(new RawPtr(reader));
            }
            int numExt = reader.ReadInt32();

            for (int i = 0; i < numExt; i++)
            {
                ExternalFiles.Add(new ExternalFile(reader));
            }
            reader.ReadCStr();
        }
Exemple #2
0
        public void AddMenu()
        {
            adds = new Adds();
            Console.WriteLine("# AddMenu #");
            Console.WriteLine("Select number to function:\n 1.Add student 2.Add class: " +
                              "\n" + "  OR Other Number to MainMenu");
            int num = int.Parse(Console.ReadLine());

            switch (num)
            {
            case 1:
                Console.WriteLine("Please enter student id name sex classid:");
                int    sid   = int.Parse(Console.ReadLine());
                string sname = Console.ReadLine();
                string ssex  = Console.ReadLine();
                int    cid1  = int.Parse(Console.ReadLine());
                adds.Addstudent(sid, sname, ssex, cid1);
                break;

            case 2:
                Console.WriteLine("Please enter class id name grade:");
                int    cid2  = int.Parse(Console.ReadLine());
                string cname = Console.ReadLine();
                int    grade = int.Parse(Console.ReadLine());
                adds.Addclass(cid2, cname, grade);
                break;

            default:
                break;
            }
        }
        private void AddToList(TextBox tb1, TextBox tb2, TextBox tb3, TextBox tb4, TextBox tb5,
                               RadioButton rb1, RadioButton rb2, RadioButton rb3,
                               Adds a1, Adds a2, Adds a3, MultimediaType multiType)
        {
            if (AreTextFieldsFilled(tb1.Text, tb2.Text, tb3.Text, tb4.Text, tb5.Text))
            {
                Adds add = CheckAdditionalFeatures(rb1, rb2, rb3, a1, a2, a3);

                try
                {
                    switch (multiType)
                    {
                    case MultimediaType.Movie: ItemList.Add(new MovieDVD(tb1.Text, tb2.Text, int.Parse(tb3.Text), tb4.Text, double.Parse(tb5.Text), add)); break;

                    case MultimediaType.Music: ItemList.Add(new MusicCD(tb1.Text, tb2.Text, int.Parse(tb3.Text), tb4.Text, double.Parse(tb5.Text), add)); break;

                    case MultimediaType.Game: ItemList.Add(new GameCD(tb1.Text, tb2.Text, int.Parse(tb3.Text), tb4.Text, double.Parse(tb5.Text), add)); break;
                    }
                }
                catch (FormatException fe)
                {
                    MessageBox.Show(@"Type 'Release Year' and 'Price' in the format of Integer or Double", "Number Format Warning");
                    Console.Write(fe.Message);
                }
            }
        }
        public P_Set <T> Remove(T value)
        {
            if (Adds.Any(e => e.Id == value.Id))
            {
                return(new(Adds, Removes.Add(value)));
            }

            return(this);
        }
Exemple #5
0
        public bool Lookup(T value)
        {
            if (Removes.Any(r => Equals(r, value)))
            {
                return(false);
            }

            return(Adds.Any(r => Equals(r, value)));
        }
Exemple #6
0
                /// <inheritdoc/>
                override public void Combat()
                {
                    if (Me.IsCasting && Me.CastingSpellID == (int)WarlockSpellIds.CATACLYSM)
                    {
                        return;
                    }

                    if (DoSharedRotation())
                    {
                        return;
                    }

                    //Adds
                    if (Adds.Count > 0)
                    {
                        if (CastOnTerrain(
                                "Shadowfury",
                                Target.Position,
                                () => Adds.Count(x => x.DistanceSquaredTo(Target) <= 12 * 12) > 2
                                ))
                        {
                            return;
                        }
                        if (DoMultitargetRotation(Adds.Count + 1))
                        {
                            return;
                        }
                    }

                    // Single DPS
                    if (DoDotting(Target))
                    {
                        return;
                    }
                    if (CastPreventDouble(
                            "Haunt",
                            () =>
                            (!Target.HasAura("Haunt") || Me.GetPower(WoWPowerType.WarlockSoulShards) >= 4) &&
                            (
                                // TODO: Trinket Procc
                                Target.HealthFraction <= 0.25f ||// the boss is reaching death
                                Me.GetPower(WoWPowerType.WarlockSoulShards) > 3 ||// We capped it (sadly we don't get it when we reached half a shard) (and yes I know whis will get this equation to true as we check against >= 4 above!)
                                Me.HasAura("Dark Soul: Misery")
                            )
                            ))
                    {
                        return;
                    }

                    // TODO: MultiDPS with Haunt, maybe?

                    // Okay.. now souldrain :D
                    if (Cast("Drain Soul"))
                    {
                        return;
                    }
                }
Exemple #7
0
 public Item(string name, string author, int year, string type, double price, Adds add)
 {
     this.Name   = name;
     this.Author = author;
     this.Year   = year;
     this.Type   = type;
     this.Price  = price;
     this.Add    = add;
 }
        public OUR_Set <T> Remove(T value, Guid tag, long timestamp)
        {
            var elementToRemove = Adds.FirstOrDefault(a => Equals(a.Value, value) && a.Tag == tag);

            if (elementToRemove is null || elementToRemove?.Timestamp > timestamp)
            {
                return(this);
            }

            return(new(Adds, Removes.Add(new OUR_SetElement <T>(value, tag, timestamp))));
        }
Exemple #9
0
        public OUR_SetWithVC <T> Add(T value, Guid tag, VectorClock vectorClock)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id && a.Tag == tag);

            if (existingElement is not null)
            {
                return(Update(value, tag, vectorClock));
            }

            return(new(Adds.Add(new OUR_SetWithVCElement <T>(value, tag, vectorClock)), Removes));
        }
        public OUR_Set <T> Add(T value, Guid tag, long timestamp)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id && a.Tag == tag);

            if (existingElement is not null)
            {
                return(Update(value, tag, timestamp));
            }

            return(new(Adds.Add(new OUR_SetElement <T>(value, tag, timestamp)), Removes));
        }
Exemple #11
0
        public OUR_SetWithVC <T> Remove(T value, Guid tag, VectorClock vectorClock)
        {
            var elementToRemove = Adds.FirstOrDefault(a => Equals(a.Value, value) && a.Tag == tag);

            if (elementToRemove is null || elementToRemove?.VectorClock > vectorClock)
            {
                return(this);
            }

            return(new(Adds, Removes.Add(new OUR_SetWithVCElement <T>(value, tag, vectorClock))));
        }
Exemple #12
0
 public override void Rollback()
 {
     Blocks = new List <EarthworkBlock>();
     Blocks.AddRange(Memo.Blocks);
     BlockIdIndexMapper = Memo.BlockIdIndexMapper;
     foreach (var Block in Blocks)
     {
         Block.Rollback();
     }
     Adds.Clear();
     Deletes.Clear();
 }
        public P_Set <T> Add(T value)
        {
            var add    = Adds.FirstOrDefault(e => e.Id == value.Id);
            var remove = Removes.FirstOrDefault(e => e.Id == value.Id);

            if (add is not null || remove is not null)
            {
                return(this);
            }

            return(new(Adds.Add(value), Removes));
        }
Exemple #14
0
        //用于下一页面实现
        //public bool IsExistChanging { set; get; }
        //public string ShowOnChanging()
        //{
        //    return "分段内容有变动,请修改相应工期设置";
        //}

        #region SectionalData
        /// <summary>
        /// 在选择节点后面插入(默认)
        /// </summary>
        /// <param name="index">所选节点Index,从0开始</param>
        /// <returns></returns>
        void add(int index, EarthworkBlock block)
        {
            //foreach (var IndexBlockId in BlockIdIndexMapper)
            //{
            //    if (IndexBlockId.Value >= index)
            //    {
            //        BlockIdIndexMapper[IndexBlockId.Key]++;
            //    }
            //}
            Blocks.Insert(index, block);
            Adds.Add(block);
        }
Exemple #15
0
        public void TestShouldCreateAdd_Update()
        {
            // Given
            var add = Adds.Create();

            // When
            var result = add.Create(Guids.Nine());

            // Then
            var updated = (Add)result;

            Assert.AreEqual(Guids.Nine(), updated.MessageId);
            Assert.AreEqual(add.Name, updated.Name);
        }
Exemple #16
0
        public override int GetSimpleHashCode()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Id);
            sb.Append(Name);
            sb.Append("Adds:" + string.Join(",", Adds.Select(c => c.IntegerValue)));
            sb.Append("Deletes:" + string.Join(",", Deletes.Select(c => c.IntegerValue)));
            sb.Append(ImplementationInfo.StartTime);
            sb.Append(ImplementationInfo.ExposureTime);
            sb.Append(ImplementationInfo.EndTime);
            sb.Append(ImplementationInfo.IsConflicted);
            return(sb.ToString().GetHashCode());
        }
Exemple #17
0
        public void Parse(AssetsReader reader)
        {
            Version      = reader.ReadCStr();
            Platform     = reader.ReadInt32();
            HasTypeTrees = reader.ReadBoolean();
            int numTypes = reader.ReadInt32();

            for (int i = 0; i < numTypes; i++)
            {
                Types.Add(new AssetsType(reader, HasTypeTrees));
            }

            List <ObjectRecord> records = new List <ObjectRecord>();
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = new ObjectRecord(reader);
                records.Add(obj);
            }

            int numAdds = reader.ReadInt32();

            for (int i = 0; i < numAdds; i++)
            {
                reader.AlignTo(4);
                Adds.Add(new RawPtr(reader));
            }
            int numExt = reader.ReadInt32();

            for (int i = 0; i < numExt; i++)
            {
                ExternalFiles.Add(new ExternalFile(reader));
            }
            reader.ReadCStr();

            //load the object infos in order based on their type
            foreach (var record in records.OrderBy(x => PreloadObjectOrder(x)).ThenBy(x => x.ObjectID))
            {
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, record);

                ObjectInfos.Add(obj);
                if (ShouldForceLoadObject(record))
                {
                    var o = obj.Object;
                }
            }
        }
Exemple #18
0
        public OUR_SetWithVC <T> Update(T value, Guid tag, VectorClock vectorClock)
        {
            var elementToUpdate = Adds.FirstOrDefault(a => a.Value.Id == value.Id && a.Tag == tag);

            if (elementToUpdate is null || elementToUpdate?.VectorClock > vectorClock)
            {
                return(this);
            }

            var adds = Adds.Remove(elementToUpdate);

            adds = adds.Add(new OUR_SetWithVCElement <T>(value, tag, vectorClock));

            return(new(adds, Removes));
        }
        public OUR_Set <T> Update(T value, Guid tag, long timestamp)
        {
            var elementToUpdate = Adds.FirstOrDefault(a => a.Value.Id == value.Id && a.Tag == tag);

            if (elementToUpdate is null || elementToUpdate?.Timestamp > timestamp)
            {
                return(this);
            }

            var adds = Adds.Remove(elementToUpdate);

            adds = adds.Add(new OUR_SetElement <T>(value, tag, timestamp));

            return(new(adds, Removes));
        }
        public bool Lookup(T value)
        {
            var added   = Adds.FirstOrDefault(a => Equals(a.Value, value));
            var removed = Removes.FirstOrDefault(r => Equals(r.Value, value));

            if (added is not null && removed is null)
            {
                return(true);
            }

            if (added is not null && added?.VectorClock > removed?.VectorClock)
            {
                return(true);
            }

            return(false);
        }
Exemple #21
0
        public LWW_SetWithVC <T> Remove(T value, VectorClock vectorClock)
        {
            if (Adds.Any(a => Equals(a.Value, value) && a.VectorClock < vectorClock))
            {
                var element = Removes.FirstOrDefault(r => r.Value.Id == value.Id);

                ImmutableHashSet <LWW_SetWithVCElement <T> > elements = Removes;

                if (element is not null)
                {
                    elements = Removes.Remove(element);
                }

                return(new(Adds, elements.Add(new LWW_SetWithVCElement <T>(value, vectorClock))));
            }

            return(this);
        }
Exemple #22
0
        public LWW_SetWithVC <T> Add(T value, VectorClock vectorClock)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id);

            if (existingElement is not null && existingElement.VectorClock < vectorClock)
            {
                var elements = Adds.Remove(existingElement);

                return(new(elements.Add(new LWW_SetWithVCElement <T>(value, vectorClock)), Removes));
            }

            if (existingElement is null)
            {
                return(new(Adds.Add(new LWW_SetWithVCElement <T>(value, vectorClock)), Removes));
            }

            return(this);
        }
Exemple #23
0
 public void Write(AssetsWriter writer)
 {
     writer.WriteCString(Version);
     writer.Write(Platform);
     writer.Write(HasTypeTrees);
     writer.Write(Types.Count());
     Types.ForEach(x => x.Write(writer));
     writer.Write(ObjectInfos.Count());
     ObjectInfos.ForEach(x => {
         writer.AlignTo(4);
         x.Write(writer);
     });
     writer.Write(Adds.Count());
     Adds.ForEach(x => x.Write(writer));
     writer.Write(ExternalFiles.Count());
     ExternalFiles.ForEach(x => x.Write(writer));
     writer.WriteCString("");
 }
Exemple #24
0
        public LWW_Set <T> Remove(T value, long timestamp)
        {
            if (Adds.Any(a => Equals(a.Value, value) && a.Timestamp < timestamp))
            {
                var element = Removes.FirstOrDefault(r => r.Value.Id == value.Id);

                ImmutableHashSet <LWW_SetElement <T> > elements = Removes;

                if (element is not null)
                {
                    elements = Removes.Remove(element);
                }

                return(new(Adds, elements.Add(new LWW_SetElement <T>(value, timestamp))));
            }

            return(this);
        }
Exemple #25
0
        public LWW_Set <T> Assign(T value, long timestamp)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id);

            if (existingElement is not null && existingElement.Timestamp < timestamp)
            {
                var elements = Adds.Remove(existingElement);

                return(new(elements.Add(new LWW_SetElement <T>(value, timestamp)), Removes));
            }

            if (existingElement is null)
            {
                return(new(Adds.Add(new LWW_SetElement <T>(value, timestamp)), Removes));
            }

            return(this);
        }
        private Adds CheckAdditionalFeatures(RadioButton rb1, RadioButton rb2, RadioButton rb3, Adds feature1, Adds feature2, Adds feature3)
        {
            Adds add = Adds.None;

            if (rb1.IsChecked.Value)
            {
                add = feature1;
            }
            if (rb2.IsChecked.Value)
            {
                add = feature2;
            }
            if (rb3.IsChecked.Value)
            {
                add = feature3;;
            }

            return(add);
        }
        /// <summary>
        /// Casts the given spell on the best target.
        /// If none is found it will always fallback to Target.
        /// </summary>
        /// <returns><c>true</c>, if spell on best target was cast, <c>false</c> otherwise.</returns>
        /// <param name="spellName">Spell name.</param>
        /// <param name="castWhen">onlyCastWhen condition for Cast()</param>
        /// <param name="bestTargetCondition">Condition to limit the UnitObjects for a bestTarget</param>
        /// <param name="preventTime">Milliseconds in which the spell won't be cast again</param>
        /// <param name="targetOverride">Spell will be cast on this target</param>
        public bool CastSpellOnBestAoETarget(string spellName, Func <UnitObject, bool> castWhen = null, Func <UnitObject, bool> bestTargetCondition = null, int preventTime = 0, UnitObject targetOverride = null)
        {
            if (castWhen == null)
            {
                castWhen = (_ => true);
            }

            if (bestTargetCondition == null)
            {
                bestTargetCondition = (_ => true);
            }

            var aoeRange   = SpellAoERange(spellName);
            var bestTarget = targetOverride ?? Adds
                             .Where(u => u.IsInCombatRangeAndLoS && u.DistanceSquared <= SpellMaxRangeSq(spellName) && bestTargetCondition(u))
                             .OrderByDescending(u => Adds.Count(o => Vector3.DistanceSquared(u.Position, o.Position) <= aoeRange)).FirstOrDefault() ?? Target;

            if (preventTime == 0)
            {
                return(SpellIsCastOnTerrain(spellName) ? CastOnTerrain(
                           spellName,
                           bestTarget.Position,
                           () => castWhen(bestTarget)
                           ) : Cast(
                           spellName,
                           bestTarget,
                           () => castWhen(bestTarget)
                           ));
            }

            return(SpellIsCastOnTerrain(spellName) ? CastOnTerrainPreventDouble(
                       spellName,
                       bestTarget.Position,
                       () => castWhen(bestTarget),
                       preventTime
                       ) : CastPreventDouble(
                       spellName,
                       () => castWhen(bestTarget),
                       bestTarget,
                       preventTime
                       ));
        }
Exemple #28
0
        public override void Add(EarthworkBlocking blocking, ElementId elementId)
        {
            var block = blocking.Blocks.FirstOrDefault(c => c.ElementIds.Exists(p => p.IntegerValue == elementId.IntegerValue));

            if (block != null)
            {
                if (block.Id == Id)
                {
                    return;
                }

                block.Delete(blocking, new List <ElementId>()
                {
                    elementId
                });
            }
            ElementIds.Add(elementId);
            ElementIdValues.Add(elementId.IntegerValue);
            Adds.Add(elementId);
            CPSettings.ApplySetting(blocking, new List <ElementId>()
            {
                elementId
            });
        }
 //--------------------------------------------
 protected DataSet getAdds(int siteid,int type)
 {
     Adds adds = new Adds();
     return adds.getAdds(siteid,1,type);
 }
Exemple #30
0
 public LWW_SetWithVC <T> Merge(ImmutableHashSet <LWW_SetWithVCElement <T> > adds, ImmutableHashSet <LWW_SetWithVCElement <T> > removes)
 {
     return(new(Adds.Union(adds), Removes.Union(removes)));
 }
 //-----------------------------------------------------------------------
 protected void Upd_Adds(int siteid, int addid, string addtitle,
                             string addImage, string addlink, string addalt, string addConte)
 {
     Adds adds = new Adds();
     adds.Upd_Adds(siteid, addid, addtitle, addImage, addlink, addalt, addConte);
 }
Exemple #32
0
 public ImmutableHashSet <OUR_SetWithVCElement <TestType> > GetAdds(Guid id)
 {
     return(Adds.Where(a => a.ValueId == id).ToImmutableHashSet());
 }
 //------------------------------------------------------
 protected void addAdds(int siteid,int type,string image,string alt,string link)
 {
     Adds adds = new Adds();
        // adds.Add_Adds(siteid, type, image, alt, link);
 }
    public DataSet getAllAdds()
    {
        Adds adds = new Adds();

        return adds.getAdds(SiteId,ContId,1);//--1 by  the SIte
    }
 //--------------------------------------------------------------------
 protected DataSet Get_Adds_By_Id(int siteid, int AddsId)
 {
     Adds adds = new Adds();
     return adds.Get_Adds_By_Id(siteid, AddsId);
 }