Пример #1
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            base.OnGroundIdle(entityItem);

            IWorldAccessor world = entityItem.World;

            if (world.Side != EnumAppSide.Server)
            {
                return;
            }

            if (entityItem.Swimming && world.Rand.NextDouble() < 0.03)
            {
                TryFillFromBlock(entityItem, entityItem.SidedPos.AsBlockPos);
            }

            if (entityItem.Swimming && world.Rand.NextDouble() < 0.01)
            {
                ItemStack[] stacks = GetContents(world, entityItem.Itemstack);
                if (MealMeshCache.ContentsRotten(stacks))
                {
                    for (int i = 0; i < stacks.Length; i++)
                    {
                        if (stacks[i] != null && stacks[i].StackSize > 0 && stacks[i].Collectible.Code.Path == "rot")
                        {
                            world.SpawnItemEntity(stacks[i], entityItem.ServerPos.XYZ);
                        }
                    }

                    SetContent(entityItem.Itemstack, null);
                }
            }
        }
Пример #2
0
 public void NotifyPlayerDroppedItemHandlers(EntityPlayer _player, EntityItem _item)
 {
     if (OnPlayerDroppedItem != null)
     {
         OnPlayerDroppedItem(_player, _item);
     }
 }
Пример #3
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            base.OnGroundIdle(entityItem);

            IWorldAccessor world = entityItem.World;

            if (world.Side != EnumAppSide.Server)
            {
                return;
            }

            if (entityItem.Swimming && world.Rand.NextDouble() < 0.01)
            {
                ItemStack[] stacks = GetContents(world, entityItem.Itemstack);

                if (MealMeshCache.ContentsRotten(stacks))
                {
                    for (int i = 0; i < stacks.Length; i++)
                    {
                        if (stacks[i] != null && stacks[i].StackSize > 0 && stacks[i].Collectible.Code.Path == "rot")
                        {
                            world.SpawnItemEntity(stacks[i], entityItem.ServerPos.XYZ);
                        }
                    }

                    Block block = world.GetBlock(new AssetLocation(Attributes["eatenBlock"].AsString()));
                    entityItem.Itemstack = new ItemStack(block);
                    entityItem.WatchedAttributes.MarkPathDirty("itemstack");
                }
            }
        }
Пример #4
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            base.OnGroundIdle(entityItem);

            IWorldAccessor world = entityItem.World;

            if (world.Side != EnumAppSide.Server)
            {
                return;
            }

            if (entityItem.Swimming && world.Rand.NextDouble() < 0.01)
            {
                ItemStack[] stacks = GetContents(world, entityItem.Itemstack);
                if (MealMeshCache.ContentsRotten(stacks))
                {
                    for (int i = 0; i < stacks.Length; i++)
                    {
                        if (stacks[i] != null && stacks[i].StackSize > 0 && stacks[i].Collectible.Code.Path == "rot")
                        {
                            world.SpawnItemEntity(stacks[i], entityItem.ServerPos.XYZ);
                        }
                    }

                    entityItem.Itemstack.Attributes.RemoveAttribute("recipeCode");
                    entityItem.Itemstack.Attributes.RemoveAttribute("quantityServings");
                    entityItem.Itemstack.Attributes.RemoveAttribute("contents");
                }
            }
        }
