//Get secondary Item public IConsumable getItem(int slot) { //Use when first starting if (_item == null) { _item = _slots[slot]; _currentSlot = slot; } return _item; }
public void Consume(IConsumable consumable) { this.ActualStats.Update(consumable.stats, MaxStats); RemoveItem(consumable); }
//Set Item slot, slots can be from 1-6 public void setSlot(int slot, IConsumable passed) { _slots[slot - 1] = passed; }
public override void Init(IConsumable consumable) { base.Init(consumable); count = 1; m_count.text = count + ""; }
/// <summary>Get an ingredient needed for a recipe.</summary> /// <param name="id">The item or category ID.</param> /// <param name="count">The number of items to find.</param> /// <param name="consumable">The matching consumables.</param> /// <param name="type">The item type to find, or <c>null</c> to match any.</param> /// <returns>Returns whether the requirement is met.</returns> public bool TryGetIngredient(int id, int count, out IConsumable consumable, ItemType?type = ItemType.Object) { return(this.TryGetIngredient(item => (type == null || item.Type == type) && (item.Sample.ParentSheetIndex == id || item.Sample.Category == id), count, out consumable)); }
public void AddConsumable(IConsumable item) { this.Consumables.Add(item); }
// provide override for IsFull (Full at 1200 Calories) public override void Consume(IConsumable item) { // provide override for Consume }
public Dictionary <string, ArrayList> GetDataCollection(ISection sections, PatientClinicalInformation ptInformation) { Dictionary <string, ArrayList> componententries = new Dictionary <string, ArrayList>(); IEntryCollection entries = sections.Entry; IStrucDocText sectiontext = sections.Text; IStrucDocElementCollection textitem = sectiontext.Items; if (entries.Count() > 0) { int count = 0; foreach (IEntry singlerecord in entries) { itemAct = singlerecord.AsAct; itemEncounter = singlerecord.AsEncounter; itemSubstanceAdministration = singlerecord.AsSubstanceAdministration; observation = singlerecord.AsObservation; organizer = singlerecord.AsOrganizer; procedure = singlerecord.AsProcedure; //if(sections.Code.Code== "18776-5") // { // } ArrayList arrayList = new ArrayList(); if (itemAct != null) { entryRelationship = itemAct.EntryRelationship; IIVL_TS efftime = itemAct.EffectiveTime; if (efftime != null && efftime.Low != null) { if (efftime.Low.Value != null) { arrayList.Add(efftime.Low.AsDateTime.ToString()); } else { arrayList.Add("null"); } } else { arrayList.Add("null"); } if (entryRelationship != null && entryRelationship.Count > 0) { observation = entryRelationship.Select(o => o.AsObservation).FirstOrDefault(); if (observation != null) { if (observation.Participant.Count() > 0) { string participent = observation.Participant.Select(p => p.ParticipantRole).FirstOrDefault().AsPlayingEntity.Name.FirstOrDefault().Text; arrayList.Add(participent); } entity = observation.EntryRelationship; foreach (IEntryRelationship singlentity in entity) { IObservation entityobservation = singlentity.AsObservation; IANY observationvalue = entityobservation.Value.FirstOrDefault(); if (observationvalue != null) { var obj = observationvalue.GetType(); string objname = obj.Name; switch (objname) { default: ICD strcd = (ICD)observationvalue; arrayList.Add(strcd.Code); arrayList.Add(strcd.DisplayName); break; case "PQ": IPQ strpq = (IPQ)observationvalue; arrayList.Add(strpq.Value.ToString() + " " + strpq.Unit.ToString()); break; } } } componententries.Add(count.ToString(), arrayList); count++; } } else { arrayList.Add(itemAct.Text.Text); componententries.Add(count.ToString(), arrayList); count++; } } else if (itemEncounter != null) { entryRelationship = itemEncounter.EntryRelationship; if ((entryRelationship.Select(t => t.TypeCode).FirstOrDefault().ToString()) == "RSON") { observation = entryRelationship.Select(o => o.AsObservation).FirstOrDefault(); IIVL_TS efftime = observation.EffectiveTime; IANY observationvalue = observation.Value.FirstOrDefault(); ICD str = (ICD)observationvalue; arrayList.Add(str.DisplayName); arrayList.Add(ptInformation.ptClinicInformation.ClinicName); if (efftime.Low != null) { arrayList.Add(efftime.Low.AsDateTime); } else { arrayList.Add(null); } arrayList.Add(str.Code); } componententries.Add(count.ToString(), arrayList); count++; } else if (itemSubstanceAdministration != null) { consumable = itemSubstanceAdministration.Consumable; manufacturedProduct = consumable.ManufacturedProduct; material = manufacturedProduct.AsMaterial; arrayList.Add(material.Code.Code); arrayList.Add(itemSubstanceAdministration.StatusCode.Code.ToString()); ISXCM_TSCollection efftime = itemSubstanceAdministration.EffectiveTime; if (efftime.Count > 1) { foreach (IVL_TS daterange in efftime) { string startdatetime = daterange.Low != null ? daterange.Low.Value != null?daterange.Low.AsDateTime.ToString() : "null" : "null"; string EndDAtetime = daterange.High != null ? daterange.High.Value != null?daterange.High.AsDateTime.ToString() : "null" : "null"; arrayList.Add(startdatetime); arrayList.Add(EndDAtetime); break; } } else { arrayList.Add(efftime[0].AsDateTime.ToString()); } arrayList.Add(material.Code.DisplayName); if (itemSubstanceAdministration.DoseQuantity != null) { arrayList.Add(itemSubstanceAdministration.DoseQuantity.Value.ToString() + " " + itemSubstanceAdministration.DoseQuantity.Unit.ToString()); } else { arrayList.Add("NA"); } if (manufacturedProduct.ManufacturerOrganization != null) { arrayList.Add(manufacturedProduct.ManufacturerOrganization.Name.ToString()); } else { arrayList.Add("NA"); } componententries.Add(count.ToString(), arrayList); count++; } else if (observation != null) { if (observation.Value.Count > 0) { IANY observationvalue = observation.Value.FirstOrDefault(); ICD str = (ICD)observationvalue; arrayList.Add(str.Code); arrayList.Add(str.DisplayName); IIVL_TS efftime = observation.EffectiveTime; if (efftime != null && efftime.Low != null) { if (efftime.Low.Value != null) { arrayList.Add(efftime.Low.AsDateTime.ToString()); } else { arrayList.Add("null"); } } else { arrayList.Add("null"); } } else { arrayList.Add(null); arrayList.Add(null); arrayList.Add(null); } componententries.Add(count.ToString(), arrayList); count++; } else if (organizer != null) { IComponent4Collection orgComponent = organizer.Component; foreach (IComponent4 objItem in orgComponent) { IObservation orgObservation = objItem.AsObservation; arrayList.Add(orgObservation.Code.DisplayName); if (orgObservation.Value != null) { IANY observationvalue = orgObservation.Value.FirstOrDefault(); var obj = observationvalue.GetType(); string objname = obj.Name; switch (objname) { default: ICD strcd = (ICD)observationvalue; arrayList.Add(strcd.Code); arrayList.Add(strcd.DisplayName); break; case "PQ": IPQ strpq = (IPQ)observationvalue; arrayList.Add(strpq.Value.ToString() + " " + strpq.Unit.ToString()); break; } //IPQ str = (IPQ)observationvalue; //arrayList.Add(str.Value.ToString() + " " + str.Unit.ToString()); } IIVL_TS efftime = orgObservation.EffectiveTime; if (efftime != null && efftime.Low != null) { if (efftime.Low.Value != null) { arrayList.Add(efftime.Low.AsDateTime.ToString()); } else { arrayList.Add("null"); } } else { arrayList.Add("null"); } if (orgObservation.ReferenceRange != null) { if (orgObservation.ReferenceRange.Count > 0) { arrayList.Add(orgObservation.ReferenceRange[0].ObservationRange.Text.Text); } else { arrayList.Add("NA"); } } } arrayList.Add(organizer.Code.Code); componententries.Add(count.ToString(), arrayList); count++; } else if (procedure != null) { if (procedure.Code != null) { arrayList.Add(procedure.Code.Code); arrayList.Add(procedure.Code.DisplayName); } else { arrayList.Add(null); arrayList.Add(null); } componententries.Add(count.ToString(), arrayList); count++; } } } return(componententries); }
private void Awake() { consumableComponent = GetComponent <IConsumable>(); consumedEffect = transform.Find("Consumed").gameObject as GameObject; this.ConsumedBehaviour = consumableComponent.ConsumedBehaviour; }
public abstract string Consume(IConsumable item);
public override bool MoveNext() { switch (_state) { case Start: _chain = _link.Compose(this); _link = null; _outer = _consumable.GetEnumerator(); _consumable = null; _state = OuterEnumeratorMoveNext; goto case OuterEnumeratorMoveNext; case OuterEnumeratorMoveNext: if (_outer.MoveNext()) { _inner = _outer.Current.GetEnumerator(); if (ReferenceEquals(_chain, this)) { _state = InnerEnumeratorMoveNextOnSelf; goto case InnerEnumeratorMoveNextOnSelf; } else { _state = InnerEnumeratorMoveNext; goto case InnerEnumeratorMoveNext; } } _state = Completing; goto case Completing; case InnerEnumeratorMoveNextOnSelf: if (!_inner.MoveNext()) { _inner.Dispose(); _inner = default; _state = OuterEnumeratorMoveNext; goto case OuterEnumeratorMoveNext; } Result = (V)(object)_inner.Current; // should be no-op as TResult should equal T return(true); case InnerEnumeratorMoveNext: if (_inner.MoveNext()) { _status = _chain.ProcessNext(_inner.Current); if (_status.IsFlowing()) { _state = CheckStopped; return(true); } _state = CheckStopped; goto case CheckStopped; } _inner.Dispose(); _inner = null; _state = OuterEnumeratorMoveNext; goto case OuterEnumeratorMoveNext; case CheckStopped: if (_status.IsStopped()) { _inner.Dispose(); _inner = null; _state = Completing; goto case Completing; } _state = InnerEnumeratorMoveNext; goto case InnerEnumeratorMoveNext; case Completing: if (_chain.ChainComplete(status & ~ChainStatus.Flow).NotStoppedAndFlowing()) { _state = Finished; return(true); } goto case Finished; case Finished: Result = default; _outer.Dispose(); _outer = null; _chain.ChainDispose(); _chain = null; _state = PostFinished; goto default; default: return(false); } }
public abstract void Nom(IConsumable item);
/// <summary> /// Initializes a new instance of the <see cref="T:ConsumptionInfo" /> class. /// </summary> public ConsumptionInfo([NotNull] IConsumable consumed, float?amount, DateTime?consumedAt) { Consumed = consumed; Amount = amount; ConsumedAt = consumedAt; }
public Resource(ResourceType resourceType, IConsumable consumable, float quantity) { ResourceType = resourceType; Consumable = consumable; Quantity = quantity; }
void IShopManager.AddConsumable(IConsumable type) { m_consumables.Add(type); GameManager.instance.notificationManager.OnShopItemsChanged?.Invoke(); }
public void AddToMenu(IConsumable item) { Menu.Add(item); }
public bool SetInput(IStorage input) { if (!Mod.CustomMachineRecipes.ContainsKey(this.big.FullId)) { return(false); } foreach (var recipe in Mod.CustomMachineRecipes[this.big.FullId]) { if (!input.TryGetIngredient((item) => recipe.Ingredients[0].Matches(item.Sample), recipe.Ingredients[0].Quantity, out IConsumable firstConsume)) { continue; } bool foundAll = true; IConsumable[] consumes = new IConsumable[recipe.Ingredients.Count]; consumes[0] = firstConsume; for (int i = 1; i < recipe.Ingredients.Count; ++i) { if (input.TryGetIngredient((item) => recipe.Ingredients[i].Matches(item.Sample), recipe.Ingredients[i].Quantity, out IConsumable consumed)) { consumes[i] = consumed; } else { foundAll = false; break; } } if (foundAll) { foreach (var consume in consumes) { consume.Take(); } this.big.TextureOverride = recipe.MachineWorkingTextureOverride; this.big.PendingTextureOverride = recipe.MachineFinishedTextureOverride; this.big.PulseIfWorking = recipe.MachinePulseWhileWorking; this.big.heldObject.Value = (StardewValley.Object)recipe.Result.Choose().Create(); this.big.MinutesUntilReady = recipe.MinutesToProcess; if (recipe.StartWorkingSound != null) { this.Location.playSound(recipe.StartWorkingSound); } if (recipe.WorkingLightOverride.HasValue) { bool oldIsLamp = this.big.isLamp.Value; this.big.isLamp.Value = recipe.WorkingLightOverride.Value; if (!oldIsLamp && this.big.isLamp.Value) { this.big.initializeLightSource(this.big.tileLocation.Value); } else if (oldIsLamp && !this.big.isLamp.Value) { this.Location.removeLightSource((int)(this.big.tileLocation.X * 797f + this.big.tileLocation.Y * 13f + 666f)); } } } } return(false); }
public static IEnumerator <V> Get <Enumerable, T, V>(IConsumable <Enumerable> selectMany, ILink <T, V> link) where Enumerable : IEnumerable <T> { return(new ConsumerEnumerators.SelectMany <Enumerable, T, V>(selectMany, link)); }
private void setSelected(IConsumable option) { this.selected = option; this.selectionEnded = true; }
public override void Init(IConsumable consumable) { base.Init(consumable); price.text = consumable.GetPrice() + ""; }
public abstract void Eat(IConsumable item);
public bool lookForIngredient(RecipeBlueprint srb, IngredientBlueprint ib, IStorage input, out IConsumable consumable) { return(input.TryGetIngredient((t) => { var item = t.Sample; item.Stack = t.Count; if (item is StardewValley.Object obj) { return srb.fitsIngredient(item, srb.materials); } return false; }, ib.stack, out consumable)); }
/**** ** TryGetIngredient ****/ /// <summary>Get an ingredient needed for a recipe.</summary> /// <param name="predicate">Returns whether an item should be matched.</param> /// <param name="count">The number of items to find.</param> /// <param name="consumable">The matching consumables.</param> /// <returns>Returns whether the requirement is met.</returns> public bool TryGetIngredient(Func <ITrackedStack, bool> predicate, int count, out IConsumable consumable) { StackAccumulator stacks = new StackAccumulator(); foreach (ITrackedStack input in this.GetItems().Where(predicate)) { TrackedItemCollection stack = stacks.Add(input); if (stack.Count >= count) { consumable = new Consumable(stack, count); return(consumable.IsMet); } } consumable = null; return(false); }
/// <summary>Provide input to the machine.</summary> /// <param name="input">The available items.</param> /// <returns>Returns whether the machine started processing an item.</returns> public bool SetInput(IStorage input) { if (!Machine.blueprint.production.Exists(p => p.materials != null && p.materials.Count > 0)) { return(false); } /* * if (Machine.blueprint.conditionaldropin && !Machine.meetsConditions) * { * Machine.meetsConditions = PyUtils.CheckEventConditions(Machine.conditions, this); * }*/ if (Machine.blueprint.conditionaldropin && !Machine.meetsConditions) { return(false); } List <IConsumable> consumables = new List <IConsumable>(); IConsumable starterItem = null; if (Machine.blueprint.starter is IngredientBlueprint ib && Machine.starterRecipe is RecipeBlueprint srb && !lookForIngredient(srb, ib, input, out starterItem)) { return(false); } if (starterItem is IConsumable) { consumables.Add(starterItem); } List <RecipeBlueprint> checkedRecipes = new List <RecipeBlueprint>(); List <IngredientBlueprint> checkedIngredients = new List <IngredientBlueprint>(); RecipeBlueprint recipe = null; StardewValley.Object dropIn = null; foreach (ITrackedStack item in input.GetItems()) { if (item.Sample is StardewValley.Object obj && Machine.findRecipeForItemType(obj) is RecipeBlueprint rb && !checkedRecipes.Contains(rb)) { checkedRecipes.Add(rb); List <IConsumable> iMaterials = new List <IConsumable>(); bool hasAll = true; foreach (IngredientBlueprint ing in rb.materials) { IConsumable nextItem = null; if (!checkedIngredients.Contains(ing) && lookForIngredient(rb, ing, input, out nextItem)) { iMaterials.Add(nextItem); } else { if (!checkedIngredients.Contains(ing)) { checkedIngredients.Add(ing); } hasAll = false; break; } } if (hasAll) { recipe = rb; dropIn = obj; consumables.AddRange(iMaterials); break; } } } if (recipe is RecipeBlueprint foundRecipe) { List <Item> materials = new List <Item>(); foreach (IConsumable con in consumables) { materials.Add(con.Take()); } Machine.startProduction(dropIn, recipe, new List <IList <Item> >() { materials }); return(true); } return(false); }
private void castSpell(IConsumable _spell, BattleCharacter target) { Spell spell = (Spell)_spell; EnqueueAction(spell.Use(this.character, target)); }
public void AddToInventory(IConsumable c) { loot.Add(c); }
public abstract void Consume(IConsumable item);
/**** ** TryGetIngredient ****/ /// <summary>Get an ingredient needed for a recipe.</summary> /// <param name="predicate">Returns whether an item should be matched.</param> /// <param name="count">The number of items to find.</param> /// <param name="consumable">The matching consumables.</param> /// <returns>Returns whether the requirement is met.</returns> public bool TryGetIngredient(Func <ITrackedStack, bool> predicate, int count, out IConsumable consumable) { int countMissing = count; ITrackedStack[] consumables = this.GetItems().Where(predicate) .TakeWhile(chestItem => { if (countMissing <= 0) { return(false); } countMissing -= chestItem.Count; return(true); }) .ToArray(); consumable = new Consumable(new TrackedItemCollection(consumables), count); return(consumable.IsMet); }
private void handleSwap(InputManager input) { int slotSelected = input.SelectItemNum; if (slotSelected >= 0) { _item = _slots[slotSelected]; _currentSlot = slotSelected; } else if (input.fCycle) { //Cycle items forward if (_currentSlot == 5) { _currentSlot = 0; _item = _slots[0]; } _currentSlot = _currentSlot + 1; _item = _slots[_currentSlot]; } else if (input.bCycle) { //Cycle items backwards if (_currentSlot == 0) { _currentSlot = 5; _item = _slots[5]; } _currentSlot = _currentSlot + 1; _item = _slots[_currentSlot]; } }
/// <summary>Get an ingredient needed for a recipe.</summary> /// <param name="id">The item or category ID.</param> /// <param name="count">The number of items to find.</param> /// <param name="consumable">The matching consumables.</param> /// <returns>Returns whether the requirement is met.</returns> public bool TryGetIngredient(int id, int count, out IConsumable consumable) { return(this.TryGetIngredient(item => item.Sample.ParentSheetIndex == id || item.Sample.Category == id, count, out consumable)); }
/// <summary> /// The Pet will not eat food when sick. /// </summary> void Eat(IConsumable consumable) { if (IsHealthy()) { consumable.Consume(); } else if (IsAlive()) { if (consumable is Medicine) consumable.Consume(); } }
public SelectMany(IConsumable <Enumerable> enumerable, ILink <T, V> first) : base(first) =>