コード例 #1
0
        private void CreateItemFromItemDrop(IEventArgs fr, Vector3 p, ItemDrop drop, string realName)
        {
            FreeMoveEntity en = fr.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(fr.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            en.AddPosition();
            en.position.Value = new Vector3(p.x, p.y, p.z);

            en.AddFreeData(FreeUtil.ReplaceVar(name, fr), null);
            en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            if (type == 1)
            {
                en.freeData.Cat = FreeEntityConstant.DeadBox;
            }
            else if (type == 2)
            {
                en.freeData.Cat = FreeEntityConstant.DropBox;
            }

            en.AddFlagImmutability(fr.GameContext.session.currentTimeObject.CurrentTime);

            SimpleItemInfo info = new SimpleItemInfo(realName, drop.cat, drop.id, drop.count, en.entityKey.Value.EntityId);

            en.freeData.Value = SingletonManager.Get <DeadBoxParser>().ToString(info);

            en.isFlagSyncNonSelf = true;
        }
コード例 #2
0
        public override void DoAction(IEventArgs args)
        {
            FreeMoveEntity en = args.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            if (pos == null)
            {
                en.AddPosition();
                en.position.Value = new Vector3(FreeUtil.ReplaceFloat(x, args), FreeUtil.ReplaceFloat(y, args),
                                                FreeUtil.ReplaceFloat(z, args));
            }
            else
            {
                UnitPosition up = pos.Select(args);
                en.AddPosition();
                en.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
            }

            string realCat = FreeUtil.ReplaceVar(cat, args);

            if (realCat == null)
            {
                realCat = "";
            }
            string realValue = FreeUtil.ReplaceVar(value, args);

            if (realValue == null)
            {
                realValue = "";
            }
            en.AddFreeData(FreeUtil.ReplaceVar(key, args), null);
            en.freeData.Cat      = realCat;
            en.freeData.Value    = realValue;
            en.isFlagSyncNonSelf = true;

            en.AddFlagImmutability(args.GameContext.session.currentTimeObject.CurrentTime);

            if (distance > 0)
            {
                en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, distance);
            }

            if (!string.IsNullOrEmpty(lifeTime))
            {
                en.AddLifeTime(DateTime.Now, FreeUtil.ReplaceInt(lifeTime, args));
            }
        }
コード例 #3
0
        private int CreateItemFromInventory(IEventArgs fr, FreeData fd, ItemInventory ii, Vector3 p, string realName, int entityId)
        {
            int itemAdded = 0;

            if (ii != null && ii.name != ChickenConstant.BagGround)
            {
                foreach (ItemPosition ip in ii.GetItems())
                {
                    FreeMoveEntity en = fr.GameContext.freeMove.CreateEntity();
                    en.AddEntityKey(new EntityKey(fr.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
                    en.AddPosition();
                    en.position.Value = new Vector3(p.x, p.y, p.z);

                    en.AddFreeData(FreeUtil.ReplaceVar(name, fr), null);
                    en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
                    en.freeData.Cat = FreeEntityConstant.DeadBox;

                    FreeItemInfo itemInfo = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());

                    if (itemInfo.cat == (int)ECategory.Weapon)
                    {
                        int key = CarryClipUtil.GetWeaponKey(ii.name, fd);
                        if (key >= 1 && key <= 3)
                        {
                            CarryClipUtil.AddCurrentClipToBag(key, fd, fr);
                        }
                    }

                    en.AddFlagImmutability(fr.GameContext.session.currentTimeObject.CurrentTime);

                    SimpleItemInfo info = new SimpleItemInfo(realName, itemInfo.cat, itemInfo.id, ip.GetCount(), en.entityKey.Value.EntityId);
                    en.freeData.Value    = SingletonManager.Get <DeadBoxParser>().ToString(info);
                    en.freeData.IntValue = entityId;

                    en.isFlagSyncNonSelf = true;

                    itemAdded++;
                }
            }

            return(itemAdded);
        }