Пример #1
0
        /// <summary>
        /// This will create a new WorldObject with a new GUID.
        /// It will return null if weenieClassId was not found.
        /// </summary>
        public static WorldObject CreateNewWorldObject(uint weenieClassId, AppliedRuleset ruleset = null)
        {
            var weenie = DatabaseManager.World.GetCachedWeenie(weenieClassId);

            if (weenie == null)
            {
                return(null);
            }

            return(CreateNewWorldObject(weenie, ruleset));
        }
Пример #2
0
        /// <summary>
        /// A new biota be created taking all of its values from weenie.
        /// </summary>
        public Player(Weenie weenie, ObjectGuid guid, uint accountId, AppliedRuleset ruleset) : base(weenie, guid, ruleset)
        {
            Character                = new Character();
            Character.Id             = guid.Full;
            Character.AccountId      = accountId;
            Character.Name           = GetProperty(PropertyString.Name);
            CharacterChangesDetected = true;

            Account = DatabaseManager.Authentication.GetAccountById(Character.AccountId);

            SetEphemeralValues();

            // Make sure properties this WorldObject requires are not null.
            AvailableExperience = AvailableExperience ?? 0;
            TotalExperience     = TotalExperience ?? 0;

            Attackable = true;

            SetProperty(PropertyString.DateOfBirth, $"{DateTime.UtcNow:dd MMMM yyyy}");
        }
Пример #3
0
        /// <summary>
        /// This will create a list of WorldObjects, all with new GUIDs and for every position provided.
        /// </summary>
        public static List <WorldObject> CreateNewWorldObjects(List <LandblockInstance> sourceObjects, List <Biota> biotas, uint?restrict_wcid, uint iid, AppliedRuleset ruleset)
        {
            var results = new List <WorldObject>();

            // spawn direct landblock objects
            foreach (var instance in sourceObjects.Where(x => x.IsLinkChild == false))
            {
                var weenie = DatabaseManager.World.GetCachedWeenie(instance.WeenieClassId);

                if (weenie == null)
                {
                    continue;
                }

                if (restrict_wcid != null && restrict_wcid.Value != instance.WeenieClassId)
                {
                    continue;
                }

                var guid = new ObjectGuid(instance.Guid);

                WorldObject worldObject;

                var biota = biotas.FirstOrDefault(b => b.Id == instance.Guid);
                if (biota == null)
                {
                    worldObject = CreateWorldObject(weenie, guid, ruleset);

                    worldObject.Location = new Position(instance.ObjCellId, instance.OriginX, instance.OriginY, instance.OriginZ, instance.AnglesX, instance.AnglesY, instance.AnglesZ, instance.AnglesW, iid);
                }
                else
                {
                    worldObject = CreateWorldObject(biota);

                    if (worldObject.Location == null)
                    {
                        log.Warn($"CreateNewWorldObjects: {worldObject.Name} (0x{worldObject.Guid}) Location was null. CreationTimestamp = {worldObject.CreationTimestamp} ({Common.Time.GetDateTimeFromTimestamp(worldObject.CreationTimestamp ?? 0).ToLocalTime()}) | Location restored from world db instance.");
                        worldObject.Location = new Position(instance.ObjCellId, instance.OriginX, instance.OriginY, instance.OriginZ, instance.AnglesX, instance.AnglesY, instance.AnglesZ, instance.AnglesW, iid);
                    }
                }

                if (worldObject != null)
                {
                    // queue linked child objects
                    foreach (var link in instance.LandblockInstanceLink)
                    {
                        var linkInstance = sourceObjects.FirstOrDefault(x => x.Guid == link.ChildGuid);

                        if (linkInstance != null)
                        {
                            worldObject.LinkedInstances.Add(linkInstance);
                        }
                    }

                    results.Add(worldObject);
                }
            }
            return(results);
        }
Пример #4
0
        /// <summary>
        /// This will create a new WorldObject with a new GUID.
        /// </summary>
        public static WorldObject CreateNewWorldObject(Weenie weenie, AppliedRuleset ruleset)
        {
            var worldObject = CreateWorldObject(weenie, GuidManager.NewDynamicGuid(), ruleset);

            return(worldObject);
        }
