public virtual TDataView CreateViewInstance(ShotData data, Transform parent) { GameObject obj = (GameObject)GameObject.Instantiate(prefab, parent, false); TDataView dataView = obj.GetComponent <TDataView>(); activeViewList.Add(dataView); dataView.BindDataToView(data); dataView.OnCreate(); return(dataView); }
public bool HasActiveView(ShotData data) { for (int i = 0; i < activeViewList.Count; ++i) { if (activeViewList[i].data == data) { return(true); } } return(false); }
public TDataView TryGetActiveView(ShotData data) { for (int i = 0; i < activeViewList.Count; ++i) { if (activeViewList[i].data == data) { return(activeViewList[i]); } } return(null); }
public virtual TDataView DePoolDataView(ShotData data) { //Error!!! Should not happen, but sometimes can; return a null to tell the list to get a new view if (pool.Peek() != null && pool.Peek().data != null) { TDataView badView = pool.Dequeue(); GameObject.Destroy(badView.gameObject); return(null); } TDataView dataView = pool.Dequeue(); activeViewList.Add(dataView); dataView.BindDataToView(data); dataView.OnDePool(); return(dataView); }
public virtual void EnPoolDataView(ShotData data) { TDataView dataView = TryGetActiveView(data); //don't allow pooling of null data if (dataView == null) { activeViewList.Remove(dataView); return; } //the user's pooling strategy might request that the object be destroyed dataView = (TDataView)dataView.OnEnPool(); if (dataView != null) { pool.Enqueue(dataView); dataView.ClearView(); } activeViewList.Remove(dataView); }
protected virtual bool Equals(ShotData other) { return(string.Equals(shotData, other.shotData)); }