diff --git a/data/map project.tiled-project b/data/map project.tiled-project index d0eb592..597da78 100644 --- a/data/map project.tiled-project +++ b/data/map project.tiled-project @@ -10,5 +10,18 @@ "properties": [ ], "propertyTypes": [ + { + "id": 1, + "name": "npcInteractType", + "storageType": "string", + "type": "enum", + "values": [ + "NPC_INTERACT_TYPE_NONE", + "NPC_INTERACT_TYPE_TEXT", + "NPC_INTERACT_TYPE_CONVO", + "NPC_INTERACT_TYPE_EVENT" + ], + "valuesAsFlags": false + } ] } diff --git a/data/map project.tiled-session b/data/map project.tiled-session index 5672977..91a7991 100644 --- a/data/map project.tiled-session +++ b/data/map project.tiled-session @@ -1,5 +1,5 @@ { - "activeFile": "minogram.tsx", + "activeFile": "map.tmj", "expandedProjectPaths": [ "templates", "." @@ -16,8 +16,8 @@ "scale": 3, "selectedLayer": 2, "viewCenter": { - "x": 6520.166666666666, - "y": 6836.833333333333 + "x": 6585.833333333333, + "y": 6840.833333333333 } }, "minogram.tsx": { @@ -33,16 +33,14 @@ "last.imagePath": "/home/yourwishes/htdocs/dusk/data", "last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates", "openFiles": [ - "map.tmj", - "overworld.tsx", - "minogram.tsx" + "map.tmj" ], "project": "map project.tiled-project", - "property.type": "int", + "property.type": "string", "recentFiles": [ "map.tmj", - "overworld.tsx", "minogram.tsx", + "overworld.tsx", "entities.tsx" ], "tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)", diff --git a/data/map.tmj b/data/map.tmj index 0ffb465..27e0de4 100644 --- a/data/map.tmj +++ b/data/map.tmj @@ -410,12 +410,6 @@ "id":3, "name":"Object Layer 1", "objects":[ - { - "id":4, - "template":"templates\/NPC.tx", - "x":6650.41666666667, - "y":6753.58333333334 - }, { "gid":257, "height":16, @@ -425,32 +419,26 @@ "type":"player_spawn", "visible":true, "width":16, - "x":6384.58333333333, - "y":6846.91666666667 + "x":6578.25, + "y":6794.25 }, { - "id":7, + "id":13, + "properties":[ + { + "name":"interactText", + "type":"string", + "value":"test.npc.text" + }, + { + "name":"interactType", + "propertytype":"npcInteractType", + "type":"string", + "value":"NPC_INTERACT_TYPE_TEXT" + }], "template":"templates\/NPC.tx", - "x":6383.25, - "y":6880.08333333333 - }, - { - "id":8, - "template":"templates\/NPC.tx", - "x":6559, - "y":6754.75 - }, - { - "id":9, - "template":"templates\/NPC.tx", - "x":6376.33333333333, - "y":6720.33333333333 - }, - { - "id":10, - "template":"templates\/NPC.tx", - "x":6697, - "y":6769.08333333333 + "x":6575, + "y":6837.33333333333 }], "opacity":1, "type":"objectgroup", @@ -459,7 +447,7 @@ "y":0 }], "nextlayerid":6, - "nextobjectid":13, + "nextobjectid":14, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.11.1", diff --git a/data/templates/NPC.tx b/data/templates/NPC.tx index f76ec07..3a29790 100644 --- a/data/templates/NPC.tx +++ b/data/templates/NPC.tx @@ -1,5 +1,10 @@ diff --git a/src/dusk/entity/npc.c b/src/dusk/entity/npc.c index ae25d3b..88f32a2 100644 --- a/src/dusk/entity/npc.c +++ b/src/dusk/entity/npc.c @@ -5,7 +5,7 @@ * https://opensource.org/licenses/MIT */ -#include "npc.h" +#include "entity.h" #include "ui/uitextbox.h" #include "locale/language.h" #include "assert/assert.h" @@ -19,6 +19,25 @@ void npcUpdate(entity_t *entity) { } void npcInteract(entity_t *player, entity_t *self) { + assertTrue(self->type == ENTITY_TYPE_NPC, "Entity must be of type NPC"); + + switch(self->npc.interactType) { + case NPC_INTERACT_TYPE_NONE: + break; + + case NPC_INTERACT_TYPE_TEXT: + break; + + case NPC_INTERACT_TYPE_CONVO: + break; + + case NPC_INTERACT_TYPE_EVENT: + break; + + default: + assertUnreachable("Unknown NPC interaction type"); + } + // uiTextboxSetText( // "Hello World how are you today? Hope things are going well for you! I am " // "having a great day, hope you are too. Did I ever tell you about the tragedy " diff --git a/src/dusk/entity/npc.h b/src/dusk/entity/npc.h index 27c1717..cbc22de 100644 --- a/src/dusk/entity/npc.h +++ b/src/dusk/entity/npc.h @@ -4,8 +4,21 @@ typedef struct _entity_t entity_t; +#define NPC_INTERACT_TEXTS_MAX 4 + +typedef enum { + NPC_INTERACT_TYPE_NONE = 0, + NPC_INTERACT_TYPE_TEXT = 1, + NPC_INTERACT_TYPE_CONVO = 2, + NPC_INTERACT_TYPE_EVENT = 3, +} npcinteracttype_t; + typedef struct { - uint32_t nothing; + npcinteracttype_t interactType; + + union { + char_t* texts[NPC_INTERACT_TEXTS_MAX]; + }; } npc_t; /** diff --git a/tools/mapcompile/mapcompile.py b/tools/mapcompile/mapcompile.py index 08a044e..7b974b7 100644 --- a/tools/mapcompile/mapcompile.py +++ b/tools/mapcompile/mapcompile.py @@ -185,7 +185,6 @@ for layerIndex, layer in enumerate(tileLayers): # Pre generate entity data -nextEntityId = 100 for obIndex, ob in enumerate(objectLayer['objects']): if 'x' not in ob or 'y' not in ob: print(f"Error: Object in object layer does not contain 'x' or 'y' key.") @@ -200,8 +199,6 @@ for obIndex, ob in enumerate(objectLayer['objects']): # Round off the coordinates ob['x'] = round(ob['x']) ob['y'] = round(ob['y']) - ob['id'] = nextEntityId - nextEntityId += 1 objectLayer['objects'][obIndex] = ob