Пример #5
0
        public async Task <IActionResult> PutEntityItem([FromRoute] int id, [FromBody] EntityItem entityItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != entityItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(entityItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EntityItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #6
0
        private EntityItem Builder(string key, byte[] value, DistributedCacheEntryOptions options)
        {
            var            now = DateTimeOffset.Now;
            DateTimeOffset endTime;

            if (options.AbsoluteExpirationRelativeToNow != null)
            {
                var absoluteExpirationRelativeToNow = options.AbsoluteExpirationRelativeToNow.Value;
                var dayString = DateTimeOffset.Now.ToString("yyyy/MM/dd");
                endTime = new DateTimeOffset(Convert.ToDateTime(dayString), absoluteExpirationRelativeToNow);
            }
            else if (options.AbsoluteExpiration != null)
            {
                endTime = options.AbsoluteExpiration.Value;
            }
            else if (options.SlidingExpiration != null)
            {
                endTime = DateTimeOffset.Now.Add(options.SlidingExpiration.Value);
            }
            else
            {
                throw new Exception("options invalid");
            }

            var entity = new EntityItem()
            {
                Key         = key,
                Value       = value,
                CreatedTime = now,
                EndTime     = endTime
            };

            return(entity);
        }
Пример #7
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            entityItem.Die(EnumDespawnReason.Removed);

            if (entityItem.World.Side == EnumAppSide.Server)
            {
                Vec3d pos = entityItem.ServerPos.XYZ;

                WaterTightContainableProps props = BlockLiquidContainerBase.GetContainableProps(entityItem.Itemstack);
                float litres = (float)entityItem.Itemstack.StackSize / props.ItemsPerLitre;

                entityItem.World.SpawnCubeParticles(pos, entityItem.Itemstack, 0.75f, Math.Min(100, (int)(2 * litres)), 0.45f);
                entityItem.World.PlaySoundAt(new AssetLocation("sounds/environment/smallsplash"), (float)pos.X, (float)pos.Y, (float)pos.Z, null);

                BlockEntityFarmland bef = api.World.BlockAccessor.GetBlockEntity(pos.AsBlockPos) as BlockEntityFarmland;
                if (bef != null)
                {
                    bef.WaterFarmland(Height.ToInt() / 6f, false);
                    bef.MarkDirty(true);
                }
            }



            base.OnGroundIdle(entityItem);
        }
Пример #8
0
        // current reached waypoint
        protected override void waypointReached(int index)
        {
            Console.WriteLine("waypointReached {0}", index);

            if (index == this.ignoredIndex)
            {
                this.ignoredIndex = -1;
                return;
            }


            Waypoint currWP = this.waypointList[index];

            if (currWP.type == WaypointType.Gathering)
            {
                this.currentIndex = index;
                this.movement.pause();
                EntityItem item = this.findEntityItemNode(currWP);
                if (item != null)
                {
                    this.startGathering(item);
                }
                else
                {
                    this.movement.resume();
                }
            }
        }
Пример #9
0
        public int UpdateItem(EntityItem entItem)
        {
            int cnt = 0;

            try
            {
                List <SqlParameter> lstParam = new List <SqlParameter>();
                Commons.ADDParameter(ref lstParam, "@ItemCode", DbType.String, entItem.ItemCode);
                Commons.ADDParameter(ref lstParam, "@ItemDesc", DbType.String, entItem.ItemDesc);
                Commons.ADDParameter(ref lstParam, "@ReorderLevel", DbType.Int32, entItem.ReorderLevel);
                Commons.ADDParameter(ref lstParam, "@ReorderMaxLevel", DbType.Int32, entItem.ReorderMaxLevel);
                Commons.ADDParameter(ref lstParam, "@UnitCode", DbType.String, entItem.UnitCode);
                Commons.ADDParameter(ref lstParam, "@SupplierCode", DbType.String, entItem.SupplierCode);
                Commons.ADDParameter(ref lstParam, "@OpenningBalance", DbType.Decimal, entItem.OpeningBalance);
                Commons.ADDParameter(ref lstParam, "@Rate", DbType.Decimal, entItem.Rate);
                Commons.ADDParameter(ref lstParam, "@GroupId", DbType.Int32, entItem.GroupId);
                Commons.ADDParameter(ref lstParam, "@ManifacturingDate", DbType.DateTime, entItem.ManifacturingDate);
                Commons.ADDParameter(ref lstParam, "@ExpiryDate", DbType.DateTime, entItem.ExpiryDate);
                Commons.ADDParameter(ref lstParam, "@ChangeBy", DbType.String, entItem.ChangeBy);
                cnt = mobjDataAcces.ExecuteQuery("sp_UpdateItem", lstParam);
            }
            catch (Exception ex)
            {
                Commons.FileLog("ItemBLL -  UpdateItem(EntityItem entItem)", ex);
            }

            return(cnt);
        }
Пример #10
0
        bool TryPlace(EntityItem entityItem, int offX, int offY, int offZ)
        {
            IWorldAccessor world = entityItem.World;
            BlockPos       pos   = entityItem.ServerPos.AsBlockPos.Add(offX, offY, offZ);
            Block          block = world.BlockAccessor.GetBlock(pos.DownCopy());

            if (!block.SideSolid[BlockFacing.UP.Index])
            {
                return(false);
            }

            bool ok = TryPlaceBlock(world, null, entityItem.Itemstack, new BlockSelection()
            {
                Position    = pos,
                Face        = BlockFacing.UP,
                HitPosition = new Vec3d(0.5, 1, 0.5)
            });

            if (ok)
            {
                entityItem.World.PlaySoundAt(entityItem.Itemstack.Block.Sounds?.Place, pos.X, pos.Y, pos.Z, null);
            }

            return(ok);
        }
        private void PopulateForm()
        {
            cmbEntity.Items.Clear();
            var entities = Caller.GetDisplayEntities();

            if (entities != null)
            {
                object selectedItem = null;
                foreach (var entity in entities)
                {
                    if (entity.Value.IsIntersect != true && FetchXmlBuilder.views.ContainsKey(entity.Value.LogicalName + "|S"))
                    {
                        var ei = new EntityItem(entity.Value);
                        cmbEntity.Items.Add(ei);
                        if (entity.Value.LogicalName == Caller.settings.LastOpenedViewEntity)
                        {
                            selectedItem = ei;
                        }
                    }
                }
                if (selectedItem != null)
                {
                    cmbEntity.SelectedItem = selectedItem;
                    UpdateViews();
                }
            }
            Enabled = true;
        }
Пример #12
0
        //On contact with entity, if the entity is on the top and the entity is an item entity, pull the entity into the hopper's inventory.

        public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact)
        {
            base.OnEntityCollide(world, entity, pos, facing, collideSpeed, isImpact);

            // Don't suck up everything instantly
            if (world.Rand.NextDouble() < 0.9)
            {
                return;
            }

            if (facing == BlockFacing.UP && entity is EntityItem)
            {
                EntityItem  inWorldItem = (EntityItem)entity;
                BlockEntity blockEntity = world.BlockAccessor.GetBlockEntity(pos);
                if (blockEntity is BlockEntityItemFlow)
                {
                    BlockEntityItemFlow beItemFlow = (BlockEntityItemFlow)blockEntity;

                    WeightedSlot ws = beItemFlow.inventory.GetBestSuitedSlot(inWorldItem.Slot);

                    if (ws.slot != null) //we have determined there is room for this itemStack in this inventory.
                    {
                        inWorldItem.Slot.TryPutInto(api.World, ws.slot, 1);
                        if (inWorldItem.Slot.StackSize <= 0)
                        {
                            inWorldItem.Itemstack = null;
                        }
                    }
                }
            }
        }
