public Emitter Clone() { Emitter tempEmitter = base.Clone <Emitter>(); // Justin Johnson, 04/2015 - retiring particle blueprints //tempEmitter.ParticleBlueprint = this.ParticleBlueprint.Clone(); tempEmitter.mInstructions = new FlatRedBall.Instructions.InstructionList(); tempEmitter.EmissionSettings = EmissionSettings.Clone(); tempEmitter.EmissionBoundary = EmissionBoundary.Clone <Polygon>(); tempEmitter.BoundedEmission = BoundedEmission; return(tempEmitter); }
public Emitter() : base() { mEmissionSettings = new EmissionSettings(); mRandom = FlatRedBallServices.Random; // Justin Johnson, 04/2015 - retiring particle blueprints //ParticleBlueprint = new Sprite(); mEmissionBoundary = Polygon.CreateRectangle(32, 32); mEmissionBoundary.AttachTo(this, false); mAreaEmission = AreaEmissionType.Point; this.ParentRotationChangesPosition = true; this.ParentRotationChangesRotation = true; mParentVelocityChangesEmissionVelocity = true; mSecondsModifier = 1.0f; }
public EmissionSettings ToEmissionSettings(string contentManagerName) { EmissionSettings emissionSettings = new EmissionSettings(); emissionSettings.VelocityRangeType = VelocityRangeType; emissionSettings.RadialVelocity = RadialVelocity; emissionSettings.RadialVelocityRange = RadialVelocityRange; emissionSettings.Billboarded = Billboarded; emissionSettings.XVelocity = XVelocity; emissionSettings.YVelocity = YVelocity; emissionSettings.ZVelocity = ZVelocity; emissionSettings.XVelocityRange = XVelocityRange; emissionSettings.YVelocityRange = YVelocityRange; emissionSettings.ZVelocityRange = ZVelocityRange; emissionSettings.WedgeAngle = WedgeAngle; emissionSettings.WedgeSpread = WedgeSpread; emissionSettings.RotationX = RotationX; emissionSettings.RotationXVelocity = RotationXVelocity; emissionSettings.RotationXRange = RotationXRange; emissionSettings.RotationXVelocityRange = RotationXVelocityRange; emissionSettings.RotationY = RotationY; emissionSettings.RotationYVelocity = RotationYVelocity; emissionSettings.RotationYRange = RotationYRange; emissionSettings.RotationYVelocityRange = RotationYVelocityRange; emissionSettings.RotationZ = RotationZ; emissionSettings.RotationZVelocity = RotationZVelocity; emissionSettings.RotationZRange = RotationZRange; emissionSettings.RotationZVelocityRange = RotationZVelocityRange; emissionSettings.XAcceleration = XAcceleration; emissionSettings.YAcceleration = YAcceleration; emissionSettings.ZAcceleration = ZAcceleration; emissionSettings.XAccelerationRange = XAccelerationRange; emissionSettings.YAccelerationRange = YAccelerationRange; emissionSettings.ZAccelerationRange = ZAccelerationRange; emissionSettings.Drag = Drag; emissionSettings.ScaleX = ScaleX; emissionSettings.ScaleY = ScaleY; emissionSettings.ScaleXRange = ScaleXRange; emissionSettings.ScaleYRange = ScaleYRange; emissionSettings.ScaleXVelocity = ScaleXVelocity; emissionSettings.ScaleYVelocity = ScaleYVelocity; emissionSettings.ScaleXVelocityRange = ScaleXVelocityRange; emissionSettings.ScaleYVelocityRange = ScaleYVelocityRange; emissionSettings.MatchScaleXToY = MatchScaleXToY; if (TextureScale > 0) { emissionSettings.TextureScale = TextureScale; } else { emissionSettings.TextureScale = -1; } #if FRB_MDX float divisionValue = 1; #else float divisionValue = 255; #endif emissionSettings.Alpha = (255 - Fade) / divisionValue; emissionSettings.Red = TintRed / divisionValue; emissionSettings.Green = TintGreen / divisionValue; emissionSettings.Blue = TintBlue / divisionValue; emissionSettings.AlphaRate = -FadeRate / divisionValue; emissionSettings.RedRate = TintRedRate / divisionValue; emissionSettings.BlueRate = TintBlueRate / divisionValue; emissionSettings.GreenRate = TintGreenRate / divisionValue; emissionSettings.BlendOperation = GraphicalEnumerations.TranslateBlendOperation(BlendOperation); emissionSettings.ColorOperation = GraphicalEnumerations.TranslateColorOperation(ColorOperation); emissionSettings.Animate = Animate; emissionSettings.CurrentChainName = CurrentChainName; // load the animation chains or the texture but not both // chains take priority over texture? if (!string.IsNullOrEmpty(AnimationChains)) { // load the animation chain, note that this could throw an exception if file names are bad or chain doesn't exist! emissionSettings.AnimationChains = FlatRedBallServices.Load <AnimationChainList>(AnimationChains, contentManagerName); if (!string.IsNullOrEmpty(CurrentChainName)) { emissionSettings.AnimationChain = emissionSettings.AnimationChains[emissionSettings.CurrentChainName]; } } else { if (!string.IsNullOrEmpty(Texture)) { // load the texture, emissionSettings.Texture = FlatRedBallServices.Load <Texture2D>(Texture, contentManagerName); } } if (Instructions != null) { emissionSettings.Instructions = Instructions.ToInstructionBlueprintList(); foreach (InstructionBlueprint blueprint in emissionSettings.Instructions) { if (GraphicalEnumerations.ConvertableSpriteProperties.Contains(blueprint.MemberName)) { blueprint.MemberValue = (float)blueprint.MemberValue / divisionValue; } //if(blueprint.MemberName.Equals("Alpha")){ //} //else if(blueprint.MemberName.Equals("AlphaRate")){ //} //else if(blueprint.MemberName.Equals("Blue")){ //} //else if(blueprint.MemberName.Equals("BlueRate")){ //} //else if(blueprint.MemberName.Equals("Green")){ //} //else if(blueprint.MemberName.Equals("GreenRate")){ //} //else if(blueprint.MemberName.Equals("Red")){ //} //else if(blueprint.MemberName.Equals("RedRate")){ //} } } // TODO: Add support for saving AnimationChains. Probably need to change the mAnimation // field from an AnimationChain to an AnimationChainSave return(emissionSettings); }
public static EmissionSettingsSave FromEmissionSettings(EmissionSettings emissionSettings) { EmissionSettingsSave emissionSettingsSave = new EmissionSettingsSave(); emissionSettingsSave.mVelocityRangeType = emissionSettings.VelocityRangeType; emissionSettingsSave.mRadialVelocity = emissionSettings.RadialVelocity; emissionSettingsSave.mRadialVelocityRange = emissionSettings.RadialVelocityRange; emissionSettingsSave.mXVelocity = emissionSettings.XVelocity; emissionSettingsSave.mYVelocity = emissionSettings.YVelocity; emissionSettingsSave.mZVelocity = emissionSettings.ZVelocity; emissionSettingsSave.mXVelocityRange = emissionSettings.XVelocityRange; emissionSettingsSave.mYVelocityRange = emissionSettings.YVelocityRange; emissionSettingsSave.mZVelocityRange = emissionSettings.ZVelocityRange; emissionSettingsSave.mWedgeAngle = emissionSettings.WedgeAngle; emissionSettingsSave.mWedgeSpread = emissionSettings.WedgeSpread; emissionSettingsSave.Billboarded = emissionSettings.Billboarded; emissionSettingsSave.mRotationX = emissionSettings.RotationX; emissionSettingsSave.mRotationXVelocity = emissionSettings.RotationXVelocity; emissionSettingsSave.mRotationXRange = emissionSettings.RotationXRange; emissionSettingsSave.mRotationXVelocityRange = emissionSettings.RotationXVelocityRange; emissionSettingsSave.mRotationY = emissionSettings.RotationY; emissionSettingsSave.mRotationYVelocity = emissionSettings.RotationYVelocity; emissionSettingsSave.mRotationYRange = emissionSettings.RotationYRange; emissionSettingsSave.mRotationYVelocityRange = emissionSettings.RotationYVelocityRange; emissionSettingsSave.mRotationZ = emissionSettings.RotationZ; emissionSettingsSave.mRotationZVelocity = emissionSettings.RotationZVelocity; emissionSettingsSave.mRotationZRange = emissionSettings.RotationZRange; emissionSettingsSave.mRotationZVelocityRange = emissionSettings.RotationZVelocityRange; emissionSettingsSave.mXAcceleration = emissionSettings.XAcceleration; emissionSettingsSave.mYAcceleration = emissionSettings.YAcceleration; emissionSettingsSave.mZAcceleration = emissionSettings.ZAcceleration; emissionSettingsSave.mXAccelerationRange = emissionSettings.XAccelerationRange; emissionSettingsSave.mYAccelerationRange = emissionSettings.YAccelerationRange; emissionSettingsSave.mZAccelerationRange = emissionSettings.ZAccelerationRange; emissionSettingsSave.mScaleX = emissionSettings.ScaleX; emissionSettingsSave.mScaleY = emissionSettings.ScaleY; emissionSettingsSave.mScaleXRange = emissionSettings.ScaleXRange; emissionSettingsSave.mScaleYRange = emissionSettings.ScaleYRange; emissionSettingsSave.mMatchScaleXToY = emissionSettings.MatchScaleXToY; emissionSettingsSave.mScaleXVelocity = emissionSettings.ScaleXVelocity; emissionSettingsSave.mScaleYVelocity = emissionSettings.ScaleYVelocity; emissionSettingsSave.mScaleXVelocityRange = emissionSettings.ScaleXVelocityRange; emissionSettingsSave.mScaleYVelocityRange = emissionSettings.ScaleYVelocityRange; if (emissionSettings.TextureScale > 0) { emissionSettingsSave.TextureScale = emissionSettings.TextureScale; } else { emissionSettingsSave.TextureScale = -1; } int multiple = 255; emissionSettingsSave.mFade = (1 - emissionSettings.Alpha) * 255; emissionSettingsSave.mTintRed = emissionSettings.Red * 255; emissionSettingsSave.mTintGreen = emissionSettings.Green * 255; emissionSettingsSave.mTintBlue = emissionSettings.Blue * 255; emissionSettingsSave.mFadeRate = -emissionSettings.AlphaRate * 255; emissionSettingsSave.mTintRedRate = emissionSettings.RedRate * 255; emissionSettingsSave.mTintGreenRate = emissionSettings.GreenRate * 255; emissionSettingsSave.mTintBlueRate = emissionSettings.BlueRate * 255; emissionSettingsSave.mBlendOperation = GraphicalEnumerations.BlendOperationToFlatRedBallMdxString(emissionSettings.BlendOperation); emissionSettingsSave.mColorOperation = GraphicalEnumerations.ColorOperationToFlatRedBallMdxString( emissionSettings.ColorOperation); // preserve animation and texture settings emissionSettingsSave.mAnimate = emissionSettings.Animate; // TODO: Justin - not sure if we need to force relative here? emissionSettingsSave.AnimationChains = emissionSettings.AnimationChains.Name; emissionSettingsSave.CurrentChainName = emissionSettings.CurrentChainName; // TODO: Justin - not sure if we neet to force relative here? emissionSettingsSave.Texture = emissionSettings.Texture.Name; emissionSettingsSave.Instructions = InstructionBlueprintListSave.FromInstructionBlueprintList(emissionSettings.Instructions); foreach (InstructionSave blueprint in emissionSettingsSave.Instructions.Instructions) { if (GraphicalEnumerations.ConvertableSpriteProperties.Contains(blueprint.Member)) { blueprint.Value = (float)blueprint.Value * multiple; } } emissionSettingsSave.mDrag = emissionSettings.Drag; return(emissionSettingsSave); }