本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}