Пример #13
0
        private void selectNodesAt(int x, int y)
        {
            float blockSize = (float)(zoomInput.Value);

            x = (int)Math.Floor(x / blockSize);
            y = (int)Math.Floor(y / blockSize);

            entityTableLocked = true;

            List <int> sel = new List <int>();

            foreach (ListViewItem listItem in entityTable.Items)
            {
                EntityItem item = (EntityItem)(listItem.Tag);
                listItem.Selected = (item.X == x && item.Y == y);
                if (listItem.Selected)
                {
                    listItem.EnsureVisible();
                }
                listItem.Focused = listItem.Selected;
            }

            entityTableLocked = false;
            entityTable.Focus();
            draw();
        }
Пример #14
0
        public void Ancertor1()
        {
            // create a simple object
            var model = new Class1
            {
                Class1_Prop1 = "Value1",
                Class1_Prop2 = new Class2()
                {
                    Class2_Prop2  = "ValueChild",
                    Class2_Field1 = 1000
                }
            };

            // transversal navigation
            Expression <object> expression            = model.AsExpression();
            EntityItem <object> lastItem              = expression.Last();
            IEnumerable <EntityItem <object> > result = lastItem.Ancestors();

            foreach (EntityItem <object> item in result)
            {
                System.Console.WriteLine(GetEntity(item));
            }

            System.Console.WriteLine("-> Parent");

            // Get first ancertos (parent)
            result = lastItem.Ancestors((item, depth) => depth == 1);

            foreach (var item in result)
            {
                System.Console.WriteLine(GetEntity(item));
            }
        }
