-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ShiJbey/development
A few docs updates
- Loading branch information
Showing
12 changed files
with
398 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Neighborly Documentation | ||
|
||
Neighborly uses Sphinx to build the documentation from reStructured Text files. The latest version of the live docs can be found on [Read the Docs](https:/neighborly.readthedocs.io/en/latest/index.html). | ||
|
||
The docs is made up of two parts: | ||
|
||
1. Wiki pages that explain Neighborly's core concepts and abstractions | ||
2. Documentation for the Python source code | ||
|
||
## Building the docs | ||
|
||
**Note:** All file paths provided below are relative to `neighborly/docs` | ||
|
||
Whenever new source code is added, run the following command to have sphinx-autodoc generate the proper documentation pages. All these pages are stored in the `./source/api` folder to keep them separated from the hand-authored wiki pages. | ||
|
||
```bash | ||
sphinx-apidoc -o ./source/api ../src/neighborly | ||
``` | ||
|
||
Finally, you can build the html files with the command below | ||
|
||
```bash | ||
# macOS/Linux | ||
make html | ||
|
||
# Windows | ||
./make.bat html | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.. _design-tips: | ||
|
||
Design Tips and FAQ | ||
=================== | ||
|
||
When should I use a new component vs. a new trait? | ||
-------------------------------------------------- | ||
|
||
Create a custom component if there is GameObject-specific data that you need to track. Traits are helpful for flexibly authoring effects but cannot hold stateful information. | ||
|
||
If you want the best of both components and traits, first create a custom component, then have the component add traits to GameObject within their :py:meth:`neighborly.ecs.Component.on_add` method. For example, in the code below, we have a ``Vampire`` component that tracks vampire-specific data and adds a ``vampirism`` trait that can define specific effects like making characters immortal or buffing existing traits. Assume we load the ``vampirism`` trait from an external data file. | ||
|
||
.. code-block:: python | ||
class Vampire(Component): | ||
"""Tracks information about a vampire.""" | ||
__slots__ = ("humans_bled",) | ||
humans_bled: int | ||
"""The number of human's they have feasted on.""" | ||
def __init__(self): | ||
super().__init__() | ||
self.humans_bled = 0 | ||
def on_add(self): | ||
add_trait(self.gameobject, "vampirism") | ||
def remove_trait(self): | ||
remove_trait(self.gameobject, "vampirism") | ||
.. code-block:: yaml | ||
vampirism: | ||
display_name: Vampirism | ||
description: This character is a vampire | ||
effects: | ||
# This effect makes them unable to die from old age because | ||
# their life decay becomes zero | ||
- type: StatBuff | ||
stat: health_decay | ||
amount: -5000 | ||
# This effect makes them more less friendly toward humans | ||
- type: AddSocialRule | ||
preconditions: | ||
- type: TargetHasTrait | ||
trait: human | ||
effects: | ||
- type: StatBuff | ||
stat: reputation | ||
amount: -15 | ||
When should I create new systems? | ||
--------------------------------- | ||
|
||
Consider creating a new system when you want a simulation mechanic to happen or be checked during every timestep (tick) of the simulation. For instance, health stats are decayed every tick, and character pregnancies are implemented as a system with custom components to ensure that pregnancies take the proper amount of time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.