本文整理汇总了C#中IElement.InheritsFromFrbType方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.InheritsFromFrbType方法的具体用法?C# IElement.InheritsFromFrbType怎么用?C# IElement.InheritsFromFrbType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.InheritsFromFrbType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateReAddToManagers
private static void GenerateReAddToManagers(IElement saveObject, ICodeBlock currentBlock)
{
bool isEntity = saveObject is EntitySave;
bool inheritsFromNonFrbType =
!string.IsNullOrEmpty(saveObject.BaseElement) && !saveObject.InheritsFromFrbType();
if (isEntity)
{
ICodeBlock reAddToManagers = null;
if (inheritsFromNonFrbType)
{
reAddToManagers = currentBlock.Function("public override void", "ReAddToManagers", "FlatRedBall.Graphics.Layer layerToAddTo");
reAddToManagers.Line("base.ReAddToManagers(layerToAddTo);");
}
else
{
reAddToManagers = currentBlock.Function("public virtual void", "ReAddToManagers", "FlatRedBall.Graphics.Layer layerToAddTo");
reAddToManagers.Line("LayerProvidedByContainer = layerToAddTo;");
}
// add "this" to managers:
GenerateAddThisEntityToManagers(saveObject, reAddToManagers);
for (int i = 0; i < saveObject.NamedObjects.Count; i++)
{
NamedObjectSave nos = saveObject.NamedObjects[i];
bool setVariables = false;
NamedObjectSaveCodeGenerator.WriteAddToManagersForNamedObject(saveObject, nos, reAddToManagers, false, setVariables);
}
}
}
示例2: GenerateAssignCustomVariables
private static void GenerateAssignCustomVariables(ICodeBlock codeBlock, IElement element)
{
bool inherits = !string.IsNullOrEmpty(element.BaseElement) && !element.InheritsFromFrbType();
if (inherits)
{
codeBlock = codeBlock.Function("public override void", "AssignCustomVariables", "bool callOnContainedElements");
codeBlock.Line("base.AssignCustomVariables(callOnContainedElements);");
}
else
{
codeBlock = codeBlock.Function("public virtual void", "AssignCustomVariables", "bool callOnContainedElements");
}
// call AssignCustomVariables on all contained objects before assigning custom variables on "this"
var ifCallOnContainedElements = codeBlock.If("callOnContainedElements");
var listOfItems = element.NamedObjects.Where(item=>
item.IsFullyDefined &&
!item.IsDisabled &&
item.Instantiate &&
!item.SetByContainer &&
!item.SetByDerived
).ToList();
GenerateAssignmentForListOfObjects(codeBlock, element, ifCallOnContainedElements, listOfItems);
foreach (CustomVariable customVariable in element.CustomVariables)
{
CustomVariableCodeGenerator.AppendAssignmentForCustomVariableInElement(codeBlock, customVariable, element);
}
EventCodeGenerator.GenerateAddToManagersBottomUp(codeBlock, element);
}
示例3: GenerateAddToManagers
internal static ICodeBlock GenerateAddToManagers(IElement saveObject)
{
ICodeBlock codeBlock = new CodeDocument(2);
ICodeBlock currentBlock = codeBlock;
bool isEntity = saveObject is EntitySave;
bool isScreen = !isEntity;
bool inheritsFromNonFrbType =
!string.IsNullOrEmpty(saveObject.BaseElement) && !saveObject.InheritsFromFrbType();
GenerateReAddToManagers(saveObject, currentBlock);
#region Generate the method header
if (isScreen)
{
currentBlock = currentBlock
.Function("public override void", "AddToManagers", "");
}
else if (saveObject.InheritsFromElement()) // it's an EntitySave
{
currentBlock = currentBlock
.Function("public override void", "AddToManagers", "FlatRedBall.Graphics.Layer layerToAddTo");
}
else // It's a base EntitySave
{
currentBlock = currentBlock
.Function("public virtual void", "AddToManagers", "FlatRedBall.Graphics.Layer layerToAddTo");
}
#endregion
PerformancePluginCodeGenerator.SaveObject = saveObject;
PerformancePluginCodeGenerator.CodeBlock = currentBlock;
PerformancePluginCodeGenerator.GenerateStart("Pooled PostInitialize");
#region Call PostInitialize *again* if this is a pooled, base Entity
FactoryCodeGenerator.CallPostInitializeIfNecessary(saveObject, currentBlock);
#endregion
PerformancePluginCodeGenerator.GenerateEnd();
PerformancePluginCodeGenerator.GenerateStart("Layer for this code");
#region Generate layer if a screen
if (IsOnOwnLayer(saveObject))
{
// Only Screens need to define a layer. Otherwise, the layer is fed to the Entity
if (isScreen)
{
currentBlock.Line("mLayer = SpriteManager.AddLayer();");
}
}
#endregion
#region Assign the layer so that custom code can get to it
if (isEntity)
{
currentBlock.Line("LayerProvidedByContainer = layerToAddTo;");
}
#endregion
PerformancePluginCodeGenerator.GenerateEnd();
GenerateAddThisEntityToManagers(saveObject, currentBlock);
const string addFilesToManagers = "Add Files to Managers";
PerformancePluginCodeGenerator.GenerateStart(saveObject, currentBlock, addFilesToManagers);
#region Add all ReferencedFileSaves
// Add referenced files before adding objects because the objects
// may be aliases for the files (if using Entire File) and may add them
// to layers.
for (int i = 0; i < saveObject.ReferencedFiles.Count; i++)
{
PerformancePluginCodeGenerator.GenerateStart("Adding file " + saveObject.ReferencedFiles[i].GetInstanceName());
currentBlock.InsertBlock(ReferencedFileSaveCodeGenerator.GetAddToManagersForReferencedFile(saveObject, saveObject.ReferencedFiles[i]));
PerformancePluginCodeGenerator.GenerateEnd();
}
#endregion
PerformancePluginCodeGenerator.GenerateEnd(saveObject, currentBlock, addFilesToManagers);
PerformancePluginCodeGenerator.GenerateStart("Create layer instances");
#region First generate all code for Layers before other stuff
//.........这里部分代码省略.........
示例4: 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);
}
}
示例5: GenerateConvertToManuallyUpdated
internal static void GenerateConvertToManuallyUpdated(ICodeBlock codeBlock, IElement saveObject, List<string[]> reusableEntireFileRfses)
{
bool hasBase = saveObject.InheritsFromElement();
ICodeBlock currentBlock = codeBlock;
currentBlock = currentBlock
.Function("ConvertToManuallyUpdated", "", Public: true, Override: hasBase, Virtual: !hasBase,
Type: "void");
if (hasBase)
{
currentBlock.Line("base.ConvertToManuallyUpdated();");
}
if (saveObject is EntitySave)
{
// It's possible that an Entity may be converted to ManuallyUpdated before
// any Draw calls get made - this means that UpdateDependencies will never get called.
// This should happen before the other manual updates are called so that everything is positioned
// right when verts are created.
currentBlock.Line("this.ForceUpdateDependenciesDeep();");
if (saveObject.InheritsFromFrbType())
{
AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseElement);
if (ati != null)
{
currentBlock.Line(ati.MakeManuallyUpdatedMethod + ";");
}
}
else
{
// Convert the Entity itself to manually updated
currentBlock.Line("FlatRedBall.SpriteManager.ConvertToManuallyUpdated(this);");
}
}
foreach (ReferencedFileSave rfs in saveObject.ReferencedFiles)
{
ReferencedFileSaveCodeGenerator.GenerateConvertToManuallyUpdated(currentBlock, rfs);
}
NamedObjectSaveCodeGenerator.WriteConvertToManuallyUpdated(currentBlock, saveObject, reusableEntireFileRfses);
}
示例6: 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;
}
示例7: GenerateAddThisEntityToManagers
private static void GenerateAddThisEntityToManagers(IElement saveObject, ICodeBlock currentBlock)
{
bool isEntity = saveObject is EntitySave;
if (isEntity)
{
PerformancePluginCodeGenerator.GenerateStart("Add this to managers");
if (saveObject.InheritsFromFrbType())
{
int m = 3;
AssetTypeInfo ati = AvailableAssetTypes.Self.GetAssetTypeFromRuntimeType(saveObject.BaseObject);
if (ati != null)
{
int addMethodIndex = 0;
var isContainerNos = saveObject.AllNamedObjects.FirstOrDefault(item => item.IsContainer);
if (isContainerNos != null && isContainerNos.IsZBuffered &&
(isContainerNos.SourceClassType == "Sprite" || isContainerNos.SourceClassType == "SpriteFrame"))
{
addMethodIndex = 1;
}
if (ati.LayeredAddToManagersMethod.Count != 0)
{
// just use the method as-is, because the template is already using "this"
currentBlock.Line(ati.LayeredAddToManagersMethod[addMethodIndex].Replace("mLayer", "layerToAddTo") + ";");
}
else if (ati.AddToManagersMethod.Count != 0)
{
currentBlock.Line(ati.AddToManagersMethod[addMethodIndex] + ";");
}
}
}
else if (!saveObject.InheritsFromElement())
{
currentBlock.Line("FlatRedBall.SpriteManager.AddPositionedObject(this);");
}
IWindowCodeGenerator.TryGenerateAddToManagers(currentBlock, saveObject);
PerformancePluginCodeGenerator.GenerateEnd();
}
}
示例8: DoesBaseHaveUncategorizedStates
private static bool DoesBaseHaveUncategorizedStates(IElement element)
{
if (string.IsNullOrEmpty(element.BaseElement) || element.InheritsFromFrbType())
{
return false;
}
else
{
IElement baseElement = ObjectFinder.Self.GetIElement(element.BaseElement);
if (baseElement != null)
{
if (baseElement.States.Count != 0)
{
return true;
}
else
{
foreach (StateSaveCategory category in baseElement.StateCategoryList)
{
if (category.SharesVariablesWithOtherCategories)
{
return true;
}
}
}
}
return false;
}
}