Пример #5
0
        /// <summary>
        /// A new biota be created taking all of its values from weenie.
        /// </summary>
        public static WorldObject CreateWorldObject(Weenie weenie, ObjectGuid guid, AppliedRuleset ruleset = null)
        {
            if (ruleset == null)
            {
                ruleset = RealmManager.DefaultRuleset;
            }

            if (weenie == null || guid == null)
            {
                return(null);
            }

            var objWeenieType = weenie.WeenieType;

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

            case WeenieType.LifeStone:
                return(new Lifestone(weenie, guid));

            case WeenieType.Door:
                return(new Door(weenie, guid));

            case WeenieType.Portal:
                return(new Portal(weenie, guid));

            case WeenieType.Book:
                return(new Book(weenie, guid));

            case WeenieType.PKModifier:
                return(new PKModifier(weenie, guid));

            case WeenieType.Cow:
                return(new Cow(weenie, guid, ruleset));

            case WeenieType.Creature:
                return(new Creature(weenie, guid, ruleset));

            case WeenieType.Container:
                return(new Container(weenie, guid));

            case WeenieType.Scroll:
                return(new Scroll(weenie, guid));

            case WeenieType.Vendor:
                return(new Vendor(weenie, guid, ruleset));

            case WeenieType.Coin:
                return(new Coin(weenie, guid));

            case WeenieType.Key:
                return(new Key(weenie, guid));

            case WeenieType.Food:
                return(new Food(weenie, guid));

            case WeenieType.Gem:
                return(new Gem(weenie, guid));

            case WeenieType.Game:
                return(new Game(weenie, guid));

            case WeenieType.GamePiece:
                return(new GamePiece(weenie, guid, ruleset));

            case WeenieType.AllegianceBindstone:
                return(new Bindstone(weenie, guid));

            case WeenieType.Clothing:
                return(new Clothing(weenie, guid));

            case WeenieType.MeleeWeapon:
                return(new MeleeWeapon(weenie, guid));

            case WeenieType.MissileLauncher:
                return(new MissileLauncher(weenie, guid));

            case WeenieType.Ammunition:
                return(new Ammunition(weenie, guid));

            case WeenieType.Missile:
                return(new Missile(weenie, guid));

            case WeenieType.Corpse:
                return(new Corpse(weenie, guid));

            case WeenieType.Chest:
                return(new Chest(weenie, guid));

            case WeenieType.Stackable:
                return(new Stackable(weenie, guid));

            case WeenieType.SpellComponent:
                return(new SpellComponent(weenie, guid));

            case WeenieType.Switch:
                return(new Switch(weenie, guid));

            case WeenieType.AdvocateFane:
                return(new AdvocateFane(weenie, guid));

            case WeenieType.AdvocateItem:
                return(new AdvocateItem(weenie, guid));

            case WeenieType.Healer:
                return(new Healer(weenie, guid));

            case WeenieType.Lockpick:
                return(new Lockpick(weenie, guid));

            case WeenieType.Caster:
                return(new Caster(weenie, guid));

            case WeenieType.ProjectileSpell:
                return(new SpellProjectile(weenie, guid));

            case WeenieType.HotSpot:
                return(new Hotspot(weenie, guid));

            case WeenieType.ManaStone:
                return(new ManaStone(weenie, guid));

            case WeenieType.House:
                return(new House(weenie, guid));

            case WeenieType.SlumLord:
                return(new SlumLord(weenie, guid));

            case WeenieType.Storage:
                return(new Storage(weenie, guid));

            case WeenieType.Hook:
                return(new Hook(weenie, guid));

            case WeenieType.Hooker:
                return(new Hooker(weenie, guid));

            case WeenieType.HousePortal:
                return(new HousePortal(weenie, guid));

            case WeenieType.SkillAlterationDevice:
                return(new SkillAlterationDevice(weenie, guid));

            case WeenieType.PressurePlate:
                return(new PressurePlate(weenie, guid));

            case WeenieType.PetDevice:
                return(new PetDevice(weenie, guid));

            case WeenieType.Pet:
                return(new Pet(weenie, guid, ruleset));

            case WeenieType.CombatPet:
                return(new CombatPet(weenie, guid, ruleset));

            case WeenieType.Allegiance:
                return(new Allegiance(weenie, guid));

            case WeenieType.AugmentationDevice:
                return(new AugmentationDevice(weenie, guid));

            case WeenieType.AttributeTransferDevice:
                return(new AttributeTransferDevice(weenie, guid));

            case WeenieType.CraftTool:
                return(new CraftTool(weenie, guid));

            case WeenieType.LightSource:
                return(new LightSource(weenie, guid));

            default:
                return(new GenericObject(weenie, guid));
            }
        }