Пример #15
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            if (entityItem.World.Side == EnumAppSide.Client || !entityItem.CollidedVertically)
            {
                return;
            }
            IBlockAccessor bA  = entityItem.World.BlockAccessor;
            BlockPos       pos = entityItem.LocalPos.AsBlockPos;

            if (TryPlace(bA, pos, entityItem))
            {
                return;
            }

            around.Shuffle(entityItem.World.Rand);

            foreach (BlockPos ipos in around)
            {
                BlockPos tpos = pos.Add(ipos);
                if (TryPlace(bA, tpos, entityItem))
                {
                    return;
                }
            }
        }
Пример #16
0
        private void updateListView()
        {
            this.list.update();
            int count = this.list.Count;

            this.countLabel.Text = count.ToString();

            this.entityListView.Items.Clear();

            for (int i = 0; i < count; ++i)
            {
                EntityItem eItem = this.list.itemAtIndex(i);
                if (eItem != null)
                {
                    ListViewItem item = new ListViewItem(eItem.uniqueId.ToString());
                    item.SubItems.Add(eItem.name);
                    item.SubItems.Add(eItem.visibleStatus.ToString());
                    item.SubItems.Add(eItem.typeId.ToString());
                    item.SubItems.Add(eItem.interacrtionId.ToString());

                    item.SubItems.Add(eItem.position.x.ToString());
                    item.SubItems.Add(eItem.position.y.ToString());
                    item.SubItems.Add(eItem.position.z.ToString());
                    item.SubItems.Add(eItem.position.r.ToString());
                    item.SubItems.Add(eItem.distance.ToString());

                    item.ForeColor = Color.LightGray;
                    this.entityListView.Items.Add(item);
                }
            }
        }
Пример #17
0
        public JsonResult GetItemInfo()
        {
            string     itemUrl    = Request["itemUrl"];
            EntityItem itemOnline = CommonHandler.GetItemOnline(itemUrl);

            itemOnline.item_url = ItemUrlPrefix + itemOnline.item_id;
            return(Json(itemOnline, JsonRequestBehavior.AllowGet));
        }
Пример #18
0
        //private static void ProcessEntityFallingBlock(EntityFallingBlock block)
        //{

        //}

        private void ProcessEntityItem(EntityItem item)
        {
            if (logItems)
            {
                Log.Out($"{Config.ModPrefix} Item Dropped:[{item.entityId}]{item.itemStack.count}x {item.itemStack.itemValue.ItemClass.Name} @{(int)item.position.x} {(int)item.position.y} {(int)item.position.z}");
            }
            item.lifetime = lifetime;
        }
