public override void _Ready() { _rigidShape = GetNode <CollisionShape>("Collision_Shape"); _grenadeMesh = GetNode <MeshInstance>("Grenade"); _blastArea = GetNode <Area>("Blast_Area"); _explosionParticle = GetNode <CPUParticles>("Explosion"); _explosionParticle.Emitting = false; _explosionParticle.OneShot = true; }
public void Explode() { if (IsLocal) { if ((Player as Spatial).Translation.DistanceTo(Translation) <= RocketJumper.MaxRocketDistance) { AffectedBodies.Add(Player); } } foreach (Node _Body in AffectedBodies) { if (_Body is IPushable Body) { float Distance = Clamp(Translation.DistanceTo(Body.Translation) - RocketJumper.MinRocketDistance, 1, RocketJumper.MaxRocketDistance); float Power = RocketJumper.MaxRocketDistance / Distance / RocketJumper.MaxRocketDistance; Vector3 Push = ((Body.Translation - Translation) / RocketJumper.MaxRocketDistance).Normalized() * RocketJumper.MaxRocketPush * Power; { Vector3 Flat = Push.Flattened(); Flat *= RocketJumper.RocketHorizontalMultiplyer; Push.x = Flat.x; Push.z = Flat.z; } Push.y /= RocketJumper.RocketVerticalDivisor; Body.ApplyPush(Push); if (Body is Player AffectedPlayer) { AffectedPlayer.RecoverPercentage = 0; } } } AffectedBodies.Clear(); AudioStreamPlayer3D ExplodeSfxInstance = ExplodeSfx.Instance() as AudioStreamPlayer3D; ExplodeSfxInstance.Play(); ExplodeSfxInstance.Translation = Translation; World.EntitiesRoot.AddChild(ExplodeSfxInstance); CPUParticles ParticleSystem = ExplodeParticles.Instance() as CPUParticles; ParticleSystem.Translation = Translation; ParticleSystem.Emitting = true; World.EntitiesRoot.AddChild(ParticleSystem); QueueFree(); }
// // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(float delta) { GetTarget(); SetPathPos(targetNavPos); ProcessInput(delta); if (HP <= 0) { CPUParticles boom = (CPUParticles)deathExplosion.Instance(); GetTree().Root.AddChild(boom); boom.Emitting = true; boom.Translation = Translation; arena.UpdateScore(bounty); QueueFree(); } }
public override void _Ready() { Mesh = GetNode <Spatial>("Mesh"); Starfield = GetNode <Starfield>("Starfield"); AnimationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); EngineParticles = GetNode <CPUParticles>("Mesh/EngineParticles"); CollisionShape = GetNode <CollisionShape>("CollisionShape"); InputHandler = GetNode <InputHandler>("InputHandler"); AudioExplosion = GetNode <AudioStreamPlayer>("AudioExplosion"); Timer = GetNode <Timer>("Timer"); Timer.Connect("timeout", this, nameof(OnTimerTimeout)); initialForwardSpeed = ForwardSpeed; initialMeshTransform = Mesh.Transform; }
public override void _Ready() { GetNode <Area>("Vision_Area").Connect("body_entered", this, "BodyEnteredVision"); GetNode <Area>("Vision_Area").Connect("body_exited", this, "BodyExitedVision"); _nodeHead = GetNode <Spatial>("Head"); _nodeRaycast = GetNode <RayCast>("Head/Ray_Cast"); _nodeFlashOne = GetNode <MeshInstance>("Head/Flash"); _nodeFlashTwo = GetNode <MeshInstance>("Head/Flash_2"); _nodeRaycast.AddException(this); _nodeRaycast.AddException(GetNode <StaticBody>("Base/Static_Body")); _nodeRaycast.AddException(GetNode <StaticBody>("Head/Static_Body")); _nodeRaycast.AddException(GetNode <Area>("Vision_Area")); _nodeFlashOne.Visible = false; _nodeFlashTwo.Visible = false; _smokeParticles = GetNode <CPUParticles>("Smoke"); _smokeParticles.Emitting = false; _turretHealth = MAX_TURRET_HEALTH; }
public override void _Ready() { _animationTree = GetNode <AnimationTree>("AnimationTree"); _shootAnimation = GetNode <AnimationPlayer>("ShootAnimation"); _model = GetNode <Spatial>("RedRobotModel"); _rayFrom = _model.GetNode <BoneAttachment>(@"Armature/Skeleton/RayFrom"); _rayMesh = _rayFrom.GetNode <MeshInstance>(@"RayMesh"); _explosionParticles = _rayFrom.GetNode <CPUParticles>(@"ExplosionParticles"); _explosionSound = GetNode <AudioStreamPlayer3D>("SoundEffects/Explosion"); _hitSound = GetNode <AudioStreamPlayer3D>("SoundEffects/Hit"); _death = GetNode <Spatial>("Death"); _shield1 = _death.GetNode <RigidBody>(@"PartShield1"); _shield2 = _death.GetNode <RigidBody>(@"PartShield2"); _shield3 = _death.GetNode <RigidBody>(@"PartShield3"); _gravity = Convert.ToSingle(ProjectSettings.GetSetting("physics/3d/default_gravity")) * (Vector3)ProjectSettings.GetSetting("physics/3d/default_gravity_vector"); _orientation = GlobalTransform; _orientation.origin = new Vector3(); }
public override void _Ready() { Cam = GetNode <Camera>("SteelCamera"); ViewmodelItem = GetNode <MeshInstance>("SteelCamera/ViewmodelArmJoint/ViewmodelTiltJoint/ViewmodelItem"); ViewmodelItem.RotationDegrees = new Vector3(0, 180, 0); ViewmodelItem.Hide(); ViewmodelTiltJoint = GetNode <Position3D>("SteelCamera/ViewmodelArmJoint/ViewmodelTiltJoint"); ViewmodelArmJoint = GetNode <Position3D>("SteelCamera/ViewmodelArmJoint"); ViewmodelArmJoint.RotationDegrees = new Vector3(); NormalViewmodelArmX = ViewmodelArmJoint.Translation.x; ViewmodelArmJoint.Translation = new Vector3(NormalViewmodelArmX, ViewmodelArmJoint.Translation.y, ViewmodelArmJoint.Translation.z); ProjectileEmitterHinge = GetNode <Spatial>("ProjectileEmitterHinge"); ProjectileEmitter = GetNode <Spatial>("ProjectileEmitterHinge/ProjectileEmitter"); BodyCollision = GetNode <CollisionShape>("BodyCollision"); BodyCapsule = (CapsuleShape)BodyCollision.Shape; Assert.ActualAssert(BodyCapsule.Height == Height); if (Possessed) { Cam.MakeCurrent(); GetNode <RayCast>("SteelCamera/RayCast").AddException(this); GetNode <Spatial>("BodyScene").Free(); AddChild(HUDInstance); GhostInstance = (Ghost)GD.Load <PackedScene>("res://World/Ghost.tscn").Instance(); GhostInstance.Hide(); GetParent().CallDeferred("add_child", GhostInstance); SfxManager = GetNode <PlayerSfxManager>("PlayerSfxManager"); } else { HeadJoint = GetNode("BodyScene").GetNode <Spatial>("HeadJoint"); LegsJoint = GetNode("BodyScene").GetNode <Spatial>("LegsJoint"); RightLegFlames = GetNode("BodyScene").GetNode <CPUParticles>("LegsJoint/RightLegFlames"); LeftLegFlames = GetNode("BodyScene").GetNode <CPUParticles>("LegsJoint/LeftLegFlames"); ThirdPersonItem = GetNode("BodyScene").GetNode <MeshInstance>("ItemMesh"); ShaderMaterial Mat = new ShaderMaterial(); Mat.Shader = Items.TileShader; ThirdPersonItem.MaterialOverride = Mat; Spatial Body = GetNode <Spatial>("BodyScene"); Body.GetNode <HitboxClass>("BodyHitbox").OwningPlayer = this; Body.GetNode <HitboxClass>("HeadJoint/HeadHitbox").OwningPlayer = this; Body.GetNode <HitboxClass>("LegsJoint/LegsHitbox").OwningPlayer = this; World.AddEntityToChunk(this); return; } Reset(); if (Net.Work.IsNetworkServer()) { SetFreeze(false); GiveDefaultItems(); } World.AddEntityToChunk(this); }
public override void _Ready() { var env = GetNode <WorldEnvironment>("sky").Environment; env.BackgroundMode = Godot.Environment.BGMode.Sky; env.BackgroundSky = new PanoramaSky() { Panorama = ((Texture)GD.Load("res://assets/park.hdr")) }; env.BackgroundSkyRotationDegrees = new Vector3(0, 140, 0); GD.Load <AudioStream>("res://assets/field.ogg").Play(Audio); var sun1 = new DirectionalLight() { LightEnergy = 0.4f }; var sun2 = new DirectionalLight() { LightEnergy = 0.4f, LightIndirectEnergy = 0 }; sun2.RotationDegrees = new Vector3(-62, -145, 0); AddChild(sun1); AddChild(sun2); InitSound(); AddChild(Audio); var gMat = new ShaderMaterial() { Shader = new Shader() { Code = @" shader_type spatial; render_mode blend_mix,depth_draw_opaque,cull_disabled,diffuse_burley,specular_schlick_ggx; uniform vec4 albedo : hint_color; uniform sampler2D texture_albedo : hint_albedo; uniform float freq = 2f; uniform float range = 2f; uniform float pow = 0.1; void vertex() { if (VERTEX.y > 0.0) { vec3 vertPos = (vec4(VERTEX, 1.0) * WORLD_MATRIX).xyz; float disp = sin(vertPos.x * range + TIME * freq) * pow; VERTEX.x += disp; VERTEX.z += disp; } } void fragment() { vec2 base_uv = UV; vec4 albedo_tex = texture(texture_albedo,base_uv); ALBEDO = albedo.rgb * albedo_tex.rgb; METALLIC = 0f; SPECULAR = 0.5; ROUGHNESS = 1f; ALPHA = albedo.a * albedo_tex.a; ALPHA_SCISSOR=0.6; }" } }; gMat.SetShaderParam("albedo", new Color("ff999900")); gMat.SetShaderParam("texture_albedo", GD.Load <Texture>("res://assets/grass5.png")); var bMat = new ShaderMaterial() { Shader = new Shader() { Code = @" shader_type spatial; render_mode blend_mix,depth_draw_opaque,cull_disabled,diffuse_burley,specular_schlick_ggx; uniform vec4 albedo : hint_color; uniform sampler2D texture_albedo : hint_albedo; uniform float freq = 16f; uniform float range = 0.7f; void vertex() { VERTEX.y += sin(TIME * freq) * (1.0 - sin(3.14 * UV.x)) * range; } void fragment() { vec2 base_uv = UV; vec4 albedo_tex = texture(texture_albedo,base_uv); ALBEDO = albedo.rgb * albedo_tex.rgb; METALLIC = 0f; SPECULAR = 0.5; ROUGHNESS = 1f; ALPHA = albedo.a * albedo_tex.a; ALPHA_SCISSOR=0.6; }" } }; bMat.SetShaderParam("albedo", new Color("ffffffff")); bMat.SetShaderParam("texture_albedo", GD.Load <Texture>("res://assets/butterfly.png")); float height = 0; for (int i = -3; i < 30; i++) { for (int j = -3; j < 3; j++) { var gInt = (Spatial)GD.Load <PackedScene>("res://scenes/Grass.tscn").Instance(); var gmesh = gInt.GetNode <MeshInstance>("Grass"); gmesh.MaterialOverride = gMat; var tempScale = gInt.Scale; tempScale.y *= 0.8f; tempScale *= (float)GD.RandRange(0.3f, 0.7f); gInt.Scale = tempScale; gInt.RotateY(Mathf.Deg2Rad((float)GD.RandRange(-180, 180))); if ((i % 2) == 0) { gInt.Translation = new Vector3(i, height -= 0.04f, j); } else { gInt.Translation = new Vector3(i, height, j + 0.5f); } void AddAdditionalGrass(Vector3 pos) { var additionalGrass2 = (Spatial)gInt.Duplicate(); var gmat2 = (ShaderMaterial)gMat.Duplicate(); gmat2.SetShaderParam("albedo", new Color("ff999900")); additionalGrass2.GetNode <MeshInstance>("Grass").MaterialOverride = gmat2; additionalGrass2.Translate(pos); AddChild(additionalGrass2); } if (i < 5) { AddAdditionalGrass(new Vector3(1.5f, 0, 0)); AddAdditionalGrass(new Vector3(-1.5f, 0, 0)); } if (i > 10) { AddAdditionalGrass(new Vector3(0, 0, 11f)); AddAdditionalGrass(new Vector3(0, 0, -11f)); } AddChild(gInt); } } var bMesh = new PlaneMesh() { Size = new Vector2(1, 1), SubdivideDepth = 1, SubdivideWidth = 1, Material = bMat }; var bPartR = new CPUParticles() { Mesh = bMesh, Scale = Scale * 0.3f, Gravity = new Vector3(0, 0, 0), Direction = new Vector3(0, 0, -1), InitialVelocity = 30, Amount = 30, Spread = 30, Lifetime = 20, InitialVelocityRandom = 0.80f, EmissionShape = CPUParticles.EmissionShapeEnum.Sphere, EmissionSphereRadius = 1, }; AddChild(bPartR); var bPartL = (CPUParticles)bPartR.Duplicate(); AddChild(bPartL); bPartR.Translate(new Vector3(15, 5, 25)); bPartL.RotationDegrees = new Vector3(0, 180, 0); bPartL.Translate(new Vector3(-15, 5, 25)); }
public override void _Ready() { var env = GetNode <WorldEnvironment>("sky").Environment; env.BackgroundColor = new Color(Lib.Node.BackgroundColorHtmlCode); env.BackgroundMode = Godot.Environment.BGMode.Sky; env.BackgroundSky = new PanoramaSky() { Panorama = ((Texture)GD.Load("res://assets/night_city.hdr")) }; env.BackgroundSkyRotationDegrees = new Vector3(0, 0, 0); env.BackgroundSkyCustomFov = 130; InitSound(); AddChild(Audio); rainAudio.Play(Audio); Audio.Seek((float)GD.RandRange(0, rainAudio.GetLength())); var glass = GetNode("Window").GetNode <MeshInstance>("Glass"); var noiseTexture = new NoiseTexture() { Noise = new OpenSimplexNoise() { Period = 40, Persistence = 0.2f }, AsNormalmap = true, BumpStrength = 32 }; glass.MaterialOverride = new SpatialMaterial() { AlbedoColor = new Color(1, 1, 1, 0.05f), AlbedoTexture = noiseTexture, NormalEnabled = true, NormalScale = -0.1f, NormalTexture = noiseTexture, RefractionEnabled = true, RefractionScale = 0.1f, RefractionTexture = noiseTexture }; var rainWindowParticles = new CPUParticles(); AddChild(rainWindowParticles); rainWindowParticles.RotateX(Mathf.Deg2Rad(16)); rainWindowParticles.Mesh = new SphereMesh() { Radius = 0.005f, Height = 0.01f, RadialSegments = 4, Rings = 4 }; rainWindowParticles.Amount = 500; rainWindowParticles.EmissionShape = CPUParticles.EmissionShapeEnum.Sphere; rainWindowParticles.EmissionSphereRadius = 4.5f; var rainParticles = new CPUParticles(); AddChild(rainParticles); rainParticles.RotateX(Mathf.Deg2Rad(16)); rainParticles.Translate(new Vector3(7.6f, 2.7f, 0)); rainParticles.Mesh = new SphereMesh() { Radius = 0.005f, Height = 1, RadialSegments = 4, Rings = 1 }; rainParticles.Amount = 200; rainParticles.EmissionShape = CPUParticles.EmissionShapeEnum.Sphere; rainParticles.EmissionSphereRadius = 8f; }
public override void _Ready() { var env = GetNode <WorldEnvironment>("sky").Environment; env.BackgroundColor = new Color(Lib.Node.BackgroundColorHtmlCode); env.BackgroundMode = Godot.Environment.BGMode.Sky; env.BackgroundSky = new PanoramaSky() { Panorama = ((Texture)GD.Load("res://assets/temple.hdr")) }; env.BackgroundSkyRotationDegrees = new Vector3(0, 0, 0); env.BackgroundSkyCustomFov = 100; InitSound(); AddChild(Audio); templeAudio.Play(Audio); Audio.Seek((float)GD.RandRange(0, templeAudio.GetLength())); var particles = new CPUParticles() { Mesh = new QuadMesh(), EmissionShape = CPUParticles.EmissionShapeEnum.Sphere, Amount = 800, EmissionSphereRadius = 0.2f, Spread = 3, Gravity = new Vector3(0, 0, 0), InitialVelocity = 1, InitialVelocityRandom = 1, ScaleAmountRandom = 0.5f, Lifetime = 20, AngularVelocity = 30, AngularVelocityRandom = 1, LinearAccel = -0.01f, Scale = Scale * 0.15f, ScaleAmount = 0.5f, AngleRandom = 1, ColorRamp = new Gradient() { Offsets = new[] { 0, 0.5f, 1 }, Colors = new[] { Color.FromHsv(0, 0, 0, 0), Color.FromHsv(0, 0, 0.7f), Color.FromHsv(0, 0, 0, 0) } } }; AddChild(particles); particles.Translate(new Vector3(0, 6f, 0)); particles.RotateZ(Mathf.Deg2Rad(90)); var mat = new SpatialMaterial() { FlagsUnshaded = true, VertexColorUseAsAlbedo = true, FlagsTransparent = true, ParamsBlendMode = SpatialMaterial.BlendMode.Add, ParamsBillboardMode = SpatialMaterial.BillboardMode.Particles, AlbedoColor = Color.FromHsv(0, 0, 0.1f), AlbedoTexture = new NoiseTexture() { Noise = new OpenSimplexNoise() { Period = 40, Persistence = 0, Lacunarity = 0.1f, } } }; particles.MaterialOverride = mat; }
public override void _Ready() { Cam = GetNode <Camera>("SteelCamera"); ViewmodelItem = GetNode <MeshInstance>("SteelCamera/ViewmodelArm/ViewmodelItem"); ViewmodelItem.Hide(); ProjectileEmitterHinge = GetNode <Spatial>("ProjectileEmitterHinge"); ProjectileEmitter = GetNode <Spatial>("ProjectileEmitterHinge/ProjectileEmitter"); if (Possessed) { Cam.MakeCurrent(); GetNode <RayCast>("SteelCamera/RayCast").AddException(this); GetNode <Spatial>("BodyScene").Free(); AddChild(HUDInstance); GhostInstance = ((PackedScene)(GD.Load("res://World/Ghost.tscn"))).Instance() as Ghost; GhostInstance.Hide(); GetParent().CallDeferred("add_child", GhostInstance); SfxManager = GetNode <PlayerSfxManager>("PlayerSfxManager"); } else { HeadJoint = GetNode("BodyScene").GetNode <Spatial>("HeadJoint"); LegsJoint = GetNode("BodyScene").GetNode <Spatial>("LegsJoint"); RightLegFlames = GetNode("BodyScene").GetNode <CPUParticles>("LegsJoint/LegFlames/Right"); LeftLegFlames = GetNode("BodyScene").GetNode <CPUParticles>("LegsJoint/LegFlames/Left"); ThirdPersonItem = GetNode("BodyScene").GetNode <MeshInstance>("ItemMesh"); ShaderMaterial Mat = new ShaderMaterial(); Mat.Shader = Items.TileShader; ThirdPersonItem.MaterialOverride = Mat; GetNode <MeshInstance>("SteelCamera/ViewmodelArm").Hide(); GetNode <CPUParticles>("SteelCamera/ViewmodelArm/Forcefield").Hide(); Spatial Body = GetNode <Spatial>("BodyScene"); Body.GetNode <HitboxClass>("BodyHitbox").OwningPlayer = this; Body.GetNode <HitboxClass>("HeadJoint/HeadHitbox").OwningPlayer = this; Body.GetNode <HitboxClass>("LegsJoint/LegsHitbox").OwningPlayer = this; SetProcess(false); return; } Respawn(); if (GetTree().IsNetworkServer()) { SetFreeze(false); } ItemGive(new Items.Instance(Items.ID.PLATFORM)); ItemGive(new Items.Instance(Items.ID.WALL)); ItemGive(new Items.Instance(Items.ID.SLOPE)); ItemGive(new Items.Instance(Items.ID.TRIANGLE_WALL)); ItemGive(new Items.Instance(Items.ID.ROCKET_JUMPER)); ItemGive(new Items.Instance(Items.ID.THUNDERBOLT)); }
public void Explode() { if (TriggeredPosition != null) { Translation = (Vector3)TriggeredPosition; } Vector3 Origin = GetNode <Spatial>("ExplosionOrigin").GetGlobalTransform().origin; if (IsLocal) { if ((Player as Spatial).Translation.DistanceTo(Origin) <= RocketJumper.MaxRocketDistance) { AffectedBodies.Add(Player); } } foreach (Node _Body in AffectedBodies) { if (_Body is IPushable Body) { PhysicsDirectSpaceState State = GetWorld().DirectSpaceState; Godot.Collections.Dictionary Results = State.IntersectRay(Origin, Body.Translation, new Godot.Collections.Array() { Body }, 1); if (Results.Count > 0) { continue; } float Distance = Clamp(Origin.DistanceTo(Body.Translation) - RocketJumper.MinRocketDistance, 1, RocketJumper.MaxRocketDistance); float Power = RocketJumper.MaxRocketDistance / Distance / RocketJumper.MaxRocketDistance; Vector3 Push = ((Body.Translation - Origin) / RocketJumper.MaxRocketDistance).Normalized() * RocketJumper.MaxRocketPush * Power; { Vector3 Flat = Push.Flattened(); Flat *= RocketJumper.RocketHorizontalMultiplyer; Push.x = Flat.x; Push.z = Flat.z; } Push.y /= RocketJumper.RocketVerticalDivisor; Body.ApplyPush(Push); } } AffectedBodies.Clear(); AudioStreamPlayer3D ExplodeSfxInstance = ExplodeSfx.Instance() as AudioStreamPlayer3D; ExplodeSfxInstance.Play(); ExplodeSfxInstance.Translation = Translation; World.EntitiesRoot.AddChild(ExplodeSfxInstance); CPUParticles ParticleSystem = ExplodeParticles.Instance() as CPUParticles; ParticleSystem.Translation = Translation; ParticleSystem.Emitting = true; World.EntitiesRoot.AddChild(ParticleSystem); QueueFree(); }