Compare commits

...

6 Commits

  1. 1
      EGFramework.csproj
  2. 112
      Example/Action3D/MainGame.tscn
  3. 46
      Example/Action3D/Script/ActionCamera.cs
  4. 69
      Example/Action3D/Script/ActionPlayer.cs
  5. BIN
      Example/Action3D/SkyBox/lakeside.jpg
  6. 35
      Example/Action3D/SkyBox/lakeside.jpg.import
  7. 6
      Example/Gateway/Script/View/ViewBacNetGateway.cs
  8. 6
      Example/Gateway/Script/View/ViewBacnetHttpServer.cs
  9. 6
      Example/Gateway/Script/View/ViewModbusGateway.cs
  10. 6
      Example/Gateway/Script/View/ViewTcpGateway.cs
  11. 2
      Example/ModbusDebugTool/Script/ViewEdit.cs
  12. 2
      Example/ModbusDebugTool/Script/ViewMenu.cs
  13. 2
      Example/ModbusDebugTool/Script/ViewModbusItem.cs
  14. 4
      Example/ModbusDebugTool/Script/ViewSettings.cs
  15. 9
      Example/SystemExamples/ItemList/HPPotion.tres
  16. 17
      Example/SystemExamples/ItemList/ItemList.CSV.import
  17. 3
      Example/SystemExamples/ItemList/ItemList.json
  18. 5
      Example/SystemExamples/ItemList/ItemList.txt
  19. 12
      Example/SystemExamples/PlayerStorage/PlayerStorage.tscn
  20. 36
      Example/SystemExamples/PlayerStorage/Script/DataStorageItem.cs
  21. 23
      Example/SystemExamples/PlayerStorage/Script/InterfaceStorage.cs
  22. 19
      Example/SystemExamples/PlayerStorage/Script/ViewStorage.cs
  23. 2
      Example/Tween/EGTween.tscn
  24. 2
      Example/Tween/Script/TweenTest.cs
  25. 6
      Example/UsingTest/Scene/TestEGFramework.tscn
  26. 102
      Example/UsingTest/Script/EGSaveTest.cs
  27. 66
      ReadMe.md
  28. 2
      addons/EGFramework/Module/NodeExtension/EGCreate.cs
  29. 6
      addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs
  30. 49
      addons/EGFramework/Module/SaveTools/EGByteSave.cs
  31. 15
      addons/EGFramework/Module/SaveTools/EGCsv.cs
  32. 67
      addons/EGFramework/Module/SaveTools/EGJsonSave.cs
  33. 16
      addons/EGFramework/Module/SaveTools/EGLiteDB.cs
  34. 161
      addons/EGFramework/Module/SaveTools/EGSave.cs
  35. 4
      addons/EGFramework/Module/SaveTools/EGSqlite.cs
  36. 23
      addons/EGFramework/Module/SaveTools/SaveToolsInterface.cs
  37. 54
      addons/Tools/ItemImporter/ToolItemImporter.cs
  38. 37
      addons/Tools/ItemImporter/ToolItemImporter.tscn
  39. 7
      addons/Tools/ItemImporter/plugin.cfg
  40. 13
      icon.svg.import
  41. 64
      project.godot

1
EGFramework.csproj

@ -16,5 +16,6 @@ @@ -16,5 +16,6 @@
<PackageReference Include="PacketDotNet" Version="0.19.3" />
<PackageReference Include="SharpPcap" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" />
<PackageReference Include="LiteDB" Version="5.0.21" />
</ItemGroup>
</Project>

112
Example/Action3D/MainGame.tscn

