as far as i know by looking at the decompiled assembly this class handles the original crate spawning:@hunternope3 - So if I understand proper you was just wrong. You can't build house like was on my server and get there automatically respawned crates. No matter if you use fougerite or not. You can loop spawning what is possible easy with fougerite, but you can't just add crates what will respawn when they are taken by player. You would need hook for that like I wrote couple post before.
C#:
public class LootableObjectSpawner : MonoBehaviour
{
public ChancePick[] _lootableChances;
[NonSerialized]
private GameObject _mySpawnedLootable;
public bool spawnOnStart = true;
public float spawnTimeMax = 10f;
public float spawnTimeMin = 5f;
private void Awake()
{
if ((this._lootableChances == null) || (this._lootableChances.Length == 0))
{
Object.Destroy(base.gameObject);
}
}
public void OnDrawGizmos()
{
Gizmos.color = Color.green;
Gizmos.DrawSphere(base.transform.position, 0.5f);
Gizmos.color = Color.blue;
Gizmos.DrawLine(base.transform.position, base.transform.position + ((Vector3) (base.transform.forward * 1f)));
}
public void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawSphere(base.transform.position, 0.5f);
Gizmos.color = Color.blue;
Gizmos.DrawLine(base.transform.position, base.transform.position + ((Vector3) (base.transform.forward * 1f)));
}
private void OnServerLoad()
{
if (this.spawnOnStart)
{
this.SpawnLootable();
}
else
{
base.Invoke("SpawnLootable", this.spawnTimeMax * 60f);
}
}
public static LootableObject RandomPick(ChancePick[] array)
{
float max = 0f;
foreach (ChancePick pick in array)
{
max += pick.weight;
}
if (max == 0f)
{
return null;
}
float num3 = Random.Range(0f, max);
foreach (ChancePick pick2 in array)
{
num3 -= pick2.weight;
if (num3 <= 0f)
{
return pick2.obj;
}
}
return array[array.Length - 1].obj;
}
private GameObject SpawnLootable()
{
Vector3 vector;
Vector3 vector2;
float num = Random.Range(this.spawnTimeMin, this.spawnTimeMax);
base.CancelInvoke("SpawnLootable");
base.Invoke("SpawnLootable", num * 60f);
if (this._mySpawnedLootable != null)
{
return null;
}
LootableObject prefab = RandomPick(this._lootableChances);
if (prefab == null)
{
Debug.Log("MAJOR WTF");
}
base.transform.GetGroundInfo(out vector, out vector2);
Quaternion quaternion = Quaternion.LookRotation(vector2);
Quaternion quaternion2 = Quaternion.Inverse(prefab.transform.GetChild(0).localRotation);
LootableObject obj3 = NetCull.InstantiateStatic<LootableObject>(prefab, vector, quaternion * quaternion2);
this._mySpawnedLootable = obj3.gameObject;
return obj3.gameObject;
}
[Serializable]
public class ChancePick
{
public LootableObject obj;
public float weight;
}
}
i tried to create a new lootableobjectspawner and calling te same method through reflection (While all values where assinged properly) but it brakes calling base.CancelInvoke().
(i will do some more tests later on)
however as i stated before a quick solution would be to simmulate the processses.
Last edited: