2010-08-08 10:06:34 +02:00
|
|
|
#ifndef H_KRNL_RESOURCES
|
|
|
|
#define H_KRNL_RESOURCES
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-05-09 08:18:20 +02:00
|
|
|
#include <util/variant.h>
|
|
|
|
|
2017-02-22 21:10:22 +01:00
|
|
|
struct building_type;
|
|
|
|
struct race;
|
2017-05-09 08:18:20 +02:00
|
|
|
struct region;
|
2017-02-22 21:10:22 +01:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
enum {
|
|
|
|
RM_USED = 1 << 0, /* resource has been used */
|
|
|
|
RM_MALLORN = 1 << 1 /* this is not wood. it's mallorn */
|
|
|
|
};
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
typedef struct rawmaterial {
|
2017-03-22 20:37:09 +01:00
|
|
|
const struct resource_type *rtype;
|
2015-01-30 20:37:14 +01:00
|
|
|
int amount;
|
|
|
|
int level;
|
|
|
|
int flags;
|
|
|
|
int base;
|
|
|
|
int divisor;
|
|
|
|
int startlevel;
|
|
|
|
struct rawmaterial *next;
|
|
|
|
} rawmaterial;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2017-04-02 14:43:53 +02:00
|
|
|
/* resource-limits for regions */
|
|
|
|
typedef enum resource_modifier_type {
|
|
|
|
RMT_END, /* array terminator */
|
|
|
|
RMT_PROD_SKILL, /* bonus on resource production skill */
|
|
|
|
RMT_PROD_SAVE, /* fractional multiplier when produced */
|
|
|
|
RMT_PROD_REQUIRE, /* building or race is required to produce this item */
|
|
|
|
RMT_USE_SAVE, /* fractional multiplier when used to manufacture something */
|
|
|
|
} resource_modifier_type;
|
|
|
|
|
2017-02-22 21:10:22 +01:00
|
|
|
typedef struct resource_mod {
|
2017-04-02 14:43:53 +02:00
|
|
|
resource_modifier_type type;
|
2017-02-22 21:10:22 +01:00
|
|
|
variant value;
|
|
|
|
const struct building_type *btype;
|
2018-04-29 13:46:17 +02:00
|
|
|
int race_mask;
|
2017-02-22 21:10:22 +01:00
|
|
|
} resource_mod;
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
typedef struct rawmaterial_type {
|
|
|
|
const struct resource_type *rtype;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
void(*terraform) (struct rawmaterial *, const struct region *);
|
|
|
|
void(*update) (struct rawmaterial *, const struct region *);
|
|
|
|
void(*use) (struct rawmaterial *, const struct region *, int amount);
|
|
|
|
int(*visible) (const struct rawmaterial *, int skilllevel);
|
|
|
|
} rawmaterial_type;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
extern struct rawmaterial_type *rawmaterialtypes;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2017-02-15 20:50:45 +01:00
|
|
|
void update_resources(struct region *r);
|
|
|
|
void terraform_resources(struct region *r);
|
|
|
|
struct rawmaterial *rm_get(struct region *,
|
2015-01-30 20:37:14 +01:00
|
|
|
const struct resource_type *);
|
2017-02-15 20:50:45 +01:00
|
|
|
struct rawmaterial_type *rmt_get(const struct resource_type *);
|
2011-03-07 08:02:35 +01:00
|
|
|
|
2018-10-30 21:01:09 +01:00
|
|
|
void set_resource(struct rawmaterial *rm, int level, int base, int divisor);
|
2017-03-22 20:37:09 +01:00
|
|
|
struct rawmaterial *add_resource(struct region *r, int level,
|
|
|
|
int base, int divisor, const struct resource_type *rtype);
|
2017-02-23 08:02:24 +01:00
|
|
|
struct rawmaterial_type *rmt_create(struct resource_type *rtype);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2017-02-26 13:19:47 +01:00
|
|
|
int limit_resource(const struct region *r, const struct resource_type *rtype);
|
|
|
|
void produce_resource(struct region *r, const struct resource_type *rtype, int amount);
|
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|