private static CodeBuilder.ICodeBlock GenerateSetToIgnorePausing(CodeBuilder.ICodeBlock codeBlock, SaveClasses.IElement element, bool hasBase) { string virtualOrOverride = "virtual"; if (hasBase) { virtualOrOverride = "override"; } codeBlock = codeBlock.Function("public " + virtualOrOverride + " void", "SetToIgnorePausing", ""); if (hasBase) { codeBlock.Line("base.SetToIgnorePausing();"); } else { codeBlock.Line("FlatRedBall.Instructions.InstructionManager.IgnorePausingFor(this);"); } foreach (NamedObjectSave nos in element.AllNamedObjects) { if (nos.IsFullyDefined && !nos.IsDisabled && !nos.IsContainer) { NamedObjectSaveCodeGenerator.AddIfConditionalSymbolIfNecesssary(codeBlock, nos); bool shouldWrapInNullCheck = nos.SetByDerived || nos.SetByContainer || nos.Instantiate == false; if (shouldWrapInNullCheck) { codeBlock = codeBlock.If(nos.InstanceName + " != null"); } if (nos.GetAssetTypeInfo() != null && nos.GetAssetTypeInfo().CanIgnorePausing) { codeBlock.Line("FlatRedBall.Instructions.InstructionManager.IgnorePausingFor(" + nos.InstanceName + ");"); } else if (nos.SourceType == SourceType.Entity) { codeBlock.Line(nos.InstanceName + ".SetToIgnorePausing();"); } if (shouldWrapInNullCheck) { codeBlock = codeBlock.End(); } NamedObjectSaveCodeGenerator.AddEndIfIfNecessary(codeBlock, nos); } } codeBlock = codeBlock.End(); return(codeBlock); }
public override CodeBuilder.ICodeBlock GenerateAdditionalMethods(CodeBuilder.ICodeBlock codeBlock, SaveClasses.IElement element) { if (element is EntitySave) { bool hasBase = element.InheritsFromElement(); if (hasBase == false) { codeBlock.Line("protected bool mIsPaused;"); var function = codeBlock.Function("public override void", "Pause", "FlatRedBall.Instructions.InstructionList instructions"); function.Line("base.Pause(instructions);"); function.Line("mIsPaused = true;"); foreach (var nos in element.AllNamedObjects) { GeneratePauseForNos(nos, function); } } codeBlock = GenerateSetToIgnorePausing(codeBlock, element, hasBase); } return(codeBlock); }