public void AddInst(string cname) { Instruction testOp; var s = cname.Split(' '); string variant = ""; var name = s[0]; if (s.Length > 1) { variant = s[1]; } if (typeof(Instruction).Namespace != null) { testOp = (Instruction)Activator.CreateInstance(Type.GetType(typeof(Instruction).Namespace + ".Instruction" + name)); } else { testOp = (Instruction)Activator.CreateInstance(Type.GetType("Instruction" + name)); } var testOpD = DataContainer.Dataset.Find((x) => { return(x.Name == name); }); testOp.Activate(testOpD, variant); if (Instructions.Count < MaxInstruction) { Instructions.Add(testOp); } else { Instructions[MaxInstruction - 1] = testOp; } OnRefreshItems?.Invoke(Instructions.ToArray()); }
/// <summary> /// This method is used to move an item into inventory. /// </summary> /// <param name="item"></param> public void PushItem(Item item) { bool flag = true; for (int i = 1; i < Items.Count; i++) { if (Items[i] == null) { Items[i] = item; OnRefreshItems(Items.ToArray()); SetRemoveCallback(item, i); flag = false; break; } } if (flag) { //Instead of opening Item destroy prompt, the item in the temporary slot will be overwritten without prompt. var i = 0;//Temporary slot Items[i]?.Remove(); Items[i] = item; SetRemoveCallback(item, i); OnRefreshItems(Items.ToArray()); } OnRefreshItems?.Invoke(Items.ToArray()); }
internal void InvokeUIRefresh() { OnChangeItemSlotAvailability?.Invoke(ActivatedSlots); OnRefreshItems?.Invoke(Items.ToArray()); }