Наследование: UnityEngine.ScriptableObject
Пример #1
0
        public static void Postfix(AbstractActor __instance, ref int __result, StatCollection ___statCollection)
        {
            CombatGameState ___Combat = (CombatGameState)Traverse.Create(__instance).Property("Combat").GetValue();

            if (___Combat.TurnDirector.IsInterleaved)
            {
                CombatHUD ___HUD = (CombatHUD)Traverse.Create(__instance).Property("HUD").GetValue();

                int baseInit     = ___statCollection.GetValue <int>("BaseInitiative");
                int phaseMod     = ___statCollection.GetValue <int>("PhaseModifier");
                int modifiedInit = baseInit + phaseMod;
                //SkillBasedInit.Logger.LogIfDebug($"Actor:({__instance.DisplayName}_{__instance.GetPilot().Name}) has stats BaseInit:{baseInit} / PhaseMod:{phaseMod}");

                if (modifiedInit < Mod.MinPhase)
                {
                    Mod.Log.Info($"Actor:({CombatantHelper.LogLabel(__instance)}) being set to {Mod.MinPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}");
                    __result = Mod.MinPhase;
                }
                else if (modifiedInit > Mod.MaxPhase)
                {
                    Mod.Log.Info($"Actor:({CombatantHelper.LogLabel(__instance)}) being set to {Mod.MaxPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}");
                    __result = Mod.MaxPhase;
                }
                else
                {
                    __result = modifiedInit;
                    //SkillBasedInit.Logger.Log($"Actor:({__instance.DisplayName}_{__instance.GetPilot().Name}) has stats BaseInit:{baseInit} + PhaseMod:{phaseMod} = modifiedInit:{modifiedInit}.");
                }
            }
        }
Пример #2
0
    //public static void ApplyUntrackedStatMod(StatAdjustment adj) {
    //    adj.target.ApplyUntrackedMod(adj.statType, adj.value, adj.modType, adj.adjustmentOptions);
    //}

    public static StatModifier ApplyTrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value, StatModificationType modType, params StatModifierOption[] statOptions)
    {
        StatModifier mod = target.ApplyAndReturnTrackedMod(stat, value, modType, source.Owner, statOptions);

        SendStatChangeEvent(source.Owner, target.Owner, stat, value);
        return(mod);
    }
Пример #3
0
 private float MaxStability(MechDef mechDef)
 {
     StatCollection statCollection = new StatCollection();
     var stat = MaxStability(statCollection, mechDef.Chassis.Stability);
     stat.Create();
     return MechDefStatisticModifier.ModifyStatistic(stat, mechDef);
 }
Пример #4
0
    public virtual void Initialize(Effect parentEffect, LayerMask mask, float life = 0f, float damage = 0f)
    {
        this.parentEffect = parentEffect;
        LayerMask         = mask;
        stats             = new StatCollection();
        stats.Initialize(statTemplate);
        ParentFacing = parentEffect.Source.Facing;


        if (this.parentEffect is EffectAttack)
        {
            EffectAttack attackEffect = this.parentEffect as EffectAttack;
            penetrating  = attackEffect.penetrate;
            numPen       = attackEffect.numPenetrations;
            impactEffect = attackEffect.impactEffectName;
        }


        this.life   = life + stats.GetStatModifiedValue(Constants.BaseStatType.Lifetime);
        this.damage = damage + stats.GetStatModifiedValue(Constants.BaseStatType.BaseDamage);

        if (this.life > 0f)
        {
            Invoke("CleanUp", this.life);
        }
    }
Пример #5
0
 private float MaxEvasivePips(MechDef mechDef)
 {
     StatCollection statCollection = new StatCollection();
     var stat = MaxEvasivePips(statCollection);
     stat.Create();
     return MechDefStatisticModifier.ModifyStatistic(stat, mechDef);
 }
        public static void FixMechInMechbay(SimGameState __instance, StatCollection ___companyStats, Dictionary <int, MechDef> ___ActiveMechs, Dictionary <int, MechDef> ___ReadyingMechs)
        {
            try
            {
                var mechDefs = ___ActiveMechs.Values.Union(___ReadyingMechs.Values).ToList();
                AutoFixer.Shared.FixSavedMech(mechDefs, __instance);

                foreach (var mechDef in mechDefs)
                {
                    string value = $"{mechDef.Description.Id}({mechDef.Description.UIName}) [";
                    if (mechDef.MechTags != null && !mechDef.MechTags.IsEmpty)
                    {
                        foreach (var mechDefMechTag in mechDef.MechTags)
                        {
                            value += mechDefMechTag + " ";
                        }
                    }
                    Control.LogError(value);
                }
            }
            catch (Exception e)
            {
                Control.LogError(e);
            }
        }
Пример #7
0
 public void setCompanyStats(StatCollection stats)
 {
     companyStats = stats;
     if (allowUpgrades)
     {
         if (!companyStats.ContainsStatistic(ADDITIONAL_MECH_STAT))
         {
             companyStats.AddStatistic(ADDITIONAL_MECH_STAT, FdefaultMechSlots);
         }
         ;
         if (!companyStats.ContainsStatistic(ADDITIONAL_PLAYER_MECH_STAT))
         {
             companyStats.AddStatistic(ADDITIONAL_PLAYER_MECH_STAT, FdefaultPlayerMechSlots);
         }
         ;
         if (!companyStats.ContainsStatistic(MAX_TONNAGE_STAT))
         {
             companyStats.AddStatistic(MAX_TONNAGE_STAT, FdefaultTonnage);
         }
         ;
         if (!companyStats.ContainsStatistic(CU_VEHICLE_STAT_NAME))
         {
             companyStats.AddStatistic(CU_VEHICLE_STAT_NAME, CuInitialVehicles);
         }
         ;
         UpdateCULances();
     }
 }
Пример #8
0
 private StatAdjustment(StatCollection source, StatCollection target, StatType statType, params StatModifierOption[] options)
 {
     this.source            = source;
     this.target            = target;
     this.statType          = statType;
     this.adjustmentOptions = options;
 }
Пример #9
0
        public void HasSameValuesTest()
        {
            var b = new StatCollection <ST>(StatCollectionType.Base);

            b[ST.A] = 10;
            b[ST.B] = 11;

            foreach (var c in CreateStatCollections())
            {
                c[ST.A] = 0;
                c[ST.B] = 0;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));

                c[ST.A] = 10;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));

                c[ST.B] = 11;

                Assert.IsTrue(c.HasSameValues(b));
                Assert.IsTrue(b.HasSameValues(c));

                c[ST.A] = 0;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));
            }
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEntity"/> class.
        /// </summary>
        /// <param name="pos">The pos.</param>
        /// <param name="size">The size.</param>
        /// <param name="templateID">The template ID.</param>
        /// <param name="name">The name.</param>
        /// <param name="desc">The desc.</param>
        /// <param name="type">The type.</param>
        /// <param name="weaponType">Type of the weapon.</param>
        /// <param name="range">The range.</param>
        /// <param name="graphic">The graphic.</param>
        /// <param name="value">The value.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="hp">The hp.</param>
        /// <param name="mp">The mp.</param>
        /// <param name="equippedBody">The equipped body.</param>
        /// <param name="actionDisplayID">The action display ID.</param>
        /// <param name="baseStats">The base stats.</param>
        /// <param name="reqStats">The req stats.</param>
        ItemEntity(Vector2 pos, Vector2 size, ItemTemplateID?templateID, string name, string desc, ItemType type,
                   WeaponType weaponType, ushort range, GrhIndex graphic, int value, byte amount, SPValueType hp, SPValueType mp,
                   string equippedBody, ActionDisplayID?actionDisplayID, IEnumerable <Stat <StatType> > baseStats,
                   IEnumerable <Stat <StatType> > reqStats) : base(pos, size)
        {
            _templateID      = templateID;
            _name            = name;
            _description     = desc;
            _graphicIndex    = graphic;
            _value           = value;
            _amount          = amount;
            _type            = type;
            _weaponType      = weaponType;
            _range           = range;
            _hp              = hp;
            _mp              = mp;
            _equippedBody    = equippedBody;
            _actionDisplayID = actionDisplayID;

            _baseStats = NewItemStats(baseStats, StatCollectionType.Base);
            _reqStats  = NewItemStats(reqStats, StatCollectionType.Requirement);

            Resized -= ItemEntity_Resized;
            Resized += ItemEntity_Resized;
        }
        internal static float AccuracyForLocation(StatCollection statCollection, ChassisLocations location)
        {
            var naming = new MechLocationNaming(location);
            var key    = naming.LocationalStatisticName("Accuracy");

            return(AccuracyForKey(statCollection, key));
        }
