예제 #1
0
        public void InqPropertyInner(BiotaPropertiesEmoteAction emoteAction, bool inRange, WorldObject sourceObject, WorldObject targetObject, ActionChain actionChain)
        {
            var category = inRange ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure;
            var useRNG   = !inRange; // ??

            InqCategory(category, emoteAction, sourceObject, targetObject, actionChain, useRNG);
        }
예제 #2
0
 public void InqProperty(string prop, BiotaPropertiesEmoteAction emoteAction, WorldObject sourceObject, WorldObject targetObject, ActionChain actionChain)
 {
     if (prop == null)
     {
         return;
     }
     InqPropertyInner(emoteAction, true, sourceObject, targetObject, actionChain);
 }
예제 #3
0
        public void InqCategory(EmoteCategory categoryId, BiotaPropertiesEmoteAction emoteAction, WorldObject sourceObject, WorldObject targetObject, ActionChain actionChain, bool useRNG = false)
        {
            var rng = useRNG ? Physics.Common.Random.RollDice(0.0f, 1.0f) : 0.0f;

            var result = sourceObject.Biota.BiotaPropertiesEmote.FirstOrDefault(e => e.Category == (uint)categoryId && e.Quest == emoteAction.Message && rng <= e.Probability);

            if (result == null)
            {
                return;
            }

            foreach (var action in result.BiotaPropertiesEmoteAction)
            {
                actionChain.AddAction(sourceObject, () =>
                {
                    ExecuteEmote(result, action, actionChain, sourceObject, targetObject);
                });
            }
        }
