protected LBGameplayComponentLink[] FindActiveOutputs() { LBGameplayComponentLink[] links = new LBGameplayComponentLink[outputs.Length]; LBGameplayComponentLink[] result = new LBGameplayComponentLink[0]; LBGameplayComponentLink lnk; LBGameplayComponent gc = null; LBLinkedGameplayComponent lgc = null; int i; Array.Copy(outputs, 0, links, 0, outputs.Length); Array.Sort(links, (a, b) => { return(a.Order.CompareTo(b.Order)); }); for (i = 0; i < links.Length; i++) { if (links[i].Target is LBGameplayComponent) { gc = (LBGameplayComponent)(links[i].Target); // если other -- LBGameplayComponent } if (links[i].Target is LBLinkedGameplayComponent) { lgc = (LBLinkedGameplayComponent)(links[i].Target); // если other -- LBLinkedGameplayComponent } if (gc != null && lgc == null) { if (bCanTransferOut(links[i])) { Array.Resize(ref result, result.Length + 1); // можно здесь брать массив размера outputs, после отбрасывать последние пустые элементы result[result.Length - 1] = links[i]; } } else if (lgc != null) { lnk = lgc.FindInputFrom(this); // если есть вход от this if (!lnk.IsEmpty) { if (bCanTransferOut(links[i]) && lgc.bCanTransferIn((lnk))) { Array.Resize(ref result, result.Length + 1); // можно здесь брать массив размера outputs, после отбрасывать последние пустые элементы result[result.Length - 1] = links[i]; } } } } return(result); }
protected virtual bool TransferOut(LBGameplayComponentLink link) { LBGameplayComponent gc = null; LBLinkedGameplayComponent lgc = null; if (link.Target is LBGameplayComponent) { gc = (LBGameplayComponent)(link.Target); } if (link.Target is LBLinkedGameplayComponent) { lgc = (LBLinkedGameplayComponent)(link.Target); } if (bCanTransferOut(link)) { if (gc != null && lgc == null) { TurnOff(); OnTransferOut(link); gc.Activate(); return(true); } else if (lgc != null) { TurnOff(); OnTransferOut(link); lgc.TurnOn(); lgc.OnTransferIn(lgc.FindInputFrom(this)); return(true); } } return(false); }