public bool bHasMatchingOutput(LBLinkedGameplayComponent other, LBGameplayComponentLink input) { LBGameplayComponentLink link, other_input; link = FindOutputTo(other); // нашли обратную свзяь на other if (link.IsEmpty) { return(false); } other_input = ((LBLinkedGameplayComponent)link.Target).FindInputFrom(this); // проверить, действительно ли other имеет вход от this if (other_input.IsEmpty) { return(false); } if (other_input == input) { return(true); } else { return(false); } }
public override bool bCanTransferIn(LBGameplayComponentLink link) { if (!base.bCanTransferIn(link)) { return(false); } return(bCheckInputCondition(link.ParamID)); }
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); }
protected bool SwitchStateOnTransferIn(LBGameplayComponentLink input_link) { if (input_state_switch != null && input_link.ParamID >= 0 && input_link.ParamID < input_state_switch.Length) { SwitchState(input_state_switch[input_link.ParamID]); return(true); } else { if (input_switch_to_default) { SwitchState(0); return(true); } } return(false); }
//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); }
protected override void OnTransferIn(LBGameplayComponentLink link) { base.OnTransferIn(link); SwitchStateOnTransferIn(link); }
protected virtual void OnTransferOut(LBGameplayComponentLink link) { }