Пример #12
0
        public static object GetBattleTechFloat(TsEnvironment env, object[] inputs)
        {
            int    statScope = env.ToInt(inputs[0]);
            string statName  = env.ToString(inputs[1]);

            Main.Logger.Log($"[GetBattleTechFloat] Triggered with scope {statScope} and statName {statName}.");

            StatCollection statCollection = SimHelper.GetStatCollection(statScope);

            if (statCollection == null) // GUARD
            {
                Main.Logger.LogError($"[GetBattleTechFloat] StatCollection is null for {statScope}");
                return(null);
            }

            if (statCollection.ContainsStatistic(statName))
            {
                float stat = statCollection.GetValue <float>(statName);
                Main.Logger.Log($"[GetBattleTechFloat] Stat {statName} found with value {stat}.");
                return(stat);
            }

            Main.Logger.LogError($"[GetBattleTechFloat] Stat {statName} does not exist for conversation operation.");
            return(null);
        }
Пример #13
0
        public static void Postfix(AbstractActor __instance, ref int __result, StatCollection ___statCollection)
        {
            Mod.Log.Trace?.Write("AA:BI - entered.");

            Mod.Log.Debug?.Write($"Actor:({CombatantUtils.Label(__instance)}) has raw result: {__result}");
            if (__instance.Combat.TurnDirector.IsInterleaved)
            {
                int baseInit     = ___statCollection.GetValue <int>("BaseInitiative");
                int phaseMod     = ___statCollection.GetValue <int>("PhaseModifier");
                int modifiedInit = baseInit + phaseMod;

                if (modifiedInit < Mod.MinPhase)
                {
                    Mod.Log.Info?.Write($"Actor:({CombatantUtils.Label(__instance)}) being set to {Mod.MinPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}");
                    __result = Mod.MinPhase;
                }
                else if (modifiedInit > Mod.MaxPhase)
                {
                    Mod.Log.Info?.Write($"Actor:({CombatantUtils.Label(__instance)}) being set to {Mod.MaxPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}");
                    __result = Mod.MaxPhase;
                }
                else
                {
                    Mod.Log.Info?.Write($"Actor:({CombatantUtils.Label(__instance)}) has stats BaseInit:{baseInit} + PhaseMod:{phaseMod} = modifiedInit:{modifiedInit}.");
                    __result = modifiedInit;
                }
            }
            else
            {
                Mod.Log.Info?.Write($"Actor:({CombatantUtils.Label(__instance)}) is non-interleaved, returning phase: {Mod.MaxPhase}.");
                __result = Mod.MaxPhase;
            }
        }
 internal static void SetupAccuracyStatistics(StatCollection statCollection)
 {
     foreach (var location in MechDefBuilder.Locations)
     {
         AccuracyForLocation(statCollection, location);
     }
 }
