public bool Push(StatusEffect statusEffect)
    {
        bool result = false;

        int id = statusEffect.Id;

        if (map.ContainsKey(id))
        {
            StatusEffect existedStatusEffect = map[id];

            bool needReposition = existedStatusEffect.EndTime != statusEffect.EndTime;

            if (!existedStatusEffect.ReachMaxNumStacks())
            {
                foreach (KeyValuePair <AttributeType, float> attribute in existedStatusEffect)
                {
                    sumAttributes.Add(attribute.Key, -attribute.Value);
                }

                existedStatusEffect.Stack(statusEffect);

                foreach (KeyValuePair <AttributeType, float> attribute in existedStatusEffect)
                {
                    sumAttributes.Add(attribute.Key, attribute.Value);
                }

                result = true;
            }

            if (needReposition)
            {
                list.Remove(existedStatusEffect);
                Insert(existedStatusEffect, current, list.Count - 1);
            }
        }
        else
        {
            if (IsEmpty())
            {
                list.Add(statusEffect);
            }
            else
            {
                Insert(statusEffect, current, list.Count - 1);
            }

            map.Add(id, statusEffect);

            foreach (KeyValuePair <AttributeType, float> attribute in statusEffect)
            {
                sumAttributes.Add(attribute.Key, attribute.Value);
            }

            result = true;
        }

        return(result);
    }
Example #2
0
        // Returns attributes of gem in item.
        public AttributeSet AttributesOf(Item gem, Item item)
        {
            AttributeSet attrs = new AttributeSet();

            // Collect gem attributes and modifiers at gem level.
            foreach (var prop in gem.Properties)
            {
                attrs.Add(prop.Attribute, new List <float>(prop.Value));
            }
            foreach (ItemMod mod in gem.Mods)
            {
                attrs.Add(mod.Attribute, new List <float>(mod.Value));
            }

            // Check if gem is in database.
            if (GemIndex.ContainsKey(gem.Name))
            {
                Gem entry = GemIndex[gem.Name];

                // Process +Level modifiers from item.
                int plusLevel = 0;
                foreach (ItemMod mod in item.Mods)
                {
                    if (mod.Attribute == "+# to Level of Socketed Gems")
                    {
                        plusLevel += (int)mod.Value[0];
                    }
                    else
                    {
                        Match m = ReGemLevelKeyword.Match(mod.Attribute);
                        if (m.Success)
                        {
                            if (gem.Keywords.Contains(m.Groups[1].Value) ||
                                m.Groups[1].Value == "Elemental" && (gem.Keywords.Contains("Cold") || gem.Keywords.Contains("Fire") || gem.Keywords.Contains("Lightning")))
                            {
                                plusLevel += (int)mod.Value[0];
                            }
                        }
                    }
                }

                // Replace level-based attributes of gem (even without level bonus).
                AttributeSet replace = entry.AttributesAtLevel(plusLevel + LevelOf(gem));

                // Add quality-based attributes if Quality attributes are defined.
                int quality = QualityOf(gem);
                if (quality > 0)
                {
                    replace.Add(entry.AttributesAtQuality(quality));
                }

                attrs.Replace(replace);
            }

            return(attrs);
        }
Example #3
0
        public void addAttr(Document doc, SketchLine sl, SketchPoint sp, bool contstr)
        {
            VariableData vd     = new VariableData(doc as Document);
            UnitVector   vec    = sl.Geometry3d.Direction;
            AttributeSet attSet = vd.AttribSetAdd(sp, "dir");

            attSet.Add("X", ValueTypeEnum.kDoubleType, vec.X);
            attSet.Add("Y", ValueTypeEnum.kDoubleType, vec.Y);
            attSet.Add("Z", ValueTypeEnum.kDoubleType, vec.Z);
            if (contstr)
            {
                string val = ut.getRefkey <SketchLine>(doc, sl, 0);
                vd.AttribAdd <SketchPoint, string>(sp, "SL", val, ValueTypeEnum.kStringType);
            }
        }
