当前位置: 首页>>代码示例>>C#>>正文


C# World.OnSpawnEntity方法代码示例

本文整理汇总了C#中World.OnSpawnEntity方法的典型用法代码示例。如果您正苦于以下问题:C# World.OnSpawnEntity方法的具体用法?C# World.OnSpawnEntity怎么用?C# World.OnSpawnEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.OnSpawnEntity方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     if (!(world.GetBlock(updatedBlock + Vector3.Down) is FarmlandBlock))
     {
         var entity = new ItemEntity(updatedBlock + new Vector3(0.5), new ItemStack(new PumpkinSeedsItem()));
         entity.ApplyRandomVelocity();
         world.SetBlock(updatedBlock, new AirBlock());
         world.OnSpawnEntity(entity);
         return;
     }
     if (!world.UpdatePending(updatedBlock))
     {
         var possibleLocations = new List<Vector3>(new[]
         {
             updatedBlock + Vector3.Left, updatedBlock + Vector3.Right,
             updatedBlock + Vector3.Forwards, updatedBlock + Vector3.Backwards
         });
         bool found = false;
         for (int i = 0; i < possibleLocations.Count; i++)
         {
             if (world.GetBlock(possibleLocations[i]) is PumpkinBlock)
                 found = true;
         }
         if (!found)
             ScheduleGrowth(world, updatedBlock);
     }
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:28,代码来源:PumpkinStemBlock.cs

示例2: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     if (world.GetBlock(updatedBlock + Vector3.Down) == 0)
     {
         world.SetBlock(updatedBlock, new AirBlock());
         world.OnSpawnEntity(new BlockEntity(updatedBlock, this));
     }
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:8,代码来源:GravelBlock.cs

示例3: OnItemUsedOnBlock

 public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entity usedBy)
 {
     var entity = PaintingEntity.CreateEntity(world, clickedBlock, clickedSide);
     if (entity != null)
         world.OnSpawnEntity(entity);
     // TODO: Remove items like this from the inventory after use
     base.OnItemUsedOnBlock(world, clickedBlock, clickedSide, cursorPosition, usedBy);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:8,代码来源:PaintingItem.cs

示例4: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     if (!(world.GetBlock(updatedBlock + Vector3.Down) is FarmlandBlock))
     {
         var entity = new ItemEntity(updatedBlock + new Vector3(0.5), new ItemStack(new PotatoItem()));
         entity.ApplyRandomVelocity();
         world.SetBlock(updatedBlock, new AirBlock());
         world.OnSpawnEntity(entity);
     }
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:11,代码来源:PotatoBlock.cs

示例5: OnItemUsedOnBlock

 public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide,
     Vector3 cursorPosition, Entity usedBy)
 {
     var direction = ItemFrameEntity.Vector3ToDirection(clickedSide);
     if (direction.HasValue)
     {
         var entity = new ItemFrameEntity(ItemStack.EmptyStack, direction.Value, clickedBlock);
         world.OnSpawnEntity(entity);
     }
     base.OnItemUsedOnBlock(world, clickedBlock, clickedSide, cursorPosition, usedBy);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:11,代码来源:ItemFrameItem.cs

示例6: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     var block = world.GetBlock(updatedBlock + Vector3.Down);
     if (!(block is SugarCaneBlock || block is DirtBlock || block is GrassBlock || block is SandBlock))
     {
         world.SetBlock(updatedBlock, new AirBlock());
         var entity = new ItemEntity(updatedBlock + new Vector3(0.5), new ItemStack(new SugarCanesItem()));
         entity.ApplyRandomVelocity();
         world.OnSpawnEntity(entity);
     }
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:12,代码来源:SugarCaneBlock.cs

示例7: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     var below = world.GetBlock(updatedBlock + Vector3.Down);
     if (!(below is SandBlock || below is CactusBlock))
     {
         world.SetBlock(updatedBlock, new AirBlock());
         var entity = new ItemEntity(updatedBlock + new Vector3(0.5), new ItemStack(this));
         entity.ApplyRandomVelocity();
         world.OnSpawnEntity(entity);
     }
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:12,代码来源:CactusBlock.cs

示例8: UsedByEntity

 public override void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
 {
     var player = usedBy as PlayerEntity;
     if (!leftClick)
     {
         if (!Item.Empty)
         {
             Orientation++;
             OnPropertyChanged("Metadata");
         }
         else
         {
             if (!player.SelectedItem.Empty)
             {
                 var slot = player.SelectedItem;
                 Item = new ItemStack(slot.Id, 1, slot.Metadata, slot.Nbt);
                 if (player.GameMode != GameMode.Creative)
                 {
                     slot.Count--;
                     player.Inventory[player.SelectedSlot] = slot;
                 }
             }
         }
     }
     else
     {
         world.OnDestroyEntity(this);
         if (player.GameMode != GameMode.Creative)
         {
             var spawnPosition = Position + new Vector3(0.5);
             switch (Direction)
             {
                 case ItemFrameDirection.North: spawnPosition += Vector3.North; break;
                 case ItemFrameDirection.South: spawnPosition += Vector3.South; break;
                 case ItemFrameDirection.East:  spawnPosition += Vector3.East;  break;
                 case ItemFrameDirection.West:  spawnPosition += Vector3.West;  break;
             }
             var frame = new ItemEntity(spawnPosition, new ItemStack(new ItemFrameItem()));
             var item = new ItemEntity(spawnPosition, Item);
             frame.ApplyRandomVelocity();
             item.ApplyRandomVelocity();
             world.OnSpawnEntity(frame);
             world.OnSpawnEntity(item);
         }
     }
     base.UsedByEntity(world, leftClick, usedBy);
 }
开发者ID:seaboy1234,项目名称:Craft.Net,代码行数:47,代码来源:ItemFrameEntity.cs

示例9: UsedByEntity

 public override void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
 {
     if (leftClick)
         world.OnDestroyEntity(this);
     var player = usedBy as PlayerEntity;
     bool drop = true;
     if (player != null)
     {
         if (player.GameMode == GameMode.Creative)
             drop = false;
     }
     if (drop)
     {
         var item = new ItemEntity(Center, new ItemStack(new PaintingItem()));
         item.ApplyRandomVelocity();
         world.OnSpawnEntity(item);
     }
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:18,代码来源:PaintingEntity.cs


注:本文中的World.OnSpawnEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。