Пример #19
0
        public static void SpawnItems(ClientInfo _cInfo)
        {
            try
            {
                if (StartingItems.Dict.Count > 0)
                {
                    World world = GameManager.Instance.World;
                    if (world.Players.dict.ContainsKey(_cInfo.entityId))
                    {
                        EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
                        if (_player != null && _player.IsSpawned() && !_player.IsDead())
                        {
                            PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].StartingItems = true;
                            PersistentContainer.DataChange = true;
                            List <string> _itemList = StartingItems.Dict.Keys.ToList();
                            for (int i = 0; i < _itemList.Count; i++)
                            {
                                string _item = _itemList[i];
                                StartingItems.Dict.TryGetValue(_item, out int[]  _itemData);
                                ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_item, false).type, false);
                                if (_itemValue.HasQuality && _itemData[1] > 0)
                                {
                                    _itemValue.Quality = _itemData[1];
                                }
                                EntityItem entityItem = new EntityItem();
                                entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                                {
                                    entityClass     = EntityClass.FromString("item"),
                                    id              = EntityFactory.nextEntityID++,
                                    itemStack       = new ItemStack(_itemValue, _itemData[0]),
                                    pos             = world.Players.dict[_cInfo.entityId].position,
                                    rot             = new Vector3(20f, 0f, 20f),
                                    lifetime        = 60f,
                                    belongsPlayerId = _cInfo.entityId
                                });
                                world.SpawnEntityInWorld(entityItem);
                                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                                Thread.Sleep(TimeSpan.FromSeconds(1));
                            }
                            Log.Out(string.Format("[SERVERTOOLS] '{0}' with id '{1}' received their starting items", _cInfo.playerName, _cInfo.CrossplatformId.CombinedString));
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] '{0}' with id '{1}' received their starting items", _cInfo.playerName, _cInfo.CrossplatformId.CombinedString));

                            Phrases.Dict.TryGetValue("StartingItems1", out string _phrase);
                            ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Player with id '{0}' has not spawned. Unable to give starting items", _cInfo.CrossplatformId.CombinedString));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in GiveStartingItemsConsole.SpawnItems: {0}", e.Message));
            }
        }
Пример #20
0
 public static void BuyAuction(ClientInfo _cInfo, int _purchase, int _price)
 {
     if (AuctionItems.TryGetValue(_purchase, out string _steamId))
     {
         if (PersistentContainer.Instance.Players[_steamId].Auction != null && PersistentContainer.Instance.Players[_steamId].Auction.Count > 0)
         {
             PersistentContainer.Instance.Players[_steamId].Auction.TryGetValue(_purchase, out ItemDataSerializable _itemData);
             ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_itemData.name, false).type, false);
             if (_itemValue != null)
             {
                 _itemValue.UseTimes = _itemData.useTimes;
                 _itemValue.Quality  = _itemData.quality;
                 World      world      = GameManager.Instance.World;
                 EntityItem entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                 {
                     entityClass     = EntityClass.FromString("item"),
                     id              = EntityFactory.nextEntityID++,
                     itemStack       = new ItemStack(_itemValue, _itemData.count),
                     pos             = world.Players.dict[_cInfo.entityId].position,
                     rot             = new Vector3(20f, 0f, 20f),
                     lifetime        = 60f,
                     belongsPlayerId = _cInfo.entityId
                 });
                 world.SpawnEntityInWorld(entityItem);
                 _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                 world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned);
                 AuctionItems.Remove(_purchase);
                 PersistentContainer.Instance.Players[_steamId].Auction.Remove(_purchase);
                 PersistentContainer.Instance.AuctionPrices.Remove(_purchase);
                 PersistentContainer.DataChange = true;
                 Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _price);
                 float _fee           = _price * ((float)Tax / 100);
                 int   _adjustedPrice = _price - (int)_fee;
                 Wallet.AddCoinsToWallet(_steamId, _adjustedPrice);
                 string _playerName = PersistentOperations.GetPlayerDataFileFromSteamId(_steamId).ecd.entityName;
                 using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                 {
                     sw.WriteLine(string.Format("{0}: {1} {2} has purchased auction entry {3}, profits went to steam id {4} {5}", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _purchase, _steamId, _playerName));
                     sw.WriteLine();
                     sw.Flush();
                     sw.Close();
                 }
                 Phrases.Dict.TryGetValue(629, out string _phrase629);
                 _phrase629 = _phrase629.Replace("{Count}", _itemData.count.ToString());
                 _phrase629 = _phrase629.Replace("{ItemName}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName());
                 _phrase629 = _phrase629.Replace("{Value}", _price.ToString());
                 _phrase629 = _phrase629.Replace("{CoinName}", Wallet.Coin_Name);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase629 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_steamId);
                 if (_cInfo2 != null)
                 {
                     Phrases.Dict.TryGetValue(630, out string _phrase630);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase630 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
 }