Example #4
0
        // Return list group of this attack.
        public ListGroup ToListGroup()
        {
            AttributeSet props = new AttributeSet();

            props.Add(IsDamageOnUse() ? "Damage per Use: #" : "Damage per Second: #", new List <float> {
                RoundHalfDownValue(DamagePerSecond(), 1)
            });

            if (Nature.Is(DamageSource.Attack))
            {
                props.Add("Chance to Hit: #%", new List <float> {
                    RoundValue(ChanceToHit(), 0)
                });
                props.Add("Attacks per Second: #", new List <float> {
                    RoundHalfDownValue(AttacksPerSecond(), 1)
                });
            }
            else
            {
                props.Add("Casts per Second: #", new List <float> {
                    RoundHalfDownValue(AttacksPerSecond(), 1)
                });
            }

            foreach (AttackSource source in Sources)
            {
                string sourcePrefix = source.Name.Length == 0 ? "" : source.Name + " ";

                foreach (DamageType type in DamageTypes)
                {
                    Damage damage = source.Deals.Find(d => d.Is(type));
                    if (damage != null)
                    {
                        props.Add(sourcePrefix + damage.ToAttribute(), damage.ToValue());
                    }
                }

                if (source.Nature.Is(DamageSource.Attack))
                {
                    props.Add(sourcePrefix + "Accuracy Rating: #", new List <float> {
                        RoundValue(source.Accuracy, 0)
                    });
                }

                if (source.CriticalChance > 0)
                {
                    // XXX: Different rounding style for spells and attacks. Really?
                    props.Add(sourcePrefix + "Critical Strike Chance: #%", new List <float> {
                        Nature.Is(DamageSource.Spell) ? RoundValue(source.CriticalChance, 1) : RoundHalfDownValue(source.CriticalChance, 1)
                    });
                    props.Add(sourcePrefix + "Critical Strike Multiplier: #%", new List <float> {
                        RoundValue(source.CriticalMultiplier, 0)
                    });
                }
            }

            return(new ListGroup(Name + (IsUseable ? "" : " (Unuseable)"), props));
        }
        public void RemoveExisting_works()
        {
            var doc = tests.TestUtilities.CreatePartDocument();

            //create the test AttributeSet
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");

            Inventor.Attribute attribute = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, "test string");

            AttributeShim.RemoveAttribute(doc, "testSet", "testAttribute");

            bool result = false;

            foreach (Inventor.Attribute i in doc.AttributeSets["testSet"])
            {
                if (i.Name.Equals("testAttribute"))
                {
                    result = true;
                }
            }

            try
            {
                Assert.IsFalse(result);
            }
            finally { doc.Close(true); }
        }
Example #6
0
        public Cfg ToCfg()
        {
            var result = new Cfg();

            foreach (var prod in Productions)
            {
                if (!prod.Value.IsTerminal)
                {
                    if (null != prod.Value.Expression)
                    {
                        var ll = prod.Value.Expression.ToDisjunctions(this, result);
                        foreach (var l in ll)
                        {
                            result.Rules.Add(new CfgRule(prod.Key, l));
                        }
                    }
                    else
                    {
                        result.Rules.Add(new CfgRule(prod.Key));
                    }
                }
                AttributeSet attrs = null;
                if (0 < prod.Value.Attributes.Count)
                {
                    attrs = new AttributeSet();
                    result.AttributeSets.Add(prod.Key, attrs);
                    foreach (var attr in prod.Value.Attributes)
                    {
                        attrs.Add(attr.Key, attr.Value);
                    }
                }
            }
            return(result);
        }
Example #7
0
        // Returns attributes of gem at specified level and quality.
        public AttributeSet AttributesOf(string gemName, int level, int quality)
        {
            if (!IsIndexed)
            {
                throw new Exception("Gem Index not started");
            }

            if (!GemIndex.ContainsKey(gemName))
            {
                return(new AttributeSet());
            }

            Gem gem = GemIndex[gemName];

            // Get level-based attributes.
            AttributeSet attrs = gem.AttributesAtLevel(level);

            // Add quality-based attributes if quality is 1 or above.
            if (quality > 0)
            {
                attrs.Add(gem.AttributesAtQuality(quality));
            }

            return(attrs);
        }
