Ejemplo n.º 1
0
        void RecvSynchronizeDynamicEntity(IIPSocket conn, BitStream r)
        {
            var           mapEntityIndex = r.ReadMapEntityIndex();
            DynamicEntity e = Map.GetDynamicEntity(mapEntityIndex);

            e.Deserialize(r);
        }
Ejemplo n.º 2
0
        void RecvEmote(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var emoticon       = r.ReadEnum <Emoticon>();

            var entity = Map.GetDynamicEntity(mapEntityIndex);

            if (entity == null)
            {
                return;
            }

            EmoticonDisplayManager.Instance.Add(entity, emoticon, GetTime());
        }
Ejemplo n.º 3
0
        void RecvCharAttack(IIPSocket conn, BitStream r)
        {
            // Read the values
            var attackerID = r.ReadMapEntityIndex();

            MapEntityIndex?attackedID;

            if (r.ReadBool())
            {
                attackedID = r.ReadMapEntityIndex();
            }
            else
            {
                attackedID = null;
            }

            ActionDisplayID?actionDisplayIDNullable;

            if (r.ReadBool())
            {
                actionDisplayIDNullable = r.ReadActionDisplayID();
            }
            else
            {
                actionDisplayIDNullable = null;
            }

            // Get the object references using the IDs provided
            var attacker = _objGrabber.GetDynamicEntity <Character>(attackerID);

            if (attacker == null)
            {
                return;
            }

            DynamicEntity attacked = attackedID.HasValue ? Map.GetDynamicEntity(attackedID.Value) : null;

            // Use the default ActionDisplayID if we were provided with a null value
            ActionDisplayID actionDisplayID = !actionDisplayIDNullable.HasValue ? GameData.DefaultActionDisplayID : actionDisplayIDNullable.Value;

            // Get the ActionDisplay to use and, if valid, execute it
            var actionDisplay = ActionDisplayScripts.ActionDisplays[actionDisplayID];

            if (actionDisplay != null)
            {
                actionDisplay.Execute(Map, attacker, attacked);
            }
        }
Ejemplo n.º 4
0
        void RecvPlaySoundAtEntity(IIPSocket conn, BitStream r)
        {
            var soundID = r.ReadSoundID();
            var index   = r.ReadMapEntityIndex();

            var entity = Map.GetDynamicEntity(index);

            if (entity == null)
            {
                return;
            }

            if (!SoundManager.Play(soundID, entity))
            {
                LogFailPlaySound(soundID);
            }
        }
Ejemplo n.º 5
0
        void RecvRemoveDynamicEntity(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var dynamicEntity  = Map.GetDynamicEntity(mapEntityIndex);

            if (dynamicEntity == null)
            {
                return;
            }

            Map.RemoveEntity(dynamicEntity);

            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Removed DynamicEntity with index `{0}`", mapEntityIndex);
            }

            dynamicEntity.Dispose();
        }
Ejemplo n.º 6
0
        void RecvChatSay(IIPSocket conn, BitStream r)
        {
            var name           = r.ReadString(GameData.MaxServerSayNameLength);
            var mapEntityIndex = r.ReadMapEntityIndex();
            var text           = r.ReadString(GameData.MaxServerSayLength);

            var chatText = CreateChatText(name, text);

            GameplayScreen.AppendToChatOutput(chatText);

            var entity = Map.GetDynamicEntity(mapEntityIndex);

            if (entity == null)
            {
                return;
            }

            GameplayScreen.AddChatBubble(entity, text);
        }
Ejemplo n.º 7
0
        void RecvStartShopping(IIPSocket conn, BitStream r)
        {
            var shopOwnerIndex = r.ReadMapEntityIndex();
            var canBuy         = r.ReadBool();
            var name           = r.ReadString();
            var itemCount      = r.ReadByte();

            var items = new IItemTemplateTable[itemCount];

            for (var i = 0; i < itemCount; i++)
            {
                var value = new ItemTemplateTable();
                value.ReadState(r);
                items[i] = value;
            }

            var shopOwner = Map.GetDynamicEntity(shopOwnerIndex);
            var shopInfo  = new ShopInfo <IItemTemplateTable>(shopOwner, name, canBuy, items);

            GameplayScreen.ShopForm.DisplayShop(shopInfo);
        }
Ejemplo n.º 8
0
        void RecvUseEntity(IIPSocket conn, BitStream r)
        {
            var usedEntityIndex = r.ReadMapEntityIndex();
            var usedByIndex     = r.ReadMapEntityIndex();

            // Grab the used DynamicEntity
            var usedEntity = _objGrabber.GetDynamicEntity <IUsableEntity>(usedEntityIndex);

            if (usedEntity == null)
            {
                return;
            }

            // Grab the one who used this DynamicEntity (we can still use it, we'll just pass null)
            var usedBy = Map.GetDynamicEntity(usedByIndex);

            if (usedBy == null)
            {
                return;
            }

            // Use it
            usedEntity.Use(usedBy);
        }