コード例 #1
0
        public BiotaPropertiesBookPageData AddPage(uint authorId, string authorName, string authorAccount, bool ignoreAuthor, string pageText)
        {
            var pages = Biota.GetBookAllPages(Guid.Full, BiotaDatabaseLock);

            if (pages == null || pages.Count == AppraisalMaxPages)
            {
                return(null);
            }

            var page = new BiotaPropertiesBookPageData()
            {
                ObjectId      = Biota.Id,
                PageId        = (uint)pages.Count,
                AuthorId      = authorId,
                AuthorName    = authorName,
                AuthorAccount = authorAccount,
                IgnoreAuthor  = ignoreAuthor,
                PageText      = pageText
            };

            Biota.AddBookPage(page, BiotaDatabaseLock, out var alreadyExists);

            if (alreadyExists)
            {
                return(null);
            }

            SetProperty(PropertyInt.AppraisalPages, pages.Count + 1);
            ChangesDetected = true;

            return(page);
        }
コード例 #2
0
        public bool DeletePage(uint pageId, Player player)
        {
            var pages = Biota.GetBookAllPages(Guid.Full, BiotaDatabaseLock);

            var page = Biota.GetBookPageData(Guid.Full, pageId, BiotaDatabaseLock);

            if (page == null || (!page.IgnoreAuthor && player.Guid.Full != page.AuthorId && !(player is Sentinel) && !(player is Admin)))
            {
                return(false);
            }

            var success = Biota.DeleteBookPage(pageId, out var entity, BiotaDatabaseLock);

            if (!success)
            {
                return(false);
            }

            if (pageId < pages.Count - 1)
            {
                // handle deleting page from middle of book
                for (var i = pageId + 1; i < pages.Count; i++)
                {
                    var page2 = Biota.GetBookPageData(Guid.Full, i, BiotaDatabaseLock);
                    page2.PageId--;
                }
            }
            SetProperty(PropertyInt.AppraisalPages, pages.Count - 1);
            ChangesDetected = true;

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Restore a WorldObject from the database.
        /// </summary>
        public Allegiance(Biota biota) : base(biota)
        {
            //Console.WriteLine($"Allegiance({biota.Id:X8}): biota constructor");

            if (MonarchId == null)
            {
                Console.WriteLine($"Allegiance({biota.Id:X8}): constructor called with no monarch");
                return;
            }

            Init(new ObjectGuid(MonarchId.Value));
        }
コード例 #4
0
ファイル: Container.cs プロジェクト: haeal/ACE
        /// <summary>
        /// Restore a WorldObject from the database.
        /// </summary>
        public Container(Biota biota) : base(biota)
        {
            if (Biota.TryRemoveProperty(PropertyBool.Open, out _, BiotaDatabaseLock))
            {
                ChangesDetected = true;
            }

            SetEphemeralValues();

            // A player has their possessions passed via the ctor. All other world objects must load their own inventory
            if (!(this is Player) && !ObjectGuid.IsPlayer(ContainerId ?? 0))
            {
                DatabaseManager.Shard.GetInventoryInParallel(biota.Id, false, biotas =>
                {
                    EnqueueAction(new ActionEventDelegate(() => SortBiotasIntoInventory(biotas)));
                });
            }
        }
コード例 #5
0
        public bool ModifyPage(uint pageId, string pageText, Player player)
        {
            var page = Biota.GetBookPageData(Guid.Full, pageId, BiotaDatabaseLock);

            if (page == null || page.PageText.Equals(pageText))
            {
                return(false);
            }

            if (page.IgnoreAuthor || (player.Guid.Full == page.AuthorId && player.Name == page.AuthorName && player.Account.AccountName == page.AuthorAccount) || player is Sentinel || player is Admin)
            {
                page.AuthorAccount = player.Account.AccountName;
                page.AuthorId      = player.Guid.Full;
                page.AuthorName    = player.Name;
                page.PageText      = pageText;
                ChangesDetected    = true;
            }
            else
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static BiotaPropertiesTextureMap GetTextureMap(this Biota biota, byte index)
 {
     return(biota.BiotaPropertiesTextureMap.FirstOrDefault(x => x.Index == index));
 }
コード例 #7
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static string GetProperty(this Biota biota, PropertyString property)
 {
     return(biota.BiotaPropertiesString.FirstOrDefault(x => x.Type == (uint)property)?.Value);
 }
コード例 #8
0
ファイル: BiotaExtensions.cs プロジェクト: roidzilla/ACE
 public static BiotaPropertiesPalette GetPalette(this Biota biota, uint subPaletteId)
 {
     return(biota.BiotaPropertiesPalette.FirstOrDefault(x => x.SubPaletteId == subPaletteId));
 }
コード例 #9
0
        public static ACE.Entity.Models.Biota ConvertToEntityBiota(ACE.Database.Models.Shard.Biota biota, bool instantiateEmptyCollections = false)
        {
            var result = new ACE.Entity.Models.Biota();

            result.Id            = biota.Id;
            result.WeenieClassId = biota.WeenieClassId;
            result.WeenieType    = (WeenieType)biota.WeenieType;

            if (biota.BiotaPropertiesBool != null && (instantiateEmptyCollections || biota.BiotaPropertiesBool.Count > 0))
            {
                result.PropertiesBool = new Dictionary <PropertyBool, bool>(biota.BiotaPropertiesBool.Count);
                foreach (var value in biota.BiotaPropertiesBool)
                {
                    result.PropertiesBool[(PropertyBool)value.Type] = value.Value;
                }
            }
            if (biota.BiotaPropertiesDID != null && (instantiateEmptyCollections || biota.BiotaPropertiesDID.Count > 0))
            {
                result.PropertiesDID = new Dictionary <PropertyDataId, uint>(biota.BiotaPropertiesDID.Count);
                foreach (var value in biota.BiotaPropertiesDID)
                {
                    result.PropertiesDID[(PropertyDataId)value.Type] = value.Value;
                }
            }
            if (biota.BiotaPropertiesFloat != null && (instantiateEmptyCollections || biota.BiotaPropertiesFloat.Count > 0))
            {
                result.PropertiesFloat = new Dictionary <PropertyFloat, double>(biota.BiotaPropertiesFloat.Count);
                foreach (var value in biota.BiotaPropertiesFloat)
                {
                    result.PropertiesFloat[(PropertyFloat)value.Type] = value.Value;
                }
            }
            if (biota.BiotaPropertiesIID != null && (instantiateEmptyCollections || biota.BiotaPropertiesIID.Count > 0))
            {
                result.PropertiesIID = new Dictionary <PropertyInstanceId, uint>(biota.BiotaPropertiesIID.Count);
                foreach (var value in biota.BiotaPropertiesIID)
                {
                    result.PropertiesIID[(PropertyInstanceId)value.Type] = value.Value;
                }
            }
            if (biota.BiotaPropertiesInt != null && (instantiateEmptyCollections || biota.BiotaPropertiesInt.Count > 0))
            {
                result.PropertiesInt = new Dictionary <PropertyInt, int>(biota.BiotaPropertiesInt.Count);
                foreach (var value in biota.BiotaPropertiesInt)
                {
                    result.PropertiesInt[(PropertyInt)value.Type] = value.Value;
                }
            }
            if (biota.BiotaPropertiesInt64 != null && (instantiateEmptyCollections || biota.BiotaPropertiesInt64.Count > 0))
            {
                result.PropertiesInt64 = new Dictionary <PropertyInt64, long>(biota.BiotaPropertiesInt64.Count);
                foreach (var value in biota.BiotaPropertiesInt64)
                {
                    result.PropertiesInt64[(PropertyInt64)value.Type] = value.Value;
                }
            }
            if (biota.BiotaPropertiesString != null && (instantiateEmptyCollections || biota.BiotaPropertiesString.Count > 0))
            {
                result.PropertiesString = new Dictionary <PropertyString, string>(biota.BiotaPropertiesString.Count);
                foreach (var value in biota.BiotaPropertiesString)
                {
                    result.PropertiesString[(PropertyString)value.Type] = value.Value;
                }
            }


            if (biota.BiotaPropertiesPosition != null && (instantiateEmptyCollections || biota.BiotaPropertiesPosition.Count > 0))
            {
                result.PropertiesPosition = new Dictionary <PositionType, PropertiesPosition>(biota.BiotaPropertiesPosition.Count);

                foreach (var record in biota.BiotaPropertiesPosition)
                {
                    var newEntity = new PropertiesPosition
                    {
                        ObjCellId = record.ObjCellId,
                        PositionX = record.OriginX,
                        PositionY = record.OriginY,
                        PositionZ = record.OriginZ,
                        RotationW = record.AnglesW,
                        RotationX = record.AnglesX,
                        RotationY = record.AnglesY,
                        RotationZ = record.AnglesZ,
                    };

                    result.PropertiesPosition[(PositionType)record.PositionType] = newEntity;
                }
            }


            if (biota.BiotaPropertiesSpellBook != null && (instantiateEmptyCollections || biota.BiotaPropertiesSpellBook.Count > 0))
            {
                result.PropertiesSpellBook = new Dictionary <int, float>(biota.BiotaPropertiesSpellBook.Count);
                foreach (var value in biota.BiotaPropertiesSpellBook)
                {
                    result.PropertiesSpellBook[value.Spell] = value.Probability;
                }
            }


            if (biota.BiotaPropertiesAnimPart != null && (instantiateEmptyCollections || biota.BiotaPropertiesAnimPart.Count > 0))
            {
                result.PropertiesAnimPart = new List <PropertiesAnimPart>(biota.BiotaPropertiesAnimPart.Count);

                foreach (var record in biota.BiotaPropertiesAnimPart.OrderBy(r => r.Order))
                {
                    var newEntity = new PropertiesAnimPart
                    {
                        Index       = record.Index,
                        AnimationId = record.AnimationId,
                    };

                    result.PropertiesAnimPart.Add(newEntity);
                }
            }

            if (biota.BiotaPropertiesPalette != null && (instantiateEmptyCollections || biota.BiotaPropertiesPalette.Count > 0))
            {
                result.PropertiesPalette = new Collection <PropertiesPalette>();

                foreach (var record in biota.BiotaPropertiesPalette.OrderBy(r => r.Order))
                {
                    var newEntity = new PropertiesPalette
                    {
                        SubPaletteId = record.SubPaletteId,
                        Offset       = record.Offset,
                        Length       = record.Length,
                    };

                    result.PropertiesPalette.Add(newEntity);
                }
            }

            if (biota.BiotaPropertiesTextureMap != null && (instantiateEmptyCollections || biota.BiotaPropertiesTextureMap.Count > 0))
            {
                result.PropertiesTextureMap = new List <PropertiesTextureMap>(biota.BiotaPropertiesTextureMap.Count);

                foreach (var record in biota.BiotaPropertiesTextureMap.OrderBy(r => r.Order))
                {
                    var newEntity = new PropertiesTextureMap
                    {
                        PartIndex  = record.Index,
                        OldTexture = record.OldId,
                        NewTexture = record.NewId,
                    };

                    result.PropertiesTextureMap.Add(newEntity);
                }
            }


            // Properties for all world objects that typically aren't modified over the original Biota

            if (biota.BiotaPropertiesCreateList != null && (instantiateEmptyCollections || biota.BiotaPropertiesCreateList.Count > 0))
            {
                result.PropertiesCreateList = new Collection <PropertiesCreateList>();

                foreach (var record in biota.BiotaPropertiesCreateList)
                {
                    var newEntity = new PropertiesCreateList
                    {
                        DatabaseRecordId = record.Id,

                        DestinationType = (DestinationType)record.DestinationType,
                        WeenieClassId   = record.WeenieClassId,
                        StackSize       = record.StackSize,
                        Palette         = record.Palette,
                        Shade           = record.Shade,
                        TryToBond       = record.TryToBond,
                    };

                    result.PropertiesCreateList.Add(newEntity);
                }
            }

            if (biota.BiotaPropertiesEmote != null && (instantiateEmptyCollections || biota.BiotaPropertiesEmote.Count > 0))
            {
                result.PropertiesEmote = new Collection <PropertiesEmote>();

                foreach (var record in biota.BiotaPropertiesEmote)
                {
                    var newEntity = new PropertiesEmote
                    {
                        DatabaseRecordId = record.Id,

                        Category      = (EmoteCategory)record.Category,
                        Probability   = record.Probability,
                        WeenieClassId = record.WeenieClassId,
                        Style         = (MotionStance?)record.Style,
                        Substyle      = (MotionCommand?)record.Substyle,
                        Quest         = record.Quest,
                        VendorType    = (VendorType?)record.VendorType,
                        MinHealth     = record.MinHealth,
                        MaxHealth     = record.MaxHealth,
                    };

                    foreach (var record2 in record.BiotaPropertiesEmoteAction.OrderBy(r => r.Order))
                    {
                        var newEntity2 = new PropertiesEmoteAction
                        {
                            DatabaseRecordId = record2.Id,

                            Type            = record2.Type,
                            Delay           = record2.Delay,
                            Extent          = record2.Extent,
                            Motion          = (MotionCommand?)record2.Motion,
                            Message         = record2.Message,
                            TestString      = record2.TestString,
                            Min             = record2.Min,
                            Max             = record2.Max,
                            Min64           = record2.Min64,
                            Max64           = record2.Max64,
                            MinDbl          = record2.MinDbl,
                            MaxDbl          = record2.MaxDbl,
                            Stat            = record2.Stat,
                            Display         = record2.Display,
                            Amount          = record2.Amount,
                            Amount64        = record2.Amount64,
                            HeroXP64        = record2.HeroXP64,
                            Percent         = record2.Percent,
                            SpellId         = record2.SpellId,
                            WealthRating    = record2.WealthRating,
                            TreasureClass   = record2.TreasureClass,
                            TreasureType    = record2.TreasureType,
                            PScript         = (PlayScript?)record2.PScript,
                            Sound           = (Sound?)record2.Sound,
                            DestinationType = record2.DestinationType,
                            WeenieClassId   = record2.WeenieClassId,
                            StackSize       = record2.StackSize,
                            Palette         = record2.Palette,
                            Shade           = record2.Shade,
                            TryToBond       = record2.TryToBond,
                            ObjCellId       = record2.ObjCellId,
                            OriginX         = record2.OriginX,
                            OriginY         = record2.OriginY,
                            OriginZ         = record2.OriginZ,
                            AnglesW         = record2.AnglesW,
                            AnglesX         = record2.AnglesX,
                            AnglesY         = record2.AnglesY,
                            AnglesZ         = record2.AnglesZ,
                        };

                        newEntity.PropertiesEmoteAction.Add(newEntity2);
                    }

                    result.PropertiesEmote.Add(newEntity);
                }
            }

            if (biota.BiotaPropertiesEventFilter != null && (instantiateEmptyCollections || biota.BiotaPropertiesEventFilter.Count > 0))
            {
                result.PropertiesEventFilter = new HashSet <int>();
                foreach (var value in biota.BiotaPropertiesEventFilter)
                {
                    result.PropertiesEventFilter.Add(value.Event);
                }
            }

            if (biota.BiotaPropertiesGenerator != null && (instantiateEmptyCollections || biota.BiotaPropertiesGenerator.Count > 0))
            {
                result.PropertiesGenerator = new List <PropertiesGenerator>(biota.BiotaPropertiesGenerator.Count);

                foreach (var record in biota.BiotaPropertiesGenerator) // TODO do we have the correct order?
                {
                    var newEntity = new PropertiesGenerator
                    {
                        DatabaseRecordId = record.Id,

                        Probability   = record.Probability,
                        WeenieClassId = record.WeenieClassId,
                        Delay         = record.Delay,
                        InitCreate    = record.InitCreate,
                        MaxCreate     = record.MaxCreate,
                        WhenCreate    = (RegenerationType)record.WhenCreate,
                        WhereCreate   = (RegenLocationType)record.WhereCreate,
                        StackSize     = record.StackSize,
                        PaletteId     = record.PaletteId,
                        Shade         = record.Shade,
                        ObjCellId     = record.ObjCellId,
                        OriginX       = record.OriginX,
                        OriginY       = record.OriginY,
                        OriginZ       = record.OriginZ,
                        AnglesW       = record.AnglesW,
                        AnglesX       = record.AnglesX,
                        AnglesY       = record.AnglesY,
                        AnglesZ       = record.AnglesZ,
                    };

                    result.PropertiesGenerator.Add(newEntity);
                }
            }


            // Properties for creatures

            if (biota.BiotaPropertiesAttribute != null && (instantiateEmptyCollections || biota.BiotaPropertiesAttribute.Count > 0))
            {
                result.PropertiesAttribute = new Dictionary <PropertyAttribute, PropertiesAttribute>(biota.BiotaPropertiesAttribute.Count);

                foreach (var record in biota.BiotaPropertiesAttribute)
                {
                    var newEntity = new PropertiesAttribute
                    {
                        InitLevel   = record.InitLevel,
                        LevelFromCP = record.LevelFromCP,
                        CPSpent     = record.CPSpent,
                    };

                    result.PropertiesAttribute[(PropertyAttribute)record.Type] = newEntity;
                }
            }

            if (biota.BiotaPropertiesAttribute2nd != null && (instantiateEmptyCollections || biota.BiotaPropertiesAttribute2nd.Count > 0))
            {
                result.PropertiesAttribute2nd = new Dictionary <PropertyAttribute2nd, PropertiesAttribute2nd>(biota.BiotaPropertiesAttribute2nd.Count);

                foreach (var record in biota.BiotaPropertiesAttribute2nd)
                {
                    var newEntity = new PropertiesAttribute2nd
                    {
                        InitLevel    = record.InitLevel,
                        LevelFromCP  = record.LevelFromCP,
                        CPSpent      = record.CPSpent,
                        CurrentLevel = record.CurrentLevel,
                    };

                    result.PropertiesAttribute2nd[(PropertyAttribute2nd)record.Type] = newEntity;
                }
            }

            if (biota.BiotaPropertiesBodyPart != null && (instantiateEmptyCollections || biota.BiotaPropertiesBodyPart.Count > 0))
            {
                result.PropertiesBodyPart = new Dictionary <CombatBodyPart, PropertiesBodyPart>(biota.BiotaPropertiesBodyPart.Count);

                foreach (var record in biota.BiotaPropertiesBodyPart)
                {
                    var newEntity = new PropertiesBodyPart
                    {
                        DType           = (DamageType)record.DType,
                        DVal            = record.DVal,
                        DVar            = record.DVar,
                        BaseArmor       = record.BaseArmor,
                        ArmorVsSlash    = record.ArmorVsSlash,
                        ArmorVsPierce   = record.ArmorVsPierce,
                        ArmorVsBludgeon = record.ArmorVsBludgeon,
                        ArmorVsCold     = record.ArmorVsCold,
                        ArmorVsFire     = record.ArmorVsFire,
                        ArmorVsAcid     = record.ArmorVsAcid,
                        ArmorVsElectric = record.ArmorVsElectric,
                        ArmorVsNether   = record.ArmorVsNether,
                        BH  = record.BH,
                        HLF = record.HLF,
                        MLF = record.MLF,
                        LLF = record.LLF,
                        HRF = record.HRF,
                        MRF = record.MRF,
                        LRF = record.LRF,
                        HLB = record.HLB,
                        MLB = record.MLB,
                        LLB = record.LLB,
                        HRB = record.HRB,
                        MRB = record.MRB,
                        LRB = record.LRB,
                    };

                    result.PropertiesBodyPart[(CombatBodyPart)record.Key] = newEntity;
                }
            }

            if (biota.BiotaPropertiesSkill != null && (instantiateEmptyCollections || biota.BiotaPropertiesSkill.Count > 0))
            {
                result.PropertiesSkill = new Dictionary <Skill, PropertiesSkill>(biota.BiotaPropertiesSkill.Count);

                foreach (var record in biota.BiotaPropertiesSkill)
                {
                    var newEntity = new PropertiesSkill
                    {
                        LevelFromPP           = record.LevelFromPP,
                        SAC                   = (SkillAdvancementClass)record.SAC,
                        PP                    = record.PP,
                        InitLevel             = record.InitLevel,
                        ResistanceAtLastCheck = record.ResistanceAtLastCheck,
                        LastUsedTime          = record.LastUsedTime,
                    };

                    result.PropertiesSkill[(Skill)record.Type] = newEntity;
                }
            }


            // Properties for books

            if (biota.BiotaPropertiesBook != null)
            {
                result.PropertiesBook = new PropertiesBook
                {
                    MaxNumPages        = biota.BiotaPropertiesBook.MaxNumPages,
                    MaxNumCharsPerPage = biota.BiotaPropertiesBook.MaxNumCharsPerPage,
                };
            }

            if (biota.BiotaPropertiesBookPageData != null && (instantiateEmptyCollections || biota.BiotaPropertiesBookPageData.Count > 0))
            {
                result.PropertiesBookPageData = new List <PropertiesBookPageData>(biota.BiotaPropertiesBookPageData.Count);

                foreach (var record in biota.BiotaPropertiesBookPageData.OrderBy(r => r.PageId))
                {
                    var newEntity = new PropertiesBookPageData
                    {
                        AuthorId      = record.AuthorId,
                        AuthorName    = record.AuthorName,
                        AuthorAccount = record.AuthorAccount,
                        IgnoreAuthor  = record.IgnoreAuthor,
                        PageText      = record.PageText,
                    };

                    result.PropertiesBookPageData.Add(newEntity);
                }
            }


            // Biota additions over Weenie

            if (biota.BiotaPropertiesAllegiance != null && (instantiateEmptyCollections || biota.BiotaPropertiesAllegiance.Count > 0))
            {
                result.PropertiesAllegiance = new Dictionary <uint, PropertiesAllegiance>(biota.BiotaPropertiesAllegiance.Count);

                foreach (var record in biota.BiotaPropertiesAllegiance)
                {
                    var newEntity = new PropertiesAllegiance
                    {
                        Banned         = record.Banned,
                        ApprovedVassal = record.ApprovedVassal,
                    };

                    result.PropertiesAllegiance[record.CharacterId] = newEntity;
                }
            }

            if (biota.BiotaPropertiesEnchantmentRegistry != null && (instantiateEmptyCollections || biota.BiotaPropertiesEnchantmentRegistry.Count > 0))
            {
                result.PropertiesEnchantmentRegistry = new Collection <PropertiesEnchantmentRegistry>();

                foreach (var record in biota.BiotaPropertiesEnchantmentRegistry)
                {
                    var newEntity = new PropertiesEnchantmentRegistry
                    {
                        EnchantmentCategory = record.EnchantmentCategory,
                        SpellId             = record.SpellId,
                        LayerId             = record.LayerId,
                        HasSpellSetId       = record.HasSpellSetId,
                        SpellCategory       = (SpellCategory)record.SpellCategory,
                        PowerLevel          = record.PowerLevel,
                        StartTime           = record.StartTime,
                        Duration            = record.Duration,
                        CasterObjectId      = record.CasterObjectId,
                        DegradeModifier     = record.DegradeModifier,
                        DegradeLimit        = record.DegradeLimit,
                        LastTimeDegraded    = record.LastTimeDegraded,
                        StatModType         = (EnchantmentTypeFlags)record.StatModType,
                        StatModKey          = record.StatModKey,
                        StatModValue        = record.StatModValue,
                        SpellSetId          = (EquipmentSet)record.SpellSetId,
                    };

                    result.PropertiesEnchantmentRegistry.Add(newEntity);
                }
            }

            if (biota.HousePermission != null && (instantiateEmptyCollections || biota.HousePermission.Count > 0))
            {
                result.HousePermissions = new Dictionary <uint, bool>(biota.HousePermission.Count);

                foreach (var record in biota.HousePermission)
                {
                    result.HousePermissions[record.PlayerGuid] = record.Storage;
                }
            }


            return(result);
        }
コード例 #10
0
 public static double?GetProperty(this Biota biota, PropertyFloat property)
 {
     return(biota.BiotaPropertiesFloat.FirstOrDefault(x => x.Type == (ushort)property)?.Value);
 }
コード例 #11
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static BiotaPropertiesBookPageData GetBookPageData(this Biota biota, uint pageId)
 {
     return(biota.BiotaPropertiesBookPageData.FirstOrDefault(x => x.PageId == pageId));
 }
コード例 #12
0
ファイル: BiotaExtensions.cs プロジェクト: Zegeger/ACE
 public static List <BiotaPropertiesEnchantmentRegistry> GetEnchantmentsByStatModType(this Biota biota, uint statModType, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterReadLock();
     try
     {
         return(biota.BiotaPropertiesEnchantmentRegistry.Where(e => (e.StatModType & statModType) == statModType).ToList());
     }
     finally
     {
         rwLock.ExitReadLock();
     }
 }
コード例 #13
0
ファイル: BiotaExtensions.cs プロジェクト: Zegeger/ACE
 public static List <BiotaPropertiesEnchantmentRegistry> GetEnchantmentsByCategory(this Biota biota, ushort spellCategory, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterReadLock();
     try
     {
         return(biota.BiotaPropertiesEnchantmentRegistry.Where(e => e.SpellCategory == spellCategory).ToList());
     }
     finally
     {
         rwLock.ExitReadLock();
     }
 }
コード例 #14
0
 public static BiotaPropertiesPosition GetProperty(this Biota weenie, PositionType positionType)
 {
     return(weenie.BiotaPropertiesPosition.FirstOrDefault(x => x.PositionType == (uint)positionType));
 }
コード例 #15
0
 public static long?GetProperty(this Biota biota, PropertyInt64 property)
 {
     return(biota.BiotaPropertiesInt64.FirstOrDefault(x => x.Type == (uint)property)?.Value);
 }
コード例 #16
0
 // =====================================
 // BiotaPropertiesSkill
 // =====================================
 public static BiotaPropertiesSkill GetSkill(this Biota biota, ushort type)
 {
     return(biota.BiotaPropertiesSkill.FirstOrDefault(x => x.Type == type));
 }
コード例 #17
0
 public static uint?GetProperty(this Biota biota, PropertyInstanceId property)
 {
     return(biota.BiotaPropertiesIID.FirstOrDefault(x => x.Type == (uint)property)?.Value);
 }
コード例 #18
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static BiotaPropertiesAttribute2nd GetAttribute2nd(this Biota biota, PropertyAttribute2nd attribute)
 {
     return(biota.BiotaPropertiesAttribute2nd.FirstOrDefault(x => x.Type == (uint)attribute));
 }
コード例 #19
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static BiotaPropertiesBodyPart GetBodyPart(this Biota biota, ushort key)
 {
     return(biota.BiotaPropertiesBodyPart.FirstOrDefault(x => x.Key == key));
 }
コード例 #20
0
ファイル: BiotaExtensions.cs プロジェクト: Zegeger/ACE
        public static Biota Clone(this Biota biota)
        {
            var result = new Biota();

            result.Id                       = biota.Id;
            result.WeenieClassId            = biota.WeenieClassId;
            result.WeenieType               = biota.WeenieType;
            result.PopulatedCollectionFlags = biota.PopulatedCollectionFlags;

            if (biota.BiotaPropertiesBook != null)
            {
                result.BiotaPropertiesBook                    = new BiotaPropertiesBook();
                result.BiotaPropertiesBook.Id                 = biota.BiotaPropertiesBook.Id;
                result.BiotaPropertiesBook.ObjectId           = biota.BiotaPropertiesBook.ObjectId;
                result.BiotaPropertiesBook.MaxNumPages        = biota.BiotaPropertiesBook.MaxNumPages;
                result.BiotaPropertiesBook.MaxNumCharsPerPage = biota.BiotaPropertiesBook.MaxNumCharsPerPage;
            }

            foreach (var value in biota.BiotaPropertiesAnimPart)
            {
                result.BiotaPropertiesAnimPart.Add(new BiotaPropertiesAnimPart
                {
                    Id          = value.Id,
                    ObjectId    = value.Id,
                    Index       = value.Index,
                    AnimationId = value.AnimationId,
                    Order       = value.Order,
                });
            }

            foreach (var value in biota.BiotaPropertiesAttribute)
            {
                result.BiotaPropertiesAttribute.Add(new BiotaPropertiesAttribute
                {
                    Id          = value.Id,
                    ObjectId    = value.ObjectId,
                    Type        = value.Type,
                    InitLevel   = value.InitLevel,
                    LevelFromCP = value.LevelFromCP,
                    CPSpent     = value.CPSpent,
                });
            }

            foreach (var value in biota.BiotaPropertiesAttribute2nd)
            {
                result.BiotaPropertiesAttribute2nd.Add(new BiotaPropertiesAttribute2nd
                {
                    Id           = value.Id,
                    ObjectId     = value.ObjectId,
                    Type         = value.Type,
                    InitLevel    = value.InitLevel,
                    LevelFromCP  = value.LevelFromCP,
                    CPSpent      = value.CPSpent,
                    CurrentLevel = value.CurrentLevel,
                });
            }

            foreach (var value in biota.BiotaPropertiesBodyPart)
            {
                result.BiotaPropertiesBodyPart.Add(new BiotaPropertiesBodyPart
                {
                    Id              = value.Id,
                    ObjectId        = value.ObjectId,
                    Key             = value.Key,
                    DType           = value.DType,
                    DVal            = value.DVal,
                    DVar            = value.DVar,
                    BaseArmor       = value.BaseArmor,
                    ArmorVsSlash    = value.ArmorVsSlash,
                    ArmorVsPierce   = value.ArmorVsPierce,
                    ArmorVsBludgeon = value.ArmorVsBludgeon,
                    ArmorVsCold     = value.ArmorVsCold,
                    ArmorVsFire     = value.ArmorVsFire,
                    ArmorVsAcid     = value.ArmorVsAcid,
                    ArmorVsElectric = value.ArmorVsElectric,
                    ArmorVsNether   = value.ArmorVsNether,
                    BH              = value.BH,
                    HLF             = value.HLF,
                    MLF             = value.MLF,
                    LLF             = value.LLF,
                    HRF             = value.HRF,
                    MRF             = value.MRF,
                    LRF             = value.LRF,
                    HLB             = value.HLB,
                    MLB             = value.MLB,
                    LLB             = value.LLB,
                    HRB             = value.HRB,
                    MRB             = value.MRB,
                    LRB             = value.LRB,
                });
            }

            foreach (var value in biota.BiotaPropertiesBookPageData)
            {
                result.BiotaPropertiesBookPageData.Add(new BiotaPropertiesBookPageData
                {
                    Id            = value.Id,
                    ObjectId      = value.ObjectId,
                    PageId        = value.PageId,
                    AuthorId      = value.AuthorId,
                    AuthorName    = value.AuthorName,
                    AuthorAccount = value.AuthorAccount,
                    IgnoreAuthor  = value.IgnoreAuthor,
                    PageText      = value.PageText,
                });
            }

            foreach (var value in biota.BiotaPropertiesBool)
            {
                result.BiotaPropertiesBool.Add(new BiotaPropertiesBool
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

            foreach (var value in biota.BiotaPropertiesCreateList)
            {
                result.BiotaPropertiesCreateList.Add(new BiotaPropertiesCreateList
                {
                    Id              = value.Id,
                    ObjectId        = value.ObjectId,
                    DestinationType = value.DestinationType,
                    WeenieClassId   = value.WeenieClassId,
                    StackSize       = value.StackSize,
                    Palette         = value.Palette,
                    Shade           = value.Shade,
                    TryToBond       = value.TryToBond,
                });
            }

            foreach (var value in biota.BiotaPropertiesDID)
            {
                result.BiotaPropertiesDID.Add(new BiotaPropertiesDID
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }


            foreach (var value in biota.BiotaPropertiesEmote)
            {
                var emote = new BiotaPropertiesEmote
                {
                    Id            = value.Id,
                    ObjectId      = value.ObjectId,
                    Category      = value.Category,
                    Probability   = value.Probability,
                    WeenieClassId = value.WeenieClassId,
                    Style         = value.Style,
                    Substyle      = value.Substyle,
                    Quest         = value.Quest,
                    VendorType    = value.VendorType,
                    MinHealth     = value.MinHealth,
                    MaxHealth     = value.MaxHealth,
                };

                foreach (var value2 in value.BiotaPropertiesEmoteAction)
                {
                    var action = new BiotaPropertiesEmoteAction
                    {
                        Id              = value2.Id,
                        EmoteId         = value2.EmoteId,
                        Order           = value2.Order,
                        Type            = value2.Type,
                        Delay           = value2.Delay,
                        Extent          = value2.Extent,
                        Motion          = value2.Motion,
                        Message         = value2.Message,
                        TestString      = value2.TestString,
                        Min             = value2.Min,
                        Max             = value2.Max,
                        Min64           = value2.Min64,
                        Max64           = value2.Max64,
                        MinDbl          = value2.MinDbl,
                        MaxDbl          = value2.MaxDbl,
                        Stat            = value2.Stat,
                        Display         = value2.Display,
                        Amount          = value2.Amount,
                        Amount64        = value2.Amount64,
                        HeroXP64        = value2.HeroXP64,
                        Percent         = value2.Percent,
                        SpellId         = value2.SpellId,
                        WealthRating    = value2.WealthRating,
                        TreasureClass   = value2.TreasureClass,
                        TreasureType    = value2.TreasureType,
                        PScript         = value2.PScript,
                        Sound           = value2.Sound,
                        DestinationType = value2.DestinationType,
                        WeenieClassId   = value2.WeenieClassId,
                        StackSize       = value2.StackSize,
                        Palette         = value2.Palette,
                        Shade           = value2.Shade,
                        TryToBond       = value2.TryToBond,
                        ObjCellId       = value2.ObjCellId,
                        OriginX         = value2.OriginX,
                        OriginY         = value2.OriginY,
                        OriginZ         = value2.OriginZ,
                        AnglesW         = value2.AnglesW,
                        AnglesX         = value2.AnglesX,
                        AnglesY         = value2.AnglesY,
                        AnglesZ         = value2.AnglesZ,
                    };

                    emote.BiotaPropertiesEmoteAction.Add(action);
                }

                result.BiotaPropertiesEmote.Add(emote);
            }


            foreach (var value in biota.BiotaPropertiesEnchantmentRegistry)
            {
                result.BiotaPropertiesEnchantmentRegistry.Add(new BiotaPropertiesEnchantmentRegistry
                {
                    Id                  = value.Id,
                    ObjectId            = value.ObjectId,
                    EnchantmentCategory = value.EnchantmentCategory,
                    SpellId             = value.SpellId,
                    LayerId             = value.LayerId,
                    HasSpellSetId       = value.HasSpellSetId,
                    SpellCategory       = value.SpellCategory,
                    PowerLevel          = value.PowerLevel,
                    StartTime           = value.StartTime,
                    Duration            = value.Duration,
                    CasterObjectId      = value.CasterObjectId,
                    DegradeModifier     = value.DegradeModifier,
                    DegradeLimit        = value.DegradeLimit,
                    LastTimeDegraded    = value.LastTimeDegraded,
                    StatModType         = value.StatModType,
                    StatModKey          = value.StatModKey,
                    StatModValue        = value.StatModValue,
                    SpellSetId          = value.SpellSetId,
                });
            }


            foreach (var value in biota.BiotaPropertiesEventFilter)
            {
                result.BiotaPropertiesEventFilter.Add(new BiotaPropertiesEventFilter
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Event    = value.Event,
                });
            }

            foreach (var value in biota.BiotaPropertiesFloat)
            {
                result.BiotaPropertiesFloat.Add(new BiotaPropertiesFloat
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

            foreach (var value in biota.BiotaPropertiesGenerator)
            {
                result.BiotaPropertiesGenerator.Add(new BiotaPropertiesGenerator
                {
                    Id            = value.Id,
                    ObjectId      = value.ObjectId,
                    Probability   = value.Probability,
                    WeenieClassId = value.WeenieClassId,
                    Delay         = value.Delay,
                    InitCreate    = value.InitCreate,
                    MaxCreate     = value.MaxCreate,
                    WhenCreate    = value.WhenCreate,
                    WhereCreate   = value.WhereCreate,
                    StackSize     = value.StackSize,
                    PaletteId     = value.PaletteId,
                    Shade         = value.Shade,
                    ObjCellId     = value.ObjCellId,
                    OriginX       = value.OriginX,
                    OriginY       = value.OriginY,
                    OriginZ       = value.OriginZ,
                    AnglesW       = value.AnglesW,
                    AnglesX       = value.AnglesX,
                    AnglesY       = value.AnglesY,
                    AnglesZ       = value.AnglesZ,
                });
            }

            foreach (var value in biota.BiotaPropertiesIID)
            {
                result.BiotaPropertiesIID.Add(new BiotaPropertiesIID
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

            foreach (var value in biota.BiotaPropertiesInt)
            {
                result.BiotaPropertiesInt.Add(new BiotaPropertiesInt
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

            foreach (var value in biota.BiotaPropertiesInt64)
            {
                result.BiotaPropertiesInt64.Add(new BiotaPropertiesInt64
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

            foreach (var value in biota.BiotaPropertiesPalette)
            {
                result.BiotaPropertiesPalette.Add(new BiotaPropertiesPalette
                {
                    Id           = value.Id,
                    ObjectId     = value.ObjectId,
                    SubPaletteId = value.SubPaletteId,
                    Offset       = value.Offset,
                    Length       = value.Length,
                });
            }

            foreach (var value in biota.BiotaPropertiesPosition)
            {
                result.BiotaPropertiesPosition.Add(new BiotaPropertiesPosition
                {
                    Id           = value.Id,
                    ObjectId     = value.ObjectId,
                    PositionType = value.PositionType,
                    ObjCellId    = value.ObjCellId,
                    OriginX      = value.OriginX,
                    OriginY      = value.OriginY,
                    OriginZ      = value.OriginZ,
                    AnglesW      = value.AnglesW,
                    AnglesX      = value.AnglesX,
                    AnglesY      = value.AnglesY,
                    AnglesZ      = value.AnglesZ,
                });
            }

            foreach (var value in biota.BiotaPropertiesSkill)
            {
                result.BiotaPropertiesSkill.Add(new BiotaPropertiesSkill
                {
                    Id                    = value.Id,
                    ObjectId              = value.ObjectId,
                    Type                  = value.Type,
                    LevelFromPP           = value.LevelFromPP,
                    SAC                   = value.SAC,
                    PP                    = value.PP,
                    InitLevel             = value.InitLevel,
                    ResistanceAtLastCheck = value.ResistanceAtLastCheck,
                    LastUsedTime          = value.LastUsedTime,
                });
            }

            foreach (var value in biota.BiotaPropertiesSpellBook)
            {
                result.BiotaPropertiesSpellBook.Add(new BiotaPropertiesSpellBook
                {
                    Id          = value.Id,
                    ObjectId    = value.ObjectId,
                    Spell       = value.Spell,
                    Probability = value.Probability,
                });
            }

            foreach (var value in biota.BiotaPropertiesString)
            {
                result.BiotaPropertiesString.Add(new BiotaPropertiesString
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

            foreach (var value in biota.BiotaPropertiesTextureMap)
            {
                result.BiotaPropertiesTextureMap.Add(new BiotaPropertiesTextureMap
                {
                    Id       = value.Id,
                    ObjectId = value.ObjectId,
                    Index    = value.Index,
                    OldId    = value.OldId,
                    NewId    = value.NewId,
                    Order    = value.Order,
                });
            }

            return(result);
        }
コード例 #21
0
        public BiotaPropertiesBookPageData GetPage(uint pageId)
        {
            var page = Biota.GetBookPageData(Guid.Full, pageId, BiotaDatabaseLock);

            return(page);
        }
コード例 #22
0
        public static ACE.Database.Models.Shard.Biota ConvertToDatabaseBiota(ACE.Database.Models.World.Weenie weenie, uint id)
        {
            var result = new ACE.Database.Models.Shard.Biota();

            result.Id            = id;
            result.WeenieClassId = weenie.ClassId;
            result.WeenieType    = weenie.Type;

            foreach (var value in weenie.WeeniePropertiesBool)
            {
                result.BiotaPropertiesBool.Add(new BiotaPropertiesBool
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }
            foreach (var value in weenie.WeeniePropertiesDID)
            {
                result.BiotaPropertiesDID.Add(new BiotaPropertiesDID
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }
            foreach (var value in weenie.WeeniePropertiesFloat)
            {
                result.BiotaPropertiesFloat.Add(new BiotaPropertiesFloat
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }
            foreach (var value in weenie.WeeniePropertiesIID)
            {
                result.BiotaPropertiesIID.Add(new BiotaPropertiesIID
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }
            foreach (var value in weenie.WeeniePropertiesInt)
            {
                result.BiotaPropertiesInt.Add(new BiotaPropertiesInt
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }
            foreach (var value in weenie.WeeniePropertiesInt64)
            {
                result.BiotaPropertiesInt64.Add(new BiotaPropertiesInt64
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }
            foreach (var value in weenie.WeeniePropertiesString)
            {
                result.BiotaPropertiesString.Add(new BiotaPropertiesString
                {
                    ObjectId = result.Id,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }


            foreach (var value in weenie.WeeniePropertiesPosition)
            {
                result.BiotaPropertiesPosition.Add(new BiotaPropertiesPosition
                {
                    ObjectId     = result.Id,
                    PositionType = value.PositionType,
                    ObjCellId    = value.ObjCellId,
                    OriginX      = value.OriginX,
                    OriginY      = value.OriginY,
                    OriginZ      = value.OriginZ,
                    AnglesW      = value.AnglesW,
                    AnglesX      = value.AnglesX,
                    AnglesY      = value.AnglesY,
                    AnglesZ      = value.AnglesZ,
                    Instance     = value.Instance,
                });
            }


            foreach (var value in weenie.WeeniePropertiesSpellBook)
            {
                result.BiotaPropertiesSpellBook.Add(new BiotaPropertiesSpellBook
                {
                    ObjectId    = result.Id,
                    Spell       = value.Spell,
                    Probability = value.Probability,
                });
            }



            foreach (var value in weenie.WeeniePropertiesAnimPart)
            {
                result.BiotaPropertiesAnimPart.Add(new BiotaPropertiesAnimPart
                {
                    ObjectId    = result.Id,
                    Index       = value.Index,
                    AnimationId = value.AnimationId
                });
            }

            foreach (var value in weenie.WeeniePropertiesPalette)
            {
                result.BiotaPropertiesPalette.Add(new BiotaPropertiesPalette
                {
                    ObjectId     = result.Id,
                    SubPaletteId = value.SubPaletteId,
                    Offset       = value.Offset,
                    Length       = value.Length,
                });
            }

            foreach (var value in weenie.WeeniePropertiesTextureMap)
            {
                result.BiotaPropertiesTextureMap.Add(new BiotaPropertiesTextureMap
                {
                    ObjectId = result.Id,
                    Index    = value.Index,
                    OldId    = value.OldId,
                    NewId    = value.NewId,
                });
            }


            // Properties for all world objects that typically aren't modified over the original weenie

            foreach (var value in weenie.WeeniePropertiesCreateList)
            {
                result.BiotaPropertiesCreateList.Add(new BiotaPropertiesCreateList
                {
                    ObjectId        = result.Id,
                    DestinationType = value.DestinationType,
                    WeenieClassId   = value.WeenieClassId,
                    StackSize       = value.StackSize,
                    Palette         = value.Palette,
                    Shade           = value.Shade,
                    TryToBond       = value.TryToBond,
                });
            }

            foreach (var value in weenie.WeeniePropertiesEmote)
            {
                var emote = new BiotaPropertiesEmote
                {
                    ObjectId      = result.Id,
                    Category      = value.Category,
                    Probability   = value.Probability,
                    WeenieClassId = value.WeenieClassId,
                    Style         = value.Style,
                    Substyle      = value.Substyle,
                    Quest         = value.Quest,
                    VendorType    = value.VendorType,
                    MinHealth     = value.MinHealth,
                    MaxHealth     = value.MaxHealth,
                };

                foreach (var value2 in value.WeeniePropertiesEmoteAction)
                {
                    var action = new BiotaPropertiesEmoteAction
                    {
                        // EmoteId is a foreign key to Emote.Id.
                        // If we don't set this to a non-zero number, EF will not auto-set this for us when we add this biota to the database.
                        // We set it to uint.MaxValue instead of 1 because 1 is more likely to be a valid foreign key. We don't want to enter a valid foreign key.
                        // We just want to enter a value that forces EF to update the record with the correct foreign key. If this behavior changes in the future and we set it to 1,
                        // we're more likely to run into an unnoticed issue (because 1 would not throw an exception and uint.MaxValue probably would).
                        // We put this here instead of in ShardDatabase for efficiency.
                        // It's possible this might be fixable with a attribute in the Emote or EmoteAction classes.
                        // It's also possible we don't have the schema defined in a way that helps scaffolding identify the relationship.
                        // Mag-nus 2018-08-04
                        EmoteId = uint.MaxValue,

                        Order           = value2.Order,
                        Type            = value2.Type,
                        Delay           = value2.Delay,
                        Extent          = value2.Extent,
                        Motion          = value2.Motion,
                        Message         = value2.Message,
                        TestString      = value2.TestString,
                        Min             = value2.Min,
                        Max             = value2.Max,
                        Min64           = value2.Min64,
                        Max64           = value2.Max64,
                        MinDbl          = value2.MinDbl,
                        MaxDbl          = value2.MaxDbl,
                        Stat            = value2.Stat,
                        Display         = value2.Display,
                        Amount          = value2.Amount,
                        Amount64        = value2.Amount64,
                        HeroXP64        = value2.HeroXP64,
                        Percent         = value2.Percent,
                        SpellId         = value2.SpellId,
                        WealthRating    = value2.WealthRating,
                        TreasureClass   = value2.TreasureClass,
                        TreasureType    = value2.TreasureType,
                        PScript         = value2.PScript,
                        Sound           = value2.Sound,
                        DestinationType = value2.DestinationType,
                        WeenieClassId   = value2.WeenieClassId,
                        StackSize       = value2.StackSize,
                        Palette         = value2.Palette,
                        Shade           = value2.Shade,
                        TryToBond       = value2.TryToBond,
                        ObjCellId       = value2.ObjCellId,
                        OriginX         = value2.OriginX,
                        OriginY         = value2.OriginY,
                        OriginZ         = value2.OriginZ,
                        AnglesW         = value2.AnglesW,
                        AnglesX         = value2.AnglesX,
                        AnglesY         = value2.AnglesY,
                        AnglesZ         = value2.AnglesZ,
                    };

                    emote.BiotaPropertiesEmoteAction.Add(action);
                }

                result.BiotaPropertiesEmote.Add(emote);
            }

            foreach (var value in weenie.WeeniePropertiesEventFilter)
            {
                result.BiotaPropertiesEventFilter.Add(new BiotaPropertiesEventFilter
                {
                    ObjectId = result.Id,
                    Event    = value.Event,
                });
            }

            foreach (var value in weenie.WeeniePropertiesGenerator)
            {
                result.BiotaPropertiesGenerator.Add(new BiotaPropertiesGenerator
                {
                    ObjectId      = result.Id,
                    Probability   = value.Probability,
                    WeenieClassId = value.WeenieClassId,
                    Delay         = value.Delay,
                    InitCreate    = value.InitCreate,
                    MaxCreate     = value.MaxCreate,
                    WhenCreate    = value.WhenCreate,
                    WhereCreate   = value.WhereCreate,
                    StackSize     = value.StackSize,
                    PaletteId     = value.PaletteId,
                    Shade         = value.Shade,
                    ObjCellId     = value.ObjCellId,
                    OriginX       = value.OriginX,
                    OriginY       = value.OriginY,
                    OriginZ       = value.OriginZ,
                    AnglesW       = value.AnglesW,
                    AnglesX       = value.AnglesX,
                    AnglesY       = value.AnglesY,
                    AnglesZ       = value.AnglesZ,
                });
            }


            // Properties for creatures

            foreach (var value in weenie.WeeniePropertiesAttribute)
            {
                result.BiotaPropertiesAttribute.Add(new BiotaPropertiesAttribute
                {
                    ObjectId    = result.Id,
                    Type        = value.Type,
                    InitLevel   = value.InitLevel,
                    LevelFromCP = value.LevelFromCP,
                    CPSpent     = value.CPSpent,
                });
            }

            foreach (var value in weenie.WeeniePropertiesAttribute2nd)
            {
                result.BiotaPropertiesAttribute2nd.Add(new BiotaPropertiesAttribute2nd
                {
                    ObjectId     = result.Id,
                    Type         = value.Type,
                    InitLevel    = value.InitLevel,
                    LevelFromCP  = value.LevelFromCP,
                    CPSpent      = value.CPSpent,
                    CurrentLevel = value.CurrentLevel,
                });
            }

            foreach (var value in weenie.WeeniePropertiesBodyPart)
            {
                result.BiotaPropertiesBodyPart.Add(new BiotaPropertiesBodyPart
                {
                    ObjectId        = result.Id,
                    Key             = value.Key,
                    DType           = value.DType,
                    DVal            = value.DVal,
                    DVar            = value.DVar,
                    BaseArmor       = value.BaseArmor,
                    ArmorVsSlash    = value.ArmorVsSlash,
                    ArmorVsPierce   = value.ArmorVsPierce,
                    ArmorVsBludgeon = value.ArmorVsBludgeon,
                    ArmorVsCold     = value.ArmorVsCold,
                    ArmorVsFire     = value.ArmorVsFire,
                    ArmorVsAcid     = value.ArmorVsAcid,
                    ArmorVsElectric = value.ArmorVsElectric,
                    ArmorVsNether   = value.ArmorVsNether,
                    BH  = value.BH,
                    HLF = value.HLF,
                    MLF = value.MLF,
                    LLF = value.LLF,
                    HRF = value.HRF,
                    MRF = value.MRF,
                    LRF = value.LRF,
                    HLB = value.HLB,
                    MLB = value.MLB,
                    LLB = value.LLB,
                    HRB = value.HRB,
                    MRB = value.MRB,
                    LRB = value.LRB,
                });
            }

            foreach (var value in weenie.WeeniePropertiesSkill)
            {
                result.BiotaPropertiesSkill.Add(new BiotaPropertiesSkill
                {
                    ObjectId              = result.Id,
                    Type                  = value.Type,
                    LevelFromPP           = value.LevelFromPP,
                    SAC                   = value.SAC,
                    PP                    = value.PP,
                    InitLevel             = value.InitLevel,
                    ResistanceAtLastCheck = value.ResistanceAtLastCheck,
                    LastUsedTime          = value.LastUsedTime,
                });
            }


            // Properties for books

            if (weenie.WeeniePropertiesBook != null)
            {
                result.BiotaPropertiesBook                    = new BiotaPropertiesBook();
                result.BiotaPropertiesBook.ObjectId           = result.Id;
                result.BiotaPropertiesBook.MaxNumPages        = weenie.WeeniePropertiesBook.MaxNumPages;
                result.BiotaPropertiesBook.MaxNumCharsPerPage = weenie.WeeniePropertiesBook.MaxNumCharsPerPage;
            }

            foreach (var value in weenie.WeeniePropertiesBookPageData)
            {
                result.BiotaPropertiesBookPageData.Add(new BiotaPropertiesBookPageData
                {
                    ObjectId      = result.Id,
                    PageId        = value.PageId,
                    AuthorId      = value.AuthorId,
                    AuthorName    = value.AuthorName,
                    AuthorAccount = value.AuthorAccount,
                    IgnoreAuthor  = value.IgnoreAuthor,
                    PageText      = value.PageText,
                });
            }

            return(result);
        }
コード例 #23
0
ファイル: WorldObjectFactory.cs プロジェクト: hooper82/ACE
        /// <summary>
        /// Restore a WorldObject from the database.
        /// Any properties tagged as Ephemeral will be removed from the biota.
        /// </summary>
        public static WorldObject CreateWorldObject(Biota biota)
        {
            var objWeenieType = (WeenieType)biota.WeenieType;

            switch (objWeenieType)
            {
            case WeenieType.Undef:
                return(null);

            case WeenieType.LifeStone:
                return(new Lifestone(biota));

            case WeenieType.Door:
                return(new Door(biota));

            case WeenieType.Portal:
                return(new Portal(biota));

            case WeenieType.Book:
                return(new Book(biota));

            case WeenieType.PKModifier:
                return(new PKModifier(biota));

            case WeenieType.Cow:
                return(new Cow(biota));

            case WeenieType.Creature:
                return(new Creature(biota));

            case WeenieType.Container:
                return(new Container(biota));

            case WeenieType.Scroll:
                return(new Scroll(biota));

            case WeenieType.Vendor:
                return(new Vendor(biota));

            case WeenieType.Coin:
                return(new Coin(biota));

            case WeenieType.Key:
                return(new Key(biota));

            case WeenieType.Food:
                return(new Food(biota));

            case WeenieType.Gem:
                return(new Gem(biota));

            case WeenieType.Game:
                return(new Game(biota));

            case WeenieType.GamePiece:
                return(new GamePiece(biota));

            case WeenieType.AllegianceBindstone:
                return(new Bindstone(biota));

            case WeenieType.Clothing:
                return(new Clothing(biota));

            case WeenieType.MeleeWeapon:
                return(new MeleeWeapon(biota));

            case WeenieType.MissileLauncher:
                return(new MissileLauncher(biota));

            case WeenieType.Ammunition:
                return(new Ammunition(biota));

            case WeenieType.Missile:
                return(new Missile(biota));

            case WeenieType.Corpse:
                return(new Corpse(biota));

            case WeenieType.Chest:
                return(new Chest(biota));

            case WeenieType.Stackable:
                return(new Stackable(biota));

            case WeenieType.SpellComponent:
                return(new SpellComponent(biota));

            case WeenieType.Switch:
                return(new Switch(biota));

            case WeenieType.AdvocateFane:
                return(new AdvocateFane(biota));

            case WeenieType.AdvocateItem:
                return(new AdvocateItem(biota));

            case WeenieType.Healer:
                return(new Healer(biota));

            case WeenieType.Lockpick:
                return(new Lockpick(biota));

            case WeenieType.Caster:
                return(new Caster(biota));

            case WeenieType.HotSpot:
                return(new Hotspot(biota));

            case WeenieType.ManaStone:
                return(new ManaStone(biota));

            case WeenieType.House:
                return(new House(biota));

            case WeenieType.SlumLord:
                return(new SlumLord(biota));

            case WeenieType.Storage:
                return(new Storage(biota));

            case WeenieType.Hook:
                return(new Hook(biota));

            case WeenieType.Hooker:
                return(new Hooker(biota));

            case WeenieType.HousePortal:
                return(new WorldObjects.HousePortal(biota));

            case WeenieType.SkillAlterationDevice:
                return(new SkillAlterationDevice(biota));

            case WeenieType.PressurePlate:
                return(new PressurePlate(biota));

            case WeenieType.PetDevice:
                return(new PetDevice(biota));

            case WeenieType.Pet:
                return(new Pet(biota));

            case WeenieType.CombatPet:
                return(new CombatPet(biota));

            case WeenieType.Allegiance:
                return(new Allegiance(biota));

            case WeenieType.AugmentationDevice:
                return(new AugmentationDevice(biota));

            case WeenieType.AttributeTransferDevice:
                return(new AttributeTransferDevice(biota));

            case WeenieType.CraftTool:
                return(new CraftTool(biota));

            case WeenieType.LightSource:
                return(new LightSource(biota));

            default:
                return(new GenericObject(biota));
            }
        }
コード例 #24
0
        // =====================================
        // Get
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static bool?GetProperty(this Biota biota, PropertyBool property)
        {
            return(biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property)?.Value);
        }
コード例 #25
0
 /// <summary>
 /// Restore a WorldObject from the database.
 /// </summary>
 public Book(Biota biota) : base(biota)
 {
     SetEphemeralValues();
 }
コード例 #26
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static uint?GetAnimationId(this Biota biota, byte index)
 {
     return(biota.BiotaPropertiesAnimPart.FirstOrDefault(x => x.Index == index)?.AnimationId);
 }
コード例 #27
0
        public static void UpdateDatabaseBiota(ShardDbContext context, ACE.Entity.Models.Biota sourceBiota, ACE.Database.Models.Shard.Biota targetBiota)
        {
            targetBiota.WeenieClassId = sourceBiota.WeenieClassId;
            targetBiota.WeenieType    = (int)sourceBiota.WeenieType;


            if (sourceBiota.PropertiesBool != null)
            {
                foreach (var kvp in sourceBiota.PropertiesBool)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesBool)
            {
                if (sourceBiota.PropertiesBool == null || !sourceBiota.PropertiesBool.ContainsKey((PropertyBool)value.Type))
                {
                    context.BiotaPropertiesBool.Remove(value);
                }
            }

            if (sourceBiota.PropertiesDID != null)
            {
                foreach (var kvp in sourceBiota.PropertiesDID)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesDID)
            {
                if (sourceBiota.PropertiesDID == null || !sourceBiota.PropertiesDID.ContainsKey((PropertyDataId)value.Type))
                {
                    context.BiotaPropertiesDID.Remove(value);
                }
            }

            if (sourceBiota.PropertiesFloat != null)
            {
                foreach (var kvp in sourceBiota.PropertiesFloat)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesFloat)
            {
                if (sourceBiota.PropertiesFloat == null || !sourceBiota.PropertiesFloat.ContainsKey((PropertyFloat)value.Type))
                {
                    context.BiotaPropertiesFloat.Remove(value);
                }
            }

            if (sourceBiota.PropertiesIID != null)
            {
                foreach (var kvp in sourceBiota.PropertiesIID)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesIID)
            {
                if (sourceBiota.PropertiesIID == null || !sourceBiota.PropertiesIID.ContainsKey((PropertyInstanceId)value.Type))
                {
                    context.BiotaPropertiesIID.Remove(value);
                }
            }

            if (sourceBiota.PropertiesInt != null)
            {
                foreach (var kvp in sourceBiota.PropertiesInt)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesInt)
            {
                if (sourceBiota.PropertiesInt == null || !sourceBiota.PropertiesInt.ContainsKey((PropertyInt)value.Type))
                {
                    context.BiotaPropertiesInt.Remove(value);
                }
            }

            if (sourceBiota.PropertiesInt64 != null)
            {
                foreach (var kvp in sourceBiota.PropertiesInt64)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesInt64)
            {
                if (sourceBiota.PropertiesInt64 == null || !sourceBiota.PropertiesInt64.ContainsKey((PropertyInt64)value.Type))
                {
                    context.BiotaPropertiesInt64.Remove(value);
                }
            }

            if (sourceBiota.PropertiesString != null)
            {
                foreach (var kvp in sourceBiota.PropertiesString)
                {
                    targetBiota.SetProperty(kvp.Key, kvp.Value);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesString)
            {
                if (sourceBiota.PropertiesString == null || !sourceBiota.PropertiesString.ContainsKey((PropertyString)value.Type))
                {
                    context.BiotaPropertiesString.Remove(value);
                }
            }


            if (sourceBiota.PropertiesPosition != null)
            {
                foreach (var kvp in sourceBiota.PropertiesPosition)
                {
                    BiotaPropertiesPosition existingValue = targetBiota.BiotaPropertiesPosition.FirstOrDefault(r => r.PositionType == (ushort)kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesPosition {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesPosition.Add(existingValue);
                    }

                    existingValue.PositionType = (ushort)kvp.Key;
                    existingValue.ObjCellId    = kvp.Value.ObjCellId;
                    existingValue.OriginX      = kvp.Value.PositionX;
                    existingValue.OriginY      = kvp.Value.PositionY;
                    existingValue.OriginZ      = kvp.Value.PositionZ;
                    existingValue.AnglesW      = kvp.Value.RotationW;
                    existingValue.AnglesX      = kvp.Value.RotationX;
                    existingValue.AnglesY      = kvp.Value.RotationY;
                    existingValue.AnglesZ      = kvp.Value.RotationZ;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesPosition)
            {
                if (sourceBiota.PropertiesPosition == null || !sourceBiota.PropertiesPosition.ContainsKey((PositionType)value.PositionType))
                {
                    context.BiotaPropertiesPosition.Remove(value);
                }
            }


            if (sourceBiota.PropertiesSpellBook != null)
            {
                foreach (var kvp in sourceBiota.PropertiesSpellBook)
                {
                    BiotaPropertiesSpellBook existingValue = targetBiota.BiotaPropertiesSpellBook.FirstOrDefault(r => r.Spell == (ushort)kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesSpellBook {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesSpellBook.Add(existingValue);
                    }

                    existingValue.Spell       = kvp.Key;
                    existingValue.Probability = kvp.Value;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesSpellBook)
            {
                if (sourceBiota.PropertiesSpellBook == null || !sourceBiota.PropertiesSpellBook.ContainsKey(value.Spell))
                {
                    context.BiotaPropertiesSpellBook.Remove(value);
                }
            }


            if (sourceBiota.PropertiesAnimPart != null)
            {
                for (int i = 0; i < sourceBiota.PropertiesAnimPart.Count; i++)
                {
                    var value = sourceBiota.PropertiesAnimPart[i];

                    BiotaPropertiesAnimPart existingValue = targetBiota.BiotaPropertiesAnimPart.FirstOrDefault(r => r.Order == i);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesAnimPart {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesAnimPart.Add(existingValue);
                    }

                    existingValue.Index       = value.Index;
                    existingValue.AnimationId = value.AnimationId;
                    existingValue.Order       = (byte)i;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesAnimPart)
            {
                if (sourceBiota.PropertiesAnimPart == null || value.Order == null || value.Order >= sourceBiota.PropertiesAnimPart.Count)
                {
                    context.BiotaPropertiesAnimPart.Remove(value);
                }
            }

            if (sourceBiota.PropertiesPalette != null)
            {
                foreach (var value in sourceBiota.PropertiesPalette)
                {
                    BiotaPropertiesPalette existingValue = targetBiota.BiotaPropertiesPalette.FirstOrDefault(r => r.SubPaletteId == value.SubPaletteId && r.Offset == value.Offset && r.Length == value.Length);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesPalette {
                            ObjectId = sourceBiota.Id, SubPaletteId = value.SubPaletteId, Offset = value.Offset, Length = value.Length
                        };

                        targetBiota.BiotaPropertiesPalette.Add(existingValue);
                    }
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesPalette)
            {
                if (sourceBiota.PropertiesPalette == null || !sourceBiota.PropertiesPalette.Any(p => p.SubPaletteId == value.SubPaletteId && p.Offset == value.Offset && p.Length == value.Length))
                {
                    context.BiotaPropertiesPalette.Remove(value);
                }
            }

            if (sourceBiota.PropertiesTextureMap != null)
            {
                for (int i = 0; i < sourceBiota.PropertiesTextureMap.Count; i++)
                {
                    var value = sourceBiota.PropertiesTextureMap[i];

                    BiotaPropertiesTextureMap existingValue = targetBiota.BiotaPropertiesTextureMap.FirstOrDefault(r => r.Order == i);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesTextureMap {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesTextureMap.Add(existingValue);
                    }

                    existingValue.Index = value.PartIndex;
                    existingValue.OldId = value.OldTexture;
                    existingValue.NewId = value.NewTexture;
                    existingValue.Order = (byte)i;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesTextureMap)
            {
                if (sourceBiota.PropertiesTextureMap == null || value.Order == null || value.Order >= sourceBiota.PropertiesTextureMap.Count)
                {
                    context.BiotaPropertiesTextureMap.Remove(value);
                }
            }


            // Properties for all world objects that typically aren't modified over the original Biota

            // This is a cluster... because there is no key per record, just the record id.
            // That poses a problem because when we add a new record to be saved, we don't know what the record id is yet.
            // It's not until we try to save the record a second time that we will then have the database persisted record (with a valid id), and the entity record (that still has a DatabaseRecordId of 0)
            // We then need to match up the record that was saved with it's entity counterpart
            var processedSourceCreateList = new HashSet <ACE.Entity.Models.PropertiesCreateList>();
            var usedTargetCreateList      = new HashSet <BiotaPropertiesCreateList>();

            if (sourceBiota.PropertiesCreateList != null)
            {
                // Process matched up records first
                foreach (var value in sourceBiota.PropertiesCreateList)
                {
                    if (value.DatabaseRecordId == 0)
                    {
                        continue;
                    }

                    // Source record should already exist in the target
                    BiotaPropertiesCreateList existingValue = targetBiota.BiotaPropertiesCreateList.FirstOrDefault(r => r.Id == value.DatabaseRecordId);

                    // If the existingValue was not found, the database was likely modified outside of ACE after our last save
                    if (existingValue == null)
                    {
                        continue;
                    }

                    CopyValueInto(value, existingValue);

                    processedSourceCreateList.Add(value);
                    usedTargetCreateList.Add(existingValue);
                }
                foreach (var value in sourceBiota.PropertiesCreateList)
                {
                    if (processedSourceCreateList.Contains(value))
                    {
                        continue;
                    }

                    // For simplicity, just find the first unused target
                    BiotaPropertiesCreateList existingValue = targetBiota.BiotaPropertiesCreateList.FirstOrDefault(r => !usedTargetCreateList.Contains(r));

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesCreateList {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesCreateList.Add(existingValue);
                    }

                    value.DatabaseRecordId = existingValue.Id;

                    CopyValueInto(value, existingValue);

                    //processedSourceCreateList.Add(value);
                    usedTargetCreateList.Add(existingValue);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesCreateList)
            {
                if (!usedTargetCreateList.Contains(value))
                {
                    context.BiotaPropertiesCreateList.Remove(value);
                }
            }

            // This is a cluster... because there is no key per record, just the record id.
            // That poses a problem because when we add a new record to be saved, we don't know what the record id is yet.
            // It's not until we try to save the record a second time that we will then have the database persisted record (with a valid id), and the entity record (that still has a DatabaseRecordId of 0)
            // We then need to match up the record that was saved with it's entity counterpart
            var emoteMap = new Dictionary <ACE.Entity.Models.PropertiesEmote, BiotaPropertiesEmote>();

            if (sourceBiota.PropertiesEmote != null)
            {
                // Process matched up records first
                foreach (var value in sourceBiota.PropertiesEmote)
                {
                    if (value.DatabaseRecordId == 0)
                    {
                        continue;
                    }

                    // Source record should already exist in the target
                    BiotaPropertiesEmote existingValue = targetBiota.BiotaPropertiesEmote.FirstOrDefault(r => r.Id == value.DatabaseRecordId);

                    // If the existingValue was not found, the database was likely modified outside of ACE after our last save
                    if (existingValue == null)
                    {
                        continue;
                    }

                    CopyValueInto(value, existingValue);

                    emoteMap[value] = existingValue;
                }
                foreach (var value in sourceBiota.PropertiesEmote)
                {
                    if (emoteMap.Keys.Contains(value))
                    {
                        continue;
                    }

                    // For simplicity, just find the first unused target
                    BiotaPropertiesEmote existingValue = targetBiota.BiotaPropertiesEmote.FirstOrDefault(r => !emoteMap.Values.Contains(r));

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesEmote {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesEmote.Add(existingValue);
                    }

                    value.DatabaseRecordId = existingValue.Id;

                    CopyValueInto(value, existingValue);

                    emoteMap[value] = existingValue;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesEmote)
            {
                if (!emoteMap.Values.Contains(value))
                {
                    context.BiotaPropertiesEmote.Remove(value);
                }
            }
            // Now process the emote actions
            foreach (var kvp in emoteMap)
            {
                for (int i = 0; i < kvp.Key.PropertiesEmoteAction.Count; i++)
                {
                    BiotaPropertiesEmoteAction existingValue = kvp.Value.BiotaPropertiesEmoteAction.FirstOrDefault(r => r.Order == i);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesEmoteAction {
                            EmoteId = kvp.Value.Id
                        };

                        kvp.Value.BiotaPropertiesEmoteAction.Add(existingValue);
                    }

                    CopyValueInto(kvp.Key.PropertiesEmoteAction[i], existingValue, (uint)i);
                }
                foreach (var value in kvp.Value.BiotaPropertiesEmoteAction)
                {
                    if (value.Order >= kvp.Key.PropertiesEmoteAction.Count)
                    {
                        context.BiotaPropertiesEmoteAction.Remove(value);
                    }
                }
            }

            if (sourceBiota.PropertiesEventFilter != null)
            {
                foreach (var value in sourceBiota.PropertiesEventFilter)
                {
                    BiotaPropertiesEventFilter existingValue = targetBiota.BiotaPropertiesEventFilter.FirstOrDefault(r => r.Event == value);

                    if (existingValue == null)
                    {
                        var entity = new BiotaPropertiesEventFilter {
                            ObjectId = sourceBiota.Id, Event = value
                        };

                        targetBiota.BiotaPropertiesEventFilter.Add(entity);
                    }
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesEventFilter)
            {
                if (sourceBiota.PropertiesEventFilter == null || !sourceBiota.PropertiesEventFilter.Any(p => p == value.Event))
                {
                    context.BiotaPropertiesEventFilter.Remove(value);
                }
            }

            // This is a cluster... because there is no key per record, just the record id.
            // That poses a problem because when we add a new record to be saved, we don't know what the record id is yet.
            // It's not until we try to save the record a second time that we will then have the database persisted record (with a valid id), and the entity record (that still has a DatabaseRecordId of 0)
            // We then need to match up the record that was saved with it's entity counterpart
            var processedSourceGenerators = new HashSet <ACE.Entity.Models.PropertiesGenerator>();
            var usedTargetGenerators      = new HashSet <BiotaPropertiesGenerator>();

            if (sourceBiota.PropertiesGenerator != null)
            {
                // Process matched up records first
                foreach (var value in sourceBiota.PropertiesGenerator)
                {
                    if (value.DatabaseRecordId == 0)
                    {
                        continue;
                    }

                    // Source record should already exist in the target
                    BiotaPropertiesGenerator existingValue = targetBiota.BiotaPropertiesGenerator.FirstOrDefault(r => r.Id == value.DatabaseRecordId);

                    // If the existingValue was not found, the database was likely modified outside of ACE after our last save
                    if (existingValue == null)
                    {
                        continue;
                    }

                    CopyValueInto(value, existingValue);

                    processedSourceGenerators.Add(value);
                    usedTargetGenerators.Add(existingValue);
                }
                foreach (var value in sourceBiota.PropertiesGenerator)
                {
                    if (processedSourceGenerators.Contains(value))
                    {
                        continue;
                    }

                    // For simplicity, just find the first unused target
                    BiotaPropertiesGenerator existingValue = targetBiota.BiotaPropertiesGenerator.FirstOrDefault(r => !usedTargetGenerators.Contains(r));

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesGenerator {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesGenerator.Add(existingValue);
                    }

                    value.DatabaseRecordId = existingValue.Id;

                    CopyValueInto(value, existingValue);

                    //processedSourceGenerators.Add(value);
                    usedTargetGenerators.Add(existingValue);
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesGenerator)
            {
                if (!usedTargetGenerators.Contains(value))
                {
                    context.BiotaPropertiesGenerator.Remove(value);
                }
            }


            // Properties for creatures

            if (sourceBiota.PropertiesAttribute != null)
            {
                foreach (var kvp in sourceBiota.PropertiesAttribute)
                {
                    BiotaPropertiesAttribute existingValue = targetBiota.BiotaPropertiesAttribute.FirstOrDefault(r => r.Type == (ushort)kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesAttribute {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesAttribute.Add(existingValue);
                    }

                    existingValue.Type        = (ushort)kvp.Key;
                    existingValue.InitLevel   = kvp.Value.InitLevel;
                    existingValue.LevelFromCP = kvp.Value.LevelFromCP;
                    existingValue.CPSpent     = kvp.Value.CPSpent;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesAttribute)
            {
                if (sourceBiota.PropertiesAttribute == null || !sourceBiota.PropertiesAttribute.ContainsKey((PropertyAttribute)value.Type))
                {
                    context.BiotaPropertiesAttribute.Remove(value);
                }
            }

            if (sourceBiota.PropertiesAttribute2nd != null)
            {
                foreach (var kvp in sourceBiota.PropertiesAttribute2nd)
                {
                    BiotaPropertiesAttribute2nd existingValue = targetBiota.BiotaPropertiesAttribute2nd.FirstOrDefault(r => r.Type == (ushort)kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesAttribute2nd {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesAttribute2nd.Add(existingValue);
                    }

                    existingValue.Type         = (ushort)kvp.Key;
                    existingValue.InitLevel    = kvp.Value.InitLevel;
                    existingValue.LevelFromCP  = kvp.Value.LevelFromCP;
                    existingValue.CPSpent      = kvp.Value.CPSpent;
                    existingValue.CurrentLevel = kvp.Value.CurrentLevel;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesAttribute2nd)
            {
                if (sourceBiota.PropertiesAttribute2nd == null || !sourceBiota.PropertiesAttribute2nd.ContainsKey((PropertyAttribute2nd)value.Type))
                {
                    context.BiotaPropertiesAttribute2nd.Remove(value);
                }
            }

            if (sourceBiota.PropertiesBodyPart != null)
            {
                foreach (var kvp in sourceBiota.PropertiesBodyPart)
                {
                    BiotaPropertiesBodyPart existingValue = targetBiota.BiotaPropertiesBodyPart.FirstOrDefault(r => r.Key == (uint)kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesBodyPart {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesBodyPart.Add(existingValue);
                    }

                    existingValue.Key             = (ushort)kvp.Key;
                    existingValue.DType           = (int)kvp.Value.DType;
                    existingValue.DVal            = kvp.Value.DVal;
                    existingValue.DVar            = kvp.Value.DVar;
                    existingValue.BaseArmor       = kvp.Value.BaseArmor;
                    existingValue.ArmorVsSlash    = kvp.Value.ArmorVsSlash;
                    existingValue.ArmorVsPierce   = kvp.Value.ArmorVsPierce;
                    existingValue.ArmorVsBludgeon = kvp.Value.ArmorVsBludgeon;
                    existingValue.ArmorVsCold     = kvp.Value.ArmorVsCold;
                    existingValue.ArmorVsFire     = kvp.Value.ArmorVsFire;
                    existingValue.ArmorVsAcid     = kvp.Value.ArmorVsAcid;
                    existingValue.ArmorVsElectric = kvp.Value.ArmorVsElectric;
                    existingValue.ArmorVsNether   = kvp.Value.ArmorVsNether;
                    existingValue.BH  = kvp.Value.BH;
                    existingValue.HLF = kvp.Value.HLF;
                    existingValue.MLF = kvp.Value.MLF;
                    existingValue.LLF = kvp.Value.LLF;
                    existingValue.HRF = kvp.Value.HRF;
                    existingValue.MRF = kvp.Value.MRF;
                    existingValue.LRF = kvp.Value.LRF;
                    existingValue.HLB = kvp.Value.HLB;
                    existingValue.MLB = kvp.Value.MLB;
                    existingValue.LLB = kvp.Value.LLB;
                    existingValue.HRB = kvp.Value.HRB;
                    existingValue.MRB = kvp.Value.MRB;
                    existingValue.LRB = kvp.Value.LRB;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesBodyPart)
            {
                if (sourceBiota.PropertiesBodyPart == null || !sourceBiota.PropertiesBodyPart.ContainsKey((CombatBodyPart)value.Key))
                {
                    context.BiotaPropertiesBodyPart.Remove(value);
                }
            }

            if (sourceBiota.PropertiesSkill != null)
            {
                foreach (var kvp in sourceBiota.PropertiesSkill)
                {
                    BiotaPropertiesSkill existingValue = targetBiota.BiotaPropertiesSkill.FirstOrDefault(r => r.Type == (ushort)kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesSkill {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesSkill.Add(existingValue);
                    }

                    existingValue.Type                  = (ushort)kvp.Key;
                    existingValue.LevelFromPP           = kvp.Value.LevelFromPP;
                    existingValue.SAC                   = (uint)kvp.Value.SAC;
                    existingValue.PP                    = kvp.Value.PP;
                    existingValue.InitLevel             = kvp.Value.InitLevel;
                    existingValue.ResistanceAtLastCheck = kvp.Value.ResistanceAtLastCheck;
                    existingValue.LastUsedTime          = kvp.Value.LastUsedTime;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesSkill)
            {
                if (sourceBiota.PropertiesSkill == null || !sourceBiota.PropertiesSkill.ContainsKey((Skill)value.Type))
                {
                    context.BiotaPropertiesSkill.Remove(value);
                }
            }


            // Properties for books

            if (sourceBiota.PropertiesBook != null)
            {
                if (targetBiota.BiotaPropertiesBook == null)
                {
                    targetBiota.BiotaPropertiesBook = new BiotaPropertiesBook {
                        ObjectId = sourceBiota.Id,
                    }
                }
                ;

                targetBiota.BiotaPropertiesBook.MaxNumPages        = sourceBiota.PropertiesBook.MaxNumPages;
                targetBiota.BiotaPropertiesBook.MaxNumCharsPerPage = sourceBiota.PropertiesBook.MaxNumCharsPerPage;
            }
            else
            {
                if (targetBiota.BiotaPropertiesBook != null)
                {
                    context.BiotaPropertiesBook.Remove(targetBiota.BiotaPropertiesBook);
                }
            }

            if (sourceBiota.PropertiesBookPageData != null)
            {
                for (int i = 0; i < sourceBiota.PropertiesBookPageData.Count; i++)
                {
                    var value = sourceBiota.PropertiesBookPageData[i];

                    BiotaPropertiesBookPageData existingValue = targetBiota.BiotaPropertiesBookPageData.FirstOrDefault(r => r.PageId == i);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesBookPageData {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesBookPageData.Add(existingValue);
                    }

                    existingValue.PageId        = (uint)i;
                    existingValue.AuthorId      = value.AuthorId;
                    existingValue.AuthorName    = value.AuthorName;
                    existingValue.AuthorAccount = value.AuthorAccount;
                    existingValue.IgnoreAuthor  = value.IgnoreAuthor;
                    existingValue.PageText      = value.PageText;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesBookPageData)
            {
                if (sourceBiota.PropertiesBookPageData == null || value.PageId >= sourceBiota.PropertiesBookPageData.Count)
                {
                    context.BiotaPropertiesBookPageData.Remove(value);
                }
            }


            // Biota additions over Weenie

            if (sourceBiota.PropertiesAllegiance != null)
            {
                foreach (var kvp in sourceBiota.PropertiesAllegiance)
                {
                    BiotaPropertiesAllegiance existingValue = targetBiota.BiotaPropertiesAllegiance.FirstOrDefault(r => r.CharacterId == kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesAllegiance {
                            AllegianceId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesAllegiance.Add(existingValue);
                    }

                    existingValue.CharacterId    = kvp.Key;
                    existingValue.Banned         = kvp.Value.Banned;
                    existingValue.ApprovedVassal = kvp.Value.ApprovedVassal;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesAllegiance)
            {
                if (sourceBiota.PropertiesAllegiance == null || !sourceBiota.PropertiesAllegiance.ContainsKey(value.CharacterId))
                {
                    context.BiotaPropertiesAllegiance.Remove(value);
                }
            }

            if (sourceBiota.PropertiesEnchantmentRegistry != null)
            {
                foreach (var value in sourceBiota.PropertiesEnchantmentRegistry)
                {
                    BiotaPropertiesEnchantmentRegistry existingValue = targetBiota.BiotaPropertiesEnchantmentRegistry.FirstOrDefault(r => r.SpellId == value.SpellId && r.LayerId == value.LayerId && r.CasterObjectId == value.CasterObjectId);

                    if (existingValue == null)
                    {
                        existingValue = new BiotaPropertiesEnchantmentRegistry {
                            ObjectId = sourceBiota.Id
                        };

                        targetBiota.BiotaPropertiesEnchantmentRegistry.Add(existingValue);
                    }

                    existingValue.EnchantmentCategory = value.EnchantmentCategory;
                    existingValue.SpellId             = value.SpellId;
                    existingValue.LayerId             = value.LayerId;
                    existingValue.HasSpellSetId       = value.HasSpellSetId;
                    existingValue.SpellCategory       = (ushort)value.SpellCategory;
                    existingValue.PowerLevel          = value.PowerLevel;
                    existingValue.StartTime           = value.StartTime;
                    existingValue.Duration            = value.Duration;
                    existingValue.CasterObjectId      = value.CasterObjectId;
                    existingValue.DegradeModifier     = value.DegradeModifier;
                    existingValue.DegradeLimit        = value.DegradeLimit;
                    existingValue.LastTimeDegraded    = value.LastTimeDegraded;
                    existingValue.StatModType         = (uint)value.StatModType;
                    existingValue.StatModKey          = value.StatModKey;
                    existingValue.StatModValue        = value.StatModValue;
                    existingValue.SpellSetId          = (uint)value.SpellSetId;
                }
            }
            foreach (var value in targetBiota.BiotaPropertiesEnchantmentRegistry)
            {
                if (sourceBiota.PropertiesEnchantmentRegistry == null || !sourceBiota.PropertiesEnchantmentRegistry.Any(p => p.SpellId == value.SpellId && p.LayerId == value.LayerId && p.CasterObjectId == value.CasterObjectId))
                {
                    context.BiotaPropertiesEnchantmentRegistry.Remove(value);
                }
            }

            if (sourceBiota.HousePermissions != null)
            {
                foreach (var kvp in sourceBiota.HousePermissions)
                {
                    HousePermission existingValue = targetBiota.HousePermission.FirstOrDefault(r => r.PlayerGuid == kvp.Key);

                    if (existingValue == null)
                    {
                        existingValue = new HousePermission {
                            HouseId = sourceBiota.Id
                        };

                        targetBiota.HousePermission.Add(existingValue);
                    }

                    existingValue.PlayerGuid = kvp.Key;
                    existingValue.Storage    = kvp.Value;
                }
            }
            foreach (var value in targetBiota.HousePermission)
            {
                if (sourceBiota.HousePermissions == null || !sourceBiota.HousePermissions.ContainsKey(value.PlayerGuid))
                {
                    context.HousePermission.Remove(value);
                }
            }
        }
コード例 #28
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static BiotaPropertiesSkill GetProperty(this Biota biota, Skill skill)
 {
     return(biota.BiotaPropertiesSkill.FirstOrDefault(x => x.Type == (uint)skill));
 }
コード例 #29
0
        public static ACE.Database.Models.Shard.Biota ConvertFromEntityBiota(ACE.Entity.Models.Biota biota, bool includeDatabaseRecordIds = false)
        {
            var result = new ACE.Database.Models.Shard.Biota();

            result.Id            = biota.Id;
            result.WeenieClassId = biota.WeenieClassId;
            result.WeenieType    = (int)biota.WeenieType;


            if (biota.PropertiesBool != null)
            {
                foreach (var kvp in biota.PropertiesBool)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }
            if (biota.PropertiesDID != null)
            {
                foreach (var kvp in biota.PropertiesDID)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }
            if (biota.PropertiesFloat != null)
            {
                foreach (var kvp in biota.PropertiesFloat)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }
            if (biota.PropertiesIID != null)
            {
                foreach (var kvp in biota.PropertiesIID)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }
            if (biota.PropertiesInt != null)
            {
                foreach (var kvp in biota.PropertiesInt)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }
            if (biota.PropertiesInt64 != null)
            {
                foreach (var kvp in biota.PropertiesInt64)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }
            if (biota.PropertiesString != null)
            {
                foreach (var kvp in biota.PropertiesString)
                {
                    result.SetProperty(kvp.Key, kvp.Value);
                }
            }


            if (biota.PropertiesPosition != null)
            {
                foreach (var kvp in biota.PropertiesPosition)
                {
                    var entity = new BiotaPropertiesPosition {
                        ObjectId = biota.Id, PositionType = (ushort)kvp.Key, ObjCellId = kvp.Value.ObjCellId, OriginX = kvp.Value.PositionX, OriginY = kvp.Value.PositionY, OriginZ = kvp.Value.PositionZ, AnglesW = kvp.Value.RotationW, AnglesX = kvp.Value.RotationX, AnglesY = kvp.Value.RotationY, AnglesZ = kvp.Value.RotationZ
                    };

                    result.BiotaPropertiesPosition.Add(entity);
                }
            }


            if (biota.PropertiesSpellBook != null)
            {
                foreach (var kvp in biota.PropertiesSpellBook)
                {
                    var entity = new BiotaPropertiesSpellBook {
                        ObjectId = biota.Id, Spell = kvp.Key, Probability = kvp.Value
                    };

                    result.BiotaPropertiesSpellBook.Add(entity);
                }
            }


            if (biota.PropertiesAnimPart != null)
            {
                for (int i = 0; i < biota.PropertiesAnimPart.Count; i++)
                {
                    var value = biota.PropertiesAnimPart[i];

                    var entity = new BiotaPropertiesAnimPart {
                        ObjectId = biota.Id, Index = value.Index, AnimationId = value.AnimationId, Order = (byte)i
                    };

                    result.BiotaPropertiesAnimPart.Add(entity);
                }
            }

            if (biota.PropertiesPalette != null)
            {
                for (int i = 0; i < biota.PropertiesPalette.Count; i++)
                {
                    var value = biota.PropertiesPalette[i];

                    var entity = new BiotaPropertiesPalette {
                        ObjectId = biota.Id, SubPaletteId = value.SubPaletteId, Offset = value.Offset, Length = value.Length, Order = (byte)i
                    };

                    result.BiotaPropertiesPalette.Add(entity);
                }
            }

            if (biota.PropertiesTextureMap != null)
            {
                for (int i = 0; i < biota.PropertiesTextureMap.Count; i++)
                {
                    var value = biota.PropertiesTextureMap[i];

                    var entity = new BiotaPropertiesTextureMap {
                        ObjectId = biota.Id, Index = value.PartIndex, OldId = value.OldTexture, NewId = value.NewTexture, Order = (byte)i
                    };

                    result.BiotaPropertiesTextureMap.Add(entity);
                }
            }


            // Properties for all world objects that typically aren't modified over the original weenie

            if (biota.PropertiesCreateList != null)
            {
                foreach (var value in biota.PropertiesCreateList)
                {
                    var entity = new BiotaPropertiesCreateList
                    {
                        ObjectId        = biota.Id,
                        DestinationType = (sbyte)value.DestinationType,
                        WeenieClassId   = value.WeenieClassId,
                        StackSize       = value.StackSize,
                        Palette         = value.Palette,
                        Shade           = value.Shade,
                        TryToBond       = value.TryToBond
                    };

                    if (includeDatabaseRecordIds)
                    {
                        entity.Id = value.DatabaseRecordId;
                    }

                    result.BiotaPropertiesCreateList.Add(entity);
                }
            }

            if (biota.PropertiesEmote != null)
            {
                foreach (var value in biota.PropertiesEmote)
                {
                    var entity = new BiotaPropertiesEmote
                    {
                        ObjectId      = biota.Id,
                        Category      = (uint)value.Category,
                        Probability   = value.Probability,
                        WeenieClassId = value.WeenieClassId,
                        Style         = (uint?)value.Style,
                        Substyle      = (uint?)value.Substyle,
                        Quest         = value.Quest,
                        VendorType    = (int?)value.VendorType,
                        MinHealth     = value.MinHealth,
                        MaxHealth     = value.MaxHealth,
                    };

                    if (includeDatabaseRecordIds)
                    {
                        entity.Id = value.DatabaseRecordId;
                    }

                    foreach (var value2 in value.PropertiesEmoteAction)
                    {
                        var entity2 = new BiotaPropertiesEmoteAction
                        {
                            // EmoteId is a foreign key to Emote.Id.
                            // If we don't set this to a non-zero number, EF will not auto-set this for us when we add this biota to the database.
                            // We set it to uint.MaxValue instead of 1 because 1 is more likely to be a valid foreign key. We don't want to enter a valid foreign key.
                            // We just want to enter a value that forces EF to update the record with the correct foreign key. If this behavior changes in the future and we set it to 1,
                            // we're more likely to run into an unnoticed issue (because 1 would not throw an exception and uint.MaxValue probably would).
                            // We put this here instead of in ShardDatabase for efficiency.
                            // It's possible this might be fixable with a attribute in the Emote or EmoteAction classes.
                            // It's also possible we don't have the schema defined in a way that helps scaffolding identify the relationship.
                            // Mag-nus 2018-08-04
                            EmoteId = uint.MaxValue,

                            Order           = (uint)value.PropertiesEmoteAction.IndexOf(value2),
                            Type            = value2.Type,
                            Delay           = value2.Delay,
                            Extent          = value2.Extent,
                            Motion          = (uint?)value2.Motion,
                            Message         = value2.Message,
                            TestString      = value2.TestString,
                            Min             = value2.Min,
                            Max             = value2.Max,
                            Min64           = value2.Min64,
                            Max64           = value2.Max64,
                            MinDbl          = value2.MinDbl,
                            MaxDbl          = value2.MaxDbl,
                            Stat            = value2.Stat,
                            Display         = value2.Display,
                            Amount          = value2.Amount,
                            Amount64        = value2.Amount64,
                            HeroXP64        = value2.HeroXP64,
                            Percent         = value2.Percent,
                            SpellId         = value2.SpellId,
                            WealthRating    = value2.WealthRating,
                            TreasureClass   = value2.TreasureClass,
                            TreasureType    = value2.TreasureType,
                            PScript         = (int?)value2.PScript,
                            Sound           = (int?)value2.Sound,
                            DestinationType = value2.DestinationType,
                            WeenieClassId   = value2.WeenieClassId,
                            StackSize       = value2.StackSize,
                            Palette         = value2.Palette,
                            Shade           = value2.Shade,
                            TryToBond       = value2.TryToBond,
                            ObjCellId       = value2.ObjCellId,
                            OriginX         = value2.OriginX,
                            OriginY         = value2.OriginY,
                            OriginZ         = value2.OriginZ,
                            AnglesW         = value2.AnglesW,
                            AnglesX         = value2.AnglesX,
                            AnglesY         = value2.AnglesY,
                            AnglesZ         = value2.AnglesZ,
                        };

                        if (includeDatabaseRecordIds)
                        {
                            entity2.Id = value2.DatabaseRecordId;
                        }

                        entity.BiotaPropertiesEmoteAction.Add(entity2);
                    }

                    result.BiotaPropertiesEmote.Add(entity);
                }
            }

            if (biota.PropertiesEventFilter != null)
            {
                foreach (var value in biota.PropertiesEventFilter)
                {
                    var entity = new BiotaPropertiesEventFilter {
                        ObjectId = biota.Id, Event = value
                    };

                    result.BiotaPropertiesEventFilter.Add(entity);
                }
            }

            if (biota.PropertiesGenerator != null)
            {
                foreach (var value in biota.PropertiesGenerator)
                {
                    var entity = new BiotaPropertiesGenerator
                    {
                        ObjectId      = biota.Id,
                        Probability   = value.Probability,
                        WeenieClassId = value.WeenieClassId,
                        Delay         = value.Delay,
                        InitCreate    = value.InitCreate,
                        MaxCreate     = value.MaxCreate,
                        WhenCreate    = (uint)value.WhenCreate,
                        WhereCreate   = (uint)value.WhereCreate,
                        StackSize     = value.StackSize,
                        PaletteId     = value.PaletteId,
                        Shade         = value.Shade,
                        ObjCellId     = value.ObjCellId,
                        OriginX       = value.OriginX,
                        OriginY       = value.OriginY,
                        OriginZ       = value.OriginZ,
                        AnglesW       = value.AnglesW,
                        AnglesX       = value.AnglesX,
                        AnglesY       = value.AnglesY,
                        AnglesZ       = value.AnglesZ,
                    };

                    if (includeDatabaseRecordIds)
                    {
                        entity.Id = value.DatabaseRecordId;
                    }

                    result.BiotaPropertiesGenerator.Add(entity);
                }
            }


            // Properties for creatures

            if (biota.PropertiesAttribute != null)
            {
                foreach (var kvp in biota.PropertiesAttribute)
                {
                    var entity = new BiotaPropertiesAttribute {
                        ObjectId = biota.Id, Type = (ushort)kvp.Key, InitLevel = kvp.Value.InitLevel, LevelFromCP = kvp.Value.LevelFromCP, CPSpent = kvp.Value.CPSpent
                    };

                    result.BiotaPropertiesAttribute.Add(entity);
                }
            }

            if (biota.PropertiesAttribute2nd != null)
            {
                foreach (var kvp in biota.PropertiesAttribute2nd)
                {
                    var entity = new BiotaPropertiesAttribute2nd {
                        ObjectId = biota.Id, Type = (ushort)kvp.Key, InitLevel = kvp.Value.InitLevel, LevelFromCP = kvp.Value.LevelFromCP, CPSpent = kvp.Value.CPSpent, CurrentLevel = kvp.Value.CurrentLevel
                    };

                    result.BiotaPropertiesAttribute2nd.Add(entity);
                }
            }

            if (biota.PropertiesBodyPart != null)
            {
                foreach (var kvp in biota.PropertiesBodyPart)
                {
                    var entity = new BiotaPropertiesBodyPart
                    {
                        ObjectId        = biota.Id,
                        Key             = (ushort)kvp.Key,
                        DType           = (int)kvp.Value.DType,
                        DVal            = kvp.Value.DVal,
                        DVar            = kvp.Value.DVar,
                        BaseArmor       = kvp.Value.BaseArmor,
                        ArmorVsSlash    = kvp.Value.ArmorVsSlash,
                        ArmorVsPierce   = kvp.Value.ArmorVsPierce,
                        ArmorVsBludgeon = kvp.Value.ArmorVsBludgeon,
                        ArmorVsCold     = kvp.Value.ArmorVsCold,
                        ArmorVsFire     = kvp.Value.ArmorVsFire,
                        ArmorVsAcid     = kvp.Value.ArmorVsAcid,
                        ArmorVsElectric = kvp.Value.ArmorVsElectric,
                        ArmorVsNether   = kvp.Value.ArmorVsNether,
                        BH  = kvp.Value.BH,
                        HLF = kvp.Value.HLF,
                        MLF = kvp.Value.MLF,
                        LLF = kvp.Value.LLF,
                        HRF = kvp.Value.HRF,
                        MRF = kvp.Value.MRF,
                        LRF = kvp.Value.LRF,
                        HLB = kvp.Value.HLB,
                        MLB = kvp.Value.MLB,
                        LLB = kvp.Value.LLB,
                        HRB = kvp.Value.HRB,
                        MRB = kvp.Value.MRB,
                        LRB = kvp.Value.LRB,
                    };

                    result.BiotaPropertiesBodyPart.Add(entity);
                }
            }

            if (biota.PropertiesSkill != null)
            {
                foreach (var kvp in biota.PropertiesSkill)
                {
                    var entity = new BiotaPropertiesSkill
                    {
                        ObjectId              = biota.Id,
                        Type                  = (ushort)kvp.Key,
                        LevelFromPP           = kvp.Value.LevelFromPP,
                        SAC                   = (uint)kvp.Value.SAC,
                        PP                    = kvp.Value.PP,
                        InitLevel             = kvp.Value.InitLevel,
                        ResistanceAtLastCheck = kvp.Value.ResistanceAtLastCheck,
                        LastUsedTime          = kvp.Value.LastUsedTime,
                    };

                    result.BiotaPropertiesSkill.Add(entity);
                }
            }


            // Properties for books

            if (biota.PropertiesBook != null)
            {
                result.BiotaPropertiesBook = new BiotaPropertiesBook
                {
                    ObjectId           = biota.Id,
                    MaxNumPages        = biota.PropertiesBook.MaxNumPages,
                    MaxNumCharsPerPage = biota.PropertiesBook.MaxNumCharsPerPage
                };
            }

            if (biota.PropertiesBookPageData != null)
            {
                foreach (var value in biota.PropertiesBookPageData)
                {
                    var entity = new BiotaPropertiesBookPageData
                    {
                        ObjectId      = biota.Id,
                        PageId        = (uint)biota.PropertiesBookPageData.IndexOf(value),
                        AuthorId      = value.AuthorId,
                        AuthorName    = value.AuthorName,
                        AuthorAccount = value.AuthorAccount,
                        IgnoreAuthor  = value.IgnoreAuthor,
                        PageText      = value.PageText
                    };

                    result.BiotaPropertiesBookPageData.Add(entity);
                }
            }



            // Biota additions over Weenie

            if (biota.PropertiesAllegiance != null)
            {
                foreach (var kvp in biota.PropertiesAllegiance)
                {
                    var entity = new BiotaPropertiesAllegiance {
                        AllegianceId = biota.Id, CharacterId = kvp.Key, Banned = kvp.Value.Banned, ApprovedVassal = kvp.Value.ApprovedVassal
                    };

                    result.BiotaPropertiesAllegiance.Add(entity);
                }
            }

            if (biota.PropertiesEnchantmentRegistry != null)
            {
                foreach (var value in biota.PropertiesEnchantmentRegistry)
                {
                    var entity = new BiotaPropertiesEnchantmentRegistry
                    {
                        ObjectId            = biota.Id,
                        EnchantmentCategory = value.EnchantmentCategory,
                        SpellId             = value.SpellId,
                        LayerId             = value.LayerId,
                        HasSpellSetId       = value.HasSpellSetId,
                        SpellCategory       = (ushort)value.SpellCategory,
                        PowerLevel          = value.PowerLevel,
                        StartTime           = value.StartTime,
                        Duration            = value.Duration,
                        CasterObjectId      = value.CasterObjectId,
                        DegradeModifier     = value.DegradeModifier,
                        DegradeLimit        = value.DegradeLimit,
                        LastTimeDegraded    = value.LastTimeDegraded,
                        StatModType         = (uint)value.StatModType,
                        StatModKey          = value.StatModKey,
                        StatModValue        = value.StatModValue,
                        SpellSetId          = (uint)value.SpellSetId,
                    };

                    result.BiotaPropertiesEnchantmentRegistry.Add(entity);
                }
            }

            if (biota.HousePermissions != null)
            {
                foreach (var kvp in biota.HousePermissions)
                {
                    var entity = new ACE.Database.Models.Shard.HousePermission {
                        HouseId = biota.Id, PlayerGuid = kvp.Key, Storage = kvp.Value
                    };

                    result.HousePermission.Add(entity);
                }
            }

            return(result);
        }
コード例 #30
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static BiotaPropertiesSpellBook GetSpell(this Biota biota, int spell)
 {
     return(biota.BiotaPropertiesSpellBook.FirstOrDefault(x => x.Spell == spell));
 }