예제 #4
0
        public static Biota CreateCopyAsBiota(this Weenie weenie, uint id)
        {
            var biota = new Biota();

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

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

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

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

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

            foreach (var value in weenie.WeeniePropertiesBodyPart)
            {
                biota.BiotaPropertiesBodyPart.Add(new BiotaPropertiesBodyPart
                {
                    ObjectId        = biota.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.WeeniePropertiesBookPageData)
            {
                biota.BiotaPropertiesBookPageData.Add(new BiotaPropertiesBookPageData
                {
                    ObjectId      = biota.Id,
                    PageId        = value.PageId,
                    AuthorId      = value.AuthorId,
                    AuthorName    = value.AuthorName,
                    AuthorAccount = value.AuthorAccount,
                    IgnoreAuthor  = value.IgnoreAuthor,
                    PageText      = value.PageText,
                });
            }

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

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

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


            foreach (var value in weenie.WeeniePropertiesEmote)
            {
                var emote = new BiotaPropertiesEmote
                {
                    ObjectId      = biota.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 correft 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);
                }

                biota.BiotaPropertiesEmote.Add(emote);
            }


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

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

            foreach (var value in weenie.WeeniePropertiesGenerator)
            {
                biota.BiotaPropertiesGenerator.Add(new BiotaPropertiesGenerator
                {
                    ObjectId      = biota.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,
                });
            }

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

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

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

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

            foreach (var value in weenie.WeeniePropertiesPosition)
            {
                biota.BiotaPropertiesPosition.Add(new BiotaPropertiesPosition
                {
                    ObjectId     = biota.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,
                });
            }

            foreach (var value in weenie.WeeniePropertiesSkill)
            {
                biota.BiotaPropertiesSkill.Add(new BiotaPropertiesSkill
                {
                    ObjectId              = biota.Id,
                    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 weenie.WeeniePropertiesSpellBook)
            {
                biota.BiotaPropertiesSpellBook.Add(new BiotaPropertiesSpellBook
                {
                    ObjectId    = biota.Id,
                    Spell       = value.Spell,
                    Probability = value.Probability,
                });
            }

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

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

            return(biota);
        }
예제 #5
0
        public void ExecuteEmote(BiotaPropertiesEmote emote, BiotaPropertiesEmoteAction emoteAction, ActionChain actionChain, WorldObject sourceObject = null, WorldObject targetObject = null)
        {
            var player         = targetObject as Player;
            var creature       = sourceObject as Creature;
            var targetCreature = targetObject as Creature;

            var emoteType = (EmoteType)emoteAction.Type;

            //if (emoteType != EmoteType.Motion && emoteType != EmoteType.Turn && emoteType != EmoteType.Move)
            //Console.WriteLine($"{WorldObject.Name}.ExecuteEmote({emoteType})");

            var text = emoteAction.Message;

            switch ((EmoteType)emoteAction.Type)
            {
            case EmoteType.Act:
                // short for 'acting' text
                var message = Replace(text, sourceObject, targetObject);
                sourceObject?.EnqueueBroadcast(new GameMessageSystemChat(message, ChatMessageType.Broadcast), 30.0f);
                break;

            case EmoteType.Activate:
                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    if (creature != null && (creature.ActivationTarget ?? 0) > 0)
                    {
                        var activationTarget = creature.CurrentLandblock?.GetObject(creature.ActivationTarget ?? 0);
                        activationTarget?.ActOnUse(creature);
                    }
                });
                break;

            case EmoteType.AddCharacterTitle:

                // emoteAction.Stat == null for all EmoteType.AddCharacterTitle entries in current db?
                if (player != null)
                {
                    player.AddTitle((CharacterTitle)emoteAction.Stat);
                }
                break;

            case EmoteType.AddContract:

                //if (player != null)
                //Contracts werent in emote table
                //player.AddContract(emoteAction.Stat);
                break;

            case EmoteType.AdminSpam:

                var players = WorldManager.GetAll();
                foreach (var onlinePlayer in players)
                {
                    onlinePlayer.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.AdminTell));
                }
                break;

            case EmoteType.AwardLevelProportionalSkillXP:

                if (player != null)
                {
                    player.GrantLevelProportionalSkillXP((Skill)emoteAction.Stat, emoteAction.Percent ?? 0, (ulong)emoteAction.Max);
                }
                break;

            case EmoteType.AwardLevelProportionalXP:

                if (player != null)
                {
                    player.GrantLevelProportionalXp(emoteAction.Percent ?? 0, (ulong)emoteAction.Max);
                }
                break;

            case EmoteType.AwardLuminance:

                if (player != null)
                {
                    player.GrantLuminance((long)emoteAction.Amount);
                }
                break;

            case EmoteType.AwardNoShareXP:

                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    if (player != null)
                    {
                        player.EarnXP((long)emoteAction.Amount64);
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat("You've earned " + emoteAction.Amount64 + " experience.", ChatMessageType.Broadcast));
                    }
                });
                break;

            case EmoteType.AwardSkillPoints:

                if (player != null)
                {
                    player.AwardSkillPoints((Skill)emoteAction.Stat, (uint)emoteAction.Amount, true);
                }
                break;

            case EmoteType.AwardSkillXP:

                if (player != null)
                {
                    player.RaiseSkillGameAction((Skill)emoteAction.Stat, (uint)emoteAction.Amount, true);
                }
                break;

            case EmoteType.AwardTrainingCredits:

                if (player != null)
                {
                    player.AddSkillCredits((int)emoteAction.Amount, true);
                }
                break;

            case EmoteType.AwardXP:

                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    if (player != null)
                    {
                        player.EarnXP((long)emoteAction.Amount64);
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat("You've earned " + emoteAction.Amount64 + " experience.", ChatMessageType.Broadcast));
                    }
                });
                break;

            case EmoteType.BLog:
                // only one test drudge used this emoteAction.
                break;

            case EmoteType.CastSpell:

                if (WorldObject is Player)
                {
                    (WorldObject as Player).CreatePlayerSpell((uint)emoteAction.SpellId);
                }

                else if (WorldObject is Creature)
                {
                    (WorldObject as Creature).CreateCreatureSpell(player.Guid, (uint)emoteAction.SpellId);
                }

                break;

            case EmoteType.CastSpellInstant:

                var spellTable = DatManager.PortalDat.SpellTable;
                var spell      = spellTable.Spells[(uint)emoteAction.SpellId];
                actionChain.AddAction(sourceObject, () =>
                {
                    if (spell.TargetEffect > 0)
                    {
                        creature.CreateCreatureSpell(targetObject.Guid, (uint)emoteAction.SpellId);
                    }
                    else
                    {
                        creature.CreateCreatureSpell((uint)emoteAction.SpellId);
                    }
                });
                break;

            case EmoteType.CloseMe:
                targetObject.Close(WorldObject);
                break;

            case EmoteType.CreateTreasure:
                break;

            case EmoteType.DecrementIntStat:

                var id   = (PropertyInt)emoteAction.Stat;
                var prop = player.GetProperty(id);
                if (prop != null)
                {
                    player.SetProperty(id, prop.Value - 1);
                }
                break;

            case EmoteType.DecrementMyQuest:
                break;

            case EmoteType.DecrementQuest:
                // Used as part of the test drudge for events
                break;

            case EmoteType.DeleteSelf:
                sourceObject.CurrentLandblock?.RemoveWorldObject(sourceObject.Guid, false);
                break;

            case EmoteType.DirectBroadcast:
                text = Replace(emoteAction.Message, WorldObject, targetObject);
                if (player != null)
                {
                    player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                }
                break;

            case EmoteType.EraseMyQuest:
                break;

            case EmoteType.EraseQuest:

                if (player != null)
                {
                    player.QuestManager.Erase(emoteAction.Message);
                }
                break;

            case EmoteType.FellowBroadcast:

                text = emoteAction.Message;
                if (player != null)
                {
                    var fellowship = player.Fellowship;
                    if (fellowship == null)
                    {
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                    }
                    else
                    {
                        foreach (var fellow in fellowship.FellowshipMembers)
                        {
                            fellow.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                        }
                    }
                }
                break;

            case EmoteType.Generate:

                uint wcid = (uint)emoteAction.WeenieClassId;
                var  item = WorldObjectFactory.CreateNewWorldObject((wcid));
                break;

            case EmoteType.Give:

                bool success = false;
                if (player != null && emoteAction.WeenieClassId != null)
                {
                    actionChain.AddAction(sourceObject, () =>
                    {
                        item          = WorldObjectFactory.CreateNewWorldObject((uint)emoteAction.WeenieClassId);
                        var stackSize = emoteAction.StackSize ?? 1;
                        var stackMsg  = "";
                        if (stackSize > 1)
                        {
                            item.StackSize = (ushort)stackSize;
                            stackMsg       = stackSize + " ";   // pluralize?
                        }
                        success = player.TryCreateInInventoryWithNetworking(item);

                        // transaction / rollback on failure?
                        if (success)
                        {
                            var msg   = new GameMessageSystemChat($"{WorldObject.Name} gives you {stackMsg}{item.Name}.", ChatMessageType.Broadcast);
                            var sound = new GameMessageSound(player.Guid, Sound.ReceiveItem, 1);
                            player.Session.Network.EnqueueSend(msg, sound);
                        }
                    });
                }
                break;

            case EmoteType.Goto:

                var rng        = Physics.Common.Random.RollDice(0.0f, 1.0f);
                var firstEmote = sourceObject.Biota.BiotaPropertiesEmote.FirstOrDefault(e => e.Category == (uint)EmoteCategory.GotoSet && rng < e.Probability);
                foreach (var action in firstEmote.BiotaPropertiesEmoteAction)
                {
                    actionChain.AddAction(player, () =>
                    {
                        ExecuteEmote(firstEmote, action, actionChain, sourceObject, targetObject);
                    });
                }
                break;

            case EmoteType.IncrementIntStat:

                if (player == null || emoteAction.Stat == null)
                {
                    break;
                }

                id   = (PropertyInt)emoteAction.Stat;
                prop = player.GetProperty(id);
                if (prop != null)
                {
                    player.SetProperty(id, prop.Value + 1);
                }
                break;

            case EmoteType.IncrementMyQuest:
                break;

            case EmoteType.IncrementQuest:

                if (player != null)
                {
                    player.QuestManager.Increment(emoteAction.Message);
                }
                break;

            case EmoteType.InflictVitaePenalty:
                if (player != null)
                {
                    player.VitaeCpPool++;                       // TODO: full path
                }
                break;

            case EmoteType.InqAttributeStat:

                if (targetCreature != null)
                {
                    var attr = targetCreature.GetCreatureAttribute((PropertyAttribute)emoteAction.Stat);
                    success = attr != null && attr.Ranks >= emoteAction.Min && attr.Ranks <= emoteAction.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqBoolStat:
                // This is only used with NPC's 24944 and 6386, which are dev tester npc's. Not worth the current effort.
                // Could also be post-ToD
                break;

            case EmoteType.InqContractsFull:
                // not part of the game at PY16?
                //if (player != null)
                //{
                //    var contracts = player.TrackedContracts;
                //    InqCategory(contracts.Count != 0 ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                //}
                break;

            case EmoteType.InqEvent:

                var started = EventManager.IsEventStarted(emoteAction.Message);
                InqCategory(started ? EmoteCategory.EventSuccess : EmoteCategory.EventFailure, emoteAction, sourceObject, targetObject, actionChain);
                break;

            case EmoteType.InqFellowNum:
                InqCategory(player != null && player.Fellowship != null ? EmoteCategory.TestSuccess : EmoteCategory.TestNoFellow, emoteAction, sourceObject, targetObject, actionChain);
                break;

            case EmoteType.InqFellowQuest:
                // focusing on 1 person quests to begin with
                break;

            case EmoteType.InqFloatStat:
                //InqProperty(target.GetProperty((PropertyFloat)emote.Stat), emote);
                break;

            case EmoteType.InqInt64Stat:
                //InqProperty(target.GetProperty((PropertyInt64)emote.Stat), emote);
                break;

            case EmoteType.InqIntStat:

                if (emoteAction.Stat != 25)
                {
                    break;                              // ??
                }
                success = player.Level >= emoteAction.Min && player.Level <= emoteAction.Max;

                // rng for failure case?
                var useRNG = !success;

                InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain, useRNG);
                break;

            case EmoteType.InqMyQuest:
                break;

            case EmoteType.InqMyQuestBitsOff:
                break;

            case EmoteType.InqMyQuestBitsOn:
                break;

            case EmoteType.InqMyQuestSolves:
                break;

            case EmoteType.InqNumCharacterTitles:

                //if (player != null)
                //InqCategory(player.NumCharacterTitles != 0 ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                break;

            case EmoteType.InqOwnsItems:

                //if (player != null)
                //InqCategory(player.Inventory.Count > 0 ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                break;

            case EmoteType.InqPackSpace:

                //if (player != null)
                //{
                //    var freeSpace = player.ContainerCapacity > player.ItemCapacity;
                //    InqCategory(freeSpace ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                //}
                break;

            case EmoteType.InqQuest:

                if (player != null)
                {
                    var hasQuest = player.QuestManager.HasQuest(emoteAction.Message);
                    InqCategory(hasQuest ? EmoteCategory.QuestSuccess : EmoteCategory.QuestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqQuestBitsOff:
                break;

            case EmoteType.InqQuestBitsOn:
                break;

            case EmoteType.InqQuestSolves:

                // should this be different from InqQuest?
                if (player != null)
                {
                    var hasQuest = player.QuestManager.HasQuest(emoteAction.Message);
                    InqCategory(hasQuest ? EmoteCategory.QuestSuccess : EmoteCategory.QuestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqRawAttributeStat:

                if (targetCreature != null)
                {
                    var attr = targetCreature.GetCreatureAttribute((PropertyAttribute)emoteAction.Stat);
                    success = attr != null && attr.Base >= emoteAction.Min && attr.Base <= emoteAction.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqRawSecondaryAttributeStat:

                if (targetCreature != null)
                {
                    var vital = targetCreature.GetCreatureVital((PropertyAttribute2nd)emoteAction.Stat);
                    success = vital != null && vital.Base >= emoteAction.Min && vital.Base <= emoteAction.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqRawSkillStat:

                if (targetCreature != null)
                {
                    var skill = targetCreature.GetCreatureSkill((Skill)emoteAction.Stat);
                    success = skill != null && skill.Base >= emoteAction.Min && skill.Base <= emoteAction.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqSecondaryAttributeStat:

                if (targetCreature != null)
                {
                    var vital = targetCreature.GetCreatureVital((PropertyAttribute2nd)emoteAction.Stat);
                    success = vital != null && vital.Ranks >= emoteAction.Min && vital.Ranks <= emoteAction.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqSkillSpecialized:

                if (targetCreature != null)
                {
                    var skill = targetCreature.GetCreatureSkill((Skill)emoteAction.Stat);
                    //InqProperty(skill.Status == SkillStatus.Specialized, emoteAction);
                }
                break;

            case EmoteType.InqSkillStat:

                if (targetCreature != null)
                {
                    var skill = targetCreature.GetCreatureSkill((Skill)emoteAction.Stat);
                    success = skill != null && skill.Ranks >= emoteAction.Min && skill.Ranks <= emoteAction.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqSkillTrained:

                if (targetCreature != null)
                {
                    var skill = targetCreature.GetCreatureSkill((Skill)emoteAction.Stat);
                    // TestNoQuality?
                    InqProperty(skill.AdvancementClass == SkillAdvancementClass.Trained || skill.AdvancementClass == SkillAdvancementClass.Specialized, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.InqStringStat:

                //InqProperty(targetCreature.GetProperty((PropertyString)emoteAction.Stat), emote);
                break;

            case EmoteType.InqYesNo:
                ConfirmationManager.ProcessConfirmation((uint)emoteAction.Stat, true);
                break;

            case EmoteType.Invalid:
                break;

            case EmoteType.KillSelf:

                if (targetCreature != null)
                {
                    targetCreature.Smite(targetCreature);
                }
                break;

            case EmoteType.LocalBroadcast:
                if (actionChain != null)
                {
                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    actionChain.AddAction(sourceObject, () =>
                    {
                        sourceObject?.EnqueueBroadcast(new GameMessageCreatureMessage(emoteAction.Message, sourceObject.Name, sourceObject.Guid.Full, ChatMessageType.Broadcast));
                    });
                }
                else
                {
                    sourceObject.EnqueueBroadcast(new GameMessageCreatureMessage(emoteAction.Message, sourceObject.Name, sourceObject.Guid.Full, ChatMessageType.Broadcast));
                }
                break;

            case EmoteType.LocalSignal:
                break;

            case EmoteType.LockFellow:

                if (player != null && player.Fellowship != null)
                {
                    player.HandleActionFellowshipChangeOpenness(false);
                }

                break;

            case EmoteType.ForceMotion:     // TODO: figure out the difference
            case EmoteType.Motion:

                if (sourceObject == null || sourceObject.CurrentMotionState == null)
                {
                    break;
                }

                if (emote.Category != (uint)EmoteCategory.Vendor && emote.Style != null)
                {
                    var startingMotion = new UniversalMotion((MotionStance)emote.Style, new MotionItem((MotionCommand)emote.Substyle));
                    var motion         = new UniversalMotion((MotionStance)emote.Style, new MotionItem((MotionCommand)emoteAction.Motion, emoteAction.Extent));

                    if (sourceObject.CurrentMotionState.Stance != startingMotion.Stance)
                    {
                        if (sourceObject.CurrentMotionState.Stance == MotionStance.Invalid)
                        {
                            actionChain.AddDelaySeconds(emoteAction.Delay);
                            actionChain.AddAction(sourceObject, () =>
                            {
                                //Console.WriteLine($"{sourceObject.Name} running starting motion {(MotionStance)emote.Style}, {(MotionCommand)emote.Substyle}");
                                sourceObject.ExecuteMotion(startingMotion);
                            });
                        }
                    }
                    else
                    {
                        if (sourceObject.CurrentMotionState.Commands.Count > 0 && sourceObject.CurrentMotionState.Commands[0].Motion == startingMotion.Commands[0].Motion)
                        {
                            actionChain.AddDelaySeconds(emoteAction.Delay);
                            actionChain.AddAction(sourceObject, () =>
                            {
                                //Console.WriteLine($"{sourceObject.Name} running motion {(MotionStance)emote.Style}, {(MotionCommand)emoteAction.Motion}");

                                float?maxRange = ClientMaxAnimRange;
                                if (MotionQueue.Contains((MotionCommand)emoteAction.Motion))
                                {
                                    maxRange = null;
                                }

                                sourceObject.ExecuteMotion(motion, true, maxRange);
                            });
                            actionChain.AddDelaySeconds(DatManager.PortalDat.ReadFromDat <DatLoader.FileTypes.MotionTable>(sourceObject.MotionTableId).GetAnimationLength((MotionCommand)emoteAction.Motion));
                            if (motion.Commands[0].Motion != MotionCommand.Sleeping && motion.Commands[0].Motion != MotionCommand.Sitting)     // this feels like it can be handled better, somehow?
                            {
                                actionChain.AddAction(sourceObject, () =>
                                {
                                    //Console.WriteLine($"{sourceObject.Name} running starting motion again {(MotionStance)emote.Style}, {(MotionCommand)emote.Substyle}");
                                    sourceObject.ExecuteMotion(startingMotion);
                                });
                            }
                        }
                    }
                }
                else
                {
                    var motion = new UniversalMotion(MotionStance.NonCombat, new MotionItem((MotionCommand)emoteAction.Motion, emoteAction.Extent));

                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    actionChain.AddAction(sourceObject, () =>
                    {
                        //Console.WriteLine($"{sourceObject.Name} running motion (block 2) {(MotionStance)emote.Style}, {(MotionCommand)emoteAction.Motion}");
                        sourceObject.ExecuteMotion(motion);
                    });
                }

                break;

            case EmoteType.Move:

                // what is the difference between this and MoveToPos?
                // using MoveToPos logic for now...
                if (targetCreature != null)
                {
                    var currentPos = targetCreature.Location;

                    var newPos = new Position();
                    newPos.LandblockId = new LandblockId(currentPos.LandblockId.Raw);
                    newPos.Pos         = new Vector3(emoteAction.OriginX ?? currentPos.Pos.X, emoteAction.OriginY ?? currentPos.Pos.Y, emoteAction.OriginZ ?? currentPos.Pos.Z);

                    if (emoteAction.AnglesX == null || emoteAction.AnglesY == null || emoteAction.AnglesZ == null || emoteAction.AnglesW == null)
                    {
                        newPos.Rotation = new Quaternion(currentPos.Rotation.X, currentPos.Rotation.Y, currentPos.Rotation.Z, currentPos.Rotation.W);
                    }
                    else
                    {
                        newPos.Rotation = new Quaternion(emoteAction.AnglesX ?? 0, emoteAction.AnglesY ?? 0, emoteAction.AnglesZ ?? 0, emoteAction.AnglesW ?? 1);
                    }

                    if (emoteAction.ObjCellId != null)
                    {
                        newPos.LandblockId = new LandblockId(emoteAction.ObjCellId.Value);
                    }

                    targetCreature.MoveTo(newPos, targetCreature.GetRunRate());
                }
                break;

            case EmoteType.MoveHome:

                // TODO: call MoveToManager on server
                if (targetCreature != null)
                {
                    targetCreature.MoveTo(targetCreature.Home, targetCreature.GetRunRate());
                }
                break;

            case EmoteType.MoveToPos:

                if (targetCreature != null)
                {
                    var currentPos = targetCreature.Location;

                    var newPos = new Position();
                    newPos.LandblockId = new LandblockId(currentPos.LandblockId.Raw);
                    newPos.Pos         = new Vector3(emoteAction.OriginX ?? currentPos.Pos.X, emoteAction.OriginY ?? currentPos.Pos.Y, emoteAction.OriginZ ?? currentPos.Pos.Z);

                    if (emoteAction.AnglesX == null || emoteAction.AnglesY == null || emoteAction.AnglesZ == null || emoteAction.AnglesW == null)
                    {
                        newPos.Rotation = new Quaternion(currentPos.Rotation.X, currentPos.Rotation.Y, currentPos.Rotation.Z, currentPos.Rotation.W);
                    }
                    else
                    {
                        newPos.Rotation = new Quaternion(emoteAction.AnglesX ?? 0, emoteAction.AnglesY ?? 0, emoteAction.AnglesZ ?? 0, emoteAction.AnglesW ?? 1);
                    }

                    if (emoteAction.ObjCellId != null)
                    {
                        newPos.LandblockId = new LandblockId(emoteAction.ObjCellId.Value);
                    }

                    targetCreature.MoveTo(newPos, targetCreature.GetRunRate());
                }
                break;

            case EmoteType.OpenMe:

                sourceObject.Open(sourceObject);
                break;

            case EmoteType.PetCastSpellOnOwner:

                if (creature != null)
                {
                    creature.CreateCreatureSpell(targetObject.Guid, (uint)emoteAction.SpellId);
                }
                break;

            case EmoteType.PhysScript:

                // TODO: landblock broadcast
                if (sourceObject != null)
                {
                    sourceObject.PhysicsObj.play_script((PlayScript)emoteAction.PScript, 1.0f);
                }
                break;

            case EmoteType.PopUp:
                if (player != null)
                {
                    if ((ConfirmationType)emoteAction.Stat == ConfirmationType.Undefined)
                    {
                        player.Session.Network.EnqueueSend(new GameEventPopupString(player.Session, emoteAction.Message));
                    }
                    else
                    {
                        Confirmation confirm = new Confirmation((ConfirmationType)emoteAction.Stat, emoteAction.Message, sourceObject.Guid.Full, targetObject.Guid.Full);
                        ConfirmationManager.AddConfirmation(confirm);
                        player.Session.Network.EnqueueSend(new GameEventConfirmationRequest(player.Session, (ConfirmationType)emoteAction.Stat, confirm.ConfirmationID, confirm.Message));
                    }
                }
                break;

            case EmoteType.RemoveContract:

                if (player != null)
                {
                    player.HandleActionAbandonContract((uint)emoteAction.Stat);
                }
                break;

            case EmoteType.RemoveVitaePenalty:

                if (player != null)
                {
                    player.VitaeCpPool = 0;                         // TODO: call full path
                }
                break;

            case EmoteType.ResetHomePosition:

                //creature = sourceObject as Creature;
                //if (creature != null)
                //    creature.Home = emoteAction.Position;
                break;

            case EmoteType.Say:

                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    sourceObject?.EnqueueBroadcast(new GameMessageCreatureMessage(emoteAction.Message, sourceObject.Name, sourceObject.Guid.Full, ChatMessageType.Emote));
                });
                break;

            case EmoteType.SetAltRacialSkills:
                break;

            case EmoteType.SetBoolStat:
                targetObject.SetProperty((PropertyBool)emoteAction.Stat, emoteAction.Amount == 0 ? false : true);
                break;

            case EmoteType.SetEyePalette:
                if (creature != null)
                {
                    creature.EyesPaletteDID = (uint)emoteAction.Display;
                }
                break;

            case EmoteType.SetEyeTexture:
                if (creature != null)
                {
                    creature.EyesTextureDID = (uint)emoteAction.Display;
                }
                break;

            case EmoteType.SetFloatStat:
                targetObject.SetProperty((PropertyFloat)emoteAction.Stat, (float)emoteAction.Amount);
                break;

            case EmoteType.SetHeadObject:
                if (creature != null)
                {
                    creature.HeadObjectDID = (uint)emoteAction.Display;
                }
                break;

            case EmoteType.SetHeadPalette:
                break;

            case EmoteType.SetInt64Stat:
                player.SetProperty((PropertyInt)emoteAction.Stat, (int)emoteAction.Amount);
                break;

            case EmoteType.SetIntStat:
                player.SetProperty((PropertyInt)emoteAction.Stat, (int)emoteAction.Amount);
                break;

            case EmoteType.SetMouthPalette:
                break;

            case EmoteType.SetMouthTexture:
                creature = sourceObject as Creature;
                if (creature != null)
                {
                    creature.MouthTextureDID = (uint)emoteAction.Display;
                }
                break;

            case EmoteType.SetMyQuestBitsOff:
                break;

            case EmoteType.SetMyQuestBitsOn:
                break;

            case EmoteType.SetMyQuestCompletions:
                break;

            case EmoteType.SetNosePalette:
                break;

            case EmoteType.SetNoseTexture:
                creature = sourceObject as Creature;
                if (creature != null)
                {
                    creature.NoseTextureDID = (uint)emoteAction.Display;
                }
                break;

            case EmoteType.SetQuestBitsOff:
                break;

            case EmoteType.SetQuestBitsOn:
                break;

            case EmoteType.SetQuestCompletions:
                break;

            case EmoteType.SetSanctuaryPosition:

                //if (player != null)
                //player.Sanctuary = emote.Position;
                break;

            case EmoteType.Sound:
                targetObject.EnqueueBroadcast(new GameMessageSound(targetObject.Guid, (Sound)emoteAction.Sound, 1.0f));
                break;

            case EmoteType.SpendLuminance:
                if (player != null)
                {
                    player.SpendLuminance((long)emoteAction.Amount);
                }
                break;

            case EmoteType.StampFellowQuest:
                break;

            case EmoteType.StampMyQuest:
                break;

            case EmoteType.StampQuest:

                // work needs to be done here
                if (player != null)
                {
                    player.QuestManager.Add(emoteAction.Message);
                }
                break;

            case EmoteType.StartBarber:
                break;

            case EmoteType.StartEvent:

                EventManager.StartEvent(emoteAction.Message);
                break;

            case EmoteType.StopEvent:

                EventManager.StopEvent(emoteAction.Message);
                break;

            case EmoteType.TakeItems:

                if (player != null && emoteAction.WeenieClassId != null)
                {
                    item = WorldObjectFactory.CreateNewWorldObject((uint)emoteAction.WeenieClassId);
                    if (item == null)
                    {
                        break;
                    }

                    success = player.TryRemoveItemFromInventoryWithNetworking(item, (ushort)emoteAction.Amount);
                }
                break;

            case EmoteType.TeachSpell:

                if (player != null)
                {
                    player.LearnSpellWithNetworking((uint)emoteAction.SpellId);
                }
                break;

            case EmoteType.TeleportSelf:

                //if (WorldObject is Player)
                //(WorldObject as Player).Teleport(emote.Position);
                break;

            case EmoteType.TeleportTarget:

                //if (player != null)
                //player.Teleport(emote.Position);
                break;

            case EmoteType.Tell:
                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    player.Session.Network.EnqueueSend(new GameMessageHearDirectSpeech(sourceObject, emoteAction.Message, player, ChatMessageType.Tell));
                });
                break;

            case EmoteType.TellFellow:

                text = emoteAction.Message;
                if (player != null)
                {
                    var fellowship = player.Fellowship;
                    if (fellowship == null)
                    {
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Tell));
                    }
                    else
                    {
                        foreach (var fellow in fellowship.FellowshipMembers)
                        {
                            fellow.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Tell));
                        }
                    }
                }
                break;

            case EmoteType.TextDirect:

                if (player != null)
                {
                    // should these delays be moved to 1 place??
                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    text = emoteAction.Message;         // no known instances of replace tokens in current text, but could be added in future
                    actionChain.AddAction(player, () =>
                    {
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                    });
                }
                break;

            case EmoteType.Turn:

                if (creature != null)
                {
                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    var pos = new Position(creature.Location.Cell, creature.Location.PositionX, creature.Location.PositionY, creature.Location.PositionZ, emoteAction.AnglesX ?? 0, emoteAction.AnglesY ?? 0, emoteAction.AnglesZ ?? 0, emoteAction.AnglesW ?? 0);
                    actionChain.AddAction(creature, () =>
                    {
                        creature.TurnTo(pos);
                    });
                    var rotateTime = creature.GetRotateDelay(pos);
                    actionChain.AddDelaySeconds(rotateTime);
                }
                break;

            case EmoteType.TurnToTarget:

                if (creature != null && targetCreature != null)
                {
                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    actionChain.AddAction(creature, () =>
                    {
                        creature.Rotate(targetCreature);
                    });
                    var rotateTime = creature.GetRotateDelay(targetCreature);
                    actionChain.AddDelaySeconds(rotateTime);
                }
                break;

            case EmoteType.UntrainSkill:

                if (player != null)
                {
                    player.UntrainSkill((Skill)emoteAction.Stat, 1);
                }
                break;

            case EmoteType.UpdateFellowQuest:
                break;

            case EmoteType.UpdateMyQuest:
                break;

            case EmoteType.UpdateQuest:

                // only delay seems to be with test NPC here
                // still, unsafe to use any emotes directly outside of a chain,
                // as they could be executed out-of-order
                if (player != null)
                {
                    var questName = emoteAction.Message;
                    player.QuestManager.Add(questName);
                    var hasQuest = player.QuestManager.HasQuest(questName);
                    InqCategory(hasQuest ? EmoteCategory.QuestSuccess : EmoteCategory.QuestFailure, emoteAction, sourceObject, targetObject, actionChain);
                }
                break;

            case EmoteType.WorldBroadcast:
                if (player != null)
                {
                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    actionChain.AddAction(sourceObject, () =>
                    {
                        player.Session.Network.EnqueueSend(new GameMessageHearDirectSpeech(sourceObject, emoteAction.Message, player, ChatMessageType.WorldBroadcast));
                    });
                }
                break;

            default:
                log.Debug($"EmoteManager.Execute - Encountered Unhandled EmoteType {(EmoteType)emoteAction.Type} for {sourceObject.Name} ({sourceObject.WeenieClassId})");
                break;
            }
        }
예제 #6
0
        public void InqProperty(double?prop, BiotaPropertiesEmoteAction emoteAction, WorldObject sourceObject, WorldObject targetObject, ActionChain actionChain)
        {
            var inRange = prop != null && (prop.Value >= emoteAction.MinDbl && prop.Value <= emoteAction.MaxDbl);

            InqPropertyInner(emoteAction, inRange, sourceObject, targetObject, actionChain);
        }
예제 #7
0
        public void InqProperty(bool?prop, BiotaPropertiesEmoteAction emoteAction, WorldObject sourceObject, WorldObject targetObject, ActionChain actionChain)
        {
            var inRange = prop != null && prop.Value;

            InqPropertyInner(emoteAction, inRange, sourceObject, targetObject, actionChain);
        }
예제 #8
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);
        }
