Example #1
0
        public Task <IObjectImpl> GetInRangeObject(ObjectGUID guid)
        {
            IObjectImpl ret = null;

            _inrangeObjects.TryGetValue(guid, out ret);
            return(Task.FromResult(ret));
        }
Example #2
0
 public CreatureEntity(ObjectGUID objectGUID, creature creature, VanillaWorld vanillaWorld)
     : base(objectGUID)
 {
     this.VanillaWorld = vanillaWorld;
     this.Creature     = creature;
     this.Template     = CreatureTemplateDatabase.SingleOrDefault(ct => ct.Entry == creature.id);
 }
Example #3
0
        public Task <IObjectImpl> GetObject(ObjectGUID guid)
        {
            IObjectImpl retval;

            _objectCache.TryGetValue(guid, out retval);
            return(Task.FromResult(retval));
        }
 public PSForceRunSpeedChange(ObjectGUID GUID, float speed)
     : base(WorldOpcodes.SMSG_FORCE_RUN_SPEED_CHANGE)
 {
     this.Write(GUID.RawGUID);
     this.Write((uint)0);
     this.Write(speed);
 }
Example #5
0
        public async Task SetGUID(ObjectGUID guid)
        {
            await SetGUID(EObjectFields.OBJECT_FIELD_GUID, guid);

            oGUID = guid;
            pGUID = new PackedGUID(guid);
        }
Example #6
0
        public GameObjectInfo(ObjectGUID guid, gameobject gameObject, gameobject_template template)
            : base(guid)
        {
            DisplayID   = template.displayId;
            Flags       = (int)template.flags;
            TypeID      = template.type;
            State       = gameObject.state;
            X           = gameObject.position_x;
            Y           = gameObject.position_y;
            Z           = gameObject.position_z;
            Rotation0   = gameObject.rotation0;
            Rotation1   = gameObject.rotation1;
            Orientation = gameObject.orientation;

            if (gameObject.rotation2 == 0 && gameObject.rotation3 == 0)
            {
                gameObject.rotation2 = (float)Math.Sin(gameObject.orientation / 2);
                gameObject.rotation3 = (float)Math.Cos(gameObject.orientation / 2);
            }

            Rotation2 = gameObject.rotation2;
            Rotation3 = gameObject.rotation3;

            Type |= (int)TypeMask.TYPEMASK_GAMEOBJECT;
        }
Example #7
0
        private Task <ObjectGUID> GeneratePlayerGUID()
        {
            var guid = new ObjectGUID(State.MaxPlayerGUID | (UInt64)HighGuid.HIGHGUID_PLAYER);

            State.MaxPlayerGUID += 1;
            return(Task.FromResult(guid));
        }
Example #8
0
 public PlayerEntity(ObjectGUID objectGUID, character databaseCharacter, WorldSession session) : base(objectGUID)
 {
     this.Character              = databaseCharacter;
     this.Session                = session;
     this.SpellCollection        = new SpellCollection(this);
     this.ActionButtonCollection = new ActionButtonCollection(this);
 }
Example #9
0
        public GameObjectInfo(ObjectGUID guid, gameobject gameObject, gameobject_template template)
            : base(guid)
        {
            DisplayID = template.displayId;
            Flags = (int)template.flags;
            TypeID = template.type;
            State = gameObject.state;
            X = gameObject.position_x;
            Y = gameObject.position_y;
            Z = gameObject.position_z;
            Rotation0 = gameObject.rotation0;
            Rotation1 = gameObject.rotation1;
            Orientation = gameObject.orientation;

            if (gameObject.rotation2 == 0 && gameObject.rotation3 == 0)
            {
                gameObject.rotation2 = (float)Math.Sin(gameObject.orientation / 2);
                gameObject.rotation3 = (float)Math.Cos(gameObject.orientation / 2);
            }

            Rotation2 = gameObject.rotation2;
            Rotation3 = gameObject.rotation3;

            Type |= (int)TypeMask.TYPEMASK_GAMEOBJECT;
        }
Example #10
0
        public void AddCreatureEntity(creature creature)
        {
            var guid           = new ObjectGUID((ulong)creature.guid, TypeID.TYPEID_UNIT);
            var creatureEntity = new CreatureEntity(guid, creature, vanillaWorld);

            CreatureEntities.Add(creatureEntity);
            creatureEntity.Setup();
        }
Example #11
0
 public async Task RemoveInRangeObject(ObjectGUID guid, IObjectImpl obj, bool remove_other = true)
 {
     RemoveInRangeObjectImpl(guid, obj);
     if (remove_other)
     {
         await obj.RemoveInRangeObject(oGUID, this, false);
     }
 }
