Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b50ca5b919 | |||
| 3456340bb7 |
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>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 652 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dc1xim3mqlj1o"
|
||||
path="res://.godot/imported/angry.png-e4eff51de743a11598498a3e284ae0a1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/characters/Vesna/angry.png"
|
||||
dest_files=["res://.godot/imported/angry.png-e4eff51de743a11598498a3e284ae0a1.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.
|
After Width: | Height: | Size: 650 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bhd8ui4bdauoq"
|
||||
path="res://.godot/imported/sad.png-07f44c713781510c0fa11821d4fa50bc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/characters/Vesna/sad.png"
|
||||
dest_files=["res://.godot/imported/sad.png-07f44c713781510c0fa11821d4fa50bc.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.
|
After Width: | Height: | Size: 649 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://4xvgqwrwh3vw"
|
||||
path="res://.godot/imported/smile.png-2ef625357927edd0d495bf554ac57e21.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/characters/Vesna/smile.png"
|
||||
dest_files=["res://.godot/imported/smile.png-2ef625357927edd0d495bf554ac57e21.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.
|
After Width: | Height: | Size: 648 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dcxkqut5edp2b"
|
||||
path="res://.godot/imported/surprise.png-79afea119cbe923f9aa9e4554a23ed80.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/characters/Vesna/surprise.png"
|
||||
dest_files=["res://.godot/imported/surprise.png-79afea119cbe923f9aa9e4554a23ed80.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.
|
After Width: | Height: | Size: 651 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ing4qavovh4r"
|
||||
path="res://.godot/imported/surprised.png-ab52144d1f41186a697c9a0e1584b3ee.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/characters/Vesna/surprised.png"
|
||||
dest_files=["res://.godot/imported/surprised.png-ab52144d1f41186a697c9a0e1584b3ee.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
|
||||
@@ -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
|
||||
|
||||
@@ -26,6 +26,15 @@
|
||||
&"nicknames": ["vesna"],
|
||||
&"offset": Vector2(-300, 0),
|
||||
&"portraits": {
|
||||
"angry": {
|
||||
"export_overrides": {
|
||||
"image": "\"res://art/characters/Vesna/angry.png\""
|
||||
},
|
||||
"mirror": false,
|
||||
"offset": Vector2(150, 0),
|
||||
"scale": 0.65,
|
||||
"scene": ""
|
||||
},
|
||||
"front": {
|
||||
"export_overrides": {
|
||||
"image": "\"res://art/animation/Vesna2D/Vesna Anims Sequences/F01-Idle/0001.png\""
|
||||
@@ -52,6 +61,42 @@
|
||||
"offset": Vector2(0, 0),
|
||||
"scale": 1.0,
|
||||
"scene": ""
|
||||
},
|
||||
"sad": {
|
||||
"export_overrides": {
|
||||
"image": "\"res://art/characters/Vesna/sad.png\""
|
||||
},
|
||||
"mirror": false,
|
||||
"offset": Vector2(150, 0),
|
||||
"scale": 0.65,
|
||||
"scene": ""
|
||||
},
|
||||
"smile": {
|
||||
"export_overrides": {
|
||||
"image": "\"res://art/characters/Vesna/smile.png\""
|
||||
},
|
||||
"mirror": false,
|
||||
"offset": Vector2(150, 0),
|
||||
"scale": 0.65,
|
||||
"scene": ""
|
||||
},
|
||||
"surprise": {
|
||||
"export_overrides": {
|
||||
"image": "\"res://art/characters/Vesna/surprise.png\""
|
||||
},
|
||||
"mirror": false,
|
||||
"offset": Vector2(150, 0),
|
||||
"scale": 0.65,
|
||||
"scene": ""
|
||||
},
|
||||
"surprised": {
|
||||
"export_overrides": {
|
||||
"image": "\"res://art/characters/Vesna/surprised.png\""
|
||||
},
|
||||
"mirror": false,
|
||||
"offset": Vector2(150, 0),
|
||||
"scale": 0.65,
|
||||
"scene": ""
|
||||
}
|
||||
},
|
||||
&"scale": 1.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
join Yeli right
|
||||
join vesna left
|
||||
join vesna (surprise) left
|
||||
[quest_complete quest_resource="res://resources/quests/demo/1_talk_yeli_1.tres"]
|
||||
Yeli (_part_side): Come here, you little quacking beast!
|
||||
- What a mess!
|
||||
|
||||
+1
-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
|
||||
@@ -188,8 +188,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