public override ICodeBlock GenerateFields(ICodeBlock codeBlock, IElement element) { /////////////////Early Out////////////////////// if (GetIfIsTopDown(element) == false) { return(codeBlock); } //////////////End Early Out////////////////////// /// codeBlock.Line("#region Top Down Fields"); codeBlock.Line("DataTypes.TopDownValues mCurrentMovement;"); codeBlock.Line("public float TopDownSpeedMultiplier { get; set; } = 1;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The current movement variables used when applying input."); codeBlock.Line("/// </summary>"); codeBlock.Property("public DataTypes.TopDownValues", "CurrentMovement") .Get() .Line("return mCurrentMovement;"); codeBlock.Property("public FlatRedBall.Input.IInputDevice", "InputDevice") .Line("get;") .Line("private set;"); codeBlock.Line("TopDownDirection mDirectionFacing;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Which direciton the character is facing."); codeBlock.Line("/// </summary>"); codeBlock.Property("protected TopDownDirection", "DirectionFacing") .Get() .Line("return mDirectionFacing;"); codeBlock.Property("public PossibleDirections", "PossibleDirections") .AutoGet().End() .AutoSet(); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The input object which controls the horizontal movement of the character."); codeBlock.Line("/// Common examples include a d-pad, analog stick, or keyboard keys."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public FlatRedBall.Input.I2DInput", "MovementInput"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Whether input is read to control the movement of the character."); codeBlock.Line("/// This can be turned off if the player should not be able to control"); codeBlock.Line("/// the character."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public bool", "InputEnabled"); codeBlock.Line("#endregion"); return(codeBlock); }
private static string GenerateClaimEntityMessageCode() { ICodeBlock topBlock = new CodeBlockBaseNoIndent(null); ICodeBlock codeBlock = topBlock.Namespace(GlueState.Self.ProjectNamespace + ".Messages"); codeBlock = codeBlock.Class("", "ClaimEntity"); codeBlock.AutoProperty("public string", "EntityName"); codeBlock.AutoProperty("public long", "OwnerId"); codeBlock.AutoProperty("public long", "EntityId"); return(topBlock.ToString()); }
private void GenerateIgnoresParentVisibility(ICodeBlock codeBlock, EntitySave entitySave) { if (!entitySave.GetInheritsFromIVisible()) { codeBlock.AutoProperty("public bool", "IgnoresParentVisibility"); } }
private void GenerateInstanceProperties(ElementSave elementSave, ICodeBlock currentBlock) { string publicOrPrivate; if (elementSave is Gum.DataTypes.ScreenSave) { // make these public for screens because the only time this will be accessed is in the Glue screen that owns it publicOrPrivate = "public"; } else { publicOrPrivate = "private"; } foreach (var instance in elementSave.Instances) { string type = GetQualifiedRuntimeTypeFor(instance); if (GetIfInstanceReferencesValidComponent(instance)) { ICodeBlock property = currentBlock.AutoProperty($"{publicOrPrivate} " + type, instance.MemberNameInCode()); } else { currentBlock.Line("// could not generate member for " + instance.Name + " because it doesn't reference a valid component"); } } }
internal static ICodeBlock AutoProperty(this ICodeBlock pCodeBlock, string pName, bool Public = false, bool Private = false, bool Protected = false, bool Internal = false, bool ProtectedInternal = false, bool Static = false, bool Override = false, bool Virtual = false, string Type = null) { return(pCodeBlock.AutoProperty( StringHelper.Modifiers( Public: Public, Private: Private, Protected: Protected, Internal: Internal, ProtectedInternal: ProtectedInternal, Static: Static, Override: Override, Virtual: Virtual, Type: Type ) , pName)); }
private static string GetGeneratedEntityNetworkCode(EntitySave entitySave) { ICodeBlock topBlock = new CodeBlockBaseNoIndent(null); string entityNamespace = CodeGeneratorCommonLogic.GetElementNamespace(entitySave); ICodeBlock codeBlock = topBlock.Namespace(entityNamespace); codeBlock = codeBlock.Class("public partial", entitySave.GetStrippedName(), " : RedGrin.INetworkEntity"); codeBlock.AutoProperty("public long", "OwnerId"); codeBlock.AutoProperty("public long", "EntityId"); GenerateGetStateMethod(entitySave, codeBlock); GenerateUpdateFromStateMethod(entitySave, codeBlock); return(topBlock.ToString()); }
private void GenerateInstanceProperties(ElementSave elementSave, ICodeBlock currentBlock) { foreach (var instance in elementSave.Instances) { string type = GetQualifiedRuntimeTypeFor(instance); if (GetIfInstanceReferencesValidComponent(instance)) { ICodeBlock property = currentBlock.AutoProperty("private " + type, instance.MemberNameInCode()); } else { currentBlock.Line("// could not generate member for " + instance.Name + " because it doesn't reference a valid component"); } } }
private static string GenerateNetStateGeneratedCode(EntitySave entitySave) { ICodeBlock topBlock = new CodeBlockBaseNoIndent(null); string netStateNamespace = CodeGeneratorCommonLogic.GetNetStateNamespace(entitySave); ICodeBlock codeBlock = topBlock.Namespace(netStateNamespace); codeBlock = codeBlock.Class("public partial", entitySave.GetStrippedName() + "NetState"); var variables = GetNetworkVariables(entitySave); foreach (var variable in variables) { codeBlock.AutoProperty($"public {variable.Type}", variable.Name); } return(topBlock.ToString()); }
public override void GenerateAdditionalClasses(ICodeBlock codeBlock, IElement element) { /////////////////Early Out////////////////////// if (TopDownEntityPropertyLogic.GetIfIsTopDown(element) == false) { return; } //////////////End Early Out////////////////////// /// var className = element.GetStrippedName(); codeBlock = codeBlock.Class("public partial", className, ": TopDown.ITopDownEntity"); codeBlock.Line("#region Top Down Fields"); WriteAnimationFields(element, codeBlock); codeBlock.Line("DataTypes.TopDownValues mCurrentMovement;"); codeBlock.Line("public float TopDownSpeedMultiplier { get; set; } = 1;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The current movement variables used when applying input."); codeBlock.Line("/// </summary>"); codeBlock.Property("public DataTypes.TopDownValues", "CurrentMovement") .Get() .Line("return mCurrentMovement;").End() .Set("private") .Line("mCurrentMovement = value;"); codeBlock.Property("public FlatRedBall.Input.IInputDevice", "InputDevice") .Line("get;") .Line("private set;"); codeBlock.Line("TopDownDirection mDirectionFacing;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Which direciton the character is facing."); codeBlock.Line("/// </summary>"); codeBlock.Property("public TopDownDirection", "DirectionFacing") .Get() .Line("return mDirectionFacing;"); codeBlock.Property("public PossibleDirections", "PossibleDirections") .AutoGet().End() .AutoSet(); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The input object which controls the horizontal movement of the character."); codeBlock.Line("/// Common examples include a d-pad, analog stick, or keyboard keys."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public FlatRedBall.Input.I2DInput", "MovementInput"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Whether input is read to control the movement of the character."); codeBlock.Line("/// This can be turned off if the player should not be able to control"); codeBlock.Line("/// the character."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public bool", "InputEnabled"); codeBlock.Line("TopDown.DirectionBasedAnimationLayer mTopDownAnimationLayer;"); codeBlock.Line("#endregion"); }
public override ICodeBlock GenerateFields(ICodeBlock codeBlock, IElement element) { ///////////////Early Out////////////////////// if (GetIfIsPlatformer(element) == false) { return(codeBlock); } /////////////End Early Out//////////////////// codeBlock.Line("#region Platformer Fields"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// See property for information."); codeBlock.Line("/// </summary>"); codeBlock.Line("bool mIsOnGround = false;"); codeBlock.Line("bool wasOnGroundLastFrame = false;"); codeBlock.Line("private float lastNonZeroPlatformerHorizontalMaxSpeed = 0;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Whether the character has hit its head on a solid"); codeBlock.Line("/// collision this frame. This typically occurs when the"); codeBlock.Line("/// character is moving up in the air. It is used to prevent"); codeBlock.Line("/// upward velocity from being applied while the player is"); codeBlock.Line("/// holding down the jump button."); codeBlock.Line("/// </summary>"); codeBlock.Line("bool mHitHead = false;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The current slope that the character is standing or walking on in degrees relative"); codeBlock.Line("/// to the direction that the character is facing. In other words, if the charater is"); codeBlock.Line("/// walking uphill to the right (positive slope), if the character turns around the value"); codeBlock.Line("/// will be negative."); codeBlock.Line("/// </summary>"); codeBlock.Line("float currentSlope = 0;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Whether the character is in the air and has double-jumped."); codeBlock.Line("/// This is used to determine which movement variables are active,"); codeBlock.Line("/// effectively preventing multiple double-jumps."); codeBlock.Line("/// </summary>"); codeBlock.Line("bool mHasDoubleJumped = false;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The time when the jump button was last pushed. This is used to"); codeBlock.Line("/// determine if upward velocity should be applied while the user"); codeBlock.Line("/// holds the jump button down."); codeBlock.Line("/// </summary>"); codeBlock.Line("double mTimeJumpPushed = double.NegativeInfinity;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The MovementValues which were active when the user last jumped."); codeBlock.Line("/// These are used to determine the upward velocity to apply while"); codeBlock.Line("/// the user holds the jump button."); codeBlock.Line("/// </summary>"); codeBlock.Line("DataTypes.PlatformerValues mValuesJumpedWith;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// See property for information."); codeBlock.Line("/// </summary>"); codeBlock.Line("DataTypes.PlatformerValues mCurrentMovement;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// See property for information."); codeBlock.Line("/// </summary>"); codeBlock.Line("HorizontalDirection mDirectionFacing;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// See property for information."); codeBlock.Line("/// </summary>"); codeBlock.Line("MovementType mMovementType;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The last time collision checks were performed. Time values uniquely"); codeBlock.Line("/// identify a game frame, so this is used to store whether collisions have"); codeBlock.Line("/// been tested this frame or not. This is used to determine whether collision"); codeBlock.Line("/// variables should be reset or not when a collision method is called, as"); codeBlock.Line("/// multiple collisions (such as vs. solid and vs. cloud) may occur in one frame."); codeBlock.Line("/// </summary>"); codeBlock.Line("double mLastCollisionTime = -1;"); codeBlock.Line("#endregion"); codeBlock.Line("#region Platformer Properties"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Returns the current time, considering whether a Screen is active. "); codeBlock.Line("/// This is used to control how long a user can hold the jump button during"); codeBlock.Line("/// a jump to apply upward velocity."); codeBlock.Line("/// </summary>"); codeBlock.Property("double", "CurrentTime") .Get() .If("FlatRedBall.Screens.ScreenManager.CurrentScreen != null") .Line("return FlatRedBall.Screens.ScreenManager.CurrentScreen.PauseAdjustedCurrentTime;") .End() .Else() .Line("return FlatRedBall.TimeManager.CurrentTime;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The current movement variables used for horizontal movement and jumping."); codeBlock.Line("/// These automatically get set according to the default platformer logic and should"); codeBlock.Line("/// not be manually adjusted."); codeBlock.Line("/// </summary>"); codeBlock.Property("protected DataTypes.PlatformerValues", "CurrentMovement") .Get() .Line("return mCurrentMovement;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Which direciton the character is facing."); codeBlock.Line("/// </summary>"); codeBlock.Property("protected HorizontalDirection", "DirectionFacing") .Get() .Line("return mDirectionFacing;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The input object which controls whether the jump was pressed."); codeBlock.Line("/// Common examples include a button or keyboard key."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public FlatRedBall.Input.IPressableInput", "JumpInput"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The input object which controls the horizontal movement of the character."); codeBlock.Line("/// Common examples include a d-pad, analog stick, or keyboard keys."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public FlatRedBall.Input.I1DInput", "HorizontalInput"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The input object which controls vertical input such as moving on ladders or falling through cloud collision."); codeBlock.Line("/// -1 represents full down, 0 is neutral, +1 is full up."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public FlatRedBall.Input.I1DInput", "VerticalInput"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The ratio that the horizontal input is being held."); codeBlock.Line("/// -1 represents full left, 0 is neutral, +1 is full right."); codeBlock.Line("/// </summary>"); codeBlock.Property("protected virtual float", "HorizontalRatio") .Get() .If("!InputEnabled") .Line("return 0;") .End() .Else() .Line("return HorizontalInput.Value;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Whether the character is on the ground. This is false"); codeBlock.Line("/// if the character has jumped or walked off of the edge"); codeBlock.Line("/// of a platform."); codeBlock.Line("/// </summary>"); codeBlock.Property("public bool", "IsOnGround") .Get() .Line("return mIsOnGround;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// The current movement type. This is set by the default platformer logic and"); codeBlock.Line("/// is used to assign the mCurrentMovement variable."); codeBlock.Line("/// </summary>"); codeBlock.Property("public MovementType", "CurrentMovementType") .Get() .Line("return mMovementType;") .End() .Set() .Line("mMovementType = value;") .Line("UpdateCurrentMovement();") .If("CurrentMovement != null") .Line("this.YAcceleration = -CurrentMovement.Gravity;"); codeBlock.Line("/// <summary>"); codeBlock.Line("/// Whether input is read to control the movement of the character."); codeBlock.Line("/// This can be turned off if the player should not be able to control"); codeBlock.Line("/// the character."); codeBlock.Line("/// </summary>"); codeBlock.AutoProperty("public bool", "InputEnabled"); // This can be used to add anything else here without the complexity of CodeBlock calls codeBlock.Line( @" /// <summary> /// Stores the value that the entity must fall down to before cloud collision is enabled. /// If this value is null, then cloud collision is enabled. When the entity falls through a /// cloud (by pressing down direction + jump), then this value is set. /// </summary> private float? cloudCollisionFallThroughY = null; "); codeBlock.Line("#endregion"); codeBlock.Line( @" /// <summary> /// Action for when the character executes a jump. /// </summary> public System.Action JumpAction; /// <summary> /// Action for when the character lands from a jump. /// </summary> public System.Action LandedAction; "); return(codeBlock); }
public static void AppendFieldOrPropertyForReferencedFile(ICodeBlock codeBlock, ReferencedFileSave referencedFile, string containerName, IElement element, string contentManagerName) { /////////////////////////////////////EARLY OUT////////////////////////////////////////////// // If the referenced file is a database for localizing, it will just be stuffed right into the localization manager if (!referencedFile.LoadedAtRuntime || referencedFile.IsDatabaseForLocalizing) return; ///////////////////////////////////END EARLY OUT///////////////////////////////////////////// string fileName = referencedFile.Name; string extension = FileManager.GetExtension(fileName); AssetTypeInfo ati = referencedFile.GetAssetTypeInfo(); string variableName = referencedFile.GetInstanceName(); #region Get the typeName string typeName = null; if (ati != null && !referencedFile.TreatAsCsv && ati.QualifiedRuntimeTypeName.QualifiedType != null) { typeName = ati.QualifiedRuntimeTypeName.QualifiedType; } else if (extension == "csv" || referencedFile.TreatAsCsv) { typeName = CsvCodeGenerator.GetEntireGenericTypeForCsvFile(referencedFile); } #endregion //////////////////////////////EARLY OUT/////////////////////////////////////// if (typeName == null) return; ///////////////////////////END EARLY OUT////////////////////////////////////// AddIfConditionalSymbolIfNecesssary(codeBlock, referencedFile); if (NeedsFullProperty(referencedFile, containerName)) { AppendPropertyForReferencedFileSave(codeBlock, referencedFile, containerName, element, contentManagerName, ati, variableName, typeName); } else { if (containerName == ContentLoadWriter.GlobalContentContainerName) { // Global Content will always have the content as properties. This is so that you can switch between // async and sync loading and not have to change reflection code codeBlock.AutoProperty(variableName, Public: referencedFile.HasPublicProperty, // Should be protected so derived classes can access this Protected: !referencedFile.HasPublicProperty, Static: referencedFile.IsSharedStatic, Type: typeName); } else { codeBlock.Line(StringHelper.Modifiers( Public: referencedFile.HasPublicProperty, // Should be protected so derived classes can access this Protected: !referencedFile.HasPublicProperty, Static: referencedFile.IsSharedStatic, Type: typeName, Name: variableName) + ";"); } } AddEndIfIfNecessary(codeBlock, referencedFile); }
public override ICodeBlock GenerateFields(ICodeBlock codeBlock, IElement element) { /////////////////Early Out////////////////// if (GetIfIsRacingEntity(element) == false) { return(codeBlock); } ///////////////End Early Out/////////////////// codeBlock.Line("float lateralToForwardTransferRatio;"); codeBlock.Line("float currentTurnRate;"); codeBlock.Line("bool IsAllowedToDrive = true;"); codeBlock.Line("bool wasMovingForwardAtStartOfCollisionRecording;"); codeBlock.Line("CollisionHistory collisionHistory = new CollisionHistory();"); var property = codeBlock.Property("public float", "EffectiveStability"); var get = property.Get(); get.Line("var toReturn = CarData.Stability;"); var ifBlock = get.If("Gas.Value == 0") .Line("toReturn += CarData.NoGasExtraStability;"); ifBlock = get.If("currentTurnRate == 0") .Line("toReturn += CarData.NoTurnExtraStability;"); get.Line("return toReturn;"); codeBlock.AutoProperty("public RacingDirection", "ForwardDirection"); codeBlock.Property("public Microsoft.Xna.Framework.Vector3", "Forward") .Get() .Switch("ForwardDirection") .CaseNoBreak("RacingDirection.Up") .Line("return RotationMatrix.Up;").End() .CaseNoBreak("RacingDirection.Right") .Line("return RotationMatrix.Right;").End() .CaseNoBreak("RacingDirection.Down") .Line("return RotationMatrix.Down;").End() .CaseNoBreak("RacingDirection.Left") .Line("return RotationMatrix.Left;").End() .Default() .Line("return RotationMatrix.Up;").End(); codeBlock.Property("public Microsoft.Xna.Framework.Vector3", "Right") .Get() .Switch("ForwardDirection") .CaseNoBreak("RacingDirection.Up") .Line("return RotationMatrix.Right;").End() .CaseNoBreak("RacingDirection.Right") .Line("return RotationMatrix.Down;").End() .CaseNoBreak("RacingDirection.Down") .Line("return RotationMatrix.Left;").End() .CaseNoBreak("RacingDirection.Left") .Line("return RotationMatrix.Up;") .Default() .Line("return RotationMatrix.Right;").End(); codeBlock.Property("public Microsoft.Xna.Framework.Vector3", "Left") .Get() .Switch("ForwardDirection") .CaseNoBreak("RacingDirection.Up") .Line("return RotationMatrix.Left;").End() .CaseNoBreak("RacingDirection.Right") .Line("return RotationMatrix.Up;").End() .CaseNoBreak("RacingDirection.Down") .Line("return RotationMatrix.Right;").End() .CaseNoBreak("RacingDirection.Left") .Line("return RotationMatrix.Down;") .Default() .Line("return RotationMatrix.Left;").End(); codeBlock.AutoProperty("private FlatRedBall.Input.I1DInput", "Gas"); codeBlock.AutoProperty("private FlatRedBall.Input.IPressableInput", "Brake"); codeBlock.AutoProperty("private FlatRedBall.Input.I1DInput", "SteeringInput"); codeBlock.Line("public FlatRedBall.Input.IInputDevice InputDevice { get; private set; }"); codeBlock.Property("public float", "CurrentForwardSpeed") .Get() .Line("return Microsoft.Xna.Framework.Vector3.Dot(this.Velocity, this.Forward);"); codeBlock.Property("public float", "CurrentLateralSpeed") .Get() .Line("return Microsoft.Xna.Framework.Vector3.Dot(this.Velocity, this.Right);"); GenerateInitializeInput(codeBlock); GenerateLateralSpeedAdjustmentActivityMethod(codeBlock); GenerateForwardBackActivityMethod(codeBlock); GenerateTurningActivity(codeBlock); GenerateBeforeAfterCollisionLogic(codeBlock); return(codeBlock); /* * * * public bool IsAllowedToDrive * { * get; set; * } = true; */ }
private static void CreateNewVariableMember(ICodeBlock codeBlock, CustomVariable customVariable, bool isExposing, IElement element) { string variableAssignment = ""; if (customVariable.DefaultValue != null) { if (!IsTypeFromCsv(customVariable)) { variableAssignment = CodeParser.ParseObjectValue(customVariable.DefaultValue); // If this is a file, we don't want to assign it here if (customVariable.GetIsFile()) { variableAssignment = null; } if (customVariable.Type == "Color") { variableAssignment = "Color." + variableAssignment.Replace("\"", ""); } else if (customVariable.Type != "string" && variableAssignment == "\"\"") { variableAssignment = null; } if (variableAssignment != null) { variableAssignment = " = " + variableAssignment; } } else if(!string.IsNullOrEmpty(customVariable.DefaultValue as string) && (string)customVariable.DefaultValue != "<NULL>") { // If the variable IsShared (ie static) then we // don't want to assign the value because the CSV // may not yet be loaded. This may create behavior // the user doesn't expect, but the alternative is either // to load the file before the user wants to (which maybe we // will end up doing) or to get a crash // Update June 2, 2013 // If the customVariable // is not "IsShared" (it's // not static), we don't want // to assign the value where we // create the variable as a field // because this means the value will // attempt to assign before LoadStaticContent. // This can cause a crash, and has in the GlueTestProject. // Update June 2, 2013 // Used to set it to null // if it's static, but we should // allow statics to set their values // if they come from global content files. if ( ReferencesCsvFromGlobalContent(customVariable) && ShouldAssignToCsv(customVariable, customVariable.DefaultValue as string)) { variableAssignment = " = " + GetAssignmentToCsvItem(customVariable, element, (string)customVariable.DefaultValue); } else { variableAssignment = null; } } } string formatString = null; bool needsToBeProperty = (customVariable.SetByDerived && !customVariable.IsShared) || customVariable.CreatesProperty || customVariable.CreatesEvent || IsVariableWholeNumberWithVelocity(customVariable); needsToBeProperty = needsToBeProperty & !customVariable.GetIsVariableState(); EventCodeGenerator.TryGenerateEventsForVariable(codeBlock, customVariable, element); string memberType = GetMemberTypeFor(customVariable, element); if (needsToBeProperty) { // If the variable // creates an event // then it needs to have // custom code (it can't be // an automatic property). bool isWholeNumberWithVelocity = IsVariableWholeNumberWithVelocity(customVariable); if (customVariable.CreatesEvent || isWholeNumberWithVelocity || customVariable.DefaultValue != null ) { string variableToAssignInProperty = "base." + customVariable.Name; // create a field for this, unless it's defined by base - then the base creates a field for it if (!isExposing && !customVariable.DefinedByBase) { variableToAssignInProperty = "m" + customVariable.Name; // First we make the field that will get set here: codeBlock.Line(StringHelper.Modifiers(Public: false, Static: customVariable.IsShared, Type: memberType, Name: variableToAssignInProperty) + variableAssignment + ";"); } string propertyHeader = null; if (isExposing) { propertyHeader = "public new " + memberType + " " + customVariable.Name; } else if (customVariable.DefinedByBase) { propertyHeader = "public override " + memberType + " " + customVariable.Name; } else if (customVariable.SetByDerived) { propertyHeader = "public virtual " + memberType + " " + customVariable.Name; } else { propertyHeader = "public " + memberType + " " + customVariable.Name; } ICodeBlock set = codeBlock.Property(propertyHeader, Static:customVariable.IsShared) .Set(); if (EventCodeGenerator.ShouldGenerateEventsForVariable(customVariable, element)) { EventCodeGenerator.GenerateEventRaisingCode(set, BeforeOrAfter.Before, customVariable.Name, element); } set.Line(variableToAssignInProperty + " = value;"); if (IsVariableWholeNumberWithVelocity(customVariable)) { set.Line(customVariable.Name + "ModifiedByVelocity = value;"); } if (EventCodeGenerator.ShouldGenerateEventsForVariable(customVariable, element)) { EventCodeGenerator.GenerateEventRaisingCode(set, BeforeOrAfter.After, customVariable.Name, element); } ICodeBlock get = set.End().Get(); codeBlock = get.Line("return " + variableToAssignInProperty + ";") .End().End(); // end the getter, end the property } else { // Static vars can't be virtual bool isVirtual = !customVariable.IsShared; codeBlock.AutoProperty(customVariable.Name, Public: true, Virtual: isVirtual, Static: customVariable.IsShared, Type: memberType); } } else { if (!customVariable.GetIsVariableState()) { codeBlock.Line(StringHelper.Modifiers(Public: true, Static: customVariable.IsShared, Type: memberType, Name: customVariable.Name) + variableAssignment + ";"); } else { if (IsVariableTunnelingToDisabledObject(customVariable, element)) { // If it's a varaible // that is exposing a // state variable for a // disabled object, we still // want to generate something: codeBlock.Line(StringHelper.Modifiers(Public: true, Static: customVariable.IsShared, Type: memberType, Name: customVariable.Name) // No assignment for now. Do we eventually want this? The reason // this even exists is to satisfy a variable that may be needed by other // code which would point to a disabled object. //+ variableAssignment + ";"); } } } }