TeamHypersomnia / Hypersomnia

Multiplayer top-down shooter made from scratch in C++. Play in your Browser! https://hypersomnia.io Made in 🇵🇱
https://hypersomnia.io/
GNU Affero General Public License v3.0
1.14k stars 49 forks source link

Design of components for bullets, grenades and rockets #238

Closed geneotech closed 7 years ago

geneotech commented 7 years ago

damage will be renamed to missile. grenade will be renamed to explosive. A flag will be introduced to determine whether it can be unpinned and thrown with just a hand. a contact_explosive will be implemented by way of explosive + missile, removing the need for a separate component.

In the future, to resolve guilt/morality mechanics, new component will be introduced, named "sender" that will be accompanying all adversary objects (whether explosives, missiles or other kinds). But for now, fixtures shall henceforth possess an array of three optional entities with whom collision is to be filtered (e.g. the gun, the holder of the gun, the vehicle of the holder), initialized at the time of setting the missile in motion, and thus lifting one responsibility from missile.

If a missile_system (former name: damage_system) detects that a missile is due to be destroyed (whether due to contact or a lifetime constraint - already implemented for gun bullets), it shall also check for the existence of an explosive within that entity. If one is found, a detonation shall follow.

Thusly: A gunshot round shall possess a missile. A grenade shall possess an explosive. A rocket shall possess both a missile and an explosive.

geneotech commented 7 years ago

There is still a problem: an explosive is currently in charge of another lifetime constraint (fields: when_released, when_explodes), a functionality that is already duplicated in missile. Thus, a rocket possessing both a missile and an explosive needlessly holds data for two lifetime constraints.

Solution: Let there be a separate component named _handfuse. A hand fuse shall be in charge of letting a character initiate some delayed event that will be done upon that item. In case of a grenade, an explosion shall follow. There may be some other uses for it, and the fuse itself has no knowledge that it is attached to an explosive device or any other.

To summarize again:

A gunshot round shall possess a missile. A grenade shall possess an explosive and a _handfuse. A rocket shall possess an explosive and a missile.

I will be implementing this approach.

geneotech commented 7 years ago

Now that I think of it, I will already just create a sender component that will serve as both the filter and the resolver of guilt or friendly fire. Otherwise, some data will be duplicated again.

geneotech commented 7 years ago

eb81c73: Actually, we currently do have a field like this, and it is named _damage_charges_beforedestruction. Moreover, we actually need to ensure that we don't queue for destruction one entity twice, because coincidentally, there is also detonation involved. A missile shall by no means detonate twice.