Example #8
0
        private Attribute <AttributeSet <NestedAttribute> > ConvertToSetOfNestedAttribute(
            JToken jsonObject, JsonSerializer serializer)
        {
            var valueProperty = jsonObject["value"];
            var nameProperty  = jsonObject["name"];

            var setAttr = new Attribute <AttributeSet <NestedAttribute> >();
            var setOfNestedAttributes = new AttributeSet <NestedAttribute>();

            foreach (var item in valueProperty.Children())
            {
                var attArr = item;
                if (item.IsNestedAttributeObject())
                {
                    attArr = item.First.Children().First();
                }
                var listOfAttrs = attArr.ToObject(typeof(List <Attribute>), serializer);
                var nestedAttr  = new NestedAttribute(new Attribute <List <Attribute> >()
                {
                    Value = listOfAttrs as List <Attribute>
                });
                setOfNestedAttributes.Add(nestedAttr);
            }

            setAttr.Value = setOfNestedAttributes;
            setAttr.Name  = nameProperty.ToString();
            return(setAttr);
        }
Example #9
0
        public void RemoveExisting_works()
        {
            Inventor.Application app = ApplicationShim.Instance();
            var      path            = app.DesignProjectManager.ActiveDesignProject.TemplatesPath;
            Document doc             = app.Documents.Add(DocumentTypeEnum.kPartDocumentObject, path + "Standard.ipt", true);

            //create the test AttributeSet
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");

            Inventor.Attribute attribute = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, "test string");

            AttributeShim.RemoveAttribute(doc, "testSet", "testAttribute");

            bool result = false;

            foreach (Inventor.Attribute i in doc.AttributeSets["testSet"])
            {
                if (i.Name.Equals("testAttribute"))
                {
                    result = true;
                }
            }

            try
            {
                Assert.IsFalse(result);
            }
            finally { doc.Close(true); }
        }
 public void AttribAdd <T>(string name, List <T> vals, ValueTypeEnum VT)
 {
     attSet = doc.AttributeSets.Add(name);
     for (int i = 0; i < vals.Count; i++)
     {
         attSet.Add(name + i, VT, vals[i]);
     }
     attSet = null;
 }
Example #11
0
        public File Parse(string fileAbsolutePath, UInt32 lastTagId = 0)
        {
            _lastTagId = lastTagId;

            var attributeSet = new AttributeSet();

            using (var file = System.IO.File.OpenRead(fileAbsolutePath)) {
                //Preamble
                var preamble = new byte[PREAMBLE_SIZE_BYTES];
                file.Read(preamble, 0, preamble.Length);

                //'DICM' Prefix
                var prefixRaw = new byte[PREFIX_SIZE_BYTES];
                file.Read(prefixRaw, 0, prefixRaw.Length);

                string prefixUTF8 = Encoding.UTF8.GetString(prefixRaw, 0, prefixRaw.Length);
                if (prefixUTF8.Equals(DICM_PREFIX, StringComparison.InvariantCultureIgnoreCase))
                {
                    OnInfo?.Invoke(this, $"Found '{DICM_PREFIX}' prefix.");
                }
                else
                {
                    OnWarning?.Invoke(this, $"Could not find '{DICM_PREFIX}' prefix.");
                }


                while (true)
                {
                    try {
                        var pos          = file.Position;
                        var newAttribute = ParseAttribute(file);
                        if (newAttribute == null)
                        {
                            OnWarning?.Invoke(this, $"Could not parse attribute at position: {pos}.");
                            continue;
                        }
                        attributeSet.Add(newAttribute.Tag.ID, newAttribute);
                        OnInfo?.Invoke(this, attributeSet.ToString());

                        if (_lastTagId > 0 && newAttribute.Tag.ID >= _lastTagId)
                        {
                            break;
                        }
                    }
                    catch (EndOfStreamException) {
                        break;
                    }
                }


                return(new File()
                {
                    IsVRExplicit = _isExplicitVr,
                    Attributes = attributeSet
                });
            }
        }
 public void AttribAdd <T>(string name, T val, ValueTypeEnum VT)
 {
     attSets = doc.AttributeSets;
     if (attSets.NameIsUsed[name])
     {
         AttribDelete(name);
     }
     attSet = attSets.Add(name); attSet.Add(name, VT, val);
     attSet = null;
 }
        public void AttribAdd <T, TVal>(T ob, string name, TVal val, ValueTypeEnum VT)
        {
            AttributeSets attSets = InvDoc.Reflect.getProp <T, AttributeSets>(ob, "AttributeSets");

            if (attSets.NameIsUsed[name])
            {
                AttribDelete(name);
            }
            attSet = attSets.Add(name); attSet.Add(name, VT, val);
            attSet = null;
        }
