Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upDropping the hardcoded "corpse" item, generating per-creature-type corpses #20069
Comments
This comment has been minimized.
This comment has been minimized.
|
Not familiar with corpses at all. Took a glance. Seems that there's an item with One must not pass a null pointer when making a corpse item, but an item can return a null pointer if it's not a corpse... (EDIT: This about What would the benefits of having separate
Arguably possible in both cases:
EDIT: Anyway, yeah, making a EDIT (2 times): expand lists |
This comment has been minimized.
This comment has been minimized.
Corpses have to be items, they can't be creatures. They can "store" a creature for stuff like proper revival instead of re-creation, but they can't be just flagged creatures. What we have now is one "corpse" object which has very little information in it, but instead recalculates everything on demand, using dead creature's monster type. This is very inflexible for purposes of overrides and also makes the monster type responsible for parameters of the corpse that are only related to being an item. |
This comment has been minimized.
This comment has been minimized.
|
Yup, that's what I understood. Concise explanation, thanks. Would it be prudent to have a |
This comment has been minimized.
This comment has been minimized.
|
Yes. There would most likely be multiple such base classes:
etc. Such hierarchical structures are useful for type checking: "is it a corpse?", "is it a zombie corpse?", "is it a zombie corpse that has cbms?" etc. |
This comment has been minimized.
This comment has been minimized.
|
Please don't plan on subclassing item, there are very good reasons for the islot idiom over a subclassing approach. In general though, different itypes for different creature corpses is a great idea, I'm not so sure about auto-generating them though, especially if that means adding more data to creature definitions, it's a bit of a separation of concern issue, and we may well not want a different itype_id for every creature type, some might be shared between monsters. A development approach suggestion, please consider implementing this piece wise, i.e. transition the simplest monster possible to this new system, allowing other corpses to continue using the old system, repeat until the system covers all the extant functionality. Novel features can be added as separate PRs once the corpses they target are transitioned. Bottom line, I don't want an "overhaul corpse generation" pr before 0.D, either proceed very incrementally or expect to keep your branch out of mainline until the next stable. |
This comment has been minimized.
This comment has been minimized.
|
Would this let me make different tiles for pulped corpses vs unpulped corpses? |
This comment has been minimized.
This comment has been minimized.
|
On Jan 23, 2017 12:25 AM, "Chezzo" <notifications@github.com> wrote:
Would this let me make different tiles for pulped corpses vs unpulped
corpses?
Not by default, but that should be doable.
|
keyspace
referenced this issue
Jan 28, 2017
Closed
Zombie Slaves appear in random area after leaving and re-entering reality bubble. #19853
This comment has been minimized.
This comment has been minimized.
Such as? I don't get the aversion to nesting.
In this case we could have a field like "corpse_item". This would allow, say, soldier zombies degrading into tough zombie corpses when dead and thus stripped of gear.
I'd probably start with allowing items to arbitrarily qualify as corpses based on something other than ID.
Sure. It's mostly brainstorming at the moment. |
This comment has been minimized.
This comment has been minimized.
|
On Feb 6, 2017 11:54 AM, "Coolthulhu" <notifications@github.com> wrote:
Please don't plan on subclassing item, there are very good reasons for the
islot idiom over a subclassing approach.
Such as?
Slots allow new combinations of types to be created by declarations in
data, a subclassing approach would require you to enumerate and define
every combination of subtypes you want to use in c++. We ran into this
issue when implementing wearable tools, but it's been used in a few other
type combinations since then.
Subclassing non-abstract classes is also a Bad Idea in general, though I'm
not going to get into that right now, the scope is too wide.
Say, you want to add "insect blood" harvest to all insect corpses - in
"flat" system it means overriding all of them manually, in "tree" one it
means altering one definition.
You're talking about data inheritance now, I said, "don't subclass the item
class".
I don't get the aversion to nesting.
When taken too far (only a few levels deep) it quickly becomes difficult to
reason about the behavior of the various classes.
|
This comment has been minimized.
This comment has been minimized.
I don't think I follow. |
This comment has been minimized.
This comment has been minimized.
|
@coolthulu, I think I can speak to the notion of "Sub classing non-abstract bases" being a bad idea. We can use the example you gave above of having a 'base' with all the dead thing properties, and then having subclasses that flesh out the robots/plants/flesh critters. With a subclass tree, you have to explicitly define the properties of a class in C++ when you declare the class. The issue here is that a given critter is now hard coded to have whatever data it has. As a simplistic example, if you wanted to create a 'cyborg' creature, you'd need to explicitly inheret from the robot and flesh creature subclasses. If, instead, you create a flat list of structures, which in this case would be:
You could then have code that expects to handle just one of the above (say code for generating meat drops from a corpse, that doesn't depend on other common data). Now, you can define the corpse of, eg, a moose as having the 'general dead' data as well as the 'flesh dead' data. A hypothetical cyber-moose would additionally have the "robot things" component. An item's included data components can be defined via a series of flags. It is conceptually very similar to using a class hierarchy in that you are factoring out common data blocks to avoid reuse, but there are a couple of key differences that are useful:
I think that moving toward this sort of approach might help with refactoring of the huge disorganized classes that you recently mentioned in another issue. As a side note, do you have a source for the use of object hierarchies in RimWorld? That strikes me as a game where the entity-component type approach would have made more sense. If they provided some reasoning for their approach I'd be interested to read about it; might be a novel point of view. |
This comment has been minimized.
This comment has been minimized.
|
Regarding Rimworld: I didn't see any rationale, just looked through the data bundled with the game. The example I gave - with corpses - was also mostly about abstracts, except that some of them would have trivial instances - zombie corpse, for example. |
This comment has been minimized.
This comment has been minimized.
|
If you haven't stumbled on the notion of Entity-Component-System game engines before, it's an enjoyable Google search. Not saying it is "right/wrong", but it is certainly another way of looking at organization, and one that I believe happens to work well when you are trying to create emergent behavior. This is one of the first articles I read on the subject: I stumbled on this basically after my own (very simple) attempt at creating a rougelike from scratch fell completely apart after a few weeks when my object model got too big to fit in my head. |
keyspace
referenced this issue
Feb 10, 2017
Merged
Multiple skill requirements per construction #20244
This comment has been minimized.
This comment has been minimized.
|
ECS by design introduces IDs for objects, which has been discussed at length here. Granted, these do not have to be persistent between savegame loads, and should not be used for anything but one-to-one mapping of identity (different from referenced issue), but still, worth taking into account. It also (essentially) requires a very efficient database with |
This comment has been minimized.
This comment has been minimized.
|
To be clear, I am not proposing a full refactor of the game to an ECS. Performance implications aside, that's tough to do incrementally, and we don't have nice decoupled blocks of logic that can be carved off into "systems" either. I was mainly referencing the idea of flattening the hierarchy to enable composition vs inheritance (which is not unique to ECS, that is just a good vehicle for communicating them in this context), and more specifically the ability to push the creature hierarchy into the JSON layer rather than the C++ inheritance system. Thanks for the link -- I'll read through that discussion and see if any of the half-formed ideas in my head still make sense afterwards. I wasn't explicitly proposing persistent ID's, but they may be implicit in what I am thinking. If so I might be proposing something that is infeasible for reasons that have been decided in the past. |
This comment has been minimized.
This comment has been minimized.
|
On Feb 13, 2017 3:58 AM, "Keyspace-1" <notifications@github.com> wrote:
It also (essentially) requires a very efficient database with SELECT-like
lookups.
It does not, I think that might be common to prevent the developer from
worrying about serialization, but it could also be implemented as a set of
hash maps keyed by entity id.
If done correctly, though, it could allow expanding the reality bubble.
Could you expand on this? The thing keeping us from making the reality
bubble larger is scaling of various algorithms that act on it, such as
field of view and dynamic lighting calculation, I don't see how an ECS
would have any impact. On the contrary, if you look at the key data
structures for the reality bubble, they're fully decomposed into
multidimensional arrays of values for efficiency. An ECS would have a lot
if trouble beating that.
|
This comment has been minimized.
This comment has been minimized.
|
May be off-topic. EDIT: Discussed on the forums.
IMO not just common but necessary, due to such systems needing to choose entities/components for handling by a system. This "choosing" is what I likened to SQL's SELECT above. And the choice of implementation greatly affects what the system could be optimised for. If you have a lot of free time, there's this article by Adam Martin that goes C-low to outline the efficiency issues. Gist: data processing order is different, and can be optimised for homogenous objects - e.g. components if 1-component-1-system is used, sets otherwise if there's an evident bottleneck, or even full entities if there's just a few of them... It all boils down to what can fit in the CPU cache. Also, it's mostly relevant for threaded applications. So not at all for C:DDA ATM.
Ah, sorry, I was in a different reality bubble (badum-tss...) and didn't think about those two. Doh!.. (Never looked at them - that's why.) |
This comment has been minimized.
This comment has been minimized.
|
This is more a todo item than an issue, and obviously no discussion in months. |
Coolthulhu commentedJan 22, 2017
The "corpse" item is limiting and implemented in ugly, hardcoded way.
Instead, we could have all creature types generate their own type of corpse, which would then be generated from a template on finalization.
Corpse's ID could be either required to be named explicitly, in which case the corpse item should have a definition somewhere, or more conveniently it could be generated from creature's id instead. For example, by prepending "corpse_" to it.
This would allow: