aboutsummaryrefslogtreecommitdiff
path: root/src/resource/inc
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-07-03 00:49:03 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-03-30 08:20:20 +0200
commit6b9f686913efc3725b2690033cd4f398e07076ba (patch)
treee9aa91a6b9f617d78123ebe7ad272fc42a60d306 /src/resource/inc
parentc9e6ae44a9aeb89b3f48f3443d6baa80103f7445 (diff)
downloadjancity-6b9f686913efc3725b2690033cd4f398e07076ba.tar.gz
Add project source code
Diffstat (limited to 'src/resource/inc')
-rw-r--r--src/resource/inc/resource.h57
-rw-r--r--src/resource/inc/resource_type.h21
2 files changed, 78 insertions, 0 deletions
diff --git a/src/resource/inc/resource.h b/src/resource/inc/resource.h
new file mode 100644
index 0000000..56da45e
--- /dev/null
+++ b/src/resource/inc/resource.h
@@ -0,0 +1,57 @@
+#ifndef RESOURCE_H
+#define RESOURCE_H
+
+#include <camera.h>
+#include <container.h>
+#include <gfx.h>
+#include <instance.h>
+#include <resource_type.h>
+#include <util.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+enum {RESOURCE_GOLD_CAPACITY = 2};
+
+struct resource
+{
+ struct instance instance;
+ enum resource_type type;
+
+ union
+ {
+ struct resource_gold
+ {
+ struct instance *miners[RESOURCE_GOLD_CAPACITY];
+ size_t n_miners;
+ } gold;
+ } res;
+};
+
+UTIL_STATIC_ASSERT(!offsetof(struct resource, instance), "must be at offset zero");
+
+struct resource_cfg
+{
+ enum resource_type type;
+ unsigned long x, y;
+};
+
+const struct container_list *resource_res(void);
+int resource_create(const struct resource_cfg *cfg, struct resource *list, size_t n);
+int resource_render(const struct resource *res, const struct camera *cam, bool sel);
+instance_sheltered_cb resource_shelter(const struct resource *res);
+bool resource_harvested(struct instance *i, instance_hp ap);
+instance_hp resource_maxhp(const struct resource *res);
+const char *resource_str(const struct resource *res);
+
+extern struct sprite resource_sprites[MAX_RESOURCE_TYPES];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RESOURCE_H */
diff --git a/src/resource/inc/resource_type.h b/src/resource/inc/resource_type.h
new file mode 100644
index 0000000..8a41148
--- /dev/null
+++ b/src/resource/inc/resource_type.h
@@ -0,0 +1,21 @@
+#ifndef RESOURCE_TYPE_H
+#define RESOURCE_TYPE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+enum resource_type
+{
+ RESOURCE_TYPE_WOOD,
+ RESOURCE_TYPE_GOLD,
+
+ MAX_RESOURCE_TYPES
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RESOURCE_TYPE_H */