void PoolThis() { // un-parent from tile gobj this.transform.SetParent(null); myExtractable = null; ObjectPool.instance.PoolObject(this.gameObject); }
protected Extractable(Extractable b) { yield = b.yield; capacity = b.capacity; yieldRate = b.yieldRate; extractableType = b.extractableType; weight = b.weight; }
public bool PlaceExtractable(Extractable newExtractable) { if (extractable != null) { return(false); } extractable = newExtractable; return(true); }
public static Extractable PlaceInstance(Extractable prototype, Tile tileBase) { Extractable newExtractable = new Extractable(prototype.Clone()); if (tileBase.PlaceExtractable(newExtractable) == false) { // placement failed return(null); } return(newExtractable); }
public void PlaceExtractable(Tile tile) { if (tile == null) { return; } Extractable newExtractable = Extractable.PlaceInstance(GetPrototype(), tile); if (newExtractable == null) { return; } }
public virtual bool RemoveItem(Extractable itemToRemove) { if (itemToRemove == null) { return(false); } Debug.Log(itemToRemove.extractableType + " removed from inventory."); itemsStored.Remove(itemToRemove); if (onInventoryChanged != null) { onInventoryChanged(itemsStored.Count); } return(true); }
public int TotalInstancesOfItem(Extractable item) { if (itemsStored.Contains(item) == false) { return(0); } int count = 0; for (int i = 0; i < itemsStored.Count; i++) { if (itemsStored[i] == item) { count++; } } return(count); }
public virtual bool AddItem(Extractable item, int count = 1) { if (currentWeight + item.weight > maxWeightCapacity) { Debug.Log("Carrying too much!"); return(false); } for (int i = 0; i < count; i++) { itemsStored.Add(item); } Debug.Log(count + " " + item.extractableType + " added to inventory"); if (onInventoryChanged != null) { onInventoryChanged(itemsStored.Count); } return(true); }
public void InitExtractable(Extractable thisExtractable) { myExtractable = thisExtractable; if (myExtractable == null) { Debug.LogError("Extract_Controller is not receivin an extractor class!"); return; } // Get sprite: if (myExtractable.spriteID != string.Empty) { sprite_renderer.sprite = SpriteManager.instance.GetSprite(myExtractable.spriteID); } else { sprite_renderer.sprite = SpriteManager.instance.GetOreSprite(); myExtractable.spriteID = sprite_renderer.sprite.name; } curProgress = 0; yield = myExtractable.yield; yieldRate = myExtractable.yieldRate; capacity = myExtractable.capacity; Init(transform.position); }
public static T ExtractOrder <T>(IEnumerable <ArgType> what, Function fct, string str) where T : Extractable { Extractable element = null; foreach (ArgType argType in what) { if (argType == ArgType.Const) { element = ExtractConst(str); } if (argType == ArgType.Variable) { element = ExtractVar(fct, str); } if (element != null) { return((T)element); } } return(null); }
public ExtractPart(Extractable what, IPart from) { What = what; From = from; }
public static ExtractPart Extract(Extractable what, IPart from) => new ExtractPart(what, from);