Example #14
0
        /// <summary>
        /// create an attribute
        /// this assumes a part document with some features is opened.
        /// </summary>
        /// <remarks></remarks>

        public void AddAttribute()
        {
            // Get the selected edge.  This assumes an edge is already selected.
            Edge oEdge = (Edge)_InvApplication.ActiveDocument.SelectSet[1];

            // Add an attribute set to the edge.  If you only need to "name" the
            // edge this is enough to find it later and you can skip the next step.
            AttributeSet oAttribSet = oEdge.AttributeSets.Add("BoltEdge");

            // Add an attribute to the set.  This can be any information you
            // want to associate with the edge.
            oAttribSet.Add("BoltRadius", ValueTypeEnum.kDoubleType, 0.5);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void CreateOccurrenceTag(AssemblyDocument AsmDocument, PartFeature PartFeature, ComponentOccurrence occurrence)
        {
            AttributeSet set = PartFeature.AttributeSets[_AttributeSet];

            Byte[] contextData = set["ContextData"].Value as Byte[];

            int keyContext = AsmDocument.ReferenceKeyManager.LoadContextFromArray(ref contextData);

            Byte[] refKey = new byte[] { };

            occurrence.GetReferenceKey(ref refKey, keyContext);

            set.Add("OccurrenceRefKey", ValueTypeEnum.kByteArrayType, refKey);


            PartDocument doc = PartFeature.Parent.Document as PartDocument;

            set = doc.ComponentDefinition.AttributeSets[_AttributeSet];

            string srcDocPath = set["SourcePartDoc"].Value as string;

            PartDocument srcDoc = FeatureUtilities.Application.Documents.Open(srcDocPath, false) as PartDocument;


            foreach (PartFeature feature in doc.ComponentDefinition.Features)
            {
                if (feature.AttributeSets.get_NameIsUsed(_AttributeSet))
                {
                    AttributeSet setFeature = feature.AttributeSets[_AttributeSet];

                    string AsmFeature = setFeature["AsmFeature"].Value as string;

                    if (!setFeature.get_NameIsUsed("OccurrenceRefKey"))
                    {
                        ObjectCollection collec = srcDoc.AttributeManager.FindObjects(_AttributeSet, "AsmFeature", AsmFeature);

                        if (collec.Count > 0)
                        {
                            PartFeature srcFeature = collec[1] as PartFeature;

                            object val = srcFeature.AttributeSets[_AttributeSet]["OccurrenceRefKey"].Value;

                            setFeature.Add("OccurrenceRefKey", ValueTypeEnum.kByteArrayType, val);
                        }
                    }
                }
            }

            srcDoc.Close(true);
        }
    public static AttributeSet Sum(params IAttributeCollection[] attributeSets)
    {
        AttributeSet attributeSet = new AttributeSet();

        foreach (IAttributeCollection attributes in attributeSets)
        {
            foreach (KeyValuePair <AttributeType, float> attribute in attributes)
            {
                attributeSet.Add(attribute.Key, attribute.Value);
            }
        }

        return(attributeSet);
    }
Example #17
0
        // Returns all attributes of gem with defined values for specified level.
        internal AttributeSet AttributesAtLevel(int level)
        {
            AttributeSet attrs = new AttributeSet();

            foreach (var lookup in LevelIndex)
            {
                List <float> value = lookup.Value.ValueAt(level);
                if (value != null)
                {
                    attrs.Add(lookup.Key, new List <float>(value));
                }
            }

            return(attrs);
        }
Example #18
0
        // Returns all attributes of gem with defined values for specified quality.
        internal AttributeSet AttributesAtQuality(int quality)
        {
            AttributeSet attrs = new AttributeSet();

            foreach (var lookup in QualityIndex)
            {
                List <float> value = lookup.Value.ValueAt(quality);
                if (value != null)
                {
                    attrs.Add(lookup.Key, new List <float>(value));
                }
            }

            return(attrs);
        }
Example #19
0
        private IAttributeSet CreateAttributeSet(int ctrlId, string ctrlName,
                                                 string desc, Type boundType, IAttribute[] atts, object tag, IControlDescriptor ctrlDescriptor = null)
        {
            var attsSet = new AttributeSet(ctrlId, ctrlName, desc, boundType, tag, ctrlDescriptor);

            if (atts?.Any() == true)
            {
                foreach (var att in atts)
                {
                    attsSet.Add(att);
                }
            }

            return(attsSet);
        }
Example #20
0
        private IAttributeSet CreateAttributeSet(int ctrlId, string ctrlName,
                                                 string desc, Type boundType, IAttribute[] atts, object tag, MemberInfo boundMemberInfo = null)
        {
            var attsSet = new AttributeSet(ctrlId, ctrlName, desc, boundType, tag, boundMemberInfo);

            if (atts?.Any() == true)
            {
                foreach (var att in atts)
                {
                    attsSet.Add(att);
                }
            }

            return(attsSet);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void CreateDocTrackingTag(string srcFullFileName, PartDocument destDoc)
        {
            AttributeSet set = null;

            try
            {
                set = destDoc.ComponentDefinition.AttributeSets[_AttributeSet];
                set["SourcePartDoc"].Value = srcFullFileName;
            }
            catch
            {
                set = destDoc.ComponentDefinition.AttributeSets.Add(_AttributeSet, true);
                set.Add("SourcePartDoc", ValueTypeEnum.kStringType, srcFullFileName);
            }
        }
Example #22
0
        private void createPart2()
        {
            // create a new part
            PartDocument            oDoc = (PartDocument)mApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject);
            PartComponentDefinition oDef = oDoc.ComponentDefinition;

            TransientGeometry oTG = mApp.TransientGeometry;

            // create sketch elements
            PlanarSketch oSketch = oDef.Sketches.Add(oDef.WorkPlanes[3]);

            oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(-5, -5), oTG.CreatePoint2d(5, 5));

            SketchPoint oSketchPt = oSketch.SketchPoints.Add(oTG.CreatePoint2d(0, 0));

            Profile oProfile = oSketch.Profiles.AddForSolid();
            // create a plate with a hole feature
            ExtrudeDefinition oExtrudDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation);

            oExtrudDef.SetDistanceExtent(1, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
            ExtrudeFeature oExtrudeF = oDef.Features.ExtrudeFeatures.Add(oExtrudDef);

            // Create an object collection for the hole center points.
            ObjectCollection oHoleCenters = default(ObjectCollection);

            oHoleCenters = mApp.TransientObjects.CreateObjectCollection();

            oHoleCenters.Add(oSketchPt);

            // create hole feature
            HolePlacementDefinition oHPdef = (HolePlacementDefinition)oDef.Features.HoleFeatures.CreateSketchPlacementDefinition(oHoleCenters);

            HoleFeature oHoleF = oDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oHPdef, "2", PartFeatureExtentDirectionEnum.kNegativeExtentDirection);

            Face         oFace   = oHoleF.SideFaces[1];
            AttributeSet oAttSet = default(AttributeSet);

            Inventor.Attribute oAtt = null;
            oAttSet = oFace.AttributeSets.Add("demoAttset");
            oAtt    = oAttSet.Add("demoAtt", ValueTypeEnum.kStringType, "namedEdge");
            if (System.IO.File.Exists("c:\temp\test2.ipt"))
            {
                System.IO.File.Delete("c:\temp\test2.ipt");
            }


            oDoc.SaveAs("c:\\temp\\test2.ipt", false);
        }
