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


C# IElement.InheritsFromEntity方法代码示例

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


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

示例1: GenerateFields

        internal static ICodeBlock GenerateFields(IElement saveObject)
        {
            ICodeBlock codeBlock = new CodeDocument(2);

            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {
                if (codeGenerator == null)
                {
                    throw new Exception("The CodeWriter contains a null code generator.  A plugin must have added this");
                }

                try
                {
                    codeGenerator.GenerateFields(codeBlock, saveObject);

                }
                catch (Exception e)
                {
                    throw new Exception("Error generating fields in generator " + codeGenerator.GetType().Name + 
                        "\n\n" + e.ToString());

                }
            }

            PerformancePluginCodeGenerator.GenerateFields(saveObject, codeBlock);

            EntitySave asEntitySave = saveObject as EntitySave;

            // No need to create LayerProvidedByContainer if this inherits from another object.
            if (asEntitySave != null && !saveObject.InheritsFromEntity())
            {
                // Add the layer that is going to get assigned in generated code
                codeBlock.Line("protected FlatRedBall.Graphics.Layer LayerProvidedByContainer = null;");
            }
            

            return codeBlock;


        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:40,代码来源:CodeWriter.cs

示例2: GenerateDestroy

        internal static ICodeBlock GenerateDestroy(IElement saveObject)
        {
            bool isScreen = saveObject is ScreenSave;
            ICodeBlock codeBlock = new CodeDocument(3);
            var currentBlock = codeBlock;

            #region Call base.Destroy if it has a derived object

            // The Screen template already includes a call to base.Destroy
            if ( saveObject.InheritsFromEntity() )
            {
                currentBlock.Line("base.Destroy();");
            }

            #endregion


            #region If Entity, remove from managers (SpriteManager, GuiManager)

            if (saveObject is EntitySave)
            {
                if (saveObject.InheritsFromFrbType())
                {
                    AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseObject);

                    if (ati != null)
                    {
                        currentBlock.Line(ati.DestroyMethod + ";");
                    }
                }
                else if (! saveObject.InheritsFromElement())
                {
                    currentBlock.Line("FlatRedBall.SpriteManager.RemovePositionedObject(this);");
                }
                
                if ((saveObject as EntitySave).ImplementsIWindow && !(saveObject as EntitySave).GetInheritsFromIWindow())
                {
                    currentBlock.Line("FlatRedBall.Gui.GuiManager.RemoveWindow(this);");
                }

            }

            #endregion

            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {
                codeGenerator.GenerateDestroy(currentBlock, saveObject);
            }

            return currentBlock;
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:51,代码来源:CodeWriter.cs

示例3: GenerateRemoveFromManagers

        private static void GenerateRemoveFromManagers(ICodeBlock currentBlock, IElement saveObject)
        {
            if (saveObject.InheritsFromElement())
            {
                currentBlock = currentBlock.Function("public override void", "RemoveFromManagers", "");
                currentBlock.Line("base.RemoveFromManagers();");
            }
            else
            {
                currentBlock = currentBlock.Function("public virtual void", "RemoveFromManagers", "");

            }

            #region Call base.Destroy if it has a derived object

            // The Screen template already includes a call to base.Destroy
            if (saveObject.InheritsFromEntity())
            {
                currentBlock.Line("base.RemoveFromManagers();");
            }

            #endregion

            if (saveObject is EntitySave)
            {
                if (saveObject.InheritsFromFrbType())
                {
                    AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseObject);

                    if (ati != null)
                    {
                        EntitySave asEntitySave = saveObject as EntitySave;

                        if (asEntitySave.CreatedByOtherEntities && !string.IsNullOrEmpty(ati.RecycledDestroyMethod))
                        {
                            currentBlock.Line(ati.RecycledDestroyMethod + ";");
                        }
                        else
                        {
                            currentBlock.Line(ati.DestroyMethod + ";");
                        }
                    }
                }

                else if (!saveObject.InheritsFromElement())
                {
                    currentBlock.Line("FlatRedBall.SpriteManager.ConvertToManuallyUpdated(this);");
                }

                if ((saveObject as EntitySave).ImplementsIWindow && !(saveObject as EntitySave).GetInheritsFromIWindow())
                {
                    currentBlock.Line("FlatRedBall.Gui.GuiManager.RemoveWindow(this);");
                }
            }

            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {
                codeGenerator.GenerateRemoveFromManagers(currentBlock, saveObject);
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:60,代码来源:CodeWriter.cs

示例4: GenerateGeneralActivity

        internal static ICodeBlock GenerateGeneralActivity(ICodeBlock codeBlock, IElement saveObject)
        {


            bool isEntity = saveObject is EntitySave;

            EntitySave entitySave = saveObject as EntitySave;

            // This code might seem a little weird.  The reason we do this
            // is because when an Entity is paused, it has a method that is
            // called.  However, when it is unpaused, there's just an instruction
            // that is executed - there is no event.  But if a Screen is paused, then
            // objects within that Screen don't get unpaused....so we're going to bet on
            // the Activity function only being called in unpaused Screens.  If this causes
            // probelsm we may have to make something a little more standard like an Unpause
            // method.
            if (isEntity &&
                (entitySave.ImplementsIClickable || entitySave.ImplementsIWindow)
                && !entitySave.GetInheritsFromIWindowOrIClickable()
                )
            {
                codeBlock.Line("mIsPaused = false;");
            }

            #region Call base.Activity if it has a derived object

            // We only need to do this for EntitySaves.  Screens inherit from the
            // Screen class so they ALWAYS call base.Activity.  It's in the generated
            // Screen template.  
            if ( saveObject.InheritsFromEntity())
            {
                codeBlock.Line("base.Activity();");
            }

            #endregion

            codeBlock._();

            // Eventually do we want to move this in the generate activity for custom variable code gen.
            CustomVariableCodeGenerator.WriteVelocityForCustomVariables(saveObject.CustomVariables, codeBlock);


            foreach (ElementComponentCodeGenerator codeGenerator in CodeWriter.CodeGenerators)
            {

                codeGenerator.GenerateActivity(codeBlock, saveObject);
            }


            return codeBlock;
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:51,代码来源:CodeWriter.cs


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