Пример #15
0
 public static void Prefix(SimGameState __instance, ref StatCollection ___companyStats)
 {
     if (__instance.DataManager.ContentPackIndex.IsContentPackOwned("heavymetal", true) && !___companyStats.ContainsStatistic("HasSeenHeavyMetalLootPopup"))
     {
         ___companyStats.AddStatistic <int>("HasSeenHeavyMetalLootPopup", 1);
     }
 }
Пример #16
0
        public static bool ReceiveHeatDamageInjury(this StatCollection statCollection, bool set = false)
        {
            const string key = "ReceiveHeatDamageInjury";

            return(statCollection.GetStatistic(key)?.Value <bool>()
                   ?? set && statCollection.AddStatistic(key, false).Value <bool>());
        }
Пример #17
0
        public static object EvaluateBattleTechString(TsEnvironment env, object[] inputs)
        {
            int    statScope    = env.ToInt(inputs[0]);
            string statName     = env.ToString(inputs[1]);
            int    operation    = env.ToInt(inputs[2]);
            string compareValue = env.ToString(inputs[3]);

            Main.Logger.Log($"[EvaluateBattleTechString] Triggered with scope '{statScope}', statName '{statName}', operation '{operation}', compareValue '{compareValue}");

            StatCollection statCollection = SimHelper.GetStatCollection(statScope);

            if (statCollection.ContainsStatistic(statName))
            {
                string stat = statCollection.GetValue <string>(statName);

                switch (operation)
                {
                case 1: // equal to
                    return(stat == compareValue);

                case 2: // not equal to
                    return(stat != compareValue);

                default:
                    return(false);
                }
            }

            Main.Logger.Log($"[EvaluateBattleTechString] Stat {statName} does not exist for conversation operation.");
            return(false);
        }
Пример #18
0
 private float UnsteadyThreshold(MechDef mechDef)
 {
     StatCollection statCollection = new StatCollection();
     var stat = UnsteadyThreshold(statCollection);
     stat.Create();
     return MechDefStatisticModifier.ModifyStatistic(stat, mechDef);
 }
Пример #19
0
    public RecoveryCooldown(float cooldown, Ability parentAbility, AbilityRecoveryManager manager) : base(parentAbility, manager)
    {
        Stats = new StatCollection(ParentAbility.Source, OnStatChanged);
        Stats.AddStat(BaseStat.StatType.CoolDown, cooldown);

        coolDownTimer = new Timer("Cooldown", cooldown, true, Refresh);
    }
Пример #20
0
 private float ToHitThisActor(MechDef mechDef)
 {
     StatCollection statCollection = new StatCollection();
     var stat = ToHitThisActor(statCollection);
     stat.Create();
     return MechDefStatisticModifier.ModifyStatistic(stat, mechDef);
 }
Пример #21
0
        internal static void Rehydrate(StatCollection companyStats, List <MechDef> mechs)
        {
            var fixers = MechDefAutoFixCategory.Fixers;

            if (fixers.Count == 0)
            {
                return;
            }

            foreach (var fixer in fixers)
            {
                fixer.SetShouldFix(companyStats);
            }

            foreach (var mech in mechs)
            {
                AutoFixMechDef(mech, fixers);
            }

            foreach (var fixer in fixers)
            {
                if (fixer.ShouldFix)
                {
                    fixer.SetFixed(companyStats);
                }
            }
        }
Пример #22
0
        // Update is called once per frame
        void Update()
        {
            // make every entity broadcasts an event to the other entities every frame
            PerceptionEVManager.TriggerEvent("PERCEPTION", new Hashtable()
            {
                { "OBJECT", this.gameObject }
            });

            // every update, if the entity is not being controlled, check for perception component alerted or not
            if (!Controlled && Perception != null && GambitCollection != null)
            {
                // enable the gambit if gambit is off and is alerted
                if (Perception.Alerted && !GambitCollection.enabled)
                {
                    GambitCollection.enabled = true;
                }
            }

            // test levelling
            if (Input.GetKeyUp(KeyCode.Space))
            {
                if (StatCollection != null)
                {
                    StatCollection.ModifyExp(50);
                }
            }
        }
