public LBGameplayComponentLink(SerializedProperty links, int item) { SerializedProperty l; l = links.GetArrayElementAtIndex(item); l.Next(true); Target = (LBGameplayComponent)l.objectReferenceValue; l.Next(false); Order = l.intValue; l.Next(false); ParamID = l.intValue; }
protected LBGameplayComponentLink[] FindActiveInputs() { LBGameplayComponentLink[] links = new LBGameplayComponentLink[inputs.Length]; LBGameplayComponentLink[] result = new LBGameplayComponentLink[0]; LBGameplayComponentLink lnk; LBGameplayComponent gc = null; LBLinkedGameplayComponent lgc = null; int i; Array.Copy(inputs, 0, links, 0, inputs.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 (bCanTransferIn(links[i])) { Array.Resize(ref result, result.Length + 1); // можно здесь брать массив размера outputs, после отбрасывать последние пустые элементы result[result.Length - 1] = links[i]; } } else if (lgc != null) { lnk = lgc.FindOutputTo(this); // если есть выход на this if (!lnk.IsEmpty) { if (bCanTransferIn(links[i]) && lgc.bCanTransferOut((lnk))) { Array.Resize(ref result, result.Length + 1); // можно здесь брать массив размера outputs, после отбрасывать последние пустые элементы result[result.Length - 1] = links[i]; } } } } return(result); }
//private protected virtual bool TransferIn(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 (bCanTransferIn(link)) { if (gc != null && lgc == null) { TurnOn(); OnTransferIn(link); gc.Deactivate(); return(true); } else if (lgc != null) { TurnOn(); OnTransferIn(link); lgc.TurnOff(); lgc.OnTransferOut(lgc.FindOutputTo(this)); return(true); } } return(false); }
public virtual bool bCanTransferIn(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 (link.Target == null) { return(false); } else if (gc != null && lgc == null) { if (bCanTurnOn() && gc.bCanDeactivate()) { return(true); } } else if (lgc != null) { if (bCanTurnOn() && lgc.bHasMatchingOutput(this, link) && lgc.bCanTurnOff()) { return(true); } } return(false); }
public LBGameplayComponentLink(LBGameplayComponent _target, int _order, int _param_id) { Target = _target; Order = _order; ParamID = _param_id; }