Example #12
0
        public PlayerEntity AddPlayerEntity(character character, WorldSession session)
        {
            ObjectGUID   guid         = new ObjectGUID((ulong)character.guid, TypeID.TYPEID_PLAYER);
            PlayerEntity playerEntity = new PlayerEntity(guid, character, session);

            PlayerEntities.Add(playerEntity);
            playerEntity.Setup();
            return(playerEntity);
        }
Example #13
0
        public void AddGameObjectEntity(gameobject gameObject)
        {
            var guid             = new ObjectGUID((ulong)gameObject.guid, TypeID.TYPEID_GAMEOBJECT);
            var template         = vanillaWorld.WorldDatabase.GetRepository <gameobject_template>().SingleOrDefault(t => t.entry == gameObject.id);
            var gameObjectEntity = new GameObjectEntity(guid, gameObject, template);

            GameObjectEntities.Add(gameObjectEntity);
            gameObjectEntity.Setup();
        }
Example #14
0
 protected void RemoveInRangeObjectImpl(ObjectGUID guid, IObjectImpl obj)
 {
     State.InRangeObjects.Remove(guid);
     _inrangeObjects.Remove(guid);
     if (obj is IPlayer)
     {
         _inrangePlayers.Remove(guid);
     }
 }
Example #15
0
        public async Task <bool> SetPlayer(IPlayer plr)
        {
            ObjectGUID plrGUID = new ObjectGUID((UInt64)plr.GetPrimaryKeyLong());

            if (State.GUID != 0)
            {
                return(false);
            }
            State.GUID = plrGUID;
            await Save();

            return(true);
        }
Example #16
0
        public UnitInfo(ObjectGUID guid) : base(guid)
        {
            Health    = 1;
            MaxHealth = 100;
            DisplayID = NativeDisplayID = 1;

            StandState      = 0;
            StandStateFlags = 0;
            Power           = 3;
            Type           |= (int)TypeMask.TYPEMASK_UNIT;

            Mana = MaxMana = MaxRage = 1000;

            WalkSpeed = 2.5f;
        }
Example #17
0
        public CreatureInfo(ObjectGUID objectGUID, creature creature, creature_template template) : base(objectGUID)
        {
            DisplayID = NativeDisplayID = creature.modelid;
            Health    = (int)creature.curhealth;
            MaxHealth = (int)template.MaxLevelHealth;
            Level     = template.MaxLevel;

            NPCFlags        = (int)template.NpcFlags;
            DynamicFlags    = (int)template.DynamicFlags;
            UnitFlag        = (int)template.UnitFlags;
            FactionTemplate = (uint)template.FactionAlliance;
            Entry           = template.Entry; //Used to set the creature name.

            CombatReach = 30f;
        }
Example #18
0
        public UnitInfo(ObjectGUID guid)
            : base(guid)
        {
            Health = 1;
            MaxHealth = 100;
            DisplayID = NativeDisplayID = 1;

            StandState = 0;
            StandStateFlags = 0;
            Power = 3;
            Type |= (int)TypeMask.TYPEMASK_UNIT;

            Mana = MaxMana = MaxRage = 1000;

            WalkSpeed = 2.5f;
        }
Example #19
0
        public CreatureInfo(ObjectGUID objectGUID, creature creature, creature_template template)
            : base(objectGUID)
        {
            DisplayID = NativeDisplayID = creature.modelid;
            Health = (int)creature.curhealth;
            MaxHealth = (int)template.MaxLevelHealth;
            Level = template.MaxLevel;

            NPCFlags = (int)template.NpcFlags;
            DynamicFlags = (int)template.DynamicFlags;
            UnitFlag = (int)template.UnitFlags;
            FactionTemplate = (uint)template.FactionAlliance;
            Entry = template.Entry; //Used to set the creature name.

            CombatReach = 30f;
        }
Example #20
0
        public async Task RemoveObject(ObjectGUID guid, IObjectImpl obj)
        {
            State.ObjectList.Remove(guid);
            State.ActiveObjects.Remove(guid);
            State.UpdatedObjects.Remove(guid);
            _objectCache.Remove(guid);

            bool activator = await obj.IsCellActivator();

            if (activator)
            {
                var posx = await obj.GetPositionX();

                var posy = await obj.GetPositionY();

                await DecRefCells(posx, posy);
            }
        }
