private void OnCreateObject(GameObject sender, EventArgs args) { if (sender.Name.Contains("missile") || sender.Name.Contains("Minion") || sender.IsAlly || !Enabled) { return; } Obj_AI_Base objis = ObjectManager.GetUnitByNetworkId <Obj_AI_Base>(sender.NetworkId); HidObject ho = HidObjects.IsHidObj(objis.SkinName); if (ho != null) { foreach (var lho in allObjects) { if (GetNearestWard(lho.Position) != null) { lho.WardObj = GetNearestWard(lho.Position); break; } } } }
private Obj_AI_Base GetNearestWard(Vector3 pos) { return (ObjectManager.Get <Obj_AI_Base>().OrderBy(wards => pos.Distance(wards.Position)) .First(ward => ward.IsValid && HidObjects.IsHidObj(ward.SkinName) != null && ward.Position.Distance(pos) <= 200)); }