Пример #23
0
    public static StatCollection GetStats(this GameObject go)
    {
        StatCollection result = null;

        Entity entity = go.Entity();

        if (entity != null)
        {
            result = entity.Stats;
        }

        Projectile projectile = go.Projectile();

        if (projectile != null)
        {
            result = projectile.ProjectileStats;
        }


        if (result == null)
        {
            Debug.LogError(go.name + " has no stats");
        }

        return(result);
    }
Пример #24
0
 private float DamageReductionMultiplierAll(MechDef mechDef)
 {
     StatCollection statCollection = new StatCollection();
     var stat = DamageReductionMultiplierAll(statCollection);
     stat.Create();
     return MechDefStatisticModifier.ModifyStatistic(stat, mechDef);
 }
Пример #25
0
 private float StructureMultiplier(MechDef mechDef)
 {
     StatCollection statCollection = new StatCollection();
     var stat = statCollection.StructureMultiplier();
     stat.Create();
     return MechDefStatisticModifier.ModifyStatistic(stat, mechDef);
 }
Пример #26
0
    protected override void Start()
    {
        //GameManager.RegisterEntity(this);
        stats = new StatCollection(statTemplate);

        Controller = GetComponent <Controller2D>();
        MyAnimator = GetComponentInChildren <Animator>();

        deckManager = GetComponentInChildren <AbilityDeckManager>();
        deckManager.Initialize(this);

        inateAbiliites = GetComponentInChildren <AbilityManager>();
        inateAbiliites.Initialize(this);

        inventory = GetComponentInChildren <Inventory>();
        inventory.Initialize();

        //AbilityManager2 = GetComponent<AbilityManager2>();
        //AbilityManager2.Initialize(MyAnimator, controller);


        wallStickTimer = new Timer(wallStickTime, true, UnStickFromWall);

        gravity         = -(2 * maxJumpheight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
    }
Пример #27
0
        private float ArmorMultiplier(MechDef mechDef)
        {
            StatCollection statCollection = new StatCollection();
            var            stat           = statCollection.ArmorMultiplier();

            stat.Create();
            return(MechDefStatisticModifier.ModifyStatistic(stat, mechDef));
        }
Пример #28
0
        internal static int GetJumpHeat(this StatCollection statCollection, float ratio)
        {
            var jumpMaxHeat = statCollection.JumpHeat().Get();
            var jumpHeat    = ratio * jumpMaxHeat;

            jumpHeat = Mathf.Max(jumpHeat, EngineFeature.settings.MinimJumpHeat);
            return(PrecisionUtils.RoundUpToInt(jumpHeat));
        }
Пример #29
0
        public void ModifyStat(RPGStatType statName, float value)
        {
            RPGVital stat = null;

            if (StatCollection.TryGetStat <RPGVital> (statName, out stat))
            {
                stat.StatValueCurrent += value;
            }
        }
Пример #30
0
    private ItemType type; //Item type

    #endregion Fields

    #region Constructors

    public BaseItem(BaseItem item)
    {
        this.itemID = item.ItemID;
        this.itemName = item.ItemName;
        this.description = item.Description;
        this.type = item.Type;
        this.maxSize = item.MaxSize;
        stats = new StatCollection();
    }
Пример #31
0
        internal static void PerformOperation(this StatCollection collection, Statistic statistic, StatisticEffectData data)
        {
            var type    = Type.GetType(data.modType);
            var variant = new Variant(type);

            variant.SetValue(data.modValue);
            variant.statName = data.statName;
            collection.PerformOperation(statistic, data.operation, variant);
        }
Пример #32
0
 public BaseItem(Dictionary<string, string> itemDictionary)
 {
     itemID = int.Parse(itemDictionary["ItemID"]);
     itemName = itemDictionary["ItemName"];
     description= itemDictionary["Description"];
     type = (ItemType)Enum.Parse(typeof(ItemType), itemDictionary["ItemType"]);
     quality = (Quality)Enum.Parse(typeof(Quality), itemDictionary["Quality"]);
     maxSize = int.Parse(itemDictionary["MaxSize"]);
     stats = new StatCollection();
 }
Пример #33
0
        public void HasAllGreaterOrEqualValuesTest()
        {
            var b = new StatCollection<ST>(StatCollectionType.Base);
            b[ST.A] = 10;
            b[ST.B] = 11;

            foreach (var c in CreateStatCollections())
            {
                c[ST.A] = 10;
                c[ST.B] = 11;

                Assert.IsTrue(c.HasAllGreaterOrEqualValues(b));
                Assert.IsTrue(b.HasAllGreaterOrEqualValues(c));

                c[ST.A] = 11;
                Assert.IsTrue(c.HasAllGreaterOrEqualValues(b));
                Assert.IsFalse(b.HasAllGreaterOrEqualValues(c));

                c[ST.A] = 10;
                c[ST.B] = 12;
                Assert.IsTrue(c.HasAllGreaterOrEqualValues(b));
                Assert.IsFalse(b.HasAllGreaterOrEqualValues(c));

                c[ST.A] = 11;
                c[ST.B] = 12;
                Assert.IsTrue(c.HasAllGreaterOrEqualValues(b));
                Assert.IsFalse(b.HasAllGreaterOrEqualValues(c));

                c[ST.A] = 9;
                c[ST.B] = 12;
                Assert.IsFalse(c.HasAllGreaterOrEqualValues(b));
                Assert.IsFalse(b.HasAllGreaterOrEqualValues(c));

                c[ST.A] = 10;
                c[ST.B] = 10;
                Assert.IsFalse(c.HasAllGreaterOrEqualValues(b));
                Assert.IsTrue(b.HasAllGreaterOrEqualValues(c));

                c[ST.A] = 5;
                c[ST.B] = 5;
                Assert.IsFalse(c.HasAllGreaterOrEqualValues(b));
                Assert.IsTrue(b.HasAllGreaterOrEqualValues(c));
            }
        }
Пример #34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Character"/> class.
        /// </summary>
        /// <param name="world">World that the character belongs to.</param>
        /// <param name="isPersistent">If the Character's state is persistent. If true, Load() MUST be called
        /// at some point during the Character's constructor!</param>
        protected Character(World world, bool isPersistent) : base(Vector2.Zero, Vector2.One)
        {
            IsAlive = false;
            _skillCaster = new CharacterSkillCaster(this);

            _world = world;
            _isPersistent = isPersistent;

            if (IsPersistent)
                _statusEffects = new PersistentCharacterStatusEffects(this);
            else
                _statusEffects = new NonPersistentCharacterStatusEffects(this);

            _statusEffects.Added -= StatusEffects_HandleOnAdd;
            _statusEffects.Added += StatusEffects_HandleOnAdd;
            _statusEffects.Removed -= StatusEffects_HandleOnRemove;
            _statusEffects.Removed += StatusEffects_HandleOnRemove;

            _baseStats = CreateStats(StatCollectionType.Base);
            _modStats = CreateStats(StatCollectionType.Modified);
            _spSync = CreateSPSynchronizer();
            _inventory = CreateInventory();
            _equipped = CreateEquipped();

            // Set up the listeners for when the stat collections change
            BaseStats.StatChanged -= BaseStatChangedHandler;
            BaseStats.StatChanged += BaseStatChangedHandler;
            ModStats.StatChanged -= ModStatChangedHandler;
            ModStats.StatChanged += ModStatChangedHandler;

            // Set up the listeners for when the equipped items change
            _equipped.Equipped -= EquippedHandler;
            _equipped.Equipped += EquippedHandler;
            _equipped.Unequipped -= UnequippedHandler;
            _equipped.Unequipped += UnequippedHandler;
        }
Пример #35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEntity"/> class.
        /// </summary>
        /// <param name="iv">The item values.</param>
        public ItemEntity(IItemTable iv) : base(Vector2.Zero, new Vector2(iv.Width, iv.Height))
        {
            _id = iv.ID;
            _templateID = iv.ItemTemplateID;

            _name = iv.Name;
            _description = iv.Description;
            _graphicIndex = iv.Graphic;
            _value = iv.Value;
            _amount = iv.Amount;
            _type = iv.Type;
            _weaponType = iv.WeaponType;
            _range = iv.Range;
            _equippedBody = iv.EquippedBody;

            _baseStats = NewItemStats(iv.Stats.Select(x => (Stat<StatType>)x), StatCollectionType.Base);
            _reqStats = NewItemStats(iv.ReqStats.Select(x => (Stat<StatType>)x), StatCollectionType.Requirement);

            Resized += ItemEntity_Resized;
        }
Пример #36
0
        /// <summary>
        /// Creates a <see cref="StatCollection{StatType}"/> from the given collection of stats.
        /// </summary>
        /// <exception cref="ArgumentException">ItemEntity does not use StatCollectionType.Modified.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>statCollectionType</c> is not a defined enum value.</exception>
        StatCollection<StatType> NewItemStats(IEnumerable<Stat<StatType>> statValues, StatCollectionType statCollectionType)
        {
            var ret = new StatCollection<StatType>(statCollectionType, statValues);

            switch (statCollectionType)
            {
                case StatCollectionType.Base:
                case StatCollectionType.Requirement:
                    ret.StatChanged += StatCollection_StatChanged;
                    break;

                case StatCollectionType.Modified:
                    throw new ArgumentException("ItemEntity does not use StatCollectionType.Modified.", "statCollectionType");

                default:
                    throw new ArgumentOutOfRangeException("statCollectionType");
            }

            return ret;
        }
Пример #37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEntity"/> class.
        /// </summary>
        /// <param name="pos">The pos.</param>
        /// <param name="size">The size.</param>
        /// <param name="templateID">The template ID.</param>
        /// <param name="name">The name.</param>
        /// <param name="desc">The desc.</param>
        /// <param name="type">The type.</param>
        /// <param name="weaponType">Type of the weapon.</param>
        /// <param name="range">The range.</param>
        /// <param name="graphic">The graphic.</param>
        /// <param name="value">The value.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="hp">The hp.</param>
        /// <param name="mp">The mp.</param>
        /// <param name="equippedBody">The equipped body.</param>
        /// <param name="actionDisplayID">The action display ID.</param>
        /// <param name="baseStats">The base stats.</param>
        /// <param name="reqStats">The req stats.</param>
        ItemEntity(Vector2 pos, Vector2 size, ItemTemplateID? templateID, string name, string desc, ItemType type,
                   WeaponType weaponType, ushort range, GrhIndex graphic, int value, byte amount, SPValueType hp, SPValueType mp,
                   string equippedBody, ActionDisplayID? actionDisplayID, IEnumerable<Stat<StatType>> baseStats,
                   IEnumerable<Stat<StatType>> reqStats) : base(pos, size)
        {
            _templateID = templateID;
            _name = name;
            _description = desc;
            _graphicIndex = graphic;
            _value = value;
            _amount = amount;
            _type = type;
            _weaponType = weaponType;
            _range = range;
            _hp = hp;
            _mp = mp;
            _equippedBody = equippedBody;
            _actionDisplayID = actionDisplayID;

            _baseStats = NewItemStats(baseStats, StatCollectionType.Base);
            _reqStats = NewItemStats(reqStats, StatCollectionType.Requirement);

            Resized += ItemEntity_Resized;
        }