Example #23
0
    private Player(int id, int maxHp, int power, int dexterity, int wisdom)
    {
        this.id = id;

        talents.Add(AttributeType.WalkSpeed_c0, 0.8f);
        talents.Add(AttributeType.JumpPower_c0, 150);
        talents.Add(AttributeType.MaxHp_c0, 10);
        talents.Add(AttributeType.CriticalChance_cp0, 0.05f);
        talents.Add(AttributeType.CriticalDamage_cp0, 1.5f);
        talents.Add(AttributeType.BaseDamage_cp0, 1);
        talents.Add(AttributeType.AttackSpeed_cp0, 1);

        inventory = new Inventory();
        inventory.Add(1, 1);
        inventory.Add(2, 1);
        inventory.Add(3, 1);

        stats = new StatisticSystem(talents, inventory);
        stats[StatisticType.Hp] = stats[StatisticType.MaxHp];
        stats.onStatisticChange.AddListener(DispatchStatisticChangeEvents);


        OnWalkSpeedChange      = new EventOnDataChange2 <float>();
        OnJumpPowerChange      = new EventOnDataChange2 <float>();
        OnHpChange             = new EventOnDataChange2 <float>();
        OnCriticalChanceChange = new EventOnDataChange2 <float>();
        OnCriticalDamageChange = new EventOnDataChange2 <float>();
        OnBaseDamageChange     = new EventOnDataChange2 <float>();
        OnAttackSpeedChange    = new EventOnDataChange2 <float>();


        playerClass = 0;

        level     = 1;
        exp       = 0;
        neededExp = 100;

        this.maxHp     = maxHp;
        this.power     = power;
        this.dexterity = dexterity;
        this.wisdom    = wisdom;

        OnLevelChange     = new EventOnDataChange1 <int>();
        OnExpChange       = new EventOnDataChange2 <int>();
        OnNeededExpChange = new EventOnDataChange1 <int>();
        OnPromotionChange = new EventOnDataChange1 <int>();
        OnPowerChange     = new EventOnDataChange1 <int>();
        OnDexterityChange = new EventOnDataChange1 <int>();
        OnWisdomChange    = new EventOnDataChange1 <int>();
    }
