Compare commits
15 Commits
2ee8c16731
...
2ed83eaa9b
Author | SHA1 | Date |
---|---|---|
jkpete | 2ed83eaa9b | 1 month ago |
jkpete | 6e8ca99ed7 | 1 month ago |
jkpete | 6d771ac5d1 | 1 month ago |
jkpete | 9a3a435d35 | 1 month ago |
jkpete | f03b8754c6 | 2 months ago |
jkpete | 33d71a706c | 2 months ago |
jkpete | 2b97da8502 | 2 months ago |
jkpete | 0804297eed | 2 months ago |
jkpete | 68a1f24645 | 2 months ago |
jkpete | 5315e625f6 | 2 months ago |
jkpete | 7fde85cffd | 2 months ago |
jkpete | d6b3d938f4 | 2 months ago |
jkpete | 35c7a5fb8c | 2 months ago |
jkpete | b41e6e989b | 2 months ago |
jkpete | b71b121852 | 2 months ago |
20 changed files with 1223 additions and 271 deletions
@ -0,0 +1,133 @@ |
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bonekg2q1lxx4"] |
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cbq4j4svebp45" path="res://Example/Tween/Texture/gBot_pieces.png" id="1_vmu55"] |
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"] |
||||||
|
|
||||||
|
[node name="Gobot" type="Node2D" parent="."] |
||||||
|
position = Vector2(157, 138) |
||||||
|
|
||||||
|
[node name="arm_left" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(77, 210) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
skeleton = NodePath("../../Skeleton2D") |
||||||
|
polygon = PackedVector2Array(188, 36, 225, 22, 276, 47, 266, 129, 248, 188, 275, 275, 298, 302, 275, 348, 220, 360, 194, 313, 176, 246, 187, 199, 184, 102, 176, 48, 224, 96, 216, 192, 240, 304, 216, 208) |
||||||
|
uv = PackedVector2Array(188, 36, 225, 22, 276, 47, 266, 129, 248, 188, 275, 275, 298, 302, 275, 348, 220, 360, 194, 313, 176, 246, 187, 199, 184, 102, 174, 44, 216, 96, 216, 192, 240, 304, 216, 200) |
||||||
|
polygons = [PackedInt32Array(14, 1, 0, 13, 12), PackedInt32Array(1, 2, 3, 14), PackedInt32Array(14, 15, 4, 3), PackedInt32Array(14, 12, 11, 15), PackedInt32Array(5, 6, 7, 16), PackedInt32Array(16, 9, 8, 7), PackedInt32Array(11, 17, 15), PackedInt32Array(15, 17, 4), PackedInt32Array(17, 16, 9, 10, 11), PackedInt32Array(4, 17, 16, 5)] |
||||||
|
bones = ["hip", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head/jaw", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right/hand_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_left", PackedFloat32Array(1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0), "hip/chest/arm_left/hand_left", PackedFloat32Array(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1), "hip/leg_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_left/calf_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_left/calf_left/foot_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2/leg_right3", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] |
||||||
|
internal_vertex_count = 4 |
||||||
|
|
||||||
|
[node name="leg_left" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(-46, 56) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
skeleton = NodePath("../../Skeleton2D") |
||||||
|
polygon = PackedVector2Array(285.231, 396.984, 311.252, 384.229, 343.905, 401.066, 341.354, 431.678, 333.701, 442.392, 327.578, 478.617, 337.782, 475.556, 340.843, 504.637, 326.047, 538.821, 327.578, 569.433, 349.517, 602.086, 382.17, 608.719, 391.354, 649.535, 403.088, 657.698, 406.66, 688.821, 397.476, 693.413, 250.027, 690.352, 247.476, 660.25, 252.068, 657.188, 247.986, 629.127, 254.619, 613.821, 254.619, 509.229, 281.66, 471.474, 290.992, 521.359, 297.01, 631.544, 294.695, 615.34, 297.473, 498.674) |
||||||
|
uv = PackedVector2Array(285.231, 396.984, 311.252, 384.229, 343.905, 401.066, 341.354, 431.678, 333.701, 442.392, 327.578, 478.617, 337.782, 475.556, 340.843, 504.637, 326.047, 538.821, 327.578, 569.433, 349.517, 602.086, 382.17, 608.719, 391.354, 649.535, 403.088, 657.698, 406.66, 688.821, 397.476, 693.413, 250.027, 690.352, 247.476, 660.25, 252.068, 657.188, 247.986, 629.127, 254.619, 613.821, 254.619, 509.229, 281.66, 471.474, 290.992, 521.359, 297.01, 631.544, 294.695, 615.34, 297.473, 498.674) |
||||||
|
polygons = [PackedInt32Array(23, 21, 20, 25, 9, 8), PackedInt32Array(25, 24, 10, 9), PackedInt32Array(20, 25, 24, 19), PackedInt32Array(26, 23, 8, 7), PackedInt32Array(22, 26, 23, 21), PackedInt32Array(7, 6, 5, 4, 3, 2, 1, 0, 22, 26), PackedInt32Array(19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 24)] |
||||||
|
bones = ["hip", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head/jaw", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right/hand_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_left/hand_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_left", PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1), "hip/leg_left/calf_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1), "hip/leg_left/calf_left/foot_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2/leg_right3", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] |
||||||
|
internal_vertex_count = 4 |
||||||
|
|
||||||
|
[node name="Body" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(-213, 183) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
polygon = PackedVector2Array(454, 19, 483, 39, 487, 82, 521, 157, 524, 194, 509.272, 215.601, 494, 238, 475, 250, 476, 260, 493, 276, 488, 312, 462, 339, 422, 348, 367, 331, 346, 297, 349, 262, 375, 251, 372, 236, 350, 205, 340, 135, 357, 85, 384, 78, 393, 37, 427, 18) |
||||||
|
uv = PackedVector2Array(454, 19, 483, 39, 487, 82, 521, 157, 524, 194, 494, 238, 475, 250, 476, 260, 493, 276, 488, 312, 462, 339, 422, 348, 367, 331, 346, 297, 349, 262, 375, 251, 372, 236, 350, 205, 340, 135, 357, 85, 384, 78, 393, 37, 427, 18) |
||||||
|
|
||||||
|
[node name="leg_right" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(59, 63) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
polygon = PackedVector2Array(89.832, 385.034, 117.043, 400.68, 119.084, 426.531, 108.88, 441.497, 108.88, 463.265, 103.437, 476.871, 115.002, 472.789, 119.084, 508.843, 104.798, 537.415, 105.478, 559.864, 125.886, 593.197, 155.818, 602.041, 166.022, 617.007, 168.063, 643.537, 182.349, 653.061, 183.029, 676.19, 174.186, 685.714, 29.2878, 683.673, 19.7639, 674.83, 25.8864, 653.061, 30.6483, 604.762, 32.6891, 510.884, 61.2605, 470.068, 63.3014, 399.32) |
||||||
|
uv = PackedVector2Array(89.832, 385.034, 117.043, 400.68, 119.084, 426.531, 108.88, 441.497, 108.88, 463.265, 103.437, 476.871, 115.002, 472.789, 119.084, 508.843, 104.798, 537.415, 105.478, 559.864, 125.886, 593.197, 155.818, 602.041, 166.022, 617.007, 168.063, 643.537, 182.349, 653.061, 183.029, 676.19, 174.186, 685.714, 29.2878, 683.673, 19.7639, 674.83, 25.8864, 653.061, 30.6483, 604.762, 32.6891, 510.884, 61.2605, 470.068, 63.3014, 399.32) |
||||||
|
|
||||||
|
[node name="arm_right" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(53, 227) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
polygon = PackedVector2Array(80, 13, 141, 46, 98, 181, 139, 320, 122, 354, 62, 365, 26, 311, 14, 229, 32, 192, 21, 120, 34, 25) |
||||||
|
uv = PackedVector2Array(80, 13, 141, 46, 98, 181, 139, 320, 122, 354, 62, 365, 26, 311, 14, 229, 32, 192, 21, 120, 34, 25) |
||||||
|
|
||||||
|
[node name="head" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(-427, -344) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
polygon = PackedVector2Array(481.482, 378.14, 484.033, 449.058, 495.767, 494.466, 537.094, 496.507, 544.747, 525.079, 667.196, 533.242, 677.91, 506.711, 713.624, 511.303, 721.278, 521.507, 765.155, 517.426, 772.808, 505.181, 800.869, 503.65, 807.502, 489.364, 809.033, 380.691, 801.89, 361.303, 813.624, 340.895, 784.033, 294.466, 761.073, 297.017, 763.114, 272.528, 711.073, 252.119, 663.624, 255.691, 659.543, 269.977, 643.216, 249.568, 620.767, 247.017, 554.441, 282.221, 565.155, 316.405, 546.788, 327.119, 510.053, 328.14) |
||||||
|
uv = PackedVector2Array(481.482, 378.14, 484.033, 449.058, 495.767, 494.466, 537.094, 496.507, 544.747, 525.079, 667.196, 533.242, 677.91, 506.711, 713.624, 511.303, 721.278, 521.507, 765.155, 517.426, 772.808, 505.181, 800.869, 503.65, 807.502, 489.364, 809.033, 380.691, 801.89, 361.303, 813.624, 340.895, 784.033, 294.466, 761.073, 297.017, 763.114, 272.528, 711.073, 252.119, 663.624, 255.691, 659.543, 269.977, 643.216, 249.568, 620.767, 247.017, 554.441, 282.221, 565.155, 316.405, 546.788, 327.119, 510.053, 328.14) |
||||||
|
|
||||||
|
[node name="jaw" type="Polygon2D" parent="Gobot"] |
||||||
|
position = Vector2(-423, -438) |
||||||
|
texture = ExtResource("1_vmu55") |
||||||
|
polygon = PackedVector2Array(488.089, 572.317, 541.793, 575.404, 544.879, 600.712, 548.583, 574.169, 616.484, 574.169, 620.805, 585.898, 635.003, 585.898, 644.879, 571.083, 716.484, 572.317, 723.891, 582.194, 738.706, 582.811, 744.262, 571.083, 819.57, 561.823, 815.867, 613.058, 788.089, 657.503, 754.756, 674.169, 654.138, 688.984, 547.965, 680.959, 498.583, 643.922, 481.916, 605.651) |
||||||
|
uv = PackedVector2Array(488.089, 572.317, 541.793, 575.404, 544.879, 600.712, 548.583, 574.169, 616.484, 574.169, 620.805, 585.898, 635.003, 585.898, 644.879, 571.083, 716.484, 572.317, 723.891, 582.194, 738.706, 582.811, 744.262, 571.083, 819.57, 561.823, 815.867, 613.058, 788.089, 657.503, 754.756, 674.169, 654.138, 688.984, 547.965, 680.959, 498.583, 643.922, 481.916, 605.651) |
||||||
|
|
||||||
|
[node name="Skeleton2D" type="Skeleton2D" parent="."] |
||||||
|
position = Vector2(157, 138) |
||||||
|
|
||||||
|
[node name="hip" type="Bone2D" parent="Skeleton2D"] |
||||||
|
position = Vector2(218, 493) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 218, 493) |
||||||
|
|
||||||
|
[node name="chest" type="Bone2D" parent="Skeleton2D/hip"] |
||||||
|
position = Vector2(1, -45) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 1, -45) |
||||||
|
|
||||||
|
[node name="head" type="Bone2D" parent="Skeleton2D/hip/chest"] |
||||||
|
position = Vector2(5, -185) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 5, -185) |
||||||
|
|
||||||
|
[node name="jaw" type="Bone2D" parent="Skeleton2D/hip/chest/head"] |
||||||
|
position = Vector2(-95, -64) |
||||||
|
rest = Transform2D(1, 0, 0, 1, -95, -64) |
||||||
|
auto_calculate_length_and_angle = false |
||||||
|
length = 150.0 |
||||||
|
bone_angle = 0.0 |
||||||
|
|
||||||
|
[node name="arm_right" type="Bone2D" parent="Skeleton2D/hip/chest"] |
||||||
|
position = Vector2(-95, -132) |
||||||
|
rest = Transform2D(1, 0, 0, 1, -95, -132) |
||||||
|
|
||||||
|
[node name="hand_right" type="Bone2D" parent="Skeleton2D/hip/chest/arm_right"] |
||||||
|
position = Vector2(-5, 101) |
||||||
|
rotation = 1.39626 |
||||||
|
rest = Transform2D(0.173648, 0.984808, -0.984808, 0.173648, -5, 101) |
||||||
|
auto_calculate_length_and_angle = false |
||||||
|
length = 120.0 |
||||||
|
bone_angle = 0.0 |
||||||
|
|
||||||
|
[node name="arm_left" type="Bone2D" parent="Skeleton2D/hip/chest"] |
||||||
|
position = Vector2(78, -142) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 78, -142) |
||||||
|
|
||||||
|
[node name="hand_left" type="Bone2D" parent="Skeleton2D/hip/chest/arm_left"] |
||||||
|
position = Vector2(1, 99) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 1, 99) |
||||||
|
auto_calculate_length_and_angle = false |
||||||
|
length = 120.0 |
||||||
|
bone_angle = 70.0 |
||||||
|
|
||||||
|
[node name="leg_left" type="Bone2D" parent="Skeleton2D/hip"] |
||||||
|
position = Vector2(55, -21) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 55, -21) |
||||||
|
|
||||||
|
[node name="calf_left" type="Bone2D" parent="Skeleton2D/hip/leg_left"] |
||||||
|
position = Vector2(-29, 98) |
||||||
|
rest = Transform2D(1, 0, 0, 1, -29, 98) |
||||||
|
|
||||||
|
[node name="foot_left" type="Bone2D" parent="Skeleton2D/hip/leg_left/calf_left"] |
||||||
|
position = Vector2(20, 135) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 20, 135) |
||||||
|
auto_calculate_length_and_angle = false |
||||||
|
length = 60.0 |
||||||
|
bone_angle = 0.0 |
||||||
|
|
||||||
|
[node name="leg_right" type="Bone2D" parent="Skeleton2D/hip"] |
||||||
|
position = Vector2(-69, -16) |
||||||
|
rest = Transform2D(1, 0, 0, 1, -69, -16) |
||||||
|
|
||||||
|
[node name="leg_right2" type="Bone2D" parent="Skeleton2D/hip/leg_right"] |
||||||
|
position = Vector2(-20, 98) |
||||||
|
rest = Transform2D(1, 0, 0, 1, -20, 98) |
||||||
|
|
||||||
|
[node name="leg_right3" type="Bone2D" parent="Skeleton2D/hip/leg_right/leg_right2"] |
||||||
|
position = Vector2(13, 133) |
||||||
|
rest = Transform2D(1, 0, 0, 1, 13, 133) |
||||||
|
auto_calculate_length_and_angle = false |
||||||
|
length = 60.0 |
||||||
|
bone_angle = 0.0 |
After Width: | Height: | Size: 453 KiB |
@ -0,0 +1,34 @@ |
|||||||
|
[remap] |
||||||
|
|
||||||
|
importer="texture" |
||||||
|
type="CompressedTexture2D" |
||||||
|
uid="uid://cbq4j4svebp45" |
||||||
|
path="res://.godot/imported/gBot_pieces.png-1c5266364ba54cfdb5b194e098160c14.ctex" |
||||||
|
metadata={ |
||||||
|
"vram_texture": false |
||||||
|
} |
||||||
|
|
||||||
|
[deps] |
||||||
|
|
||||||
|
source_file="res://Example/Tween/Texture/gBot_pieces.png" |
||||||
|
dest_files=["res://.godot/imported/gBot_pieces.png-1c5266364ba54cfdb5b194e098160c14.ctex"] |
||||||
|
|
||||||
|
[params] |
||||||
|
|
||||||
|
compress/mode=0 |
||||||
|
compress/high_quality=false |
||||||
|
compress/lossy_quality=0.7 |
||||||
|
compress/hdr_compression=1 |
||||||
|
compress/normal_map=0 |
||||||
|
compress/channel_pack=0 |
||||||
|
mipmaps/generate=false |
||||||
|
mipmaps/limit=-1 |
||||||
|
roughness/mode=0 |
||||||
|
roughness/src_normal="" |
||||||
|
process/fix_alpha_border=true |
||||||
|
process/premult_alpha=false |
||||||
|
process/normal_map_invert_y=false |
||||||
|
process/hdr_as_srgb=false |
||||||
|
process/hdr_clamp_exposure=false |
||||||
|
process/size_limit=0 |
||||||
|
detect_3d/compress_to=1 |
@ -1,15 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
using System.Threading.Tasks; |
|
||||||
|
|
||||||
namespace EGFramework |
|
||||||
{ |
|
||||||
public class EGCsv : EGModule |
|
||||||
{ |
|
||||||
public override void Init() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,226 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Data; |
||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using System.Linq.Expressions; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace EGFramework |
||||||
|
{ |
||||||
|
public class EGCsvSave : IEGSaveData, IEGSave, IEGSaveReadOnly |
||||||
|
{ |
||||||
|
public bool IsReadOnly { get; set; } |
||||||
|
public Encoding StringEncoding { set; get; } = Encoding.UTF8; |
||||||
|
private string DefaultPath { set; get; } |
||||||
|
private List<string[]> CsvDataBlock { get; set; } |
||||||
|
private Dictionary<string,int> CsvDataHeader = new Dictionary<string,int>(); |
||||||
|
public IOCContainer TypeDataContainer = new IOCContainer(); |
||||||
|
private string ReadText { set; get; } |
||||||
|
|
||||||
|
|
||||||
|
public void InitSaveFile(string path) |
||||||
|
{ |
||||||
|
ReadDataBlock(path); |
||||||
|
} |
||||||
|
|
||||||
|
public void InitReadOnly(string data) |
||||||
|
{ |
||||||
|
ReadText = data; |
||||||
|
if(ReadText != null || ReadText != ""){ |
||||||
|
CsvDataBlock = GetCSVDataBlockFromText(ReadText,out CsvDataHeader); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void InitReadOnly(byte[] data) |
||||||
|
{ |
||||||
|
ReadText = StringEncoding.GetString(data); |
||||||
|
if(ReadText != null || ReadText != ""){ |
||||||
|
CsvDataBlock = GetCSVDataBlockFromText(ReadText,out CsvDataHeader); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void ReadDataBlock(string path){ |
||||||
|
DefaultPath = path; |
||||||
|
try |
||||||
|
{ |
||||||
|
FileStream fileStream = new FileStream(path,FileMode.Open); |
||||||
|
byte[] buffer = new byte[fileStream.Length]; |
||||||
|
fileStream.Read(buffer, 0, (int)fileStream.Length); |
||||||
|
fileStream.Close(); |
||||||
|
fileStream.Dispose(); |
||||||
|
ReadText = StringEncoding.GetString(buffer); |
||||||
|
} |
||||||
|
catch (System.Exception e) |
||||||
|
{ |
||||||
|
Godot.GD.Print("e:" + e); |
||||||
|
throw; |
||||||
|
} |
||||||
|
if(ReadText != null || ReadText != ""){ |
||||||
|
CsvDataBlock = GetCSVDataBlockFromText(ReadText,out CsvDataHeader); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void WriteDataBlock(string path){ |
||||||
|
try |
||||||
|
{ |
||||||
|
FileStream fileStream = File.Create(path); |
||||||
|
string writeText = ""; |
||||||
|
string headerText = ""; |
||||||
|
foreach(string headStr in CsvDataHeader.Keys){ |
||||||
|
headerText+=headStr + ","; |
||||||
|
} |
||||||
|
headerText = headerText.Remove(headerText.Length-1,1); |
||||||
|
writeText = headerText + "\n"; |
||||||
|
foreach(string[] lineData in CsvDataBlock){ |
||||||
|
string lineText = ""; |
||||||
|
foreach(string singleData in lineData){ |
||||||
|
lineText += singleData + ","; |
||||||
|
} |
||||||
|
lineText = lineText.Remove(lineText.Length-1,1); |
||||||
|
writeText += lineText + "\n"; |
||||||
|
} |
||||||
|
writeText = writeText.Remove(writeText.Length-1,1); |
||||||
|
byte[] data = StringEncoding.GetBytes(writeText); |
||||||
|
fileStream.Write(data,0,data.Length); |
||||||
|
fileStream.Close(); |
||||||
|
fileStream.Dispose(); |
||||||
|
} |
||||||
|
catch (System.Exception e) |
||||||
|
{ |
||||||
|
Godot.GD.Print("e:" + e); |
||||||
|
throw; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public List<string[]> GetCSVDataBlockFromText(string text,out Dictionary<string,int> header){ |
||||||
|
List<string[]> csvBlock = new List<string[]>(); |
||||||
|
string[] lineData = text.Split('\n'); |
||||||
|
string[] headerStr = lineData[0].Split(','); |
||||||
|
header = new Dictionary<string,int>(); |
||||||
|
for (int i = 0; i < headerStr.Length; i++) |
||||||
|
{ |
||||||
|
header.Add(headerStr[i],i); |
||||||
|
} |
||||||
|
for (int lineID = 0; lineID < lineData.Length; lineID++) |
||||||
|
{ |
||||||
|
if (lineID!=0){ |
||||||
|
csvBlock.Add(lineData[lineID].Split(',')); |
||||||
|
} |
||||||
|
} |
||||||
|
return csvBlock; |
||||||
|
} |
||||||
|
|
||||||
|
public string[] ReadLine(int id){ |
||||||
|
if(CsvDataBlock.Count()>0){ |
||||||
|
return CsvDataBlock[id]; |
||||||
|
}else{ |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void WriteLine(string[] lineData){ |
||||||
|
CsvDataBlock.Add(lineData); |
||||||
|
this.WriteDataBlock(DefaultPath); |
||||||
|
} |
||||||
|
|
||||||
|
public void SetData<TData>(string dataKey, TData data, object id) |
||||||
|
{ |
||||||
|
if(IsReadOnly){ |
||||||
|
throw new Exception("This file is readonly! can't set any data to file."); |
||||||
|
} |
||||||
|
bool IsAdd = false; |
||||||
|
int dataID = 0; |
||||||
|
if(id.GetType()==typeof(int)){ |
||||||
|
dataID = (int)id; |
||||||
|
}else if(int.TryParse(id.ToString() ,out dataID)){ |
||||||
|
throw new Exception("Id cannot be convert to int!"); |
||||||
|
} |
||||||
|
if(dataID>=CsvDataBlock.Count() || dataID < 0){ |
||||||
|
IsAdd = true; |
||||||
|
} |
||||||
|
string[] csvSet = new string[CsvDataHeader.Keys.Count()]; |
||||||
|
foreach(PropertyInfo property in data.GetType().GetProperties()){ |
||||||
|
CsvParamAttribute csvParam = property.GetCustomAttribute<CsvParamAttribute>(); |
||||||
|
if(csvParam != null && CsvDataHeader.ContainsKey(csvParam._name)){ |
||||||
|
csvSet[CsvDataHeader[csvParam._name]] = property.GetValue(data).ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
if(IsAdd){ |
||||||
|
CsvDataBlock.Add(csvSet); |
||||||
|
}else{ |
||||||
|
CsvDataBlock[dataID] = csvSet; |
||||||
|
} |
||||||
|
this.WriteDataBlock(DefaultPath); |
||||||
|
} |
||||||
|
|
||||||
|
public TData GetData<TData>(string dataKey, object id) where TData : new() |
||||||
|
{ |
||||||
|
TData data = new TData(); |
||||||
|
int dataID = 0; |
||||||
|
if(id.GetType()==typeof(int)){ |
||||||
|
dataID = (int)id; |
||||||
|
}else if(int.TryParse(id.ToString() ,out dataID)){ |
||||||
|
throw new Exception("Id cannot be convert to int!"); |
||||||
|
} |
||||||
|
if(dataID>=CsvDataBlock.Count()){ |
||||||
|
throw new IndexOutOfRangeException("Parameter index is out of range."); |
||||||
|
} |
||||||
|
foreach(PropertyInfo property in data.GetType().GetProperties()){ |
||||||
|
CsvParamAttribute csvParam = property.GetCustomAttribute<CsvParamAttribute>(); |
||||||
|
if(csvParam != null && CsvDataHeader.ContainsKey(csvParam._name)){ |
||||||
|
string valueStr = CsvDataBlock[dataID][CsvDataHeader[csvParam._name]]; |
||||||
|
if(property.PropertyType==typeof(string)){ |
||||||
|
property.SetValue(data,valueStr); |
||||||
|
}else{ |
||||||
|
property.SetValue(data,Convert.ChangeType(valueStr,property.PropertyType)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return data; |
||||||
|
} |
||||||
|
public IEnumerable<TData> GetAll<TData>(string dataKey) where TData : new() |
||||||
|
{ |
||||||
|
// throw new NotImplementedException(); |
||||||
|
List<TData> DataList = new List<TData>(); |
||||||
|
PropertyInfo[] properties = typeof(TData).GetProperties(); |
||||||
|
for (int dataID = 0; dataID < CsvDataBlock.Count(); dataID++){ |
||||||
|
TData data = new TData(); |
||||||
|
foreach(PropertyInfo property in properties){ |
||||||
|
CsvParamAttribute csvParam = property.GetCustomAttribute<CsvParamAttribute>(); |
||||||
|
if(csvParam != null && CsvDataHeader.ContainsKey(csvParam._name)){ |
||||||
|
string valueStr = CsvDataBlock[dataID][CsvDataHeader[csvParam._name]]; |
||||||
|
if(property.PropertyType==typeof(string)){ |
||||||
|
property.SetValue(data,valueStr); |
||||||
|
}else{ |
||||||
|
property.SetValue(data,Convert.ChangeType(valueStr,property.PropertyType)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
DataList.Add(data); |
||||||
|
} |
||||||
|
TypeDataContainer.Register(DataList); |
||||||
|
return DataList; |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<TData> FindData<TData>(string dataKey, Expression<Func<TData, bool>> expression) where TData : new() |
||||||
|
{ |
||||||
|
List<TData> sourceList; |
||||||
|
if(TypeDataContainer.self.ContainsKey(typeof(List<TData>))){ |
||||||
|
sourceList = TypeDataContainer.Get<List<TData>>(); |
||||||
|
}else{ |
||||||
|
sourceList = (List<TData>)GetAll<TData>(dataKey); |
||||||
|
} |
||||||
|
return sourceList.Where(expression.Compile()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] |
||||||
|
public class CsvParamAttribute: Attribute{ |
||||||
|
public string _name { set; get; } |
||||||
|
public CsvParamAttribute(string name){ |
||||||
|
this._name = name; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,16 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
using System.Threading.Tasks; |
|
||||||
using LiteDB; |
|
||||||
|
|
||||||
namespace EGFramework |
|
||||||
{ |
|
||||||
public class EGLiteDB : EGModule |
|
||||||
{ |
|
||||||
public override void Init() |
|
||||||
{ |
|
||||||
// throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,65 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using System.Linq.Expressions; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using LiteDB; |
||||||
|
|
||||||
|
namespace EGFramework |
||||||
|
{ |
||||||
|
public class EGLiteDBSave : IEGSave,IEGSaveData |
||||||
|
{ |
||||||
|
private string DefaultPath { set; get; } |
||||||
|
private LiteDatabase _Database { set; get; } |
||||||
|
private LiteDatabase Database{ |
||||||
|
get { |
||||||
|
if(_Database == null){ |
||||||
|
InitSaveFile(DefaultPath); |
||||||
|
} |
||||||
|
return _Database; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void InitSaveFile(string path) |
||||||
|
{ |
||||||
|
DefaultPath = path; |
||||||
|
if (!Directory.Exists(Path.GetDirectoryName(DefaultPath))) |
||||||
|
{ |
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(DefaultPath)); |
||||||
|
} |
||||||
|
// Default is "SaveData/DefaultLiteDBData.db" |
||||||
|
_Database = new LiteDatabase(path); |
||||||
|
} |
||||||
|
|
||||||
|
public TData GetData<TData>(string dataKey, object id) where TData : new() |
||||||
|
{ |
||||||
|
LiteCollection<TData> collection = (LiteCollection<TData>)Database.GetCollection<TData>(dataKey); |
||||||
|
TData result = collection.FindById((BsonValue)id); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public void SetData<TData>(string dataKey, TData data, object id) |
||||||
|
{ |
||||||
|
LiteCollection<TData> collection = (LiteCollection<TData>)Database.GetCollection<TData>(dataKey); |
||||||
|
if(collection.FindById((BsonValue)id)==null){ |
||||||
|
collection.Insert((BsonValue)id, data); |
||||||
|
} |
||||||
|
collection.Update(data); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<TData> GetAll<TData>(string dataKey) where TData : new() |
||||||
|
{ |
||||||
|
LiteCollection<TData> collection = (LiteCollection<TData>)Database.GetCollection<TData>(dataKey); |
||||||
|
return collection.FindAll(); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<TData> FindData<TData>(string dataKey, Expression<Func<TData, bool>> expression) where TData : new() |
||||||
|
{ |
||||||
|
LiteCollection<TData> collection = (LiteCollection<TData>)Database.GetCollection<TData>(dataKey); |
||||||
|
return collection.Find(expression); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -1,54 +0,0 @@ |
|||||||
#if TOOLS |
|
||||||
using Godot; |
|
||||||
using System; |
|
||||||
|
|
||||||
namespace EGFramework.Example.SystemExamples.PlayerStorage |
|
||||||
{ |
|
||||||
[Tool] |
|
||||||
public partial class ToolItemImporter : EditorPlugin |
|
||||||
{ |
|
||||||
PackedScene MainPanel = ResourceLoader.Load<PackedScene>("res://addons/Tools/ItemImporter/ToolItemImporter.tscn"); |
|
||||||
Control MainPanelInstance; |
|
||||||
public override void _EnterTree() |
|
||||||
{ |
|
||||||
// Initialization of the plugin goes here. |
|
||||||
MainPanelInstance = (Control)MainPanel.Instantiate(); |
|
||||||
// Add the main panel to the editor's main viewport. |
|
||||||
EditorInterface.Singleton.GetEditorMainScreen().AddChild(MainPanelInstance); |
|
||||||
// Hide the main panel. Very much required. |
|
||||||
_MakeVisible(false); |
|
||||||
} |
|
||||||
|
|
||||||
public override void _ExitTree() |
|
||||||
{ |
|
||||||
// Clean-up of the plugin goes here. |
|
||||||
if (MainPanelInstance != null) |
|
||||||
{ |
|
||||||
MainPanelInstance.QueueFree(); |
|
||||||
} |
|
||||||
} |
|
||||||
public override bool _HasMainScreen() |
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
public override void _MakeVisible(bool visible) |
|
||||||
{ |
|
||||||
if (MainPanelInstance != null) |
|
||||||
{ |
|
||||||
MainPanelInstance.Visible = visible; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string _GetPluginName() |
|
||||||
{ |
|
||||||
return "Tool Item Importer"; |
|
||||||
} |
|
||||||
|
|
||||||
public override Texture2D _GetPluginIcon() |
|
||||||
{ |
|
||||||
return EditorInterface.Singleton.GetEditorTheme().GetIcon("Node", "EditorIcons"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
#endif |
|
@ -1,37 +0,0 @@ |
|||||||
[gd_scene format=3 uid="uid://bglw1yht7w1kt"] |
|
||||||
|
|
||||||
[node name="ToolItemImporter" type="Control"] |
|
||||||
layout_mode = 3 |
|
||||||
anchors_preset = 15 |
|
||||||
anchor_right = 1.0 |
|
||||||
anchor_bottom = 1.0 |
|
||||||
grow_horizontal = 2 |
|
||||||
grow_vertical = 2 |
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="."] |
|
||||||
layout_mode = 1 |
|
||||||
offset_right = 69.0 |
|
||||||
offset_bottom = 31.0 |
|
||||||
text = "导入CSV" |
|
||||||
|
|
||||||
[node name="Button2" type="Button" parent="."] |
|
||||||
layout_mode = 1 |
|
||||||
anchors_preset = 1 |
|
||||||
anchor_left = 1.0 |
|
||||||
anchor_right = 1.0 |
|
||||||
offset_left = -72.0 |
|
||||||
offset_bottom = 31.0 |
|
||||||
grow_horizontal = 0 |
|
||||||
text = "重新载入" |
|
||||||
|
|
||||||
[node name="Button3" type="Button" parent="."] |
|
||||||
layout_mode = 1 |
|
||||||
anchors_preset = 1 |
|
||||||
anchor_left = 1.0 |
|
||||||
anchor_right = 1.0 |
|
||||||
offset_left = -71.0 |
|
||||||
offset_top = 36.0 |
|
||||||
offset_right = 1.0 |
|
||||||
offset_bottom = 67.0 |
|
||||||
grow_horizontal = 0 |
|
||||||
text = "重新载入" |
|
@ -1,7 +0,0 @@ |
|||||||
[plugin] |
|
||||||
|
|
||||||
name="ItemImporter" |
|
||||||
description="a csv ItemImporter" |
|
||||||
author="jkpete" |
|
||||||
version="" |
|
||||||
script="ToolItemImporter.cs" |
|
Loading…
Reference in new issue