|
From: <red...@pr...> - 2003-12-31 03:57:16
|
Hi mamutas and all,
How about this. We have ICarriable for objects that can be carried, and ICarrier
for those that can carry. In that way we can make a nice system, suppose this:
class ICarriable
{};
class ICarrier
{};
class Soldier : public ICarrier
{};
class Aircraft : public ICarrier
{};
ICarrier should be able to present a simple but unified view for carrying items.
For instance Aircraft's dont mind the size of the stuff you put on them as long
as the weight do pass over an specified ammount. On the other side Soldiers do
mind the real proportions and the specific place in where you put them. That
makes the interface pretty difficult. One solution is to think that carriers
have containers, and those containers specify the limits on size. However, the
carrier itself specify the limit on weight. You can either enumerate the
containers or give them a symbolic name (like "righthand" or "backpack" ) to be
accesible from a scripting language. So for instance to move the rocket launcher
from the backpack to the hand you do the following.
ICarrierContainer* backpack = this->getCarrierContainer ("backpack");
// Get the object via its code or whatever.
ICarriable* object = backpack->takeoutObject ( ... );
ICarrierContainer* hand = this->getCarrierContainer ("righthand");
if (hand->isEmpty ())
{
// The ... is the parameters to specify how to add them, I must say
// that I dont have a clue how to specify those parameters to unify both
// types of carrier objects.
hand->addObject (object, ... );
}
else // we dont do anything, or rollback the action :D ;
Other solution is to have different type of interfaces and that those use the
same type of ICarriable objects (as we have now), one is IStore (where position
in the store is not relevant, only total size or weight and the other is
ICarrier (used to be called Wearable) where not only size and weight are
relevant but position too.
Any though will be welcomed, cause I am stuck on this.
Greetings
Red Knight
Quoting Mamutas Plaukotas <ma...@pr...>:
> Here is what I think:
>
> We need two interfaces (sorry, but I cannot come up with good names :( )
> 1) IsCarryable (the item which can be carried). That is an 'Ability'
> interface which defines that the object can be carried, for example weapons
> or corpses. Some objects cannot be carried, like phones, dishes, food items,
> etc., although they are small enough, but there is no need to carry them.
> 2) AbleToCarry (an object which can carry objects implemented IsCarryable
> interfaces). Those could be aircrafts, units, general store facilities, etc.
> That interface will be 'Behaviour' in my opinion.
>
> Regards,
> mamutas
|