예제 #9
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);
                }
            }
        }
예제 #10
0
        /// <summary>
        /// copied from Biota.Clone extension method and modified
        /// </summary>
        /// <param name="biota"></param>
        /// <param name="guid"></param>
        /// <returns></returns>
        public static Biota SetGuidAndScrubPKs(Biota biota, uint guid)
        {
            Biota result = new Biota
            {
                Id                       = guid,
                WeenieClassId            = biota.WeenieClassId,
                WeenieType               = biota.WeenieType,
                PopulatedCollectionFlags = biota.PopulatedCollectionFlags
            };

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

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

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

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

            foreach (BiotaPropertiesBodyPart value in biota.BiotaPropertiesBodyPart)
            {
                result.BiotaPropertiesBodyPart.Add(new BiotaPropertiesBodyPart
                {
                    Id              = 0,
                    ObjectId        = guid,
                    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 (BiotaPropertiesBookPageData value in biota.BiotaPropertiesBookPageData)
            {
                result.BiotaPropertiesBookPageData.Add(new BiotaPropertiesBookPageData
                {
                    Id            = 0,
                    ObjectId      = guid,
                    PageId        = value.PageId,
                    AuthorId      = value.AuthorId,
                    AuthorName    = value.AuthorName,
                    AuthorAccount = value.AuthorAccount,
                    IgnoreAuthor  = value.IgnoreAuthor,
                    PageText      = value.PageText,
                });
            }

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

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

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


            foreach (BiotaPropertiesEmote value in biota.BiotaPropertiesEmote)
            {
                BiotaPropertiesEmote emote = new BiotaPropertiesEmote
                {
                    Id            = 0,
                    ObjectId      = guid,
                    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 (BiotaPropertiesEmoteAction value2 in value.BiotaPropertiesEmoteAction)
                {
                    BiotaPropertiesEmoteAction action = new BiotaPropertiesEmoteAction
                    {
                        Id              = 0,
                        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 (BiotaPropertiesEnchantmentRegistry value in biota.BiotaPropertiesEnchantmentRegistry)
            {
                result.BiotaPropertiesEnchantmentRegistry.Add(new BiotaPropertiesEnchantmentRegistry
                {
                    //Id = 0,
                    ObjectId            = guid,
                    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,//perhaps this needs foreign PK to be scrubbed out as well
                    DegradeModifier     = value.DegradeModifier,
                    DegradeLimit        = value.DegradeLimit,
                    LastTimeDegraded    = value.LastTimeDegraded,
                    StatModType         = value.StatModType,
                    StatModKey          = value.StatModKey,
                    StatModValue        = value.StatModValue,
                    SpellSetId          = value.SpellSetId,
                });
            }


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

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

            foreach (BiotaPropertiesGenerator value in biota.BiotaPropertiesGenerator)
            {
                result.BiotaPropertiesGenerator.Add(new BiotaPropertiesGenerator
                {
                    Id            = 0,
                    ObjectId      = guid,
                    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 (BiotaPropertiesIID value in biota.BiotaPropertiesIID)
            {
                result.BiotaPropertiesIID.Add(new BiotaPropertiesIID
                {
                    Id       = 0,
                    ObjectId = guid,
                    Type     = value.Type,
                    Value    = value.Value,
                });
            }

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

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

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

            foreach (BiotaPropertiesPosition value in biota.BiotaPropertiesPosition)
            {
                result.BiotaPropertiesPosition.Add(new BiotaPropertiesPosition
                {
                    Id           = 0,
                    ObjectId     = guid,
                    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 (BiotaPropertiesSkill value in biota.BiotaPropertiesSkill)
            {
                result.BiotaPropertiesSkill.Add(new BiotaPropertiesSkill
                {
                    Id                    = 0,
                    ObjectId              = guid,
                    Type                  = value.Type,
                    LevelFromPP           = value.LevelFromPP,
                    SAC                   = value.SAC,
                    PP                    = value.PP,
                    InitLevel             = value.InitLevel,
                    ResistanceAtLastCheck = value.ResistanceAtLastCheck,
                    LastUsedTime          = value.LastUsedTime,
                });
            }

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

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

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

            return(result);
        }
예제 #11
0
        public void ExecuteEmote(BiotaPropertiesEmote emote, BiotaPropertiesEmoteAction emoteAction, ActionChain actionChain, WorldObject sourceObject = null, WorldObject targetObject = null)
        {
            var player = targetObject as Player;

            switch ((EmoteType)emoteAction.Type)
            {
            case EmoteType.Say:

                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    sourceObject.CurrentLandblock.EnqueueBroadcast(sourceObject.Location, new GameMessageCreatureMessage(emoteAction.Message, sourceObject.Name, sourceObject.Guid.Full, ChatMessageType.Emote));
                });
                break;

            case EmoteType.Motion:

                if (emote.Category != (uint)EmoteCategory.Vendor && emote.Style != null)
                {
                    var startingMotion = new UniversalMotion((MotionStance)emote.Style, new MotionItem((MotionCommand)emote.Substyle));
                    var motion         = new UniversalMotion((MotionStance)emote.Style, new MotionItem((MotionCommand)emoteAction.Motion, emoteAction.Extent));

                    if (sourceObject.CurrentMotionState.Stance != startingMotion.Stance)
                    {
                        if (sourceObject.CurrentMotionState.Stance == MotionStance.Invalid)
                        {
                            actionChain.AddDelaySeconds(emoteAction.Delay);
                            actionChain.AddAction(sourceObject, () =>
                            {
                                sourceObject.DoMotion(startingMotion);
                                sourceObject.CurrentMotionState = startingMotion;
                            });
                        }
                    }
                    else
                    {
                        if (sourceObject.CurrentMotionState.Commands.Count > 0 && sourceObject.CurrentMotionState.Commands[0].Motion == startingMotion.Commands[0].Motion)
                        {
                            actionChain.AddDelaySeconds(emoteAction.Delay);
                            actionChain.AddAction(sourceObject, () =>
                            {
                                sourceObject.DoMotion(motion);
                                sourceObject.CurrentMotionState = motion;
                            });
                            actionChain.AddDelaySeconds(DatManager.PortalDat.ReadFromDat <DatLoader.FileTypes.MotionTable>(sourceObject.MotionTableId).GetAnimationLength((MotionCommand)emoteAction.Motion));
                            if (motion.Commands[0].Motion != MotionCommand.Sleeping && motion.Commands[0].Motion != MotionCommand.Sitting)     // this feels like it can be handled better, somehow?
                            {
                                actionChain.AddAction(sourceObject, () =>
                                {
                                    sourceObject.DoMotion(startingMotion);
                                    sourceObject.CurrentMotionState = startingMotion;
                                });
                            }
                        }
                    }
                }
                else
                {
                    var motion = new UniversalMotion(MotionStance.Standing, new MotionItem((MotionCommand)emoteAction.Motion, emoteAction.Extent));

                    actionChain.AddDelaySeconds(emoteAction.Delay);
                    actionChain.AddAction(sourceObject, () =>
                    {
                        sourceObject.DoMotion(motion);
                        sourceObject.CurrentMotionState = motion;
                    });
                }

                break;

            case EmoteType.Tell:
                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    player.Session.Network.EnqueueSend(new GameMessageHearDirectSpeech(sourceObject, emoteAction.Message, player, ChatMessageType.Tell));
                });
                break;

            case EmoteType.TurnToTarget:
                actionChain.AddDelaySeconds(emoteAction.Delay);
                var creature = sourceObject is Creature ? (Creature)sourceObject : null;
                actionChain.AddAction(sourceObject, () =>
                {
                    creature.Rotate(player);
                });
                actionChain.AddDelaySeconds(creature.GetRotateDelay(player));
                break;

            case EmoteType.AwardXP:
                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    if (player != null)
                    {
                        player.EarnXP((long)emoteAction.Amount64);
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat("You've earned " + emoteAction.Amount64 + " experience.", ChatMessageType.System));
                    }
                });
                break;

            case EmoteType.Give:
                actionChain.AddAction(sourceObject, () =>
                {
                    if (player != null)
                    {
                        uint weenie      = (uint)emoteAction.WeenieClassId;
                        WorldObject item = WorldObjectFactory.CreateNewWorldObject(weenie);
                        if (emoteAction.WeenieClassId != null)
                        {
                            if (emoteAction.StackSize > 1)
                            {
                                item.StackSize = (ushort)emoteAction.StackSize;
                                player.Session.Network.EnqueueSend(new GameMessageSystemChat(WorldObject.Name + " gives you " + emoteAction.StackSize + " " + item.Name + ".", ChatMessageType.System));
                            }
                            else
                            {
                                player.Session.Network.EnqueueSend(new GameMessageSystemChat(WorldObject.Name + " gives you " + item.Name + ".", ChatMessageType.System));
                            }
                            var success = player.TryCreateInInventoryWithNetworking(item);
                        }
                    }
                });
                break;

            case EmoteType.UpdateQuest:
                //This is for the quest NPC's. This will be filled out when quests are added.
                break;

            case EmoteType.Turn:
                actionChain.AddDelaySeconds(emoteAction.Delay);
                creature = sourceObject is Creature ? (Creature)sourceObject : null;
                var pos = new Position(creature.Location.Cell, creature.Location.PositionX, creature.Location.PositionY, creature.Location.PositionZ, emoteAction.AnglesX ?? 0, emoteAction.AnglesY ?? 0, emoteAction.AnglesZ ?? 0, emoteAction.AnglesW ?? 0);
                actionChain.AddAction(sourceObject, () =>
                {
                    creature.TurnTo(pos);
                });
                actionChain.AddDelaySeconds(creature.GetTurnToDelay(pos));
                break;

            case EmoteType.Activate:
                creature = sourceObject is Creature ? (Creature)sourceObject : null;
                actionChain.AddDelaySeconds(emoteAction.Delay);
                actionChain.AddAction(sourceObject, () =>
                {
                    if ((creature.ActivationTarget ?? 0) > 0)
                    {
                        var activationTarget = creature.CurrentLandblock.GetObject(new ObjectGuid(creature.ActivationTarget ?? 0));
                        activationTarget.ActOnUse(creature);
                    }
                });
                break;

            default:
                log.Debug($"EmoteManager.Execute - Encountered Unhandled EmoteType {(EmoteType)emoteAction.Type} for {sourceObject.Name} ({sourceObject.WeenieClassId})");
                break;
            }
        }
        private void UpdateBiota(ShardDbContext context, Biota existingBiota, Biota biota)
        {
            // This pattern is described here: https://docs.microsoft.com/en-us/ef/core/saving/disconnected-entities
            // You'll notice though that we're not using the recommended: context.Entry(existingEntry).CurrentValues.SetValues(newEntry);
            // It is EXTREMLY slow. 4x or more slower. I suspect because it uses reflection to find the properties that the object contains
            // Manually setting the properties like we do below is the best case scenario for performance. However, it also has risks.
            // If we add columns to the schema and forget to add those changes here, changes to the biota may not propegate to the database.
            // Mag-nus 2018-08-18

            context.Entry(existingBiota).CurrentValues.SetValues(biota);

            foreach (var value in biota.BiotaPropertiesAnimPart)
            {
                BiotaPropertiesAnimPart existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesAnimPart.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesAnimPart.Add(value);
                }
                else
                {
                    existingValue.Index       = value.Index;
                    existingValue.AnimationId = value.AnimationId;
                    existingValue.Order       = value.Order;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesAnimPart)
            {
                if (!biota.BiotaPropertiesAnimPart.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesAnimPart.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesAttribute)
            {
                BiotaPropertiesAttribute existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesAttribute.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesAttribute.Add(value);
                }
                else
                {
                    existingValue.Type        = value.Type;
                    existingValue.InitLevel   = value.InitLevel;
                    existingValue.LevelFromCP = value.LevelFromCP;
                    existingValue.CPSpent     = value.CPSpent;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesAttribute)
            {
                if (!biota.BiotaPropertiesAttribute.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesAttribute.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesAttribute2nd)
            {
                BiotaPropertiesAttribute2nd existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesAttribute2nd.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesAttribute2nd.Add(value);
                }
                else
                {
                    existingValue.Type         = value.Type;
                    existingValue.InitLevel    = value.InitLevel;
                    existingValue.LevelFromCP  = value.LevelFromCP;
                    existingValue.CPSpent      = value.CPSpent;
                    existingValue.CurrentLevel = value.CurrentLevel;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesAttribute2nd)
            {
                if (!biota.BiotaPropertiesAttribute2nd.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesAttribute2nd.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesBodyPart)
            {
                BiotaPropertiesBodyPart existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesBodyPart.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesBodyPart.Add(value);
                }
                else
                {
                    existingValue.Key             = value.Key;
                    existingValue.DType           = value.DType;
                    existingValue.DVal            = value.DVal;
                    existingValue.DVar            = value.DVar;
                    existingValue.BaseArmor       = value.BaseArmor;
                    existingValue.ArmorVsSlash    = value.ArmorVsSlash;
                    existingValue.ArmorVsPierce   = value.ArmorVsPierce;
                    existingValue.ArmorVsBludgeon = value.ArmorVsBludgeon;
                    existingValue.ArmorVsCold     = value.ArmorVsCold;
                    existingValue.ArmorVsFire     = value.ArmorVsFire;
                    existingValue.ArmorVsAcid     = value.ArmorVsAcid;
                    existingValue.ArmorVsElectric = value.ArmorVsElectric;
                    existingValue.ArmorVsNether   = value.ArmorVsNether;
                    existingValue.BH  = value.BH;
                    existingValue.HLF = value.HLF;
                    existingValue.MLF = value.MLF;
                    existingValue.LLF = value.LLF;
                    existingValue.HRF = value.HRF;
                    existingValue.MRF = value.MRF;
                    existingValue.LRF = value.LRF;
                    existingValue.HLB = value.HLB;
                    existingValue.MLB = value.MLB;
                    existingValue.LLB = value.LLB;
                    existingValue.HRB = value.HRB;
                    existingValue.MRB = value.MRB;
                    existingValue.LRB = value.LRB;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesBodyPart)
            {
                if (!biota.BiotaPropertiesBodyPart.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesBodyPart.Remove(value);
                }
            }

            if (biota.BiotaPropertiesBook != null)
            {
                if (existingBiota.BiotaPropertiesBook == null)
                {
                    existingBiota.BiotaPropertiesBook = biota.BiotaPropertiesBook;
                }
                else
                {
                    existingBiota.BiotaPropertiesBook.MaxNumPages        = biota.BiotaPropertiesBook.MaxNumPages;
                    existingBiota.BiotaPropertiesBook.MaxNumCharsPerPage = biota.BiotaPropertiesBook.MaxNumCharsPerPage;
                }
            }
            else
            {
                if (existingBiota.BiotaPropertiesBook != null)
                {
                    context.BiotaPropertiesBook.Remove(existingBiota.BiotaPropertiesBook);
                }
            }

            foreach (var value in biota.BiotaPropertiesBookPageData)
            {
                BiotaPropertiesBookPageData existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesBookPageData.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesBookPageData.Add(value);
                }
                else
                {
                    existingValue.PageId        = value.PageId;
                    existingValue.AuthorId      = value.AuthorId;
                    existingValue.AuthorName    = value.AuthorName;
                    existingValue.AuthorAccount = value.AuthorAccount;
                    existingValue.IgnoreAuthor  = value.IgnoreAuthor;
                    existingValue.PageText      = value.PageText;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesBookPageData)
            {
                if (!biota.BiotaPropertiesBookPageData.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesBookPageData.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesBool)
            {
                BiotaPropertiesBool existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesBool.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesBool.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesBool)
            {
                if (!biota.BiotaPropertiesBool.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesBool.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesCreateList)
            {
                BiotaPropertiesCreateList existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesCreateList.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesCreateList.Add(value);
                }
                else
                {
                    existingValue.DestinationType = value.DestinationType;
                    existingValue.WeenieClassId   = value.WeenieClassId;
                    existingValue.StackSize       = value.StackSize;
                    existingValue.Palette         = value.Palette;
                    existingValue.Shade           = value.Shade;
                    existingValue.TryToBond       = value.TryToBond;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesCreateList)
            {
                if (!biota.BiotaPropertiesCreateList.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesCreateList.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesDID)
            {
                BiotaPropertiesDID existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesDID.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesDID.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesDID)
            {
                if (!biota.BiotaPropertiesDID.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesDID.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesEmote)
            {
                BiotaPropertiesEmote existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesEmote.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesEmote.Add(value);
                }
                else
                {
                    existingValue.Category      = value.Category;
                    existingValue.Probability   = value.Probability;
                    existingValue.WeenieClassId = value.WeenieClassId;
                    existingValue.Style         = value.Style;
                    existingValue.Substyle      = value.Substyle;
                    existingValue.Quest         = value.Quest;
                    existingValue.VendorType    = value.VendorType;
                    existingValue.MinHealth     = value.MinHealth;
                    existingValue.MaxHealth     = value.MaxHealth;

                    foreach (var value2 in value.BiotaPropertiesEmoteAction)
                    {
                        BiotaPropertiesEmoteAction existingValue2 = (value2.Id == 0 ? null : existingValue.BiotaPropertiesEmoteAction.FirstOrDefault(r => r.Id == value2.Id));

                        if (existingValue2 == null)
                        {
                            existingValue.BiotaPropertiesEmoteAction.Add(value2);
                        }
                        else
                        {
                            existingValue2.EmoteId         = value2.EmoteId;
                            existingValue2.Order           = value2.Order;
                            existingValue2.Type            = value2.Type;
                            existingValue2.Delay           = value2.Delay;
                            existingValue2.Extent          = value2.Extent;
                            existingValue2.Motion          = value2.Motion;
                            existingValue2.Message         = value2.Message;
                            existingValue2.TestString      = value2.TestString;
                            existingValue2.Min             = value2.Min;
                            existingValue2.Max             = value2.Max;
                            existingValue2.Min64           = value2.Min64;
                            existingValue2.Max64           = value2.Max64;
                            existingValue2.MinDbl          = value2.MinDbl;
                            existingValue2.MaxDbl          = value2.MaxDbl;
                            existingValue2.Stat            = value2.Stat;
                            existingValue2.Display         = value2.Display;
                            existingValue2.Amount          = value2.Amount;
                            existingValue2.Amount64        = value2.Amount64;
                            existingValue2.HeroXP64        = value2.HeroXP64;
                            existingValue2.Percent         = value2.Percent;
                            existingValue2.SpellId         = value2.SpellId;
                            existingValue2.WealthRating    = value2.WealthRating;
                            existingValue2.TreasureClass   = value2.TreasureClass;
                            existingValue2.TreasureType    = value2.TreasureType;
                            existingValue2.PScript         = value2.PScript;
                            existingValue2.Sound           = value2.Sound;
                            existingValue2.DestinationType = value2.DestinationType;
                            existingValue2.WeenieClassId   = value2.WeenieClassId;
                            existingValue2.StackSize       = value2.StackSize;
                            existingValue2.Palette         = value2.Palette;
                            existingValue2.Shade           = value2.Shade;
                            existingValue2.TryToBond       = value2.TryToBond;
                            existingValue2.ObjCellId       = value2.ObjCellId;
                            existingValue2.OriginX         = value2.OriginX;
                            existingValue2.OriginY         = value2.OriginY;
                            existingValue2.OriginZ         = value2.OriginZ;
                            existingValue2.AnglesW         = value2.AnglesW;
                            existingValue2.AnglesX         = value2.AnglesX;
                            existingValue2.AnglesY         = value2.AnglesY;
                            existingValue2.AnglesZ         = value2.AnglesZ;
                        }
                    }
                    foreach (var value2 in value.BiotaPropertiesEmoteAction)
                    {
                        if (!existingValue.BiotaPropertiesEmoteAction.Any(p => p.Id == value2.Id))
                        {
                            context.BiotaPropertiesEmoteAction.Remove(value2);
                        }
                    }
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesEmote)
            {
                if (!biota.BiotaPropertiesEmote.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesEmote.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesEnchantmentRegistry)
            {
                BiotaPropertiesEnchantmentRegistry existingValue = (value.ObjectId == 0 ? null : existingBiota.BiotaPropertiesEnchantmentRegistry.FirstOrDefault(r => r.ObjectId == value.ObjectId && r.SpellId == value.SpellId && r.LayerId == value.LayerId && r.CasterObjectId == value.CasterObjectId));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesEnchantmentRegistry.Add(value);
                }
                else
                {
                    existingValue.EnchantmentCategory = value.EnchantmentCategory;
                    existingValue.SpellId             = value.SpellId;
                    existingValue.LayerId             = value.LayerId;
                    existingValue.HasSpellSetId       = value.HasSpellSetId;
                    existingValue.SpellCategory       = 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         = value.StatModType;
                    existingValue.StatModKey          = value.StatModKey;
                    existingValue.StatModValue        = value.StatModValue;
                    existingValue.SpellSetId          = value.SpellSetId;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesEnchantmentRegistry)
            {
                if (!biota.BiotaPropertiesEnchantmentRegistry.Any(p => p.ObjectId == value.ObjectId && p.SpellId == value.SpellId && p.LayerId == value.LayerId && p.CasterObjectId == value.CasterObjectId))
                {
                    context.BiotaPropertiesEnchantmentRegistry.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesEventFilter)
            {
                BiotaPropertiesEventFilter existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesEventFilter.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesEventFilter.Add(value);
                }
                else
                {
                    existingValue.Event = value.Event;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesEventFilter)
            {
                if (!biota.BiotaPropertiesEventFilter.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesEventFilter.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesFloat)
            {
                BiotaPropertiesFloat existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesFloat.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesFloat.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesFloat)
            {
                if (!biota.BiotaPropertiesFloat.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesFloat.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesGenerator)
            {
                BiotaPropertiesGenerator existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesGenerator.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesGenerator.Add(value);
                }
                else
                {
                    existingValue.Probability   = value.Probability;
                    existingValue.WeenieClassId = value.WeenieClassId;
                    existingValue.Delay         = value.Delay;
                    existingValue.InitCreate    = value.InitCreate;
                    existingValue.MaxCreate     = value.MaxCreate;
                    existingValue.WhenCreate    = value.WhenCreate;
                    existingValue.WhereCreate   = value.WhereCreate;
                    existingValue.StackSize     = value.StackSize;
                    existingValue.PaletteId     = value.PaletteId;
                    existingValue.Shade         = value.Shade;
                    existingValue.ObjCellId     = value.ObjCellId;
                    existingValue.OriginX       = value.OriginX;
                    existingValue.OriginY       = value.OriginY;
                    existingValue.OriginZ       = value.OriginZ;
                    existingValue.AnglesW       = value.AnglesW;
                    existingValue.AnglesX       = value.AnglesX;
                    existingValue.AnglesY       = value.AnglesY;
                    existingValue.AnglesZ       = value.AnglesZ;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesGenerator)
            {
                if (!biota.BiotaPropertiesGenerator.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesGenerator.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesIID)
            {
                BiotaPropertiesIID existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesIID.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesIID.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesIID)
            {
                if (!biota.BiotaPropertiesIID.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesIID.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesInt)
            {
                BiotaPropertiesInt existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesInt.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesInt.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesInt)
            {
                if (!biota.BiotaPropertiesInt.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesInt.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesInt64)
            {
                BiotaPropertiesInt64 existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesInt64.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesInt64.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesInt64)
            {
                if (!biota.BiotaPropertiesInt64.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesInt64.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesPalette)
            {
                BiotaPropertiesPalette existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesPalette.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesPalette.Add(value);
                }
                else
                {
                    existingValue.SubPaletteId = value.SubPaletteId;
                    existingValue.Offset       = value.Offset;
                    existingValue.Length       = value.Length;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesPalette)
            {
                if (!biota.BiotaPropertiesPalette.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesPalette.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesPosition)
            {
                BiotaPropertiesPosition existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesPosition.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesPosition.Add(value);
                }
                else
                {
                    existingValue.PositionType = value.PositionType;
                    existingValue.ObjCellId    = value.ObjCellId;
                    existingValue.OriginX      = value.OriginX;
                    existingValue.OriginY      = value.OriginY;
                    existingValue.OriginZ      = value.OriginZ;
                    existingValue.AnglesW      = value.AnglesW;
                    existingValue.AnglesX      = value.AnglesX;
                    existingValue.AnglesY      = value.AnglesY;
                    existingValue.AnglesZ      = value.AnglesZ;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesPosition)
            {
                if (!biota.BiotaPropertiesPosition.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesPosition.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesSkill)
            {
                BiotaPropertiesSkill existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesSkill.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesSkill.Add(value);
                }
                else
                {
                    existingValue.Type                  = value.Type;
                    existingValue.LevelFromPP           = value.LevelFromPP;
                    existingValue.SAC                   = value.SAC;
                    existingValue.PP                    = value.PP;
                    existingValue.InitLevel             = value.InitLevel;
                    existingValue.ResistanceAtLastCheck = value.ResistanceAtLastCheck;
                    existingValue.LastUsedTime          = value.LastUsedTime;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesSkill)
            {
                if (!biota.BiotaPropertiesSkill.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesSkill.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesSpellBook)
            {
                BiotaPropertiesSpellBook existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesSpellBook.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesSpellBook.Add(value);
                }
                else
                {
                    existingValue.Spell       = value.Spell;
                    existingValue.Probability = value.Probability;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesSpellBook)
            {
                if (!biota.BiotaPropertiesSpellBook.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesSpellBook.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesString)
            {
                BiotaPropertiesString existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesString.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesString.Add(value);
                }
                else
                {
                    existingValue.Type  = value.Type;
                    existingValue.Value = value.Value;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesString)
            {
                if (!biota.BiotaPropertiesString.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesString.Remove(value);
                }
            }

            foreach (var value in biota.BiotaPropertiesTextureMap)
            {
                BiotaPropertiesTextureMap existingValue = (value.Id == 0 ? null : existingBiota.BiotaPropertiesTextureMap.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.BiotaPropertiesTextureMap.Add(value);
                }
                else
                {
                    existingValue.Index = value.Index;
                    existingValue.OldId = value.OldId;
                    existingValue.NewId = value.NewId;
                    existingValue.Order = value.Order;
                }
            }
            foreach (var value in existingBiota.BiotaPropertiesTextureMap)
            {
                if (!biota.BiotaPropertiesTextureMap.Any(p => p.Id == value.Id))
                {
                    context.BiotaPropertiesTextureMap.Remove(value);
                }
            }

            foreach (var value in biota.HousePermission)
            {
                HousePermission existingValue = (value.Id == 0 ? null : existingBiota.HousePermission.FirstOrDefault(r => r.Id == value.Id));

                if (existingValue == null)
                {
                    existingBiota.HousePermission.Add(value);
                }
                else
                {
                    existingValue.PlayerGuid = value.PlayerGuid;
                    existingValue.Storage    = value.Storage;
                }
            }
            foreach (var value in existingBiota.HousePermission)
            {
                if (!biota.HousePermission.Any(p => p.Id == value.Id))
                {
                    context.HousePermission.Remove(value);
                }
            }
        }
예제 #13
0
        public static Biota CreateCopyAsBiota(this Weenie weenie, uint id)
        {
            var biota = new Biota();

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

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

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

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

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

            foreach (var value in weenie.WeeniePropertiesBodyPart)
            {
                biota.BiotaPropertiesBodyPart.Add(new BiotaPropertiesBodyPart
                {
                    ObjectId        = biota.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.WeeniePropertiesBookPageData)
            {
                biota.BiotaPropertiesBookPageData.Add(new BiotaPropertiesBookPageData
                {
                    ObjectId      = biota.Id,
                    PageId        = value.PageId,
                    AuthorId      = value.AuthorId,
                    AuthorName    = value.AuthorName,
                    AuthorAccount = value.AuthorAccount,
                    IgnoreAuthor  = value.IgnoreAuthor,
                    PageText      = value.PageText,
                });
            }

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

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

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


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

                biota.BiotaPropertiesEmote.Add(emote);
            }

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

                biota.BiotaPropertiesEmoteAction.Add(action);
            }


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

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

            foreach (var value in weenie.WeeniePropertiesGenerator)
            {
                biota.BiotaPropertiesGenerator.Add(new BiotaPropertiesGenerator
                {
                    ObjectId      = biota.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,
                });
            }

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

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

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

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

            foreach (var value in weenie.WeeniePropertiesPosition)
            {
                biota.BiotaPropertiesPosition.Add(new BiotaPropertiesPosition
                {
                    ObjectId     = biota.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,
                });
            }

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

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

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

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

            return(biota);
        }