Ejemplo n.º 1
0
        /// <summary>
        /// This should be called after any postback and/or before any save.  due to how we can delete mid-row
        /// in the UI, properties are only soft-deleted and need to be physically removed here.
        /// </summary>
        public void CleanDeletedAndEmptyProperties()
        {
            StringStats?.RemoveAll(x => x == null || x.Deleted || string.IsNullOrEmpty(x.Value));
            IntStats?.RemoveAll(x => x == null || x.Deleted);
            Int64Stats?.RemoveAll(x => x == null || x.Deleted);
            FloatStats?.RemoveAll(x => x == null || x.Deleted);
            BoolStats?.RemoveAll(x => x == null || x.Deleted);
            DidStats?.RemoveAll(x => x == null || x.Deleted);
            Spells?.RemoveAll(x => x == null || x.Deleted);
            Book?.Pages?.RemoveAll(x => x == null || x.Deleted);
            Positions?.RemoveAll(x => x == null || x.Deleted);
            EmoteTable?.ForEach(es => es?.Emotes?.ForEach(esa => esa?.Actions?.RemoveAll(x => x == null || x.Deleted)));
            EmoteTable?.ForEach(es => es?.Emotes?.RemoveAll(x => x == null || x.Deleted));
            EmoteTable?.RemoveAll(x => x == null || x.Deleted || x.Emotes?.Count < 1);
            Body?.BodyParts?.RemoveAll(x => x == null || x.Deleted);
            GeneratorTable?.RemoveAll(x => x == null || x.Deleted);
            CreateList?.RemoveAll(x => x == null || x.Deleted);
            Skills?.RemoveAll(x => x == null || x.Deleted);

            // this property's existence causes all sorts of problems.  needs to go away.
            IntStats?.RemoveAll(x => x.Key == 9007);

            if (!HasAbilities)
            {
                Attributes = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This should be called after any postback and/or before any save.  due to how we can delete mid-row
        /// in the UI, properties are only soft-deleted and need to be physically removed here.
        /// </summary>
        public void CleanDeletedAndEmptyProperties()
        {
            StringProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            IntProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            Int64Properties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            DoubleProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            BoolProperties?.RemoveAll(x => x == null || x.Deleted);
            DidProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            IidProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            Spells?.RemoveAll(x => x == null || x.Deleted);
            BookProperties?.RemoveAll(x => x == null || x.Deleted);
            Positions?.RemoveAll(x => x == null || x.Deleted);
            EmoteTable.ForEach(es => es.Emotes.RemoveAll(x => x == null || x.Deleted));
            EmoteTable?.RemoveAll(x => x == null || x.Deleted);
            BodyParts?.RemoveAll(x => x == null || x.Deleted);
            GeneratorTable?.RemoveAll(x => x == null || x.Deleted);
            CreateList?.RemoveAll(x => x == null || x.Deleted);
            Skills.RemoveAll(x => x == null || x.Deleted);

            if (!HasAbilities)
            {
                Abilities = null;
            }
        }
Ejemplo n.º 3
0
        public Weenie.Weenie ConvertToWeenie(out List <string> messages)
        {
            messages = new List <string>();
            Weenie.Weenie w = new Weenie.Weenie
            {
                DataObjectId  = WeenieId,
                WeenieClassId = WeenieId
            };

            w.IntProperties.Add(new Shared.IntProperty()
            {
                IntPropertyId = (int)IntPropertyId.WeenieType,
                Value         = WeenieTypeId
            });

            IntStats.ForEach(stat =>
            {
                w.IntProperties.Add(new Shared.IntProperty()
                {
                    IntPropertyId = stat.Key,
                    Value         = stat.Value
                });
            });

            Int64Stats?.ForEach(stat =>
            {
                w.Int64Properties.Add(new Shared.Int64Property()
                {
                    Int64PropertyId = stat.Key,
                    Value           = stat.Value
                });
            });

            FloatStats?.ForEach(stat =>
            {
                w.DoubleProperties.Add(new Shared.DoubleProperty()
                {
                    DoublePropertyId = stat.Key,
                    Value            = stat.Value
                });
            });

            DidStats?.ForEach(stat =>
            {
                w.DidProperties.Add(new Shared.DataIdProperty()
                {
                    DataIdPropertyId = stat.Key,
                    Value            = stat.Value
                });
            });

            BoolStats?.ForEach(stat =>
            {
                w.BoolProperties.Add(new Shared.BoolProperty()
                {
                    BoolPropertyId = stat.Key,
                    Value          = stat.BoolValue
                });
            });

            StringStats?.ForEach(stat =>
            {
                w.StringProperties.Add(new Shared.StringProperty()
                {
                    StringPropertyId = stat.Key,
                    Value            = stat.Value
                });
            });

            Book?.Pages.ForEach(page =>
            {
                w.BookProperties.Add(new Shared.BookPage()
                {
                    AuthorAccount = page.AuthorAccount,
                    AuthorId      = page.AuthorId,
                    AuthorName    = page.AuthorName,
                    IgnoreAuthor  = page.IgnoreAuthor ?? false,
                    Page          = 1 + (uint)Book.Pages.IndexOf(page),
                    PageText      = page.PageText
                });
            });

            Skills?.ForEach(skill =>
            {
                w.Skills.Add(new Shared.Skill()
                {
                    SkillId         = skill.SkillId,
                    Ranks           = skill.Skill.Ranks,
                    ExperienceSpent = skill.Skill.XpInvested,
                    Status          = skill.Skill.TrainedLevel,
                    BaseValue       = 0
                });
            });

            Spells?.ForEach(spell =>
            {
                w.Spells.Add(new Shared.Spell()
                {
                    SpellId     = spell.SpellId,
                    Probability = spell.Stats.CastingChance
                });
            });

            Positions?.ForEach(position =>
            {
                w.Positions.Add(new Shared.Position()
                {
                    X            = position.Position.Frame.Position.X,
                    Y            = position.Position.Frame.Position.Y,
                    Z            = position.Position.Frame.Position.Z,
                    QW           = position.Position.Frame.Rotations.W,
                    QX           = position.Position.Frame.Rotations.X,
                    QY           = position.Position.Frame.Rotations.Y,
                    QZ           = position.Position.Frame.Rotations.Z,
                    Landblock    = position.Position.LandCellId,
                    PositionType = position.PositionType
                });
            });

            GeneratorTable?.ForEach(entry =>
            {
                Shared.GeneratorTable gt = new Shared.GeneratorTable
                {
                    Frame = new Shared.Frame()
                };
                gt.Frame.Origin = new Shared.Origin();
                gt.Frame.Angles = new Shared.Angles();

                PropertyCopier <GeneratorTable, Shared.GeneratorTable> .Copy(entry, gt);
                gt.Frame.Angles.W = entry.Frame.Rotations.W;
                gt.Frame.Angles.X = entry.Frame.Rotations.X;
                gt.Frame.Angles.Y = entry.Frame.Rotations.Y;
                gt.Frame.Angles.Z = entry.Frame.Rotations.Z;
                gt.Frame.Origin.X = entry.Frame.Position.X;
                gt.Frame.Origin.Y = entry.Frame.Position.Y;
                gt.Frame.Origin.Z = entry.Frame.Position.Z;

                w.GeneratorTable.Add(gt);
            });

            uint emoteSetCounter = 0;

            if (EmoteTable != null)
            {
                emoteSetCounter = (uint)EmoteTable?.Count;
            }

            uint emoteCounter = 0;
            uint holdCategory = 0;

            EmoteTable?.ForEach(category =>
            {
                if (category.EmoteCategoryId != holdCategory)
                {
                    holdCategory = (uint)category.EmoteCategoryId;

                    if (holdCategory != 0)
                    {
                        emoteSetCounter--;
                    }
                }

                category.Emotes.ForEach(e =>
                {
                    var es = new Shared.EmoteSet()
                    {
                        EmoteSetGuid    = Guid.NewGuid(),
                        ClassId         = e.ClassId,
                        EmoteCategoryId = e.Category,
                        MaxHealth       = e.MaxHealth,
                        MinHealth       = e.MinHealth,
                        Probability     = e.Probability,
                        Quest           = e.Quest,
                        Style           = e.Style,
                        SubStyle        = e.SubStyle,
                        SortOrder       = emoteSetCounter,
                        VendorType      = e.VendorType
                    };

                    emoteCounter = 0;
                    e.Emotes.ForEach(ea =>
                    {
                        es.Emotes.Add(new Shared.Emote()
                        {
                            Amount              = ea.Amount,
                            Amount64            = ea.Amount64,
                            CreationProfile     = ea?.Item?.Convert(),
                            Delay               = ea.Delay ?? 0f,
                            Deleted             = false,
                            Display             = ea.Display,
                            EmoteTypeId         = ea.EmoteActionType,
                            EmoteGuid           = Guid.NewGuid(),
                            EmoteSetGuid        = es.EmoteSetGuid,
                            Extent              = ea.Extent ?? 0f,
                            HeroXp64            = ea.HeroXp64,
                            Maximum             = ea.Max,
                            Maximum64           = ea.Maximum64,
                            MaximumFloat        = ea.FMax,
                            Message             = ea.Message,
                            Minimum             = ea.Min,
                            Minimum64           = ea.Minimum64,
                            MinimumFloat        = ea.FMin,
                            Motion              = (MotionCommand?)ea.Motion,
                            Percent             = ea.Percent,
                            PhysicsScript       = (PhysicsScriptType?)ea.PScript,
                            PositionLandBlockId = null, // no source
                            PositionX           = ea.Frame?.Position.X,
                            PositionY           = ea.Frame?.Position.Y,
                            PositionZ           = ea.Frame?.Position.Z,
                            RotationW           = ea.Frame?.Rotations.W,
                            RotationX           = ea.Frame?.Rotations.X,
                            RotationY           = ea.Frame?.Rotations.Y,
                            RotationZ           = ea.Frame?.Rotations.Z,
                            Sound               = ea.Sound,
                            SpellId             = ea.SpellId,
                            Stat          = ea.Stat,
                            TestString    = ea.TestString,
                            TreasureClass = (TreasureClass?)ea.TreasureClass,
                            TreasureType  = (uint?)ea.TreasureType,
                            SortOrder     = emoteCounter,
                            WealthRating  = (WealthRating?)ea.WealthRating
                        });
                        emoteCounter++;
                    });
                    w.EmoteTable.Add(es);
                });
            });

            CreateList?.ForEach(ci =>
            {
                w.CreateList.Add(ci.Convert());
            });

            if (w.HasAbilities)
            {
                w.Abilities.Strength     = Attributes.Strength.Convert(AbilityId.Strength);
                w.Abilities.Endurance    = Attributes.Endurance.Convert(AbilityId.Endurance);
                w.Abilities.Coordination = Attributes.Coordination.Convert(AbilityId.Coordination);
                w.Abilities.Quickness    = Attributes.Quickness.Convert(AbilityId.Quickness);
                w.Abilities.Focus        = Attributes.Focus.Convert(AbilityId.Focus);
                w.Abilities.Self         = Attributes.Self.Convert(AbilityId.Self);

                w.Vitals.Health  = Attributes.Health.Convert(AbilityId.Health);
                w.Vitals.Stamina = Attributes.Stamina.Convert(AbilityId.Stamina);
                w.Vitals.Mana    = Attributes.Mana.Convert(AbilityId.Mana);
            }

            Body?.BodyParts?.ForEach(bp =>
            {
                var part = new Shared.BodyPart()
                {
                    BodyHeight     = bp.BodyPart.BH,
                    BodyPartType   = (BodyPartType)bp.Key,
                    Damage         = bp.BodyPart.DVal,
                    DamageType     = (DamageType)bp.BodyPart.DType,
                    DamageVariance = bp.BodyPart.DVar
                };

                if (bp.BodyPart.ArmorValues != null)
                {
                    part.ArmorValues.Base     = bp.BodyPart.ArmorValues.BaseArmor;
                    part.ArmorValues.Acid     = bp.BodyPart.ArmorValues.ArmorVsAcid;
                    part.ArmorValues.Bludgeon = bp.BodyPart.ArmorValues.ArmorVsBludgeon;
                    part.ArmorValues.Cold     = bp.BodyPart.ArmorValues.ArmorVsCold;
                    part.ArmorValues.Electric = bp.BodyPart.ArmorValues.ArmorVsElectric;
                    part.ArmorValues.Fire     = bp.BodyPart.ArmorValues.ArmorVsFire;
                    part.ArmorValues.Nether   = bp.BodyPart.ArmorValues.ArmorVsNether;
                    part.ArmorValues.Pierce   = bp.BodyPart.ArmorValues.ArmorVsPierce;
                    part.ArmorValues.Slash    = bp.BodyPart.ArmorValues.ArmorVsSlash;
                }

                if (bp.BodyPart.SD != null)
                {
                    part.TargetingData.HighLeftBack   = bp.BodyPart.SD.HLB;
                    part.TargetingData.HighLeftFront  = bp.BodyPart.SD.HLF;
                    part.TargetingData.HighRightBack  = bp.BodyPart.SD.HRB;
                    part.TargetingData.HighRightFront = bp.BodyPart.SD.HRF;
                    part.TargetingData.LowLeftBack    = bp.BodyPart.SD.LLB;
                    part.TargetingData.LowLeftFront   = bp.BodyPart.SD.LLF;
                    part.TargetingData.LowRightBack   = bp.BodyPart.SD.LRB;
                    part.TargetingData.LowRightFront  = bp.BodyPart.SD.LRF;
                    part.TargetingData.MidLeftBack    = bp.BodyPart.SD.MLB;
                    part.TargetingData.MidLeftFront   = bp.BodyPart.SD.MLF;
                    part.TargetingData.MidRightBack   = bp.BodyPart.SD.MRB;
                    part.TargetingData.MidRightFront  = bp.BodyPart.SD.MRF;
                }

                w.BodyParts.Add(part);
            });

            return(w);
        }