Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks if a specified LBLinkedGameplayComponent is present in @inputs array of this component
        /// </summary>
        /// <param name="c">A component, whuch should be searched for</param>
        /// <returns></returns>
        public bool bHasInputConnection(LBLinkedGameplayComponent c)
        {
            int i;

            for (i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].Target == c)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public LBGameplayComponentLink FindOutputTo(LBLinkedGameplayComponent c)
        {
            int i;

            for (i = 0; i < outputs.Length; i++)
            {
                if (outputs[i].Target == c)
                {
                    return(outputs[i]);
                }
            }

            return(LBGameplayComponentLink.Empty);
        }
Ejemplo n.º 4
0
        public LBGameplayComponentLink FindInputFrom(LBLinkedGameplayComponent c)
        {
            int i;

            for (i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].Target == c)
                {
                    return(inputs[i]);
                }
            }

            return(LBGameplayComponentLink.Empty);
        }
Ejemplo n.º 5
0
        public bool bHasOutputTo(LBLinkedGameplayComponent c)
        {
            int i;

            for (i = 0; i < outputs.Length; i++)
            {
                if (outputs[i].Target == c)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        //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);
        }
Ejemplo n.º 8
0
        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);
        }