public async Task TestFurnaceRecipeMatcher() { var loader = new FurnaceRecipeLoader(); using (var sr = new StreamReader(File.OpenRead(Path.Combine(RootDir, "furnace.txt")))) { await loader.LoadRecipes(sr); } var matcher = new FurnaceRecipeMatcher(loader.Recipes, loader.Fuels); var recipe = matcher.FindRecipe( new Slot { BlockId = (short)BlockStates.Wood().Id, ItemCount = 1 }); var fuel = matcher.FindFuel( new Slot { BlockId = (short)BlockStates.Wood().Id, ItemCount = 1 }); Assert.NotNull(recipe); Assert.Equal(ItemStates.Coal(CoalType.Charcoal), new ItemState { Id = (uint)recipe.Output.BlockId, MetaValue = (uint)recipe.Output.ItemDamage }); Assert.Equal((short)BlockStates.Wood().Id, fuel.Slot.BlockId); }
private DBAccessor() { //var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //SafeCreateDirectory(documents + @"\HardwareLedger\Database\"); //Directory = documents + @"\HardwareLedger\Database\{0}.json"; Directory = @"Database\{0}.json"; //SafeCreateDirectory(documents + @"\HardwareLedger\Database\"); SafeCreateDirectory(@"Database\"); data = new Dictionary <Type, List <IPgmRow> >(); Reserves = ReadJson <Reserve, DBObject.Reserve>(); ShopTypes = ReadJson <ShopType, DBObject.ShopType>(); ItemTypes = ReadJson <ItemType, DBObject.ItemType>(); ItemStates = ReadJson <ItemState, DBObject.ItemState>(); Malfunctions = ReadJson <Malfunction, DBObject.Malfunction>(); Relations = ReadJson <Relation, DBObject.Relation>(); CollectSchedules = ReadJson <CollectSchedule, DBObject.CollectSchedule>(); ReserveShippings = ReadJson <ReserveShipping, DBObject.ReserveShipping>(); data.Add(typeof(Reserve), Reserves.Cast <IPgmRow>().ToList()); data.Add(typeof(ShopType), ShopTypes.Cast <IPgmRow>().ToList()); data.Add(typeof(ItemType), ItemTypes.Cast <IPgmRow>().ToList()); data.Add(typeof(ItemState), ItemStates.Cast <IPgmRow>().ToList()); data.Add(typeof(Malfunction), Malfunctions.Cast <IPgmRow>().ToList()); data.Add(typeof(Relation), Relations.Cast <IPgmRow>().ToList()); data.Add(typeof(CollectSchedule), CollectSchedules.Cast <IPgmRow>().ToList()); data.Add(typeof(ReserveShipping), ReserveShippings.Cast <IPgmRow>().ToList()); }
public void CleanUp() { CleanUpRequests++; if (CleanUpRequests % 3 == 0) { ItemStates.RemoveWhere(o => !o.Item.IsAlive); foreach (var stateCollection in ItemStates) { stateCollection.CleanUp(); } } if (CleanUpRequests % 6 == 0) { var allValues = Owner.Items.Select(o => o.Value).Distinct().ToList(); ItemStates.RemoveWhere(o => !allValues.Contains(o.Item.Target)); foreach (var stateCollection in ItemStates) { stateCollection.CleanContexts(Owner.Items.Where(o => stateCollection.Item.Target.Equals(o.Value)) .Select(o => o.GetAncestors())); } } if (CleanUpRequests > 5) { CleanUpRequests = 0; } }
public void ChooseRandomState() { int stateNumber = Random.Range(0, System.Enum.GetNames(typeof(ItemStates)).Length); itemState = (ItemStates)stateNumber; ChooseColor(); }
public void LoadExpansionState(ITreeViewModelItem treeViewModelItem) { var isExpanded = ItemStates.SingleOrDefault(o => o.Item.IsAlive && o.Item.Target.Equals(treeViewModelItem.Value))?. GetExpansionState(treeViewModelItem.GetAncestors().Select(o => o.Value)); if (isExpanded != null) { treeViewModelItem.IsExpanded = (bool)isExpanded; } }
/// <summary> /// Initialises a new instance of the Item class. /// </summary> /// <param name="weight">The weight.</param> /// <param name="texture">The texture.</param> /// <param name="itemType">The type.</param> /// <param name="owner">The owning game world.</param> public Item(float weight, string texture, string itemType, GameWorld owner) : base(owner) { _itemType = itemType; _texture = texture; _isReserved = false; _isMemberOfSpatialIndex = false; _itemState = ItemStates.Nowhere; _holder = null; _weight = weight; _position = new Point(-1, -1); _storageSize = 1; }
public void SaveExpansionState(ITreeViewModelItem treeViewModelItem) { var currentStates = ItemStates.SingleOrDefault(o => o.Item.IsAlive && o.Item.Target.Equals(treeViewModelItem.Value)); if (currentStates != null) { currentStates.SetExpansionState(treeViewModelItem.GetAncestors().Select(o => o.Value), treeViewModelItem.IsExpanded); } else { var stateRetainer = new ReferenceExpansionRetainer(treeViewModelItem.Value); stateRetainer.SetExpansionState(treeViewModelItem.GetAncestors().Select(o => o.Value), treeViewModelItem.IsExpanded); ItemStates.Add(stateRetainer); } }
private void Start() { itemState = ItemStates.Dirty; }
public void SetItemState(ItemStates state) { itemState = state; }