You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.8 KiB

using System;
using UnityEngine;
namespace MU3
{
// Token: 0x020004C1 RID: 1217
public class ObjectCache
{
// Token: 0x06001DF9 RID: 7673 RVA: 0x000BE4C0 File Offset: 0x000BE4C0
public ObjectCache(Transform parent, GameObject prefab, int capacity = 8)
{
this.size_ = 0;
this.objects_ = new GameObject[capacity];
this.parent_ = parent;
this.prefab_ = prefab;
}
// Token: 0x1700034D RID: 845
// (get) Token: 0x06001DFA RID: 7674 RVA: 0x000BE4EC File Offset: 0x000BE4EC
// (set) Token: 0x06001DFB RID: 7675 RVA: 0x000BE4F8 File Offset: 0x000BE4F8
public int Capacity
{
get
{
return this.objects_.Length;
}
set
{
if (value <= this.objects_.Length)
{
return;
}
Array.Resize<GameObject>(ref this.objects_, value);
}
}
// Token: 0x1700034E RID: 846
// (get) Token: 0x06001DFC RID: 7676 RVA: 0x000BE518 File Offset: 0x000BE518
public int Size
{
get
{
return this.size_;
}
}
// Token: 0x06001DFD RID: 7677 RVA: 0x000BE520 File Offset: 0x000BE520
public GameObject pop()
{
if (0 < this.size_)
{
this.size_--;
GameObject gameObject = this.objects_[this.size_];
this.objects_[this.size_] = null;
gameObject.SetActive(true);
return gameObject;
}
return UnityEngine.Object.Instantiate<GameObject>(this.prefab_);
}
// Token: 0x06001DFE RID: 7678 RVA: 0x000BE578 File Offset: 0x000BE578
public bool tryPop(out GameObject obj, Vector3 position, Quaternion rotation, bool create = true)
{
if (0 < this.size_)
{
this.size_--;
obj = this.objects_[this.size_];
this.objects_[this.size_] = null;
obj.transform.position = position;
obj.transform.localRotation = rotation;
obj.SetActive(true);
return true;
}
if (create)
{
obj = UnityEngine.Object.Instantiate<GameObject>(this.prefab_, position, rotation);
}
else
{
obj = null;
}
return false;
}
// Token: 0x06001DFF RID: 7679 RVA: 0x000BE600 File Offset: 0x000BE600
public void push(GameObject obj)
{
if (this.objects_.Length <= this.size_)
{
Array.Resize<GameObject>(ref this.objects_, this.objects_.Length << 1);
}
obj.transform.SetParent(this.parent_);
obj.SetActive(false);
this.objects_[this.size_] = obj;
this.size_++;
}
// Token: 0x06001E00 RID: 7680 RVA: 0x000BE66C File Offset: 0x000BE66C
public void fillCapacity()
{
int num = this.Capacity - this.size_;
for (int i = 0; i < num; i++)
{
this.push(UnityEngine.Object.Instantiate<GameObject>(this.prefab_));
}
}
// Token: 0x04004868 RID: 18536
protected int size_;
// Token: 0x04004869 RID: 18537
protected Transform parent_;
// Token: 0x0400486A RID: 18538
protected GameObject prefab_;
// Token: 0x0400486B RID: 18539
protected GameObject[] objects_;
}
}