// Called when the node enters the scene tree for the first time. public override void _Ready() { particles = GetNode <Particles2D>("Particles2D"); particlesMaterial = particles.ProcessMaterial as ParticlesMaterial; noise = new OpenSimplexNoise(); noise.Octaves = 4; noise.Period = 20f; noise.Persistence = 0.8f; }
public override void _Ready() { _world = (World)GetNode("/root/World"); _light = (Light2D)GetNode("Light2D"); var mat = (ParticlesMaterial)ProcessMaterial; _sound = (AudioStreamPlayer)FindNode("ExtinguishSound"); var gradient = new Gradient(); gradient.AddPoint(2048 * 0.0f, new Color(255, 0, 0)); gradient.AddPoint(2048 * 0.2f, new Color(255, 90, 0)); gradient.AddPoint(2048 * 0.4f, new Color(255, 109, 0)); gradient.AddPoint(2048 * 0.6f, new Color(255, 154, 0)); gradient.AddPoint(2048 * 0.8f, new Color(255, 206, 0)); gradient.AddPoint(2048 * 1.0f, new Color(255, 226, 6)); var gradientTex = new GradientTexture(); gradientTex.SetGradient(gradient); gradientTex.SetWidth(2048); var scale = new Curve(); scale.AddPoint(new Vector2(0.0f, 1.0f)); scale.AddPoint(new Vector2(1.0f, 0.5f)); var scaleTex = new CurveTexture(); scaleTex.SetCurve(scale); var matCopy = new ParticlesMaterial() { EmissionShape = ParticlesMaterial.EMISSION_SHAPE_SPHERE, EmissionSphereRadius = 10, FlagDisableZ = true, Spread = 180, Gravity = new Vector3(0, -98, 0), InitialVelocity = 2, InitialVelocityRandom = 1, AngularVelocity = 10, RadialAccel = -15, Scale = 3, ColorRamp = gradientTex, ScaleCurve = scaleTex }; this.ProcessMaterial = matCopy; }
public void SetModulateColor(string setTag, Color modColor) { GD.Print($"SetModulateColor, setTag={setTag}, modColor={modColor}, source points={numberOfSourcePoints}"); if (String.IsNullOrEmpty(setTag) || (setTag == "all")) { for (int idx = 1; idx <= numberOfSourcePoints; idx++) { string strKey = $"set{idx}"; Particles2D particleSetCurrent = GetParticleSet(strKey); if (particleSetCurrent != null) { ParticlesMaterial procMaterial = (ParticlesMaterial)particleSetCurrent.ProcessMaterial; procMaterial.Color = modColor; } } } }
// Called when the node enters the scene tree for the first time. public override void _Ready() { //Setting the objects to the correct nodepath pipe = GetNode <RigidBody2D>(pipePath) as RigidBody2D; largeRodPipe = GetNode <RigidBody2D>(largeRodPipePath) as RigidBody2D; smallRodPipe = GetNode <RigidBody2D>(smallRodPipePath) as RigidBody2D; largeRodLimiter = GetNode <RigidBody2D>(largeRodLimiterPath) as RigidBody2D; smallRodLimiter = GetNode <RigidBody2D>(smallRodLimiterPath) as RigidBody2D; wheel = GetNode <RigidBody2D>(wheelPath) as RigidBody2D; limiter = GetNode <RigidBody2D>(limiterPath) as RigidBody2D; steamInTank = GetNode <Particles2D>(steamInTankPath) as Particles2D; steamInPipe1 = GetNode <Particles2D>(steamInPipePath1) as Particles2D; steamInPipe2 = GetNode <Particles2D>(steamInPipePath2) as Particles2D; steamInPipe3 = GetNode <Particles2D>(steamInPipePath3) as Particles2D; tankSteam = ResourceLoader.Load("res://Assets/Scenes/particlesTank.tres") as ParticlesMaterial; lid = GetNode <RigidBody2D>(lidPath) as RigidBody2D; lidLifter = GetNode <RigidBody2D>(lidLifterPath) as RigidBody2D; steamInputRate = GetNode <Label>(steamInputRatePath) as Label; wheelX = wheel.Position.x; wheelY = wheel.Position.y; lidInitialHeight = lid.Position.y; lidLifterInitialHeight = lidLifter.Position.y; steamInPipe1.Amount = (int)(flowRate * flowRateMagnifier); steamInPipe2.Amount = (int)(flowRate * flowRateMagnifier); steamInPipe3.Amount = (int)(flowRate * flowRateMagnifier); pipeY = (int)pipe.Position.y; limiterY = (int)limiter.Position.y; largeRodLimiterY = (int)largeRodLimiter.Position.y; largeRodPipeY = (int)largeRodPipe.Position.y; restOfV = 262 * 125; }
public void SetBasicAttributes(int amount, float lifetime, float lifeRandomness, float explosiveness, float angularVelocity, float Angle) { for (int idx = 1; idx <= numberOfSourcePoints; idx++) { string strKey = $"set{idx}"; Particles2D particleSetCurrent = GetParticleSet(strKey); GD.Print($"SetBasicAttributes, strKey={strKey}, particleSetCurrent={particleSetCurrent}"); if (particleSetCurrent != null) { particleSetCurrent.Amount = amount; if (lifetime >= 0.1) { particleSetCurrent.Lifetime = lifetime; } if (explosiveness > 0.05) { particleSetCurrent.Explosiveness = explosiveness; } ParticlesMaterial procMaterial = (ParticlesMaterial)particleSetCurrent.ProcessMaterial; procMaterial.AngularVelocity = angularVelocity; procMaterial.Angle = Angle; } } }
/// <summary> /// Called before the simulation is added to the main tree /// </summary> public void Setup() { _processMaterial = (ParticlesMaterial)ProcessMaterial; }