Example #24
0
        // requires: All slots in this are null or non-constants
        // effects: Returns the non-null slots of this
        internal AttributeSet GetNonNullSlots()
        {
            AttributeSet attributes = new AttributeSet(MemberPath.EqualityComparer);

            foreach (ProjectedSlot projectedSlot in m_projectedSlots)
            {
                // null means 'unused' slot -- we ignore those
                if (projectedSlot != null)
                {
                    MemberProjectedSlot projectedVar = projectedSlot as MemberProjectedSlot;
                    Debug.Assert(projectedVar != null, "Projected slot must not be a constant");
                    attributes.Add(projectedVar.MemberPath);
                }
            }
            return(attributes);
        }
        public void AttDoesExist_returnsTrue()
        {
            var doc = tests.TestUtilities.CreatePartDocument();

            //create the test attribute
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");
            Attribute    _            = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, "test string");

            var result = AttributeShim.AttributeExists(doc, "testSet", "testAttribute");

            try
            {
                Assert.IsTrue(result);
            }
            finally { doc.Close(true); }
        }
        public void GetExisting_works()
        {
            var doc = tests.TestUtilities.CreatePartDocument();

            //create the test Attribute
            var          test         = "test string";
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");

            Inventor.Attribute attribute = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, test);

            var result = AttributeShim.GetAttributeValue(doc, "testSet", "testAttribute");

            try
            {
                Assert.AreEqual(result, test);
            }
            finally { doc.Close(true); }
        }
Example #27
0
        public void DoesExist_returnsTrue()
        {
            Inventor.Application app = ApplicationShim.Instance();
            var      path            = app.DesignProjectManager.ActiveDesignProject.TemplatesPath;
            Document doc             = app.Documents.Add(DocumentTypeEnum.kPartDocumentObject, path + "Standard.ipt", true);

            //create the test attribute
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");
            Attribute    _            = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, "test string");


            var result = AttributeShim.AttributeExists(doc, "testSet", "testAttribute");

            try
            {
                Assert.IsTrue(result);
            }
            finally { doc.Close(true); }
        }
Example #28
0
        /// <summary>
        /// Performs a deep clone of the CFG
        /// </summary>
        /// <returns>A new CFG equal to this CFG</returns>
        public Cfg Clone()
        {
            var result = new Cfg();
            var ic     = Rules.Count;

            for (var i = 0; i < ic; ++i)
            {
                result.Rules.Add(Rules[i].Clone());
            }
            foreach (var attrs in AttributeSets)
            {
                var d = new AttributeSet();
                result.AttributeSets.Add(attrs.Key, d);
                foreach (var attr in attrs.Value)
                {
                    d.Add(attr.Key, attr.Value);
                }
            }
            return(result);
        }
