Merge pull request #3173 from homeofpoe/patch-20

Update README.md
This commit is contained in:
Griatch 2023-04-29 07:55:15 +02:00 committed by GitHub
commit cadbaa7832

View file

@ -2,23 +2,23 @@
_Contrib by ChrisLR 2021_ _Contrib by ChrisLR 2021_
# The Components Contrib ## The Components Contrib
This contrib introduces Components and Composition to Evennia. This contrib introduces Components and Composition to Evennia.
Each 'Component' class represents a feature that will be 'enabled' on a typeclass instance. Each 'Component' class represents a feature that will be 'enabled' on a typeclass instance.
You can register these components on an entire typeclass or a single object at runtime. You can register these components on an entire typeclass or a single object at runtime.
It supports both persisted attributes and in-memory attributes by using Evennia's AttributeHandler. It supports both persisted attributes and in-memory attributes by using Evennia's AttributeHandler.
# Pros ## Pros
- You can reuse a feature across multiple typeclasses without inheritance - You can reuse a feature across multiple typeclasses without inheritance
- You can cleanly organize each feature into a self-contained class. - You can cleanly organize each feature into a self-contained class.
- You can check if your object supports a feature without checking its instance. - You can check if your object supports a feature without checking its instance.
# Cons ## Cons
- It introduces additional complexity. - It introduces additional complexity.
- A host typeclass instance is required. - A host typeclass instance is required.
# How to install ## How to install
To enable component support for a typeclass, To enable component support for a typeclass,
import and inherit the ComponentHolderMixin, similar to this import and inherit the ComponentHolderMixin, similar to this
@ -126,7 +126,7 @@ from typeclasses.components import health
``` ```
Both of the above examples will work. Both of the above examples will work.
# Full Example ## Full Example
```python ```python
from evennia.contrib.base_systems import components from evennia.contrib.base_systems import components