Example #21
0
        public async Task AddInRangeObject(ObjectGUID guid, IObjectImpl obj, bool add_other = true)
        {
            if (guid == oGUID) //Cannot be inrange of self
            {
                return;
            }
            if (_inrangeObjects.ContainsKey(guid))
            {
                return; //already inrange
            }
            AddInRangeObjectImpl(guid, obj);

            await OnAddInRangeObject(guid, obj);

            if (add_other)
            {
                await obj.AddInRangeObject(oGUID, this, false);
            }
        }
Example #22
0
        public static IObjectImpl GetObject(IGrainFactory factory, ObjectGUID guid)
        {
            var highguid = guid.ToHighGUID();

            switch (highguid)
            {
            case HighGuid.HIGHGUID_UNIT:
            {
                return(factory.GetGrain <ICreature>(guid.ToInt64()));
            }

            case HighGuid.HIGHGUID_PLAYER:
            {
                return(factory.GetGrain <IPlayer>(guid.ToInt64()));
            }
            }

            return(factory.GetGrain <IObject>(0));
        }
Example #23
0
        protected void AddInRangeObjectImpl(ObjectGUID guid, IObjectImpl obj)
        {
            if (guid == oGUID) //Cannot be inrange of self
            {
                return;
            }
            if (!State.InRangeObjects.Contains(guid))
            {
                State.InRangeObjects.Add(guid);
            }
            if (!_inrangeObjects.ContainsKey(guid))
            {
                _inrangeObjects.Add(guid, obj);
                if (obj is IPlayer)
                {
                    _inrangePlayers.Add(guid, obj);
                }
            }

            if (_inrangeObjectTracker != null)
            {
                _inrangeObjectTracker.Add(guid, obj);
            }
        }
Example #24
0
 public async Task RemoveObject(ObjectGUID guid, IObjectImpl obj)
 {
     State.Objects.Remove(guid);
     _objectCache.Remove(guid);
     await obj.SetCell(0);
 }
Example #25
0
 public async Task AddObject(ObjectGUID guid, IObjectImpl obj)
 {
     State.Objects.Add(guid);
     _objectCache.Add(guid, obj);
     await obj.SetCell((UInt64) this.GetPrimaryKeyLong());
 }
Example #26
0
 public ObjectInfo(ObjectGUID guid)
 {
     GUID = guid.RawGUID;
     Type = (int)TypeMask.TYPEMASK_OBJECT;
     Scale = 1;
 }
Example #27
0
        public PlayerInfo(ObjectGUID guid, character databaseCharacter, ChrRaces race, ChrClasses chrClass)
            : base(guid)
        {
            this.Class = chrClass;
            this.ClassID = this.Class.ClassID;
            this.Gender = databaseCharacter.gender;
            this.Power = (byte)this.Class.PowerType;

            this.Race = race;
            this.RaceID = race.RaceID;
            this.FactionTemplate = race.FactionID;
            this.DisplayID = this.NativeDisplayID = (int)(this.Gender == 0 ? race.ModelM : race.ModelF);
            this.Health = (int)databaseCharacter.health;

            //Level = databaseCharacter.Level;
            this.XP = (int)databaseCharacter.xp;
            this.NextLevelXP = 400;

            Byte[] playerBytes = BitConverter.GetBytes(databaseCharacter.playerBytes);
            Byte[] playerBytes2 = BitConverter.GetBytes(databaseCharacter.playerBytes2);

            this.Skin = playerBytes[0];
            this.Face = playerBytes[1];
            this.HairStyle = playerBytes[2];
            this.HairColor = playerBytes[3];
            this.Accessory = playerBytes2[0];

            FactionTemplate = race.FactionID;
            UnitFlag = (int)UnitFlags.UNIT_FLAG_PVP;
            FlagUnk = 0x08 | 0x20;
            WatchedFactionIndex = (int)databaseCharacter.watchedFaction;

            this.Money = (int)databaseCharacter.money;

            /*

            item_template[] equipment = ItemUtils.GenerateInventoryByIDs(Utils.CSVStringToIntArray(databaseCharacter.equipmentCache));
            VisualItems = new Item[19];
            for (byte itemSlot = 0; itemSlot < 19; itemSlot++)
            {
                if (equipment == null) return;
                if (equipment[itemSlot] != null)
                {
                    VisualItems[itemSlot] = new Item()
                                                {
                                                    Creator = guid.RawGUID,
                                                    EnchantmentIDs = new[] { 0, 0 },
                                                    Entry = equipment[itemSlot].entry,
                                                    RandomPropertyID = equipment[itemSlot].RandomProperty,
                                                    ItemSuffixFactor = 3
                                                };

                }
                else
                {
                    VisualItems[itemSlot] = new Item()
                                                {
                                                    Creator = 0,
                                                    EnchantmentIDs = new[] { 0, 0 },
                                                    Entry = 0,
                                                    RandomPropertyID = 0,
                                                    ItemSuffixFactor = 0
                                                };
                }
            }*/

            Type |= (int)TypeMask.TYPEMASK_PLAYER;
        }