Пример #21
0
        /// <summary>
        /// Spawns a dropped item into the world.
        /// </summary>
        public EntityItem spawnItem(ItemStack stack, Vector3 position, Quaternion rotation, Vector3 force)
        {
            EntityItem entityItem = (EntityItem)this.spawnEntity(EntityRegistry.item, position, rotation);

            entityItem.setStack(stack);
            entityItem.rBody.AddForce(force, ForceMode.Impulse);

            return(entityItem);
        }
 public EntityItem Convert(EntityBase <TContent> source, EntityItem destination, ResolutionContext context)
 {
     return(new EntityItem
     {
         Id = source.Id,
         Name = source.Name ?? string.Empty,
         ContentsCount = source.Contents.Count
     });
 }
Пример #23
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            if (entityItem.World.Side == EnumAppSide.Client)
            {
                return;
            }
            if (entityItem.ShouldDespawn)
            {
                return;
            }

            if (TryPlace(entityItem, 0, 0, 0))
            {
                entityItem.Die(EnumDespawnReason.Removed, null);
                return;
            }
            if (TryPlace(entityItem, 0, 1, 0))
            {
                entityItem.Die(EnumDespawnReason.Removed, null);
                return;
            }
            if (TryPlace(entityItem, 0, -1, 0))
            {
                entityItem.Die(EnumDespawnReason.Removed, null);
                return;
            }

            if (!entityItem.CollidedVertically)
            {
                return;
            }

            List <BlockPos> offsetsList = new List <BlockPos>();

            for (int x = -1; x < 1; x++)
            {
                for (int y = -1; y < 1; y++)
                {
                    for (int z = -1; z < 1; z++)
                    {
                        offsetsList.Add(new BlockPos(x, y, z));
                    }
                }
            }

            BlockPos[] offsets = offsetsList.ToArray();
            offsets.Shuffle(entityItem.World.Rand);

            for (int i = 0; i < offsets.Length; i++)
            {
                if (TryPlace(entityItem, offsets[i].X, offsets[i].Y, offsets[i].Z))
                {
                    entityItem.Die(EnumDespawnReason.Removed, null);
                    return;
                }
            }
        }
 public static bool Import(string filepath, EntityItemData entityItemData)
 {
     // using (var fs = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     using (var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         // ブック読み込み
         IWorkbook book;
         if (Path.GetExtension(filepath) == ".xls")
         {
             book = new HSSFWorkbook(fs);
         }
         else if (Path.GetExtension(filepath) == ".xlsx")
         {
             book = new XSSFWorkbook(fs);
         }
         else
         {
             Debug.LogError("拡張子がエクセルファイルではありません: " + filepath);
             return(false);
         }
         // シート読み込み
         var items         = new List <EntityItem>();
         var entity_type   = typeof(EntityItem);
         var entity_fields = entity_type.GetFields(BindingFlags.Instance | BindingFlags.Public);
         for (int sheet_idx = 0, total_sheets = book.NumberOfSheets; sheet_idx < total_sheets; ++sheet_idx)
         {
             // シート取得
             ISheet sheet = book.GetSheetAt(sheet_idx);
             // シート名の先頭に#がついていたら、無視する
             if (sheet.SheetName.StartsWith("#"))
             {
                 continue;
             }
             // 行データ読み込み
             for (int i = kStartRow, l = sheet.LastRowNum; i <= l; ++i)
             {
                 Debug.Log($"\t行{i}の読み込み");
                 var row  = sheet.GetRow(i);
                 var clm  = kStartColumn;
                 var item = new EntityItem();
                 // skip
                 if (row.GetCell(clm++).StringCellValueEx().Any())
                 {
                     continue;
                 }
                 foreach (var field in entity_fields)
                 {
                     field.SetValue(item, row.GetCell(clm++).GetValue(field.FieldType));
                 }
                 items.Add(item);
                 Debug.Log($"\t結果:{item}");
             }
         }
         entityItemData.dataList = items.ToArray();
     }
     return(true);
 }