@ -0,0 +1,112 @@ @@ -0,0 +1,112 @@
[gd_scene load_steps=19 format=3 uid="uid://05atvgqt8tku"]
[ext_resource type="Texture2D" uid="uid://ss8dh8aaqc4w" path="res://Example/Action3D/SkyBox/lakeside.jpg" id="1_akq3m"]
[ext_resource type="Texture2D" uid="uid://31r216hix0wk" path="res://icon.svg" id="2_b66wh"]
[ext_resource type="Script" path="res://Example/Action3D/Script/ActionPlayer.cs" id="2_c0s4j"]
[ext_resource type="Script" path="res://Example/Action3D/Script/ActionCamera.cs" id="3_ue0e3"]
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_hbme1"]
panorama = ExtResource("1_akq3m")
[sub_resource type="Sky" id="Sky_qmmlv"]
sky_material = SubResource("PanoramaSkyMaterial_hbme1")
[sub_resource type="Environment" id="Environment_dusyb"]
background_mode = 2
sky = SubResource("Sky_qmmlv")
glow_enabled = true
fog_light_color = Color(0.152941, 0.168627, 0.196078, 1)
fog_density = 0.05
fog_aerial_perspective = 1.0
fog_height = 0.5
fog_height_density = 0.4
adjustment_brightness = 1.91
[sub_resource type="BoxShape3D" id="BoxShape3D_hm8uo"]
size = Vector3(60, 1, 60)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_c0bvn"]
albedo_texture = ExtResource("2_b66wh")
[sub_resource type="BoxMesh" id="BoxMesh_2gv65"]
material = SubResource("StandardMaterial3D_c0bvn")
size = Vector3(60, 1, 60)
[sub_resource type="BoxShape3D" id="BoxShape3D_4jggu"]
[sub_resource type="BoxShape3D" id="BoxShape3D_7005m"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_byd0k"]
albedo_color = Color(0, 0.219608, 0.176471, 1)
[sub_resource type="BoxMesh" id="BoxMesh_h3y2r"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r4ehu"]
albedo_color = Color(0.517647, 0.886275, 0.807843, 1)
rim_enabled = true
rim_tint = 0.48
[sub_resource type="BoxMesh" id="BoxMesh_3o4en"]
material = SubResource("StandardMaterial3D_r4ehu")
size = Vector3(0.5, 0.5, 0.5)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dv57j"]
albedo_color = Color(0.294118, 0.294118, 0.294118, 1)
metallic = 1.0
metallic_specular = 1.0
[sub_resource type="BoxMesh" id="BoxMesh_iv7ly"]
material = SubResource("StandardMaterial3D_dv57j")
size = Vector3(0.6, 0.6, 0.6)
[node name="MainGame" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_dusyb")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.642788, -0.383022, 0.663414, 0, 0.866025, 0.5, -0.766044, -0.321394, 0.55667, 0, 0, 0)
shadow_enabled = true
[node name="Ground" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.01419, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00709915, 0.117098, -0.180923)
shape = SubResource("BoxShape3D_hm8uo")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"]
mesh = SubResource("BoxMesh_2gv65")
[node name="Area3D" type="Area3D" parent="."]
visible = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("BoxShape3D_4jggu")
[node name="Pivot" type="Node3D" parent="."]
script = ExtResource("3_ue0e3")
[node name="Camera3D" type="Camera3D" parent="Pivot"]
transform = Transform3D(1, 0, 0, 0, 0.976296, 0.21644, 0, -0.21644, 0.976296, 0, 1, 2)
[node name="Player" type="CharacterBody3D" parent="."]
script = ExtResource("2_c0s4j")
JumpSpeed = 2.0
FallAcceleration = 9.8
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0296049, -9.53674e-07, 0.00402832)
shape = SubResource("BoxShape3D_7005m")
[node name="Body" type="MeshInstance3D" parent="Player"]
material_override = SubResource("StandardMaterial3D_byd0k")
mesh = SubResource("BoxMesh_h3y2r")
[node name="Head" type="MeshInstance3D" parent="Player/Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 0)
mesh = SubResource("BoxMesh_3o4en")
[node name="Hair" type="MeshInstance3D" parent="Player/Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0.15)
mesh = SubResource("BoxMesh_iv7ly")

46
Example/Action3D/Script/ActionCamera.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
using Godot;
using System;
public partial class ActionCamera : Node3D
{
[Export]
public float Speed { get; set; } = 4;
private Vector3 _targetRotation = Vector3.Zero;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
if (Input.IsActionPressed("camera_up"))
{
_targetRotation.X -= Speed*(float)delta;
}
if (Input.IsActionPressed("camera_down"))
{
_targetRotation.X += Speed*(float)delta;
}
if (Input.IsActionPressed("camera_left"))
{
_targetRotation.Y += Speed*(float)delta;
}
if (Input.IsActionPressed("camera_right"))
{
_targetRotation.Y -= Speed*(float)delta;
}
if (_targetRotation.X>30*Mathf.Pi/180)
{
_targetRotation.X = 30*Mathf.Pi/180;
}
if (_targetRotation.X<-30*Mathf.Pi/180){
_targetRotation.X = -30*Mathf.Pi/180;
}
this.Rotation = this.Rotation.Lerp(_targetRotation,Speed*(float)delta) ;
}
}

69
Example/Action3D/Script/ActionPlayer.cs

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
using Godot;
using System;
namespace EGFramework.Examples.Action3D{
public partial class ActionPlayer : CharacterBody3D
{
[Export]
public float Speed { get; set; } = 14;
[Export]
public float JumpSpeed { set; get; } = 15;
[Export]
public float FallAcceleration { get; set; } = 75;
public float FallSpeed { get; set; } = 0;
private Vector3 _targetVelocity = Vector3.Zero;
public Node3D CameraPivot { set; get; }
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
CameraPivot = this.GetNode<Node3D>("../Pivot");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
// We create a local variable to store the input direction.
var direction = Vector3.Zero;
direction.X = Input.GetAxis("move_left", "move_right");
direction.Z = Input.GetAxis("move_forward", "move_back");
if (direction.Length() > 0)
{
// this.Rotation = new Vector3(0,CameraPivot.Rotation.Y,0);
this.GetNode<Node3D>("Body").Rotation = new Vector3(0,CameraPivot.Rotation.Y,0);
direction = direction.Normalized();
direction = direction.Rotated(Vector3.Up, CameraPivot.Rotation.Y);
}
// direction.Rotated(Vector3.Up, CameraPivot.Rotation.Y);
// Ground velocity
_targetVelocity.X = direction.X * Speed;
_targetVelocity.Z = direction.Z * Speed;
if (!IsOnFloor()) // If in the air, fall towards the floor. Literally gravity
{
// GD.Print(FallSpeed);
FallSpeed -= FallAcceleration * (float)delta;
_targetVelocity.Y += FallSpeed;
}else{
if (Input.IsActionPressed("jump"))
{
_targetVelocity.Y = 0.1f;
FallSpeed = JumpSpeed;
}
}
this.Velocity = _targetVelocity;
MoveAndSlide();
CameraPivot.Position = this.Position;
}
}
}

BIN
Example/Action3D/SkyBox/lakeside.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

35
Example/Action3D/SkyBox/lakeside.jpg.import

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ss8dh8aaqc4w"
path.s3tc="res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Example/Action3D/SkyBox/lakeside.jpg"
dest_files=["res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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=0

6
Example/Gateway/Script/View/ViewBacNetGateway.cs

@ -20,16 +20,16 @@ namespace EGFramework.Examples.Gateway{ @@ -20,16 +20,16 @@ namespace EGFramework.Examples.Gateway{
public void InitGateway()
{
if(this.EGSave().GetDataByFile<DataBacnetGatewaySetting>() == null){
if(this.EGSave().GetObjectFromJson<DataBacnetGatewaySetting>() == null){
DataBacnetGatewaySetting = new DataBacnetGatewaySetting(){
MqttHost = "192.168.1.220",
HttpServerPrefix = "http://127.0.0.1:5000/",
ResponseTheme = "/LocalBacnetResponse",
RequestTheme = "/LocalBacnetRequest"
};
this.EGSave().SetDataToFile(DataBacnetGatewaySetting);
this.EGSave().SetObjectToJson(DataBacnetGatewaySetting);
}else{
DataBacnetGatewaySetting = this.EGSave().GetDataByFile<DataBacnetGatewaySetting>();
DataBacnetGatewaySetting = this.EGSave().GetObjectFromJson<DataBacnetGatewaySetting>();
}
this.EGEnabledProtocolTool<EGBacnet>();
this.EGEnabledProtocolTool<EGMqtt>();

6
Example/Gateway/Script/View/ViewBacnetHttpServer.cs

@ -13,16 +13,16 @@ namespace EGFramework.Examples.Gateway{ @@ -13,16 +13,16 @@ namespace EGFramework.Examples.Gateway{
}
}
public void InitGateway(){
if(this.EGSave().GetDataByFile<DataBacnetGatewaySetting>() == null){
if(this.EGSave().GetObjectFromJson<DataBacnetGatewaySetting>() == null){
DataBacnetGatewaySetting = new DataBacnetGatewaySetting(){
MqttHost = "192.168.1.220",
HttpServerPrefix = "http://127.0.0.1:5000/",
ResponseTheme = "/LocalBacnetResponse",
RequestTheme = "/LocalBacnetRequest"
};
this.EGSave().SetDataToFile(DataBacnetGatewaySetting);
this.EGSave().SetObjectToJson(DataBacnetGatewaySetting);
}else{
DataBacnetGatewaySetting = this.EGSave().GetDataByFile<DataBacnetGatewaySetting>();
DataBacnetGatewaySetting = this.EGSave().GetObjectFromJson<DataBacnetGatewaySetting>();
}
this.EGEnabledProtocolTool<EGBacnet>();
this.EGHttpServerListen(DataBacnetGatewaySetting.HttpServerPrefix+"WhoIs/",requestMsg=>{

6
Example/Gateway/Script/View/ViewModbusGateway.cs

@ -43,11 +43,11 @@ namespace EGFramework.Examples.Gateway{ @@ -43,11 +43,11 @@ namespace EGFramework.Examples.Gateway{
public void InitGateway()
{
if(this.EGSave().GetDataByFile<DataModbusGatewaySetting>() == null){
if(this.EGSave().GetObjectFromJson<DataModbusGatewaySetting>() == null){
InitSettings();
this.EGSave().SetDataToFile(Setting);
this.EGSave().SetObjectToJson(Setting);
}else{
Setting = this.EGSave().GetDataByFile<DataModbusGatewaySetting>();
Setting = this.EGSave().GetObjectFromJson<DataModbusGatewaySetting>();
}
this.EGEnabledProtocolTool<EGTCPClient>();
this.EGEnabledProtocolTool<EGSerialPort>();

6
Example/Gateway/Script/View/ViewTcpGateway.cs

@ -14,7 +14,7 @@ namespace EGFramework.Examples.Gateway{ @@ -14,7 +14,7 @@ namespace EGFramework.Examples.Gateway{
}
public void InitGateway(){
if(this.EGSave().GetDataByFile<DataTcpGatewaySetting>() == null){
if(this.EGSave().GetObjectFromJson<DataTcpGatewaySetting>() == null){
DataTcpGatewaySetting = new DataTcpGatewaySetting();
DataTcpGatewaySetting.DataTcpGatewayDevices.Add(new DataTcpGatewayDevice(){
Host = "127.0.0.1",
@ -23,9 +23,9 @@ namespace EGFramework.Examples.Gateway{ @@ -23,9 +23,9 @@ namespace EGFramework.Examples.Gateway{
ResponseTheme = "/LocalTCPResponse",
RequestTheme = "/LocalTCPRequest"
});
this.EGSave().SetDataToFile(DataTcpGatewaySetting);
this.EGSave().SetObjectToJson(DataTcpGatewaySetting);
}else{
DataTcpGatewaySetting = this.EGSave().GetDataByFile<DataTcpGatewaySetting>();
DataTcpGatewaySetting = this.EGSave().GetObjectFromJson<DataTcpGatewaySetting>();
}
this.EGEnabledProtocolTool<EGTCPClient>();
this.EGEnabledProtocolTool<EGMqtt>();

2
Example/ModbusDebugTool/Script/ViewEdit.cs

@ -75,7 +75,7 @@ namespace EGFramework.Examples.ModbusDebugTool{ @@ -75,7 +75,7 @@ namespace EGFramework.Examples.ModbusDebugTool{
this.EGGetObject<DataModbus>().Items.Remove(DataModbusItem.GetKey());
}
this.EGGetObject<DataModbus>().Items.Add(modbusItem.GetKey(),modbusItem);
this.EGSave().SetDataToFile(this.EGGetObject<DataModbus>());
this.EGSave().SetObjectToJson(this.EGGetObject<DataModbus>());
this.Visible = false;
this.ViewMenu.RefreshSaveData();

2
Example/ModbusDebugTool/Script/ViewMenu.cs

@ -20,7 +20,7 @@ namespace EGFramework.Examples.ModbusDebugTool{ @@ -20,7 +20,7 @@ namespace EGFramework.Examples.ModbusDebugTool{
Edit = this.GetNode<ViewEdit>("Edit");
Edit.Visible = false;
this.EGEnabledProtocolTools();
DataModbus dataModbus = this.EGSave().GetDataByFile<DataModbus>();
DataModbus dataModbus = this.EGSave().GetObjectFromJson<DataModbus>();
if (dataModbus == null)
{
dataModbus = new DataModbus();

2
Example/ModbusDebugTool/Script/ViewModbusItem.cs

@ -66,7 +66,7 @@ namespace EGFramework.Examples.ModbusDebugTool{ @@ -66,7 +66,7 @@ namespace EGFramework.Examples.ModbusDebugTool{
if(this.EGGetObject<DataModbus>().Items.ContainsKey(DataModbusItem.GetKey())){
this.EGGetObject<DataModbus>().Items.Remove(DataModbusItem.GetKey());
}
this.EGSave().SetDataToFile(this.EGGetObject<DataModbus>());
this.EGSave().SetObjectToJson(this.EGGetObject<DataModbus>());
this.GetNode<ViewMenu>("/root/Menu").RefreshSaveData();
}

4
Example/ModbusDebugTool/Script/ViewSettings.cs

@ -14,7 +14,7 @@ namespace EGFramework.Examples.ModbusDebugTool{ @@ -14,7 +14,7 @@ namespace EGFramework.Examples.ModbusDebugTool{
}
public void LoadSettings(){
DataModbusSettings settings = this.EGSave().GetDataByFile<DataModbusSettings>();
DataModbusSettings settings = this.EGSave().GetObjectFromJson<DataModbusSettings>();
this.EGRegisterObject(settings);
UpdateSettings(settings);
EditBaudRate.Text = settings.BaudRate.ToString();
@ -36,7 +36,7 @@ namespace EGFramework.Examples.ModbusDebugTool{ @@ -36,7 +36,7 @@ namespace EGFramework.Examples.ModbusDebugTool{
};
UpdateSettings(settings);
this.EGRegisterObject(settings);
this.EGSave().SetDataToFile(this.EGGetObject<DataModbusSettings>());
this.EGSave().SetObjectToJson(this.EGGetObject<DataModbusSettings>());
this.Visible = false;
}
catch (System.Exception ex)

9
Example/SystemExamples/ItemList/HPPotion.tres

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bhsavl0d80s6j"]
[ext_resource type="Script" path="res://Example/SystemExamples/PlayerStorage/Script/DataStorageItem.cs" id="1_j773b"]
[resource]
script = ExtResource("1_j773b")
Id = 0
Name = ""
Info = ""

17
Example/SystemExamples/ItemList/ItemList.CSV.import

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
[remap]
importer="csv_translation"
type="Translation"
uid="uid://dhb625wmjnlwy"
[deps]
files=["res://Example/SystemExamples/ItemList/ItemList.en.translation", "res://Example/SystemExamples/ItemList/ItemList.es.translation", "res://Example/SystemExamples/ItemList/ItemList.ja.translation"]
source_file="res://Example/SystemExamples/ItemList/ItemList.CSV"
dest_files=["res://Example/SystemExamples/ItemList/ItemList.en.translation", "res://Example/SystemExamples/ItemList/ItemList.es.translation", "res://Example/SystemExamples/ItemList/ItemList.ja.translation"]
[params]
compress=true
delimiter=0

3
Example/SystemExamples/ItemList/ItemList.json

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
{
}

5
Example/SystemExamples/ItemList/ItemList.txt

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
keys,en,es,ja
GREET,"Hello, friend!","Hola, amigo!",こんにちは
ASK,How are you?,Cómo está?,元気ですか
BYE,Goodbye,Adiós,さようなら
QUOTE,"""Hello"" said the man.","""Hola"" dijo el hombre.",「こんにちは」男は言いました

12
Example/SystemExamples/PlayerStorage/PlayerStorage.tscn

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://tee7nc525si7"]
[ext_resource type="Script" path="res://Example/SystemExamples/PlayerStorage/Script/ViewStorage.cs" id="1_goow2"]
[node name="PlayerStorage" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_goow2")

36
Example/SystemExamples/PlayerStorage/Script/DataStorageItem.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Godot;
namespace EGFramework.Example.SystemExamples.PlayerStorage
{
public partial class DataStorageItem : Resource, IItem
{
[Export] public int Id { set; get; }
[Export] public string Name { set; get; }
[Export(PropertyHint.MultilineText)] public string Info { set; get; }
[Export] public Texture Icon { set; get; }
public Texture GetIcon()
{
throw new NotImplementedException();
}
public string GetInfo()
{
throw new NotImplementedException();
}
public int GetItemId()
{
throw new NotImplementedException();
}
public string GetName()
{
throw new NotImplementedException();
}
}
}

23
Example/SystemExamples/PlayerStorage/Script/InterfaceStorage.cs

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Godot;
namespace EGFramework.Example.SystemExamples.PlayerStorage
{
public interface IItem
{
public int GetItemId();
public string GetName();
public Texture GetIcon();
public string GetInfo();
}
public interface IBackPackItem : IItem{
public int GetCount();
}
public interface ICostItem: IItem {
public void OnCost();
}
}

19
Example/SystemExamples/PlayerStorage/Script/ViewStorage.cs

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
using Godot;
using System;
using EGFramework;
public partial class ViewStorage : Node,IEGFramework
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
// this.GetModule<EGByteSave>().SaveToFile("nihao");
Variant result = this.GetModule<EGByteSave>().LoadFromFile();
GD.Print(result);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}

2
Example/Tween/EGTween.tscn

@ -27,4 +27,4 @@ position = Vector2(146, 80) @@ -27,4 +27,4 @@ position = Vector2(146, 80)
[node name="Polygon2D" type="Polygon2D" parent="."]
position = Vector2(146, 97)
polygon = PackedVector2Array(0, 0, 100, 0, 213.683, 76.1096, 454, 237, 0, 100, 0, 0)
polygon = PackedVector2Array(0, 0, 100, 0, 327, 56, 454, 237, 0, 100, 0, 0)

2
Example/Tween/Script/TweenTest.cs

@ -33,7 +33,7 @@ namespace EGFramework.Examples.TweenAnime{ @@ -33,7 +33,7 @@ namespace EGFramework.Examples.TweenAnime{
// tween3.TweenProperty(Target,"size",new Vector2(40,100),0.5f);
// tween3.TweenProperty(Target,"size",new Vector2(40,40),0.5f);
// tween3.SetLoops();
Target2D.TweenRotationByAngle(360f,1.0f);
Target2D.TweenRotationByAngle(360f,1.0f).KillOnEnd();
}
public void TweenOver(){

6
Example/UsingTest/Scene/TestEGFramework.tscn

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dfa86yq8m28rk"]
[ext_resource type="Script" path="res://Example/UsingTest/Script/EGTest.cs" id="1_s8hm3"]
[ext_resource type="Script" path="res://Example/UsingTest/Script/EGSaveTest.cs" id="1_eij2h"]
[node name="TestEgFramework" type="Control"]
layout_mode = 3
@ -9,7 +9,7 @@ anchor_right = 1.0 @@ -9,7 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_s8hm3")
script = ExtResource("1_eij2h")
[node name="Timer" type="Timer" parent="."]
autostart = true
@ -23,5 +23,3 @@ offset_bottom = 164.0 @@ -23,5 +23,3 @@ offset_bottom = 164.0
layout_mode = 0
offset_right = 50.0
offset_bottom = 50.0
[connection signal="pressed" from="Button1" to="." method="OnButton1Click"]

102
Example/UsingTest/Script/EGSaveTest.cs

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
using Godot;
using LiteDB;
using System;
using System.IO;
namespace EGFramework.Examples.Test{
public partial class EGSaveTest : Node,IEGFramework
{
public override void _Ready()
{
base._Ready();
this.EGSave().OpenUserPath();
// GD.Print(ProjectSettings.GlobalizePath("res://SaveData/Default.json"));
// GD.Print(ProjectSettings.GlobalizePath("user://SaveData/Default.json"));
// GD.Print(Path.GetDirectoryName(ProjectSettings.GlobalizePath("res://SaveData/Default.json")));
// TestLiteDB();
}
public void TestSqlite(){
// string result = this.EGSqlite().CreateTable<SqliteBackpackItem>();
this.EGSqlite().SaveData(new SqliteBackpackItem{
ItemID = 10,
ItemCount = 1,
BackpackID = 1,
});
GD.Print(this.EGSqlite().ExceptionMsg);
// var properties = typeof(SqliteBackpackItem).GetFields();
// Godot.GD.Print(properties.Count() + " Readed ");
}
public void TestLiteDB(){
// 打开数据库 (如果不存在自动创建)
using(var db = new LiteDatabase("SaveData/MyData.db"))
{
// 获取一个集合 (如果不存在创建)
LiteCollection<Customer> col = (LiteCollection<Customer>)db.GetCollection<Customer>("customers");
GD.Print(col);
// // 创建新顾客实例
// var customer = new Customer
// {
// Id = 200,
// Name = "Alexander King",
// Phones = new string[] { "8000-0000", "9000-0000" },
// IsActive = true
// };
// // 插入新顾客文档 (Id 自增)
// for (int i = 0; i < 10000; i++)
// {
// customer.Id ++;
// col.Insert(customer);
// }
// // 更新集合中的一个文档
// customer.Name = "Joana Doe";
// col.Update(customer);
// // 使用文档的 Name 属性为文档建立索引
// col.EnsureIndex(x => x.Name);
// 使用 LINQ 查询文档
// var results = col.Find(x => x.Name.StartsWith("Al"));
// GD.Print("Find:"+results.Count());
// string ids = "";
// foreach(var item in results){
// ids += "["+item.Id.ToString()+"]";
// }
// GD.Print(ids);
// // 让我们创建在电话号码字段上创建一个索引 (使用表达式). 它是一个多键值索引
// //col.EnsureIndex(x => x.Phones, "$.Phones[*]");
// col.EnsureIndex(x => x.Phones);
// // 现在我们可以查询电话号码
// var r = col.FindOne(x => x.Phones.Contains("8888-5555"));\
// Test Other
// ILiteCollection<SqliteBackpackItem> col = db.GetCollection<SqliteBackpackItem>("SqliteBackpackItem");
// var item = new SqliteBackpackItem{
// ItemID = 10,
// ItemCount = 1,
// BackpackID = 1,
// };
// for (int i = 0; i < 100; i++)
// {
// col.Insert(item);
// }
}
}
}
public struct SqliteBackpackItem{
public int Id { get; set; }
public int ItemID { get; set; }
public int ItemCount { get; set; }
public int BackpackID { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string[] Phones { get; set; }
public bool IsActive { get; set; }
}
}

66
ReadMe.md

@ -16,26 +16,18 @@ @@ -16,26 +16,18 @@
>
> Godot 在 [宽松的 MIT 许可证](https://docs.godotengine.org/zh-cn/4.x/about/complying_with_licenses.html#doc-complying-with-licenses) 下完全自由且开源,没有附加条件、没有抽成、什么都没有。用户的游戏乃至引擎的每一行代码,都归用户自己所有。Godot 的开发完全独立且由社区驱动,允许用户为满足需求重塑引擎。它受到不以盈利为目标的 [Godot 基金会](https://godot.foundation/)支持。
# 一、准备工作
## 1.下载开发环境
本章节所有环境均在开源IDE `VSCode`,`Godot4.2 - .NET` 的环境下进行,请确保已经下载好`VSCode`,`Godot4.2 - .NET`,如果您有购买Rider或者其他编码工具可以根据自己的喜好来替代VSCode。
## 2.VSCode 插件安装
打开VSCode, 按下`Ctrl+Shift+X`,在搜索栏里面搜索`C# Tools for Godot`,安装该插件,因为该插件可能依赖于`C#`插件,同时需要安装`C#`插件。
同上,搜索并安装`NuGet Package Manager GUI`插件,用于Nuget包的安装与管理。
## 3.Nuget包的安装
打开VSCode,按下`Ctrl+Shift+P`,在搜索栏里面搜索`Nuget Package ManagerGUI`,选择右侧`Install New Pakage` ,依次安装以下依赖包:
@ -50,15 +42,54 @@ @@ -50,15 +42,54 @@
注意:这些Nuget包仅为目前框架版本所用,后续可能会有新的Nuget包导入,会在此处列出。
## 4.删除不需要的Module(可选)
如果您只想使用部分功能,或者不想安装对应的Nuget包依赖,可以直接删除对应的Module脚本文件。
无需担心,除了部分Module存在相关依赖,大部分Module是支持直接删除的。
## 5.EG插件库简介
### 5.1 EGSave篇
---
#### Sqlite数据持久化扩展:
注意:本功能需要依赖安装 `Microsoft.Data.Sqlite` Nuget扩展,将以下代码放入*.csproj 工程文件中,或者通过Nuget安装上述包。
```xml
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.1" />
```
使用案例(保存数据=>保存单一数据,目前来看该功能仍需改进):
```csharp
public partial class EGSaveTest : Node,IEGFramework
{
public override void _Ready()
{
TestSqlite();
}
public void TestSqlite(){
// string result = this.EGSqlite().CreateTable<SqliteBackpackItem>();
this.EGSqlite().SaveData(new SqliteBackpackItem{
ItemID = 10,
ItemCount = 1,
BackpackID = 1,
});
GD.Print(this.EGSqlite().ExceptionMsg);
}
}
public struct SqliteBackpackItem{
public int ItemID;
public int ItemCount;
public int BackpackID;
}
```
结构类要求:保存字段不能使用 {get;set;},所有数据会自动生成自增序列的ID,字段名称不能为ID。
# 二、框架简介
@ -68,8 +99,6 @@ @@ -68,8 +99,6 @@
协议文件均存放在目录addons\EGFramework\License_Third_Part下面
## 1.使用框架
添加using,并继承接口IEGFramework,即可使用该框架了。
@ -96,12 +125,8 @@ public class DataTest{ @@ -96,12 +125,8 @@ public class DataTest{
public string PlayerName;
public int Hp;
}
```
## 2.直接使用Module
继承接口IEGFramework时,可以直接通过this.GetModule这个扩展方法直接获取该模块。上面的代码可以通过直接调用的方式改写成如下:
@ -128,8 +153,6 @@ public class DataTest{ @@ -128,8 +153,6 @@ public class DataTest{
}
```
## 3.扩展框架(编写Module)
编写框架时,要用到IModule这个接口,任何继承了该接口的类均视为Module,可以被上面的方法Get到。
@ -150,14 +173,14 @@ namespace EGFramework @@ -150,14 +173,14 @@ namespace EGFramework
{
void RegisterObject<T>(T object_);
T GetObject<T>() where T : class,new();
}
public class EGObject : EGModule,IEGObject
{
private IOCContainer ObjectContainer = new IOCContainer();
public override void Init()
{
}
public TObject GetObject<TObject>() where TObject : class,new()
@ -178,7 +201,7 @@ namespace EGFramework @@ -178,7 +201,7 @@ namespace EGFramework
return ObjectContainer.self.ContainsKey(typeof(TObject));
}
}
public static class CanGetObjectExtension
{
public static T EGGetObject<T>(this IEGFramework self) where T : class,new()
@ -206,5 +229,4 @@ namespace EGFramework @@ -206,5 +229,4 @@ namespace EGFramework
}
}
```

2
addons/EGFramework/Module/NodeExtension/EGCreate.cs

@ -42,7 +42,7 @@ namespace EGFramework{ @@ -42,7 +42,7 @@ namespace EGFramework{
}
public static void Alert(this Node self,string alertMsg){
}
}
}

6
addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs

@ -4,6 +4,12 @@ using System; @@ -4,6 +4,12 @@ using System;
namespace EGFramework.EGTween{
public static class EGTweenExtension
{
#region Function
public static Tween KillOnEnd(this Tween self){
self.TweenCallback(Callable.From(self.Kill));
return self;
}
#endregion
#region Position
public static Tween TweenPosition(this Control self,Vector2 position,float delay){
Tween tween = self.CreateTween();

49
addons/EGFramework/Module/SaveTools/EGByteSave.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Runtime.Serialization.Formatters.Binary;
using Godot;
namespace EGFramework
{
public class EGByteSave : EGModule, IEGSave,IEGSaveObject
{
public void SaveToFile(string content)
{
using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Write);
Variant hp = 10;
file.StoreVar(hp);
Variant pos = new Vector2(100,100);
file.StoreVar(pos);
}
public Variant LoadFromFile()
{
using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Read);
Variant content = file.GetVar();
Variant pos = file.GetVar();
return pos;
}
public override void Init()
{
}
public void InitSaveFile(string path)
{
//throw new NotImplementedException();
}
public void SetObject<TObject>(string objectKey , TObject obj)
{
throw new NotImplementedException();
}
public TObject GetObject<TObject>(string objectKey) where TObject : new()
{
throw new NotImplementedException();
}
}
}

15
addons/EGFramework/Module/SaveTools/EGCsv.cs

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EGFramework
{
public class EGCsv : EGModule
{
public override void Init()
{
}
}
}

67
addons/EGFramework/Module/SaveTools/EGJsonSave.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace EGFramework
{
public class EGJsonSave : IEGSave,IEGSaveObject
{
private string DefaultPath { set; get; }
private JObject _SaveObject;
private JObject SaveObject{
get {
if(_SaveObject == null){
InitSaveFile(DefaultPath);
}
return _SaveObject;
}
}
/// <summary>
/// Init a new save data file or load an other file with json suffix, if you want to load other save data, please use this function to reload;
/// </summary>
public void InitSaveFile(string path)
{
DefaultPath = path;
if(!File.Exists(path)){
if (!Directory.Exists(DefaultPath))
{
Directory.CreateDirectory(Path.GetDirectoryName(DefaultPath));
File.WriteAllText(DefaultPath,"{}");
}else if(!File.Exists(DefaultPath)){
File.WriteAllText(DefaultPath,"{}");
}
}
using (StreamReader reader = File.OpenText(path))
{
_SaveObject = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
}
}
public void SetObject<TObject>(string objectKey,TObject obj)
{
if(SaveObject.ContainsKey(typeof(TObject).ToString())){
SaveObject[typeof(TObject).ToString()] = JToken.FromObject(obj);
}else{
SaveObject.Add(typeof(TObject).ToString(),JToken.FromObject(obj));
}
File.WriteAllText(DefaultPath,JsonConvert.SerializeObject(SaveObject,Formatting.Indented));
}
/// <summary>
/// Get data from file, if your data is not in file, then throw an exception.
/// </summary>
public TObject GetObject<TObject>(string objectKey) where TObject : new()
{
if(!SaveObject.ContainsKey(typeof(TObject).ToString())){
throw new Exception("Key not found!");
}
TObject data = SaveObject[typeof(TObject).ToString()].ToObject<TObject>();
return data;
}
}
}

16
addons/EGFramework/Module/SaveTools/EGLiteDB.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
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();
}
}
}

161
addons/EGFramework/Module/SaveTools/EGSave.cs

@ -1,122 +1,103 @@ @@ -1,122 +1,103 @@
using System;
using System.IO;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Godot;
namespace EGFramework
{
public interface IEGSave{
void SetDataToFile<TData>(TData data);
TData GetDataByFile<TData>() where TData : class,new();
void InitSaveData(string fileName);
public enum TypeEGSave{
Json = 0,
Bson = 1,
Byte = 2,
XML = 3
}
public enum TypeDBSave{
Csv = 0,
Sqlite = 1,
LiteDB = 2,
}
public class EGSave : EGModule,IEGSave
{
private string DefaultSaveFile = "Default";
private string DefaultSaveFolder = "SaveData";
private JObject _SaveObject;
private JObject SaveObject{
get {
if(_SaveObject == null){
InitSaveObject();
}
return _SaveObject;
}
}
public EGSave(){
public class EGSave : EGModule
{
#region About Godot File's PATH
// Godot's Path has res:// and user://
// UserPath is used for every platform such as android.
// You can use ProjectSettings.GlobalizePath("") to convert a "local" path like res://path/to/file.txt to an absolute OS path.
#endregion
}
/// <summary>
/// if you want to define default save data file name, please use "this.RegisterModule(new EGSave("FileName"))"in your architecture code(Init function);
/// </summary>
/// <param name="fileName"></param>
public EGSave(string fileName){
this.DefaultSaveFile = fileName;
}
private Dictionary<string,IEGSaveData> DataBaseFiles = new Dictionary<string,IEGSaveData>();
private Dictionary<string,IEGSaveObject> ObjectFiles = new Dictionary<string,IEGSaveObject>();
public EGSave() {}
public override void Init()
{
if (!Directory.Exists(DefaultSaveFolder))
{
Directory.CreateDirectory(DefaultSaveFolder);
File.WriteAllText(DefaultSaveFolder + "/" + DefaultSaveFile + ".json","{}");
}else if(!File.Exists(DefaultSaveFolder + "/" + DefaultSaveFile + ".json")){
File.WriteAllText(DefaultSaveFolder + "/" + DefaultSaveFile + ".json","{}");
LoadObjectFile("Default/SaveData.json".GetGodotUserPath(),TypeEGSave.Json);
}
public void LoadDataFile(string path,TypeDBSave type){
switch(type){
case TypeDBSave.Csv:
break;
default:
break;
}
}
private void InitSaveObject(){
using (StreamReader reader = File.OpenText(DefaultSaveFolder + "/" + DefaultSaveFile + ".json"))
{
_SaveObject = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
public void LoadObjectFile(string path,TypeEGSave type){
switch(type){
case TypeEGSave.Json:
EGJsonSave newJsonFile = new EGJsonSave();
newJsonFile.InitSaveFile(path);
ObjectFiles.Add(path, newJsonFile);
break;
default:
break;
}
}
/// <summary>
/// Push SaveObject data set to file
/// </summary>
public void SaveToFile(){
SaveToFile(DefaultSaveFile);
public void SetObject<TObject>(string path,string objectKey,TObject obj){
ObjectFiles[path].SetObject(objectKey,obj);
}
private void SaveToFile(string fileName){
File.WriteAllText(DefaultSaveFolder + "/" + fileName + ".json",JsonConvert.SerializeObject(SaveObject,Formatting.Indented));
public TObject GetObject<TObject>(string path,string key) where TObject : new(){
return ObjectFiles[path].GetObject<TObject>(key);
}
/// <summary>
/// Push data to SaveObject object cache, this function will not save data to file, if you hope not to IO operation frequently, you can use this with SaveToFile.
/// </summary>
/// <param name="data"></param>
/// <typeparam name="TData"></typeparam>
public void SetData<TData>(TData data){
//SaveObject = JObject.FromObject(data);
if(SaveObject.ContainsKey(typeof(TData).ToString())){
SaveObject[typeof(TData).ToString()] = JToken.FromObject(data);
}else{
SaveObject.Add(typeof(TData).ToString(),JToken.FromObject(data));
}
}
//------------------------------------------------------------------------------//
/// <summary>
/// Get data from file, if your data is not in file, then get null.
/// </summary>
/// <typeparam name="TData"></typeparam>
public TData GetDataByFile<TData>() where TData : class,new(){
if(!SaveObject.ContainsKey(typeof(TData).ToString())){
return null;
}
TData data = SaveObject[typeof(TData).ToString()].ToObject<TData>();
return data;
#region Default Json Operation
public void SetObjectToJson<TObject>(TObject obj){
ObjectFiles["Default/SaveData.json"].SetObject(typeof(TObject).ToString(),obj);
}
public TObject GetObjectFromJson<TObject>() where TObject : new(){
return ObjectFiles["Default/SaveData.json"].GetObject<TObject>(typeof(TObject).ToString());
}
#endregion
/// <summary>
/// Save data to file
/// </summary>
/// <param name="data">your any type of data</param>
/// <typeparam name="TData"></typeparam>
public void SetDataToFile<TData>(TData data)
{
SetData(data);
SaveToFile();
//------------------------------------------------------------------------------//
public void OpenResPath(){
OS.ShellOpen("".GetGodotResPath());
}
/// <summary>
/// Init a new save data file or load an other file with json suffix, if you want to load other save data, please use this function to reload;
/// </summary>
/// <param name="fileName"></param>
public void InitSaveData(string fileName)
{
DefaultSaveFile = fileName;
if(!File.Exists(DefaultSaveFolder + "/" + DefaultSaveFile + ".json")){
File.WriteAllText(DefaultSaveFolder + "/" + DefaultSaveFile + ".json","{}");
}
InitSaveObject();
public void OpenUserPath(){
OS.ShellOpen("".GetGodotUserPath());
}
}
}
public static class CanGetEGSaveExtension{
public static EGSave EGSave(this IEGFramework self){
return EGArchitectureImplement.Interface.GetModule<EGSave>();
return self.GetModule<EGSave>();
}
public static string GetGodotResPath(this string absPath){
return ProjectSettings.GlobalizePath("res://"+absPath);
}
public static string GetGodotUserPath(this string absPath){
return ProjectSettings.GlobalizePath("user://"+absPath);
}
}
}

4
addons/EGFramework/Module/SQL/EGSqlite.cs → addons/EGFramework/Module/SaveTools/EGSqlite.cs

@ -10,7 +10,7 @@ namespace EGFramework{ @@ -10,7 +10,7 @@ namespace EGFramework{
List<TData> GetDataSet<TData>() where TData : new();
void InitDatabase(string dataBaseName);
}
public class EGSqlite : EGModule,IEGSqlite
public class EGSqlite : EGModule
{
public string DBName = "Default";
private string DefaultDBFolder = "SaveData";
@ -81,6 +81,7 @@ namespace EGFramework{ @@ -81,6 +81,7 @@ namespace EGFramework{
string sqlCommand = "CREATE TABLE " + typeof(TData).Name;
sqlCommand += "(\"ID\" INTEGER NOT NULL UNIQUE,";
var properties = typeof(TData).GetFields();
Godot.GD.Print(properties.Count() + " Readed ");
foreach(var property in properties){
if(property.FieldType == typeof(int) || property.FieldType == typeof(bool) || property.FieldType.IsEnum){
sqlCommand += "\"" + property.Name + "\" INTEGER" + " NOT NULL,";
@ -92,6 +93,7 @@ namespace EGFramework{ @@ -92,6 +93,7 @@ namespace EGFramework{
}
}
sqlCommand += "PRIMARY KEY(\"ID\" AUTOINCREMENT))";
Godot.GD.Print(sqlCommand);
SqliteCommand createCommand = new SqliteCommand(sqlCommand,SqliteConn);
result = result + createCommand.ExecuteNonQuery().ToString();
}

23
addons/EGFramework/Module/SaveTools/SaveToolsInterface.cs

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EGFramework
{
public interface IEGSave{
void InitSaveFile(string path);
}
public interface IEGSaveObject{
void SetObject<TObject>(string objectKey,TObject obj);
TObject GetObject<TObject>(string objectKey) where TObject : new();
}
//
public interface IEGSaveData{
void SetData<TData>(TData data,string dataKey,int id);
TData GetData<TData>(string dataKey,int id) where TData : new();
IList<TData> QueryData<TData>(string dataKey,string sql) where TData : new();
}
}

54
addons/Tools/ItemImporter/ToolItemImporter.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
#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

37
addons/Tools/ItemImporter/ToolItemImporter.tscn

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
[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 = "重新载入"

7
addons/Tools/ItemImporter/plugin.cfg

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
[plugin]
name="ItemImporter"
description="a csv ItemImporter"
author="jkpete"
version=""
script="ToolItemImporter.cs"

13
icon.svg.import

@ -3,25 +3,26 @@ @@ -3,25 +3,26 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://31r216hix0wk"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"]
[params]
compress/mode=0
compress/mode=2
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/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@ -31,7 +32,7 @@ process/normal_map_invert_y=false @@ -31,7 +32,7 @@ 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
detect_3d/compress_to=0
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

64
project.godot

@ -12,7 +12,7 @@ config_version=5 @@ -12,7 +12,7 @@ config_version=5
config/name="EGFramework"
config/tags=PackedStringArray("official")
run/main_scene="res://Example/Tween/EGTween.tscn"
run/main_scene="res://Example/UsingTest/Scene/TestEGFramework.tscn"
config/features=PackedStringArray("4.2", "C#", "GL Compatibility")
config/icon="res://icon.svg"
@ -20,7 +20,67 @@ config/icon="res://icon.svg" @@ -20,7 +20,67 @@ config/icon="res://icon.svg"
project/assembly_name="EGFramework"
[editor_plugins]
enabled=PackedStringArray("res://addons/Tools/ItemImporter/plugin.cfg")
[input]
move_forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_back={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
camera_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
]
}
camera_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
camera_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
]
}
camera_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

Loading…
Cancel
Save