Example #28
0
 public Item()
 {
     GUID = new ObjectGUID(TypeID.TYPEID_ITEM, HighGUID.HIGHGUID_ITEM);
 }
Example #29
0
 public override async Task OnAddInRangeObject(ObjectGUID guid, IObjectImpl obj)
 {
     await BuildCreateUpdateForObject(obj);
 }
Example #30
0
 public virtual Task OnAddInRangeObject(ObjectGUID guid, IObjectImpl obj)
 {
     return(TaskDone.Done);
 }
Example #31
0
 public ObjectEntity(ObjectGUID objectGUID) : base(objectGUID)
 {
     this.Location = new Location();
 }
Example #32
0
 protected UnitEntity(ObjectGUID objectGUID) : base(objectGUID)
 {
 }
Example #33
0
        public PlayerInfo(ObjectGUID guid, character databaseCharacter, ChrRaces race, ChrClasses chrClass) : base(guid)
        {
            this.Class   = chrClass;
            this.ClassID = this.Class.ClassID;
            this.Gender  = databaseCharacter.gender;
            this.Power   = (byte)this.Class.PowerType;

            this.Race            = race;
            this.RaceID          = race.RaceID;
            this.FactionTemplate = race.FactionID;
            this.DisplayID       = this.NativeDisplayID = (int)(this.Gender == 0 ? race.ModelM : race.ModelF);
            this.Health          = (int)databaseCharacter.health;

            //Level = databaseCharacter.Level;
            this.XP          = (int)databaseCharacter.xp;
            this.NextLevelXP = 400;

            Byte[] playerBytes  = BitConverter.GetBytes(databaseCharacter.playerBytes);
            Byte[] playerBytes2 = BitConverter.GetBytes(databaseCharacter.playerBytes2);

            this.Skin      = playerBytes[0];
            this.Face      = playerBytes[1];
            this.HairStyle = playerBytes[2];
            this.HairColor = playerBytes[3];
            this.Accessory = playerBytes2[0];

            FactionTemplate     = race.FactionID;
            UnitFlag            = (int)UnitFlags.UNIT_FLAG_PVP;
            FlagUnk             = 0x08 | 0x20;
            WatchedFactionIndex = (int)databaseCharacter.watchedFaction;


            this.Money = (int)databaseCharacter.money;

/*
 *
 *          item_template[] equipment = ItemUtils.GenerateInventoryByIDs(Utils.CSVStringToIntArray(databaseCharacter.equipmentCache));
 *          VisualItems = new Item[19];
 *          for (byte itemSlot = 0; itemSlot < 19; itemSlot++)
 *          {
 *              if (equipment == null) return;
 *              if (equipment[itemSlot] != null)
 *              {
 *                  VisualItems[itemSlot] = new Item()
 *                                              {
 *                                                  Creator = guid.RawGUID,
 *                                                  EnchantmentIDs = new[] { 0, 0 },
 *                                                  Entry = equipment[itemSlot].entry,
 *                                                  RandomPropertyID = equipment[itemSlot].RandomProperty,
 *                                                  ItemSuffixFactor = 3
 *                                              };
 *
 *              }
 *              else
 *              {
 *                  VisualItems[itemSlot] = new Item()
 *                                              {
 *                                                  Creator = 0,
 *                                                  EnchantmentIDs = new[] { 0, 0 },
 *                                                  Entry = 0,
 *                                                  RandomPropertyID = 0,
 *                                                  ItemSuffixFactor = 0
 *                                              };
 *              }
 *          }*/

            Type |= (int)TypeMask.TYPEMASK_PLAYER;
        }
Example #34
0
 public GameObjectEntity(ObjectGUID objectGUID, gameobject databaseGameObject, gameobject_template template)
     : base(objectGUID)
 {
     this.Template   = template;
     this.GameObject = databaseGameObject;
 }
Example #35
0
 public ObjectInfo(ObjectGUID guid)
 {
     GUID  = guid.RawGUID;
     Type  = (int)TypeMask.TYPEMASK_OBJECT;
     Scale = 1;
 }