Пример #25
0
        private List <SqlParameter> CreateParameterDeleteItem(EntityItem entItem)
        {
            List <SqlParameter> lstParam = new List <SqlParameter>();

            Commons.ADDParameter(ref lstParam, "@ItemCode", DbType.String, entItem.ItemCode);
            Commons.ADDParameter(ref lstParam, "@Discontinued", DbType.Boolean, entItem.DisContinued);
            Commons.ADDParameter(ref lstParam, "@DisContRemark", DbType.String, entItem.DisContRemark);
            return(lstParam);
        }
Пример #26
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            base.OnGroundIdle(entityItem);
            IWorldAccessor world = entityItem.World;

            GroundTransform.Rotation.Y = world.ElapsedMilliseconds / 10f % 360f;
            GroundTransform.Rotation.Z = world.ElapsedMilliseconds / 10f % 360f;
            GroundTransform.Rotation.X = world.ElapsedMilliseconds / 10f % 360f;
        }
Пример #27
0
        public EntityItemRenderer(Entity entity, ICoreClientAPI api) : base(entity, api)
        {
            entityitem = (EntityItem)entity;
            scaleRand  = (float)api.World.Rand.NextDouble() / 20f - 1 / 40f;

            touchGroundMS = entityitem.itemSpawnedMilliseconds - api.World.Rand.Next(5000);

            yRotRand = (float)api.World.Rand.NextDouble() * GameMath.TWOPI;
        }
Пример #28
0
        public void NotifyPlayerCollectedItemHandlers(EntityPlayer _player, EntityItem _item)
        {
            if (OnPlayerCollectedItem != null)
            {
                ItemStack itemStack = ItemUtils.GetItemStack(_item);

                OnPlayerCollectedItem(_player, itemStack);
            }
        }
Пример #29
0
        public override void OnGroundIdle(EntityItem entityItem)
        {
            base.OnGroundIdle(entityItem);

            if (entityItem.FeetInLiquid)
            {
                SetRemainingWateringSeconds(entityItem.Itemstack, CapacitySeconds);
            }
        }
Пример #30
0
        void DoSelectItem(Location location)
        {
            EntityItem matchInside          = null;
            EntityItem nearestMatch         = null;
            int        nearestMatchDistance = int.MaxValue;

            foreach (EntityItem item in classItems)
            {
                if (item.IsInSamePart)
                {
                    IClass c = (IClass)item.Entity;
                    if (c.Region.IsInside(location.Line, location.Column))
                    {
                        matchInside = item;
                        // when there are multiple matches inside (nested classes), use the last one
                    }
                    else
                    {
                        // Not a perfect match?
                        // Try to first the nearest match. We want the classes combo box to always
                        // have a class selected if possible.
                        int matchDistance = Math.Min(Math.Abs(location.Line - c.Region.BeginLine),
                                                     Math.Abs(location.Line - c.Region.EndLine));
                        if (matchDistance < nearestMatchDistance)
                        {
                            nearestMatchDistance = matchDistance;
                            nearestMatch         = item;
                        }
                    }
                }
            }
            jumpOnSelectionChange = false;
            try {
                classComboBox.SelectedItem = matchInside ?? nearestMatch;
                // the SelectedItem setter will update the list of member items
            } finally {
                jumpOnSelectionChange = true;
            }
            matchInside = null;
            foreach (EntityItem item in memberItems)
            {
                if (item.IsInSamePart)
                {
                    IMember member = (IMember)item.Entity;
                    if (member.Region.IsInside(location.Line, location.Column) || member.BodyRegion.IsInside(location.Line, location.Column))
                    {
                        matchInside = item;
                    }
                }
            }
            jumpOnSelectionChange = false;
            try {
                membersComboBox.SelectedItem = matchInside;
            } finally {
                jumpOnSelectionChange = true;
            }
        }
