本文整理汇总了C#中IItemRepository.GetItemProvider方法的典型用法代码示例。如果您正苦于以下问题:C# IItemRepository.GetItemProvider方法的具体用法?C# IItemRepository.GetItemProvider怎么用?C# IItemRepository.GetItemProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IItemRepository
的用法示例。
在下文中一共展示了IItemRepository.GetItemProvider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateFurnace
private void UpdateFurnace(IEventScheduler scheduler, IWorld world, Coordinates3D coords, IItemRepository itemRepository)
{
if (TrackedFurnaces.ContainsKey(coords))
TrackedFurnaces.Remove(coords);
if (world.GetBlockID(coords) != FurnaceBlock.BlockID && world.GetBlockID(coords) != LitFurnaceBlock.BlockID)
{
/*if (window != null && !window.IsDisposed)
window.Dispose();*/
return;
}
var state = GetState(world, coords);
var inputStack = state.Items[FurnaceWindow.IngredientIndex];
var outputStack = state.Items[FurnaceWindow.OutputIndex];
var input = itemRepository.GetItemProvider(inputStack.ID) as ISmeltableItem;
// Update burn time
var burnTime = state.BurnTimeRemaining;
if (state.BurnTimeRemaining > 0)
{
state.BurnTimeRemaining -= 20; // ticks
if (state.BurnTimeRemaining <= 0)
{
state.BurnTimeRemaining = 0;
state.BurnTimeTotal = 0;
world.SetBlockID(coords, FurnaceBlock.BlockID);
}
}
// Update cook time
if (state.CookTime < 200 && state.CookTime >= 0)
{
state.CookTime += 20; // ticks
if (state.CookTime >= 200)
state.CookTime = 200;
}
// Are we done cooking?
if (state.CookTime == 200 && burnTime > 0)
{
state.CookTime = -1;
if (input != null && (outputStack.Empty || outputStack.CanMerge(input.SmeltingOutput)))
{
if (outputStack.Empty)
outputStack = input.SmeltingOutput;
else if (outputStack.CanMerge(input.SmeltingOutput))
outputStack.Count += input.SmeltingOutput.Count;
state.Items[FurnaceWindow.OutputIndex] = outputStack;
state.Items[FurnaceWindow.IngredientIndex].Count--;
}
}
SetState(world, coords, state);
TryInitializeFurnace(state, scheduler, world, coords, itemRepository);
}
示例2: TryInitializeFurnace
private void TryInitializeFurnace(FurnaceState state, IEventScheduler scheduler, IWorld world,
Coordinates3D coords, IItemRepository itemRepository)
{
if (TrackedFurnaces.ContainsKey(coords))
return;
var inputStack = state.Items[FurnaceWindow.IngredientIndex];
var fuelStack = state.Items[FurnaceWindow.FuelIndex];
var outputStack = state.Items[FurnaceWindow.OutputIndex];
var input = itemRepository.GetItemProvider(inputStack.ID) as ISmeltableItem;
var fuel = itemRepository.GetItemProvider(fuelStack.ID) as IBurnableItem;
if (state.BurnTimeRemaining > 0)
{
if (state.CookTime == -1 && input != null && (outputStack.Empty || outputStack.CanMerge(input.SmeltingOutput)))
{
state.CookTime = 0;
SetState(world, coords, state);
}
var subject = new FurnaceEventSubject();
TrackedFurnaces[coords] = subject;
scheduler.ScheduleEvent("smelting", subject, TimeSpan.FromSeconds(1),
server => UpdateFurnace(server.Scheduler, world, coords, itemRepository));
return;
}
if (fuel != null && input != null) // We can maybe start
{
if (outputStack.Empty || outputStack.CanMerge(input.SmeltingOutput))
{
// We can definitely start
state.BurnTimeRemaining = state.BurnTimeTotal = (short)(fuel.BurnTime.TotalSeconds * 20);
state.CookTime = 0;
state.Items[FurnaceWindow.FuelIndex].Count--;
SetState(world, coords, state);
world.SetBlockID(coords, LitFurnaceBlock.BlockID);
var subject = new FurnaceEventSubject();
TrackedFurnaces[coords] = subject;
scheduler.ScheduleEvent("smelting", subject, TimeSpan.FromSeconds(1),
server => UpdateFurnace(server.Scheduler, world, coords, itemRepository));
}
}
}