コード例 #1
0
ファイル: ActionSet.cs プロジェクト: sergeev/NexusForever
        public void Save(CharacterContext context)
        {
            if (saveMask == ActionSetSaveMask.None)
            {
                return;
            }

            if ((saveMask & ActionSetSaveMask.ActionSetAmps) != 0)
            {
                foreach ((ushort id, ActionSetAmp amp) in amps.OrderBy(i => i.Value.PendingDelete == true).ToList())
                {
                    if (amp.PendingDelete)
                    {
                        amps.Remove(id);
                    }

                    amp.Save(context);
                }
            }

            if ((saveMask & ActionSetSaveMask.ActionSetActions) != 0)
            {
                foreach ((UILocation location, ActionSetShortcut shortcut) in actions.OrderBy(i => i.Value.PendingDelete == true).ToList())
                {
                    if (shortcut.PendingDelete)
                    {
                        actions.Remove(location);
                    }

                    shortcut.Save(context);
                }
            }

            saveMask = ActionSetSaveMask.None;
        }
コード例 #2
0
ファイル: ActionSet.cs プロジェクト: sergeev/NexusForever
        /// <summary>
        /// Add AMP to <see cref="ActionSet"/> with supplied id.
        /// </summary>
        public void AddAmp(ushort id)
        {
            EldanAugmentationEntry entry = GameTableManager.Instance.EldanAugmentation.GetEntry(id);

            if (entry == null)
            {
                throw new ArgumentException($"Invalid eldan augmentation id {id}!");
            }

            if (amps.TryGetValue(id, out ActionSetAmp amp) && !amp.PendingDelete)
            {
                throw new InvalidOperationException($"Failed to add AMP {id}, location is already occupied!");
            }

            checked
            {
                AmpPoints -= (byte)entry.PowerCost;
            }

            if (amp != null)
            {
                amp.EnqueueDelete(false);
            }
            else
            {
                amps.Add(id, new ActionSetAmp(this, entry, true));
            }

            saveMask |= ActionSetSaveMask.ActionSetAmps;

            log.Trace($"Added AMP {id} to action set {Index}.");
        }
コード例 #3
0
ファイル: ActionSet.cs プロジェクト: sergeev/NexusForever
        /// <summary>
        /// Remove shortcut from <see cref="ActionSet"/> at supplied <see cref="UILocation"/>.
        /// </summary>
        public void RemoveShortcut(UILocation location)
        {
            ActionSetShortcut shortcut = GetShortcut(location);

            if (shortcut == null)
            {
                throw new ArgumentException($"Failed to remove shortcut from {location}, location isn't occupied!");
            }

            if (shortcut.ShortcutType == ShortcutType.Spell)
            {
                checked
                {
                    TierPoints += CalculateTierCost(shortcut.Tier);
                }
            }

            if (shortcut.PendingCreate)
            {
                actions.Remove(location);
            }
            else
            {
                shortcut.EnqueueDelete(true);
                saveMask |= ActionSetSaveMask.ActionSetActions;
            }

            log.Trace($"Removed shortcut {shortcut.ShortcutType} {shortcut.ObjectId} at {location} from action set {Index}.");
        }
コード例 #4
0
ファイル: ActionSet.cs プロジェクト: sergeev/NexusForever
        /// <summary>
        /// Add shortcut to <see cref="ActionSet"/> to supplied <see cref="UILocation"/>.
        /// </summary>
        public void AddShortcut(UILocation location, ShortcutType type, uint objectId, byte tier)
        {
            if (actions.TryGetValue(location, out ActionSetShortcut shortcut) && !shortcut.PendingDelete)
            {
                throw new InvalidOperationException($"Failed to add shortcut {type} {objectId} to {location}, location is occupied!");
            }

            if (type == ShortcutType.Spell)
            {
                checked
                {
                    TierPoints -= CalculateTierCost(tier);
                }
            }

            if (shortcut != null)
            {
                shortcut.EnqueueDelete(false);
                shortcut.ShortcutType = type;
                shortcut.ObjectId     = objectId;
                shortcut.Tier         = tier;
            }
            else
            {
                actions.Add(location, new ActionSetShortcut(this, location, type, objectId, tier));
            }

            saveMask |= ActionSetSaveMask.ActionSetActions;

            log.Trace($"Added shortcut {type} {objectId} at {location} to action set {Index}.");
        }
コード例 #5
0
ファイル: ActionSet.cs プロジェクト: sergeev/NexusForever
        /// <summary>
        /// Update a <see cref="ShortcutType.Spell"/> shortcut with supplied tier.
        /// </summary>
        public void UpdateSpellShortcut(uint spell4BaseId, byte tier)
        {
            ActionSetShortcut shortcut = GetShortcut(ShortcutType.Spell, spell4BaseId);

            if (shortcut == null)
            {
                throw new ArgumentException();
            }

            checked
            {
                TierPoints += CalculateTierCost(shortcut.Tier);
                TierPoints -= CalculateTierCost(tier);
            }

            shortcut.Tier = tier;
            saveMask     |= ActionSetSaveMask.ActionSetActions;
        }
コード例 #6
0
ファイル: ActionSet.cs プロジェクト: sergeev/NexusForever
        private void RemoveAmp(ActionSetAmp amp)
        {
            if (amp == null)
            {
                throw new ArgumentNullException();
            }

            checked
            {
                AmpPoints += (byte)amp.Entry.PowerCost;
            }

            if (amp.PendingCreate)
            {
                amps.Remove((ushort)amp.Entry.Id);
            }
            else
            {
                amp.EnqueueDelete(true);
                saveMask |= ActionSetSaveMask.ActionSetAmps;
            }

            log.Trace($"Removed AMP {amp.Entry.Id} from action set {Index}.");
        }