This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record "_origin" as property on entity.
Otherwise it would be re-calculated each time the entity mind was recreated.
- Loading branch information
1 parent
be094c1
commit fd173f3
Showing
5 changed files
with
42 additions
and
13 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
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
17 changes: 17 additions & 0 deletions
17
data/rulesets/deeds/scripts/world/traits/OriginRecording.py
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,17 @@ | ||
import server | ||
from atlas import Operation, Entity | ||
|
||
|
||
class OriginRecording(server.Thing): | ||
"""Records an "_origin" property when created. This property can then be used by mind code to make sure that | ||
NPCs are moving in place.""" | ||
|
||
def __init__(self, cpp): | ||
# At init time not all properties have been applied yet, so we need to send ourselves a "setup" | ||
# op which will be handled immediately, but with a guarantee that all props are installed. | ||
self.send_world(Operation("setup", to=self.id)) | ||
|
||
def setup_operation(self, op): | ||
origin = self.get_prop_map("_origin") | ||
if not origin: | ||
return Operation('set', Entity(id=self.id, _origin={"$eid": self.location.parent.id, "pos": self.location.pos}), to=self.id) |