Example #29
0
        public void GetExisting_works()
        {
            Inventor.Application app = ApplicationShim.Instance();
            var      path            = app.DesignProjectManager.ActiveDesignProject.TemplatesPath;
            Document doc             = app.Documents.Add(DocumentTypeEnum.kPartDocumentObject, path + "Standard.ipt", true);


            //create the test Attribute
            var          test         = "test string";
            AttributeSet attributeSet = doc.AttributeSets.Add("testSet");

            Inventor.Attribute attribute = attributeSet.Add("testAttribute", ValueTypeEnum.kStringType, test);


            var result = AttributeShim.GetAttributeValue(doc, "testSet", "testAttribute");


            try
            {
                Assert.AreEqual(result, test);
            }
            finally { doc.Close(true); }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void CreatePartFeatureTag(AssemblyDocument AsmDocument,
                                                PartFeature AsmFeature,
                                                PartFeature PartFeature,
                                                ComponentOccurrence Occurrence)
        {
            if (PartFeature == null)
            {
                return;
            }

            AttributeSet set = PartFeature.AttributeSets.Add(_AttributeSet, true);

            set.Add("AsmFile", ValueTypeEnum.kStringType, AsmDocument.FullFileName);
            set.Add("AsmDoc", ValueTypeEnum.kStringType, AsmDocument.FullDocumentName);
            set.Add("AsmIntName", ValueTypeEnum.kStringType, AsmDocument.InternalName);
            set.Add("AsmFeature", ValueTypeEnum.kStringType, AsmFeature.Name);


            Byte[] contextData = new byte[] { };

            int keyContext = AsmDocument.ReferenceKeyManager.CreateKeyContext();

            AsmDocument.ReferenceKeyManager.SaveContextToArray(keyContext, ref contextData);

            set.Add("ContextData", ValueTypeEnum.kByteArrayType, contextData);


            Byte[] featureRefKey = new byte[] { };

            AsmFeature.GetReferenceKey(ref featureRefKey, keyContext);

            set.Add("AsmFeatureRefKey", ValueTypeEnum.kByteArrayType, featureRefKey);


            Byte[] occRefKey = new byte[] { };

            Occurrence.GetReferenceKey(ref occRefKey, keyContext);

            set.Add("OccurrenceRefKey", ValueTypeEnum.kByteArrayType, occRefKey);
        }
Example #31
0
            // Return list group of this attack.
            public ListGroup ToListGroup()
            {
                AttributeSet props = new AttributeSet();

                props.Add(IsDamageOnUse() ? "Damage per Use: #" : "Damage per Second: #", new List<float> { RoundHalfDownValue(DamagePerSecond(), 1) });

                if (Nature.Is(DamageSource.Attack))
                {
                    props.Add("Chance to Hit: #%", new List<float> { RoundValue(ChanceToHit(), 0) });
                    props.Add("Attacks per Second: #", new List<float> { RoundHalfDownValue(AttacksPerSecond(), 1) });
                }
                else
                    props.Add("Casts per Second: #", new List<float> { RoundHalfDownValue(AttacksPerSecond(), 1) });

                foreach (AttackSource source in Sources)
                {
                    string sourcePrefix = source.Name.Length == 0 ? "" : source.Name + " ";

                    foreach (DamageType type in DamageTypes)
                    {
                        Damage damage = source.Deals.Find(d => d.Is(type));
                        if (damage != null)
                            props.Add(sourcePrefix + damage.ToAttribute(), damage.ToValue());
                    }

                    if (source.Nature.Is(DamageSource.Attack))
                        props.Add(sourcePrefix + "Accuracy Rating: #", new List<float> { RoundValue(source.Accuracy, 0) });

                    if (source.CriticalChance > 0)
                    {
                        // XXX: Different rounding style for spells and attacks. Really?
                        props.Add(sourcePrefix + "Critical Strike Chance: #%", new List<float> { Nature.Is(DamageSource.Spell) ? RoundValue(source.CriticalChance, 1) : RoundHalfDownValue(source.CriticalChance, 1) });
                        props.Add(sourcePrefix + "Critical Strike Multiplier: #%", new List<float> { RoundValue(source.CriticalMultiplier, 0) });
                    }
                }

                return new ListGroup(Name + (IsUseable ? "" : " (Unuseable)"), props);
            }
Example #32
0
        // Initializes structures.
        public static void Initialize(SkillTree skillTree, ItemAttributes itemAttrs)
        {
            Items = itemAttrs.Equip.ToList();

            MainHand = new Weapon(WeaponHand.Main, Items.Find(i => i.Class == ItemClass.MainHand));
            OffHand = new Weapon(WeaponHand.Off, Items.Find(i => i.Class == ItemClass.OffHand));

            // If main hand weapon has Counts as Dual Wielding modifier, then clone weapon to off hand.
            // @see http://pathofexile.gamepedia.com/Wings_of_Entropy
            if (MainHand.Attributes.ContainsKey("Counts as Dual Wielding"))
                OffHand = MainHand.Clone(WeaponHand.Off);

            IsDualWielding = MainHand.IsWeapon() && OffHand.IsWeapon();
            if (IsDualWielding)
            {
                // Set dual wielded bit on weapons.
                MainHand.Hand |= WeaponHand.DualWielded;
                OffHand.Hand |= WeaponHand.DualWielded;
            }
            IsWieldingShield = MainHand.Is(WeaponType.Shield) || OffHand.Is(WeaponType.Shield);
            IsWieldingStaff = MainHand.Is(WeaponType.Staff);

            Level = skillTree.Level;
            if (Level < 1) Level = 1;
            else if (Level > 100) Level = 100;

            Global = new AttributeSet();

            Tree = new AttributeSet(skillTree.SelectedAttributesWithoutImplicit);
            Global.Add(Tree);

            // Keystones.
            Acrobatics = Tree.ContainsKey("#% Chance to Dodge Attacks. #% less Armour and Energy Shield, #% less Chance to Block Spells and Attacks");
            AvatarOfFire = Tree.ContainsKey("Deal no Non-Fire Damage");
            BloodMagic = Tree.ContainsKey("Removes all mana. Spend Life instead of Mana for Skills");
            ChaosInoculation = Tree.ContainsKey("Maximum Life becomes #, Immune to Chaos Damage");
            IronGrip = Tree.ContainsKey("The increase to Physical Damage from Strength applies to Projectile Attacks as well as Melee Attacks");
            IronReflexes = Tree.ContainsKey("Converts all Evasion Rating to Armour. Dexterity provides no bonus to Evasion Rating");
            NecromanticAegis = Tree.ContainsKey("All bonuses from an equipped Shield apply to your Minions instead of you");
            ResoluteTechnique = Tree.ContainsKey("Never deal Critical Strikes");
            VaalPact = Tree.ContainsKey("Life Leech applies instantly at #% effectiveness. Life Regeneration has no effect.");
            ZealotsOath = Tree.ContainsKey("Life Regeneration applies to Energy Shield instead of Life");

            Equipment = new AttributeSet();
            foreach (ItemAttributes.Attribute attr in itemAttrs.NonLocalMods)
                Equipment.Add(attr.TextAttribute, new List<float>(attr.Value));

            if (NecromanticAegis && OffHand.IsShield())
            {
                // Remove all bonuses of shield from equipment set.
                // @see http://pathofexile.gamepedia.com/Necromantic_Aegis
                foreach (var attr in OffHand.Attributes)
                    Equipment.Remove(attr);
                // Remove all bonuses from shield itself.
                OffHand.Attributes.Clear();
            }

            Global.Add(Equipment);

            CoreAttributes();

            Implicit = new AttributeSet(SkillTree.ImplicitAttributes(Global, Level));
            Global.Add(Implicit);

            // Innate dual wielding bonuses.
            // @see http://pathofexile.gamepedia.com/Dual_wielding
            if (IsDualWielding)
            {
                Global["#% more Attack Speed"] = new List<float>() { 10 };
                Global["#% more Physical Damage with Weapons"] = new List<float>() { 20 };
            }
        }
Example #33
0
 // requires: All slots in this are null or non-constants
 // effects: Returns the non-null slots of this
 internal AttributeSet GetNonNullSlots()
 {
     AttributeSet attributes = new AttributeSet(MemberPath.EqualityComparer);
     foreach (ProjectedSlot projectedSlot in m_projectedSlots)
     {
         // null means 'unused' slot -- we ignore those
         if (projectedSlot != null)
         {
             MemberProjectedSlot projectedVar = projectedSlot as MemberProjectedSlot;
             Debug.Assert(projectedVar != null, "Projected slot must not be a constant");
             attributes.Add(projectedVar.MemberPath);
         }
     }
     return attributes;
 }