Abt to update mapcompile into files
This commit is contained in:
@ -10,5 +10,18 @@
|
|||||||
"properties": [
|
"properties": [
|
||||||
],
|
],
|
||||||
"propertyTypes": [
|
"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
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"activeFile": "minogram.tsx",
|
"activeFile": "map.tmj",
|
||||||
"expandedProjectPaths": [
|
"expandedProjectPaths": [
|
||||||
"templates",
|
"templates",
|
||||||
"."
|
"."
|
||||||
@ -16,8 +16,8 @@
|
|||||||
"scale": 3,
|
"scale": 3,
|
||||||
"selectedLayer": 2,
|
"selectedLayer": 2,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 6520.166666666666,
|
"x": 6585.833333333333,
|
||||||
"y": 6836.833333333333
|
"y": 6840.833333333333
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minogram.tsx": {
|
"minogram.tsx": {
|
||||||
@ -33,16 +33,14 @@
|
|||||||
"last.imagePath": "/home/yourwishes/htdocs/dusk/data",
|
"last.imagePath": "/home/yourwishes/htdocs/dusk/data",
|
||||||
"last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates",
|
"last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates",
|
||||||
"openFiles": [
|
"openFiles": [
|
||||||
"map.tmj",
|
"map.tmj"
|
||||||
"overworld.tsx",
|
|
||||||
"minogram.tsx"
|
|
||||||
],
|
],
|
||||||
"project": "map project.tiled-project",
|
"project": "map project.tiled-project",
|
||||||
"property.type": "int",
|
"property.type": "string",
|
||||||
"recentFiles": [
|
"recentFiles": [
|
||||||
"map.tmj",
|
"map.tmj",
|
||||||
"overworld.tsx",
|
|
||||||
"minogram.tsx",
|
"minogram.tsx",
|
||||||
|
"overworld.tsx",
|
||||||
"entities.tsx"
|
"entities.tsx"
|
||||||
],
|
],
|
||||||
"tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)",
|
"tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)",
|
||||||
|
48
data/map.tmj
48
data/map.tmj
@ -410,12 +410,6 @@
|
|||||||
"id":3,
|
"id":3,
|
||||||
"name":"Object Layer 1",
|
"name":"Object Layer 1",
|
||||||
"objects":[
|
"objects":[
|
||||||
{
|
|
||||||
"id":4,
|
|
||||||
"template":"templates\/NPC.tx",
|
|
||||||
"x":6650.41666666667,
|
|
||||||
"y":6753.58333333334
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"gid":257,
|
"gid":257,
|
||||||
"height":16,
|
"height":16,
|
||||||
@ -425,32 +419,26 @@
|
|||||||
"type":"player_spawn",
|
"type":"player_spawn",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":16,
|
"width":16,
|
||||||
"x":6384.58333333333,
|
"x":6578.25,
|
||||||
"y":6846.91666666667
|
"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",
|
"template":"templates\/NPC.tx",
|
||||||
"x":6383.25,
|
"x":6575,
|
||||||
"y":6880.08333333333
|
"y":6837.33333333333
|
||||||
},
|
|
||||||
{
|
|
||||||
"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
|
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
@ -459,7 +447,7 @@
|
|||||||
"y":0
|
"y":0
|
||||||
}],
|
}],
|
||||||
"nextlayerid":6,
|
"nextlayerid":6,
|
||||||
"nextobjectid":13,
|
"nextobjectid":14,
|
||||||
"orientation":"orthogonal",
|
"orientation":"orthogonal",
|
||||||
"renderorder":"right-down",
|
"renderorder":"right-down",
|
||||||
"tiledversion":"1.11.1",
|
"tiledversion":"1.11.1",
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<template>
|
<template>
|
||||||
<tileset firstgid="1" source="../entities.tsx"/>
|
<tileset firstgid="1" source="../entities.tsx"/>
|
||||||
<object name="NPC" type="npc" gid="1" width="16" height="16"/>
|
<object name="NPC" type="ENTITY_TYPE_NPC" gid="1" width="16" height="16">
|
||||||
|
<properties>
|
||||||
|
<property name="interactText" value=""/>
|
||||||
|
<property name="interactType" propertytype="npcInteractType" value="NPC_INTERACT_TYPE_NONE"/>
|
||||||
|
</properties>
|
||||||
|
</object>
|
||||||
</template>
|
</template>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "npc.h"
|
#include "entity.h"
|
||||||
#include "ui/uitextbox.h"
|
#include "ui/uitextbox.h"
|
||||||
#include "locale/language.h"
|
#include "locale/language.h"
|
||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
@ -19,6 +19,25 @@ void npcUpdate(entity_t *entity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void npcInteract(entity_t *player, entity_t *self) {
|
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(
|
// uiTextboxSetText(
|
||||||
// "Hello World how are you today? Hope things are going well for you! I am "
|
// "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 "
|
// "having a great day, hope you are too. Did I ever tell you about the tragedy "
|
||||||
|
@ -4,8 +4,21 @@
|
|||||||
|
|
||||||
typedef struct _entity_t entity_t;
|
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 {
|
typedef struct {
|
||||||
uint32_t nothing;
|
npcinteracttype_t interactType;
|
||||||
|
|
||||||
|
union {
|
||||||
|
char_t* texts[NPC_INTERACT_TEXTS_MAX];
|
||||||
|
};
|
||||||
} npc_t;
|
} npc_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,7 +185,6 @@ for layerIndex, layer in enumerate(tileLayers):
|
|||||||
|
|
||||||
|
|
||||||
# Pre generate entity data
|
# Pre generate entity data
|
||||||
nextEntityId = 100
|
|
||||||
for obIndex, ob in enumerate(objectLayer['objects']):
|
for obIndex, ob in enumerate(objectLayer['objects']):
|
||||||
if 'x' not in ob or 'y' not in ob:
|
if 'x' not in ob or 'y' not in ob:
|
||||||
print(f"Error: Object in object layer does not contain 'x' or 'y' key.")
|
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
|
# Round off the coordinates
|
||||||
ob['x'] = round(ob['x'])
|
ob['x'] = round(ob['x'])
|
||||||
ob['y'] = round(ob['y'])
|
ob['y'] = round(ob['y'])
|
||||||
ob['id'] = nextEntityId
|
|
||||||
nextEntityId += 1
|
|
||||||
|
|
||||||
objectLayer['objects'][obIndex] = ob
|
objectLayer['objects'][obIndex] = ob
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user