本文整理汇总了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);
}
示例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));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}