FlatRedBall.Glue.GuiDisplay.AvailableAnimationChainsStringConverter.GetReferencedAclsThroughSetVariables C# (CSharp) Метод

GetReferencedAclsThroughSetVariables() приватный статический Метод

private static GetReferencedAclsThroughSetVariables ( IElement element, NamedObjectSave referencedNos, StateSave stateSave ) : AnimationChainListSave
element IElement
referencedNos FlatRedBall.Glue.SaveClasses.NamedObjectSave
stateSave FlatRedBall.Glue.SaveClasses.StateSave
Результат AnimationChainListSave
        private static AnimationChainListSave GetReferencedAclsThroughSetVariables(IElement element, NamedObjectSave referencedNos, StateSave stateSave)
        {
            AnimationChainListSave foundAcls = null;

            // Give states the priority
            if(stateSave != null)
            {
                foreach(var item in stateSave.InstructionSaves)
                {
                    var customVariable = element.CustomVariables.FirstOrDefault(variable => variable.Name == item.Member);

                    if(customVariable != null && customVariable.SourceObject == referencedNos.InstanceName && customVariable.SourceObjectProperty == "AnimationChains")
                    {
                        string value = (string)item.Value;

                        foundAcls = LoadAnimationChainListSave(element, value);
                    }
                }

            }

            if (foundAcls == null)
            {
                // Does this have a set AnimationChainList?
                foreach (CustomVariable customVariable in element.CustomVariables)
                {
                    if (customVariable.SourceObject == referencedNos.InstanceName && customVariable.SourceObjectProperty == "AnimationChains")
                    {
                        string value = (string)customVariable.DefaultValue;

                        foundAcls = LoadAnimationChainListSave(element, value);

                    }
                }
            }

            // If the acls is null that means that it hasn't been set by custom variables, but the NOS itself may have a value set right on the Sprite for the current AnimationChain
            if (foundAcls == null)
            {
                var instruction = referencedNos.GetInstructionFromMember("AnimationChains");
                if (instruction != null)
                {
                    foundAcls = LoadAnimationChainListSave(element, (string)instruction.Value);
                }
            }


            return foundAcls;
        }