Пример #31
0
 public void ejectRecord(World world, int i, int j, int k, int l)
 {
     world.playRecord(null, i, j, k);
     world.setBlockMetadataWithNotify(i, j, k, 0);
     int i1 = (Item.record13.shiftedIndex + l) - 1;
     float f = 0.7F;
     double d = (world.rand.nextFloat()*f) + (1.0F - f)*0.5D;
     double d1 = (world.rand.nextFloat()*f) + (1.0F - f)*0.20000000000000001D +
                 0.59999999999999998D;
     double d2 = (world.rand.nextFloat()*f) + (1.0F - f)*0.5D;
     var entityitem = new EntityItem(world, i + d, j + d1, k + d2,
                                     new ItemStack(i1, 1, 0));
     entityitem.delayBeforeCanPickup = 10;
     world.entityJoinedWorld(entityitem);
 }
Пример #32
0
 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k,
     int l)
 {
     int i1 = world.getBlockId(i, j, k);
     Material material = world.getBlockMaterial(i, j + 1, k);
     if (!material.isSolid() && i1 == Block.grass.blockID || i1 == Block.dirt.blockID)
     {
         Block block = Block.tilledField;
         world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, block.stepSound.func_737_c(),
                               (block.stepSound.func_738_a() + 1.0F)/2.0F, block.stepSound.func_739_b()*0.8F);
         if (world.singleplayerWorld)
         {
             return true;
         }
         world.setBlockWithNotify(i, j, k, block.blockID);
         itemstack.damageItem(1);
         if (world.rand.nextInt(8) == 0 && i1 == Block.grass.blockID)
         {
             int j1 = 1;
             for (int k1 = 0; k1 < j1; k1++)
             {
                 float f = 0.7F;
                 float f1 = world.rand.nextFloat()*f + (1.0F - f)*0.5F;
                 float f2 = 1.2F;
                 float f3 = world.rand.nextFloat()*f + (1.0F - f)*0.5F;
                 var entityitem = new EntityItem(world, i + f1, j + f2, k + f3,
                                                 new ItemStack(seeds));
                 entityitem.delayBeforeCanPickup = 10;
                 world.entityJoinedWorld(entityitem);
             }
         }
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #33
0
        public EntityItem CreateSmartFormEntityFromObjectDefinition(ObjectDefinition metaObj)
        {
            Log.WriteVerbose(string.Format(BeginLogMessage, CLASS_NAME, "CreateSmartFormEntityFromObjectDefinition(ObjectDefinition metaObj)"));
            EntityItem entity = new EntityItem();

            entity.Name = metaObj.DisplayName;

            foreach (FieldDefinition field in metaObj.Fields)
            {
                EntityItemProperty property = new EntityItemProperty()
                {
                    Name = field.Id,
                    DisplayName = field.DisplayName
                    //Type = field.DataType.
                };
                entity.Properties.Add(property);
            }
            Log.WriteVerbose(string.Format(FinishLogMessage, CLASS_NAME, "CreateSmartFormEntityFromObjectDefinition(ObjectDefinition metaObj)"));
            return entity;
        }
Пример #34
0
        public ObjectDefinition GetSmartFormObjectDefinition(EntityItem entity)
        {
            Log.WriteVerbose(string.Format(BeginLogMessage, CLASS_NAME, "GetSmartFormObjectDefinition(EntityItem entity)"));
            ObjectDefinition metaObj = new ObjectDefinition("SmartForm|Sharepoint");
            metaObj.DisplayName = entity.Name;

            foreach (EntityItemProperty property in entity.Properties)
            {
                FieldDefinition field = new FieldDefinition(property.Name, property.DisplayName, new FieldType(typeof(string)), false, false);
            }
            Log.WriteVerbose(string.Format(FinishLogMessage, CLASS_NAME, "GetSmartFormObjectDefinition(EntityItem entity)"));
            return metaObj;
        }