Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5636c0da67 | |||
| 4578a2cfda |
Generated
-1
@@ -1 +0,0 @@
|
||||
Babushka
|
||||
@@ -1,3 +0,0 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="project" />
|
||||
</component>
|
||||
@@ -8,7 +8,4 @@
|
||||
<Folder Include="prefabs\UI\Inventory\" />
|
||||
<Folder Include="scripts\CSharp\Low Code\Randomizer\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="SpineSkeletonDataResource" load_steps=3 format=3 uid="uid://b8320gi2iry7e"]
|
||||
|
||||
[ext_resource type="SpineAtlasResource" uid="uid://bp5dm6ppdxyfy" path="res://art/animation/Cat/sk_cat.atlas" id="1_silct"]
|
||||
[ext_resource type="SpineSkeletonFileResource" uid="uid://dj4q5ov01nmar" path="res://art/animation/Cat/sk_cat.skel" id="2_bwfy5"]
|
||||
|
||||
[resource]
|
||||
atlas_res = ExtResource("1_silct")
|
||||
skeleton_file_res = ExtResource("2_bwfy5")
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cdqhc3rpjiod2"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://b8320gi2iry7e" path="res://art/animation/Cat/cat.tres" id="1_x424w"]
|
||||
|
||||
[node name="Cat" type="Node2D"]
|
||||
|
||||
[node name="SpineSprite" type="SpineSprite" parent="."]
|
||||
skeleton_data_res = ExtResource("1_x424w")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "Idle"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
@@ -0,0 +1,29 @@
|
||||
sk_cat.png
|
||||
size:4930,1270
|
||||
filter:Linear,Linear
|
||||
pma:true
|
||||
cat_backleg_lower
|
||||
bounds:0,0,72,113
|
||||
cat_backleg_upper
|
||||
bounds:493,0,181,200
|
||||
offsets:0,1,181,201
|
||||
cat_body
|
||||
bounds:986,0,493,349
|
||||
cat_eyeball
|
||||
bounds:1479,0,302,155
|
||||
cat_eyelashes
|
||||
bounds:1972,0,331,160
|
||||
cat_frontleg_lower
|
||||
bounds:2465,0,84,115
|
||||
offsets:0,1,84,116
|
||||
cat_frontleg_upper
|
||||
bounds:2958,0,76,169
|
||||
cat_head
|
||||
bounds:3451,0,422,575
|
||||
offsets:0,2,422,577
|
||||
cat_leg
|
||||
bounds:3944,0,218,635
|
||||
cat_nose
|
||||
bounds:4437,0,294,93
|
||||
cat_pupil
|
||||
bounds:0,635,235,117
|
||||
@@ -0,0 +1,16 @@
|
||||
[remap]
|
||||
|
||||
importer="spine.atlas"
|
||||
type="SpineAtlasResource"
|
||||
uid="uid://bp5dm6ppdxyfy"
|
||||
path="res://.godot/imported/sk_cat.atlas-209e52708ae51512bd5a9c13ecef821d.spatlas"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/animation/Cat/sk_cat.atlas"
|
||||
dest_files=["res://.godot/imported/sk_cat.atlas-209e52708ae51512bd5a9c13ecef821d.spatlas"]
|
||||
|
||||
[params]
|
||||
|
||||
normal_map_prefix="n"
|
||||
specular_map_prefix="s"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 515 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bxbae280ae8yv"
|
||||
path="res://.godot/imported/sk_cat.png-400ad3198e50487a16cece95aef9c056.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/animation/Cat/sk_cat.png"
|
||||
dest_files=["res://.godot/imported/sk_cat.png-400ad3198e50487a16cece95aef9c056.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
|
||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
[remap]
|
||||
|
||||
importer="spine.skel"
|
||||
type="SpineSkeletonFileResource"
|
||||
uid="uid://dj4q5ov01nmar"
|
||||
path="res://.godot/imported/sk_cat.skel-040dd3b0902fe4467d3f597cd8205232.spskel"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/animation/Cat/sk_cat.skel"
|
||||
dest_files=["res://.godot/imported/sk_cat.skel-040dd3b0902fe4467d3f597cd8205232.spskel"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -4,22 +4,19 @@ importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://b3kyrsoobmkhp"
|
||||
path="res://.godot/imported/best_house_blender.blend-ac89c74aef2f275bdf4b4baadee17c0c.scn"
|
||||
valid=false
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/mockups/3d/best_house_blender.blend"
|
||||
dest_files=["res://.godot/imported/best_house_blender.blend-ac89c74aef2f275bdf4b4baadee17c0c.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/root_script=null
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_name_suffixes=true
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
@@ -34,9 +31,6 @@ animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
blender/nodes/visible=0
|
||||
blender/nodes/active_collection_only=false
|
||||
@@ -56,4 +50,3 @@ blender/materials/export_materials=1
|
||||
blender/animation/limit_playback=true
|
||||
blender/animation/always_sample=true
|
||||
blender/animation/group_tracks=true
|
||||
gltf/naming_version=0
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libspine_godot.ios.template_debug</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>spine-godot</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.esotericsoftware.spine.spine-godot</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4.2.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.0</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>DTPlatformName</key>
|
||||
<string>iphoneos</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libspine_godot.ios.template_release</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>spine-godot</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.esotericsoftware.spine.spine-godot</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4.2.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.0</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>DTPlatformName</key>
|
||||
<string>iphoneos</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libspine_godot.macos.editor</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>spine-godot</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.esotericsoftware.spine.spine-godot</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4.2.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.12</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libspine_godot.macos.template_debug</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>spine-godot</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.esotericsoftware.spine.spine-godot</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4.2.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.12</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libspine_godot.macos.template_release</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>spine-godot</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.esotericsoftware.spine.spine-godot</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4.2.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.12</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "spine_godot_library_init"
|
||||
compatibility_minimum = "4.1"
|
||||
|
||||
[libraries]
|
||||
|
||||
macos.editor = "macos/libspine_godot.macos.editor.framework"
|
||||
macos.debug = "macos/libspine_godot.macos.template_debug.framework"
|
||||
macos.release = "macos/libspine_godot.macos.template_release.framework"
|
||||
|
||||
ios.debug = "ios/libspine_godot.ios.template_debug.framework"
|
||||
ios.release = "ios/libspine_godot.ios.template_release.framework"
|
||||
|
||||
windows.editor.x86_64 = "windows/libspine_godot.windows.editor.x86_64.dll"
|
||||
windows.debug.x86_64 = "windows/libspine_godot.windows.template_debug.x86_64.dll"
|
||||
windows.release.x86_64 = "windows/libspine_godot.windows.template_release.x86_64.dll"
|
||||
|
||||
linux.editor.x86_64 = "linux/libspine_godot.linux.editor.x86_64.so"
|
||||
linux.debug.x86_64 = "linux/libspine_godot.linux.template_debug.x86_64.so"
|
||||
linux.release.x86_64 = "linux/libspine_godot.linux.template_release.x86_64.so"
|
||||
|
||||
linux.editor.arm64 = "linux/libspine_godot.linux.editor.arm64.so"
|
||||
linux.debug.arm64 = "linux/libspine_godot.linux.template_debug.arm64.so"
|
||||
linux.release.arm64 = "linux/libspine_godot.linux.template_release.arm64.so"
|
||||
|
||||
linux.editor.rv64 = "linux/libspine_godot.linux.editor.rv64.so"
|
||||
linux.debug.rv64 = "linux/libspine_godot.linux.template_debug.rv64.so"
|
||||
linux.release.rv64 = "linux/libspine_godot.linux.template_release.rv64.so"
|
||||
|
||||
android.debug.x86_64 = "android/libspine_godot.android.template_debug.x86_64.so"
|
||||
android.release.x86_64 = "android/libspine_godot.android.template_release.x86_64.so"
|
||||
|
||||
android.debug.arm64 = "android/libspine_godot.android.template_debug.arm64.so"
|
||||
android.release.arm64 = "android/libspine_godot.android.template_release.arm64.so"
|
||||
|
||||
web.debug.threads.wasm32 = "web/libspine_godot.web.template_debug.wasm32.wasm"
|
||||
web.release.threads.wasm32 = "web/libspine_godot.web.template_release.wasm32.wasm"
|
||||
web.debug.wasm32 = "web/libspine_godot.web.template_debug.wasm32.nothreads.wasm"
|
||||
web.release.wasm32 = "web/libspine_godot.web.template_release.wasm32.nothreads.wasm"
|
||||
@@ -0,0 +1 @@
|
||||
uid://cjp18u5g8vh2o
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
-3
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="Babushka"
|
||||
run/main_scene="uid://66pmq4efjip8"
|
||||
run/main_scene="uid://bopv10dqm1knc"
|
||||
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
|
||||
run/max_fps=120
|
||||
boot_splash/fullsize=false
|
||||
@@ -141,6 +141,7 @@ directories/tres_directory={
|
||||
"beet": "res://resources/items/beet.tres",
|
||||
"beetRoot": "res://resources/quests/beetRoot.tres",
|
||||
"beet_seed": "res://resources/items/beet_seed.tres",
|
||||
"cat": "res://art/animation/Cat/cat.tres",
|
||||
"choice_panel_focus": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_focus.tres",
|
||||
"choice_panel_hover": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_hover.tres",
|
||||
"choice_panel_normal": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_normal.tres",
|
||||
@@ -188,8 +189,6 @@ directories/tres_directory={
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/size/window_width_override=1200
|
||||
window/size/window_height_override=720
|
||||
window/stretch/mode="viewport"
|
||||
window/stretch/aspect="keep_height"
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -186,7 +186,7 @@ public partial class PlantBehaviour2D : Node2D
|
||||
|
||||
private void SetActiveHarvestablePlant(bool active)
|
||||
{
|
||||
//_harvestablePlant.IsActive = active;
|
||||
_harvestablePlant.IsActive = active;
|
||||
_harvestablePlant.UpdateVisuals();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
using Godot;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
// Do not instantiate this resource
|
||||
// But it has to be a resource because Godot
|
||||
[GlobalClass]
|
||||
public partial class ItemInstance : Resource, IJsonSerializable
|
||||
public partial class ItemInstance: Resource
|
||||
{
|
||||
[Export] public required ItemResource blueprint;
|
||||
[Export] public int amount = 1;
|
||||
@@ -20,18 +17,4 @@ public partial class ItemInstance : Resource, IJsonSerializable
|
||||
amount = amount
|
||||
};
|
||||
}
|
||||
|
||||
public void LoadFromJson(JObject json)
|
||||
{
|
||||
var blueprintPath = json.GetStringValue("blueprint");
|
||||
blueprint = GD.Load<ItemResource>(blueprintPath);
|
||||
amount = json.GetIntValue("amount");
|
||||
}
|
||||
|
||||
public JObject SaveToJson()
|
||||
{
|
||||
return new(
|
||||
new JProperty("blueprint", blueprint.ResourcePath),
|
||||
new JProperty("amount", amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
using Babushka.scripts.CSharp.Common.Savegame;
|
||||
using Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
public partial class ItemOnGround2D : PositionalEntity
|
||||
public partial class ItemOnGround2D : Node, ISaveable
|
||||
{
|
||||
private ItemInstance _itemInstance;
|
||||
|
||||
[Export] public bool IsActive = true;
|
||||
[Export] private bool _infiniteSupply = false;
|
||||
[Export] private int _finiteSupply = 1;
|
||||
[Export] private bool _saveToDisk = true;
|
||||
|
||||
private int pickUpCounter = 0;
|
||||
|
||||
[Signal] public delegate void SuccessfulPickUpEventHandler();
|
||||
|
||||
|
||||
|
||||
private Label _itemLabel => GetNode<Label>("ItemLabel");
|
||||
private Label _pickupErrorLabel => GetNode<Label>("PickupErrorLabel");
|
||||
private Sprite2D _iconSprite => GetNode<Sprite2D>("Icon");
|
||||
@@ -30,12 +34,16 @@ public partial class ItemOnGround2D : PositionalEntity
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
LoadFromSaveData();
|
||||
UpdateVisuals();
|
||||
_pickupErrorLabel.Text = "";
|
||||
}
|
||||
|
||||
public void TryPickUp()
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
var result = InventoryManager.Instance.CollectItem(itemInstance.Clone());
|
||||
EmitSignal(SignalName.SuccessfulPickUp);
|
||||
if (result == InventoryActionResult.Success)
|
||||
@@ -50,7 +58,16 @@ public partial class ItemOnGround2D : PositionalEntity
|
||||
|
||||
private void Pickup()
|
||||
{
|
||||
// remove from entity manager
|
||||
if (!_infiniteSupply)
|
||||
{
|
||||
pickUpCounter++;
|
||||
if (pickUpCounter >= _finiteSupply)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
UpdateSaveData();
|
||||
}
|
||||
}
|
||||
|
||||
private void FailToPickup()
|
||||
@@ -63,6 +80,9 @@ public partial class ItemOnGround2D : PositionalEntity
|
||||
|
||||
public void UpdateVisuals()
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
_iconSprite.Texture = itemInstance?.blueprint?.icon;
|
||||
if (_iconSprite.Texture == null)
|
||||
{
|
||||
@@ -74,20 +94,7 @@ public partial class ItemOnGround2D : PositionalEntity
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadEntity(JObject json)
|
||||
{
|
||||
base.LoadEntity(json);
|
||||
_itemInstance.LoadFromJson(json.GetObject("item"));
|
||||
}
|
||||
|
||||
protected override void SaveEntity(JObject json)
|
||||
{
|
||||
base.SaveEntity(json);
|
||||
json["item"] = _itemInstance.SaveToJson();
|
||||
}
|
||||
|
||||
// old save
|
||||
/*
|
||||
// todo: What do we do with instances that are created at runtime?
|
||||
public void UpdateSaveData()
|
||||
{
|
||||
if (!_saveToDisk)
|
||||
@@ -150,5 +157,5 @@ public partial class ItemOnGround2D : PositionalEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
using Godot;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
using Babushka.scripts.CSharp.GameEntity.Types;
|
||||
using Godot;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
|
||||
public partial class Entity : Node2D
|
||||
{
|
||||
private long _id;
|
||||
protected virtual EntityType Type => EntityType.None;
|
||||
|
||||
protected virtual void SaveEntity(JObject json)
|
||||
{
|
||||
json["id"] = _id;
|
||||
json["type"] = (int)Type;
|
||||
}
|
||||
|
||||
protected virtual void LoadEntity(JObject json)
|
||||
{
|
||||
_id = json.GetLongValue("id");
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://hnmpt23ovfgl
|
||||
@@ -1,27 +0,0 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
using Godot;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
|
||||
public partial class PositionalEntity : Entity
|
||||
{
|
||||
public string sceneName = "none";
|
||||
|
||||
protected override void SaveEntity(JObject json)
|
||||
{
|
||||
base.SaveEntity(json);
|
||||
json["posx"] = Position.X;
|
||||
json["posy"] = Position.Y;
|
||||
json["scene"] = sceneName;
|
||||
}
|
||||
|
||||
protected override void LoadEntity(JObject json)
|
||||
{
|
||||
base.LoadEntity(json);
|
||||
Position = new Vector2(
|
||||
json.GetFloatValue("posx"),
|
||||
json.GetFloatValue("posy"));
|
||||
sceneName = json.GetStringValue("scene");
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://bs38dulqv7sop
|
||||
@@ -1,44 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
|
||||
public static class EntityLoadSaveUtil
|
||||
{
|
||||
private static void AssertTokenType(this JObject json, string key, JTokenType type)
|
||||
{
|
||||
var token = json[key];
|
||||
if (token == null) throw new MalformedJsonException(json, key, "does not exist");
|
||||
if (!token.HasValues) throw new MalformedJsonException(json, key, "has no value");
|
||||
if (token.Type != type) throw new MalformedJsonException(json, key, $"is not of type {type}");
|
||||
}
|
||||
|
||||
public static long GetLongValue(this JObject json, string key)
|
||||
{
|
||||
AssertTokenType(json, key, JTokenType.Integer);
|
||||
return json.Value<long>(key);
|
||||
}
|
||||
|
||||
public static int GetIntValue(this JObject json, string key)
|
||||
{
|
||||
AssertTokenType(json, key, JTokenType.Integer);
|
||||
return json.Value<int>(key);
|
||||
}
|
||||
|
||||
public static float GetFloatValue(this JObject json, string key)
|
||||
{
|
||||
AssertTokenType(json, key, JTokenType.Float);
|
||||
return json.Value<float>(key);
|
||||
}
|
||||
|
||||
public static JObject GetObject(this JObject json, string key)
|
||||
{
|
||||
AssertTokenType(json, key, JTokenType.Object);
|
||||
return json.Value<JObject>(key)!;
|
||||
}
|
||||
|
||||
public static string GetStringValue(this JObject json, string key)
|
||||
{
|
||||
AssertTokenType(json, key, JTokenType.String);
|
||||
return json.Value<string>(key)!;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://ccu6p418viliu
|
||||
@@ -1,9 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
|
||||
public interface IJsonSerializable
|
||||
{
|
||||
public void LoadFromJson(JObject json);
|
||||
public JObject SaveToJson();
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://cuma3347l55mb
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
|
||||
public class MalformedJsonException(JObject actualJson, string key, string problem) : Exception
|
||||
{
|
||||
public override string Message => $"JsonObject was malformed: {key} {problem}";
|
||||
public override IDictionary Data => new Dictionary<string, JObject> { { "json", actualJson } };
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://d1o066hh84ow
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.GameEntity.Types;
|
||||
using Godot;
|
||||
using Entity = Babushka.scripts.CSharp.GameEntity.Entities.Entity;
|
||||
using PositionalEntity = Babushka.scripts.CSharp.GameEntity.Entities.PositionalEntity;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Management;
|
||||
|
||||
public partial class EntityManager : Node
|
||||
{
|
||||
[Export] private EntityNodeCreator _nodeCreator = null!;
|
||||
|
||||
private EntitySceneManager? _currentEntitySceneManager;
|
||||
|
||||
|
||||
private readonly List<Entity> _allEntities = new();
|
||||
|
||||
public IEnumerable<Entity> AllEntities => _allEntities;
|
||||
|
||||
public IEnumerable<PositionalEntity> AllPositionalEntities => _allEntities.OfType<PositionalEntity>();
|
||||
|
||||
public T NewPositionalEntity<T>(EntityType type, Vector2 position, string? scene = null) where T : PositionalEntity
|
||||
{
|
||||
if (scene == null)
|
||||
{
|
||||
if (_currentEntitySceneManager == null)
|
||||
throw new Exception("No current scene. Specify scene to spawn an entity");
|
||||
|
||||
scene = _currentEntitySceneManager.sceneName;
|
||||
}
|
||||
|
||||
var newEntity = _nodeCreator.Create<T>(type);
|
||||
newEntity.Position = position;
|
||||
newEntity.sceneName = scene;
|
||||
_allEntities.Add(newEntity);
|
||||
|
||||
_currentEntitySceneManager.AddIfNeeded(newEntity);
|
||||
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public void UnloadScene()
|
||||
{
|
||||
if (_currentEntitySceneManager == null) return;
|
||||
_currentEntitySceneManager.RemoveAllEntities();
|
||||
_currentEntitySceneManager = null;
|
||||
}
|
||||
|
||||
public void LoadScene(EntitySceneManager sceneManager)
|
||||
{
|
||||
_currentEntitySceneManager = sceneManager;
|
||||
foreach (var entity in AllPositionalEntities)
|
||||
{
|
||||
_currentEntitySceneManager.AddIfNeeded(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://umop2b1m1qm8
|
||||
@@ -1,14 +0,0 @@
|
||||
using PositionalEntity = Babushka.scripts.CSharp.GameEntity.Entities.PositionalEntity;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Management;
|
||||
|
||||
public static class EntityManagerUtil
|
||||
{
|
||||
public static void AddIfNeeded(this EntitySceneManager? self, PositionalEntity entity)
|
||||
{
|
||||
if(self == null) return;
|
||||
if(self.sceneName != entity.sceneName) return;
|
||||
|
||||
self.AddEntity(entity);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://dc3283h7sx4cl
|
||||
@@ -1,16 +0,0 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.Types;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using Entity = Babushka.scripts.CSharp.GameEntity.Entities.Entity;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Management;
|
||||
|
||||
public partial class EntityNodeCreator : Node
|
||||
{
|
||||
[Export] private Dictionary<EntityType, PackedScene> _entityPrefabs;
|
||||
|
||||
public T Create<T>(EntityType type) where T:Entity
|
||||
{
|
||||
return _entityPrefabs[type].Instantiate<T>();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://bogqp274y1pgr
|
||||
@@ -1,25 +0,0 @@
|
||||
using Godot;
|
||||
using PositionalEntity = Babushka.scripts.CSharp.GameEntity.Entities.PositionalEntity;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Management;
|
||||
|
||||
public partial class EntitySceneManager : Node2D
|
||||
{
|
||||
[Export] public string sceneName = "none";
|
||||
|
||||
public void AddEntity(PositionalEntity entity)
|
||||
{
|
||||
AddChild(entity);
|
||||
}
|
||||
|
||||
public void RemoveAllEntities()
|
||||
{
|
||||
foreach (var entity in GetChildren())
|
||||
{
|
||||
if (entity is PositionalEntity positionalEntity)
|
||||
{
|
||||
RemoveChild(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://ca1pg6k3gn47y
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Types;
|
||||
|
||||
public enum EntityType
|
||||
{
|
||||
None = 0,
|
||||
Yeli = 1,
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://cjygyr4lc224m
|
||||
@@ -1,16 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Babushka.scripts.CSharp.mock;
|
||||
|
||||
public static class DialogicStarter
|
||||
{
|
||||
public static async Task Dialog(string dialog)
|
||||
{
|
||||
// implement
|
||||
}
|
||||
|
||||
public static void SetValue(string key, int value)
|
||||
{
|
||||
// implement
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Babushka.scripts.CSharp.mock;
|
||||
|
||||
public static class ObjectLookup
|
||||
{
|
||||
// Referenzen werden bei startup gesetzt
|
||||
|
||||
// Quests
|
||||
public static PotatoQuest potatoQuest;
|
||||
|
||||
// NPCs
|
||||
public static YeliNpc yeliNpc;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.mock;
|
||||
|
||||
public partial class PotatoQuest:Node
|
||||
{
|
||||
// Yeli will 5 kartoffeln haben.
|
||||
// Man kann Yeli auch erstmal weniger geben.
|
||||
// Yeli sagt dir dann, wie viele kartoffeln noch fehlen.
|
||||
|
||||
public enum State
|
||||
{
|
||||
Unavailable, // bevor die quest verfügbar ist
|
||||
YeliRequest, // Yeli fragt nach kartoffeln
|
||||
BringPotato, // Vesna soll kartoffeln bringen
|
||||
Done // kartoffeln abgegeben
|
||||
}
|
||||
|
||||
public State state = State.Unavailable;
|
||||
public int potatoesWanted = 5;
|
||||
public int potatoesBrought = 0;
|
||||
public ItemResource itemBlueprint; // potato item
|
||||
|
||||
public void Activate() // wird von woanders aufgerufen
|
||||
{
|
||||
if (state == State.Unavailable)
|
||||
state = State.YeliRequest;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://dpl5xeuiu7cwg
|
||||
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Babushka.scripts.CSharp.Common.NPC;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.mock;
|
||||
|
||||
// Dieses script enthält ALLE möglichen dialogoptionen die Yeli in der gesamten Demo hat.
|
||||
// Das script ist dafür verantwortlich den richtigen Dialog zu starten.
|
||||
public partial class YeliDialog : Node
|
||||
{
|
||||
public async void StartDialog() // kann zu jedem zeitpunkt vom spieler getriggert werden
|
||||
{
|
||||
var potato = ObjectLookup.potatoQuest;
|
||||
var yeli = ObjectLookup.yeliNpc;
|
||||
var inventory = InventoryManager.Instance.playerInventory!;
|
||||
|
||||
if (yeli.isSleeping) // wenn yeli schläft kann keine quest von ihr angenommen werden, auch wenn die quest verfügbar ist
|
||||
{
|
||||
await DialogicStarter.Dialog("YeliSleep"); // "ZZZ"
|
||||
}
|
||||
else if (potato.state == PotatoQuest.State.YeliRequest)
|
||||
{
|
||||
await DialogicStarter.Dialog("YeliAskForPotato"); // "Can you bring me 5 potatoes?"
|
||||
potato.state = PotatoQuest.State.BringPotato;
|
||||
}
|
||||
else if (potato.state == PotatoQuest.State.BringPotato)
|
||||
{
|
||||
var potatoesTodo = potato.potatoesWanted - potato.potatoesBrought;
|
||||
var potatoesAvailable = inventory.TotalItemsOfBlueprint(potato.itemBlueprint);
|
||||
var takePotatoes = Math.Min(potatoesTodo, potatoesAvailable);
|
||||
|
||||
inventory.TryRemoveAllItems(new ItemInstance
|
||||
{ blueprint = potato.itemBlueprint, amount = takePotatoes }); // should not fail
|
||||
potato.potatoesWanted -= takePotatoes;
|
||||
|
||||
potatoesTodo = potato.potatoesWanted - potato.potatoesBrought;
|
||||
|
||||
var isComplete = potatoesTodo <= 0;
|
||||
var wasSomeDelivered = takePotatoes > 0;
|
||||
|
||||
if (isComplete)
|
||||
{
|
||||
await DialogicStarter.Dialog("YeliPotatoThankYou"); // "thanks for bringing me all the potatoes"
|
||||
potato.state = PotatoQuest.State.Done;
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogicStarter.SetValue("potatoes", potatoesTodo); // setzt die Dialogic variable
|
||||
|
||||
if (wasSomeDelivered)
|
||||
{
|
||||
await DialogicStarter.Dialog("YeliPotatoThanksButMore"); // "thank you but i need {potatoes} more potatoes"
|
||||
}
|
||||
else
|
||||
{
|
||||
await DialogicStarter.Dialog("YeliPotatoMore"); // "I still need {potatoes} more potatoes"
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await DialogicStarter.Dialog("YeliDefault"); // "I'm happy to have you around" oder so
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://ssob0ssvbskx
|
||||
@@ -1,9 +0,0 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
|
||||
namespace Babushka.scripts.CSharp.mock;
|
||||
|
||||
public partial class YeliNpc : Entity
|
||||
{
|
||||
public bool isSleeping = false;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user