当前位置: 首页>>代码示例>>C#>>正文


C# NamedObjectSave.GetContainerType方法代码示例

本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.GetContainerType方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.GetContainerType方法的具体用法?C# NamedObjectSave.GetContainerType怎么用?C# NamedObjectSave.GetContainerType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlatRedBall.Glue.SaveClasses.NamedObjectSave的用法示例。


在下文中一共展示了NamedObjectSave.GetContainerType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExcludeAndIncludeGlueVariables

        private void ExcludeAndIncludeGlueVariables(NamedObjectSave instance)
        {

            bool shouldIncludeSourceClassType = true;
            bool shouldIncludeSourceFile = true;
            bool shouldIncludeSourceName = true;
            bool shouldIncludeSourceClassGenericType = true;
            bool shouldShowCurrentState = true;
            bool shouldIncludeIncludeInIVisible = true;
            bool shouldIncludeIncludeInIClickable = true;
            bool shouldIncludeIsContainer = true;
            bool shouldShowIsZBuffered = false;
            bool shouldIncludeSetByContainer = true;

            ExcludeMember("InstructionSaves");
            ExcludeMember("Properties");
            ExcludeMember("FileCreatedBy");
            ExcludeMember("FulfillsRequirement");
            ExcludeMember("IsNodeHidden");


            if (DisplayMode == DisplayModes.VariablesOnly)
            {
                ExcludeAllMembers();
            }
            else
            {

                if (DisplayMode != DisplayModes.Debug)
                {
                    ExcludeMember("InstantiatedByBase");
                }

                var containerType = instance.GetContainerType();

                // Screens can't be IVisible/IClickable so no need to show these properties
                // in screens
                shouldIncludeIncludeInIVisible = containerType == ContainerType.Entity;
                shouldIncludeIncludeInIClickable = containerType == ContainerType.Entity;

                bool shouldShowAttachToContainer = containerType == ContainerType.Entity &&
                    instance.IsList == false;
                // Not sure if we want to keep this or not, but currently objects in Entities can't be attached to the Camera
                bool shouldShowAttachToCamera = instance.GetContainerType() == ContainerType.Screen;

                if (!shouldShowAttachToContainer)
                {
                    this.ExcludeMember("AttachToContainer");
                }


                if (!shouldShowAttachToCamera)
                {
                    ExcludeMember("AttachToCamera");
                }

                if (instance.SourceType == SaveClasses.SourceType.FlatRedBallType && instance.SourceClassType == "Layer")
                {

                }

                // We used to not show the AddToManagers property for objects inside Entities, but as I worked on SteamBirds
                // I found myself needing it.
                //else if (ContainerType == ContainerType.Entity)
                //{
                //    ExcludeMember("AddToManagers");
                //}

                if (instance.SetByDerived)
                {
                    ExcludeMember("AttachToContainer");
                }
                if (instance.InstantiatedByBase)
                {
                    ExcludeMember("SourceType");
                    shouldIncludeSourceClassType = false;
                    shouldIncludeSourceClassGenericType = false;

                    ExcludeMember("InstanceName");
                    ExcludeMember("CallActivity");
                    ExcludeMember("IgnoresPausing");
                    ExcludeMember("HasPublicProperty");
                    ExcludeMember("ExposedInDerived");

                    ExcludeMember("SetByDerived");
                    ExcludeMember("SetByContainer");
                }

                bool shouldIncludeAddToManagers = !instance.InstantiatedByBase && !instance.IsList;
                if (!shouldIncludeAddToManagers)
                {
                    ExcludeMember("AddToManagers");
                }

                UpdateLayerIncludeAndExclude(instance);

                if (containerType != ContainerType.Entity)
                {
                    shouldIncludeIsContainer = false;
                    shouldIncludeSetByContainer = false;
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:101,代码来源:NamedObjectPropertyGridDisplayer.cs

示例2: WriteAttachTo

        private static void WriteAttachTo(NamedObjectSave namedObject, ICodeBlock codeBlock, List<string[]> referencedFilesAlreadyUsingFullFile, ReferencedFileSave rfs)
        {

            string objectName = namedObject.FieldName;
            AssetTypeInfo ati = namedObject.GetAssetTypeInfo();

            if ((namedObject.GetContainerType() == ContainerType.Entity && namedObject.AttachToContainer) || namedObject.AttachToCamera)
            {
                bool shouldAttach = true;



                if (ati != null)
                {
                    shouldAttach = ati.ShouldAttach;
                }
                if (namedObject.IsList)
                {
                    shouldAttach = false;
                }

                if (shouldAttach)
                {
                    string whatToAttachTo = "this";

                    if (namedObject.AttachToCamera)
                    {
                        whatToAttachTo = "FlatRedBall.Camera.Main";
                    }


                    // Files (like .scnx) can
                    // contain objects which can
                    // be attached to other objects
                    // in the file.  In some cases this
                    // hierarchy is important.  Therefore,
                    // the generated code will 
                    string attachMethodCall = "AttachTo";
                    bool wrapInIf = true;
                    if (ati != null && !string.IsNullOrEmpty(ati.AttachToNullOnlyMethod))
                    {
                        attachMethodCall = ati.AttachToNullOnlyMethod;
                        wrapInIf = false;
                    }

                    string tabs = "\t\t\t";

                    if (namedObject.ClassType == "SpriteRig")
                    {
                        codeBlock.Line(objectName + ".Root.AttachTo(" + whatToAttachTo + ", true);");

                    }
                    else
                    {
                        var currentBlock = codeBlock;

                        if (wrapInIf)
                        {
                            currentBlock = currentBlock
                                .If(objectName + ".Parent == null");
                        }


                        // March 26, 2012
                        // We used to attach
                        // objects to their parents
                        // by using absolute positions.
                        // The problem is that this means
                        // that if a script ran before the
                        // attachment happened (when a variable
                        // was set) then the script may run before
                        // attachment happened and sometimes after.
                        // That means users would have to handle both
                        // relative and absoltue cases.  We're going to
                        // make attachments happen first so that attachment
                        // happens right away - then the user can always write
                        // scripts using relative values.
                        WriteCopyToAbsoluteInInitializeCode(namedObject, currentBlock, referencedFilesAlreadyUsingFullFile, ati, objectName, rfs);

                        // March 27, 2012
                        // We used to attach
                        // by passing 'true' as
                        // the 2nd argument meaning
                        // that the relative values were
                        // set from absolute.  Now we use
                        // the relative values so that the
                        // script can simply set Relative values
                        // always whether it's before or after attachment
                        // and it'll just work.
                        if (namedObject.AttachToCamera)
                        {
                            string adjustRelativeZLine = null;

                            if (ati != null && !string.IsNullOrEmpty(ati.AdjustRelativeZ))
                            {
                                adjustRelativeZLine = ati.AdjustRelativeZ;
                            }
                            else
                            {
                                adjustRelativeZLine = "this.RelativeZ += value";
//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:NamedObjectSaveCodeGenerator.cs


注:本文中的FlatRedBall.Glue.SaveClasses.NamedObjectSave.GetContainerType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。