[Freeciv-Dev] Re: unit flags/capabilities
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
> How would this proposed inheritence system handle flying settlers?
>
> We're not talking about a system with a fixed list of units for the
> ruleset to pick from (or, at least IMO, we shouldn't be). Ultimately a
> more flexible system that allows the ruleset to specify every property
> of the unit would be better. This would also allow SMAC-style units
> with a minimum of fuss.
now, see... this is good. this is a requirement that drives design :)
so lets see what we want to do. we need to be able to define some structure
that allows units to pick and choose capabilities. for example, a flying unit
that can build cities.
i see a couple different ways to do this. the first is through the use of
flags. each flag defines a capability or property. a unit specification
subscribes to the flags that have been provided. of course, you'd basically
need an unlimitted flag-space for extension (my previous discussion on unit
flags solves this and provides this capability). the only issue this doesn't
gracefully solve is a value association with the a flag. for example, a
transport unit needs to specify how many units it can transport.
implementing this will probably eliminate the need for the an inheritance
hierarchy because it it encapsulates specialization as static data as opposed
to overloaded functions or data.
the alternative is to do it functionally and that's a little more
complicated. this isn't a bad thing though because it allows modularization
of each capability and some real flexibility when you're setting it all up.
but, even in this case, i don't think you need the inheritence. you'll have
to modularize all the units - or at least write enough code so that units can
specify either generic or specialized capability flags.
struct movement_capab {
int (*can_move_land)();
int (*can_move_sea)();
int (*can_move_air)();
// ...
};
struct transport_capab {
int trans_max; // total number of units
int (*load_unit)( unit *); // loads a unit into the transport
unit *(*unload_unit)(); // unloads a unit
};
struct build_city_capab {
int (*build_city)();
};
keep in mind that this is off the top of my head. each capability structure
defines a set of properties and methods associated with the unit. the unit
structure contains the following structure:
struct capability_vector {
transport_capab *transport;
build_city_capab *build_city;
// ...
};
then, when you're defining units, each unit can customize its data and refine
the way that this stuff is implemented.
// in flying_settler.c
static int flying_settler_can_move() { return 1; }
static struct movement_capab {
flying_settler_can_move,
flying_settler_can_move,
0
};
static struct build_city_capab {
generic_build_city // defined elsewhere
};
or something like that... it would take a little more thought to really
refine the way this works.
andy
- [Freeciv-Dev] Re: unit flags/capabilities, (continued)
- [Freeciv-Dev] Re: unit flags/capabilities, Raimar Falke, 2001/11/29
- [Freeciv-Dev] Re: unit flags/capabilities, Reinier Post, 2001/11/30
- [Freeciv-Dev] Re: unit flags/capabilities, Raimar Falke, 2001/11/30
- [Freeciv-Dev] Re: unit flags/capabilities, Andrew Sutton, 2001/11/30
- [Freeciv-Dev] Re: unit flags/capabilities, Reinier Post, 2001/11/30
- [Freeciv-Dev] Re: unit flags/capabilities, Andrew Sutton, 2001/11/29
- [Freeciv-Dev] Re: unit flags/capabilities, Raimar Falke, 2001/11/29
- [Freeciv-Dev] Re: unit flags/capabilities, Andrew Sutton, 2001/11/29
- [Freeciv-Dev] Re: unit flags/capabilities, Reinier Post, 2001/11/29
- [Freeciv-Dev] Re: unit flags/capabilities, vze2zq63, 2001/11/29
- [Freeciv-Dev] Re: unit flags/capabilities,
Andrew Sutton <=
- Message not available
- [Freeciv-Dev] Re: unit flags/capabilities, Andrew Sutton, 2001/11/29
|
|