using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; namespace SRMultiplayer.Networking { public class NetworkAmmo : Ammo { public static Dictionary All = new Dictionary(); public string ID; public SiloStorage Silo; public NetworkAmmo(SiloStorage silo, HashSet potentialAmmo, int numSlots, int usableSlots, Predicate[] slotPreds, Func slotMaxCountFunction) : base(potentialAmmo, numSlots, usableSlots, slotPreds, slotMaxCountFunction) { Silo = silo; var landplotLocation = GetInParent(silo.gameObject); if (landplotLocation != null) { ID = landplotLocation.id; } else { ID = GetInParent(silo.gameObject).id; } ID += "-" + silo.name; All[ID] = this; } private T GetInParent(GameObject obj) { var cmp = obj.GetComponent(); if(cmp != null) { return cmp; } if(obj.transform.parent != null) { return GetInParent(obj.transform.parent.gameObject); } return default(T); } } }