Move files and folders to new repo format to enable multi-project format
This commit is contained in:
85
Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs
Normal file
85
Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IDroppedItem : IRigidBody3D
|
||||
{
|
||||
void RescueItem();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class DroppedItem : RigidBody3D, IDroppedItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
|
||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||
|
||||
[Node] private Sprite2D Sprite { get; set; } = default!;
|
||||
|
||||
[Node] private Area3D Pickup { get; set; } = default!;
|
||||
|
||||
public InventoryItem Item { get; set; }
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
ContactMonitor = true;
|
||||
Sprite.Texture = Item.ItemStats.Texture;
|
||||
}
|
||||
|
||||
public async void Drop()
|
||||
{
|
||||
AddCollisionExceptionWith((Node)Player);
|
||||
Pickup.Monitorable = false;
|
||||
Pickup.Monitoring = false;
|
||||
GlobalPosition = Player.CurrentPosition + Vector3.Up;
|
||||
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * 5.0f);
|
||||
await ToSignal(GetTree().CreateTimer(1), "timeout");
|
||||
RemoveCollisionExceptionWith((Node)Player);
|
||||
Pickup.Monitorable = true;
|
||||
Pickup.Monitoring = true;
|
||||
}
|
||||
|
||||
public void RescueItem()
|
||||
{
|
||||
ContactMonitor = false;
|
||||
Pickup.Monitorable = false;
|
||||
Pickup.Monitoring = false;
|
||||
PlayRescueAnimation();
|
||||
Game.RescuedItems.Items.Add(Item);
|
||||
}
|
||||
|
||||
private void PlayRescueAnimation()
|
||||
{
|
||||
LoadShader("res://src/vfx/shaders/PixelMelt.gdshader");
|
||||
var tweener = GetTree().CreateTween();
|
||||
SetShaderValue(true);
|
||||
tweener.TweenMethod(Callable.From((float x) => SetShaderValue(x)), 0.0f, 0.3f, 2f);
|
||||
tweener.TweenCallback(Callable.From(QueueFree));
|
||||
}
|
||||
|
||||
private void LoadShader(string shaderPath)
|
||||
{
|
||||
var shader = GD.Load<Shader>(shaderPath);
|
||||
Sprite.Material = new ShaderMaterial();
|
||||
var shaderMaterial = (ShaderMaterial)Sprite.Material;
|
||||
shaderMaterial.Shader = shader;
|
||||
}
|
||||
|
||||
private void SetShaderValue(float shaderValue)
|
||||
{
|
||||
var shaderMaterial = (ShaderMaterial)Sprite.Material;
|
||||
shaderMaterial.SetShaderParameter("progress", shaderValue);
|
||||
}
|
||||
|
||||
private void SetShaderValue(bool shaderValue)
|
||||
{
|
||||
var shaderMaterial = (ShaderMaterial)Sprite.Material;
|
||||
shaderMaterial.SetShaderParameter("reverse", shaderValue);
|
||||
}
|
||||
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c2sps6uamyyw2
|
||||
105
Zennysoft.Game.Ma/src/items/dropped/DroppedItem.tscn
Normal file
105
Zennysoft.Game.Ma/src/items/dropped/DroppedItem.tscn
Normal file
@@ -0,0 +1,105 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://brq11lswpqxei"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c2sps6uamyyw2" path="res://src/items/dropped/DroppedItem.cs" id="1_67jk4"]
|
||||
[ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="2_cu1v3"]
|
||||
[ext_resource type="Material" uid="uid://x2bv1q51mcjq" path="res://src/enemy/PixelMelt.tres" id="2_eat5q"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_28r8g"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_x5q15"]
|
||||
resource_name = "ItemRescued"
|
||||
length = 2.0
|
||||
step = 0.0666667
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite3D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1.99543),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0.0207178, 0.192374, 0), Vector3(0.0207178, 1.26338, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_eat5q"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite3D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0.0207178, 0.192374, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_eat5q"]
|
||||
_data = {
|
||||
&"ItemRescued": SubResource("Animation_x5q15"),
|
||||
&"RESET": SubResource("Animation_eat5q")
|
||||
}
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_x5q15"]
|
||||
viewport_path = NodePath("Sprite3D/SubViewportContainer/SubViewport")
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eat5q"]
|
||||
radius = 0.47
|
||||
|
||||
[node name="DroppedItem" type="RigidBody3D"]
|
||||
collision_layer = 1024
|
||||
collision_mask = 5
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
axis_lock_angular_z = true
|
||||
gravity_scale = 0.8
|
||||
contact_monitor = true
|
||||
max_contacts_reported = 50
|
||||
script = ExtResource("1_67jk4")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_28r8g")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_eat5q")
|
||||
}
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(0.41, 0, 0, 0, 0.41, 0, 0, 0, 0.41, 0.0207178, 0.192374, 0)
|
||||
billboard = 2
|
||||
shaded = true
|
||||
texture_filter = 0
|
||||
render_priority = 100
|
||||
texture = SubResource("ViewportTexture_x5q15")
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="Sprite3D"]
|
||||
visibility_layer = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Sprite3D/SubViewportContainer"]
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="Sprite3D/SubViewportContainer/SubViewport"]
|
||||
unique_name_in_owner = true
|
||||
material = ExtResource("2_eat5q")
|
||||
scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("2_cu1v3")
|
||||
centered = false
|
||||
offset = Vector2(2000, 2000)
|
||||
|
||||
[node name="Pickup" type="Area3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
|
||||
shape = SubResource("CapsuleShape3D_eat5q")
|
||||
Reference in New Issue
Block a user