Skip to content

Commit

Permalink
fix(VTriggerUntouch): add documentation for zCTriggerUntouch
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Jan 3, 2024
1 parent fe6fdb1 commit ea95684
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
35 changes: 35 additions & 0 deletions docs/engine/objects/zCTriggerUntouch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# zCTriggerUntouch

!!! abstract inline end "Quick Infos"
**Type:** Virtual Object<br/>
**Format Name:** ZenGin Archive<br/>
**File Extension:** `.ZEN`<br/>
**Class Name:** `zCTriggerUntouch`<br/>
**Version Identifiers:**<br />
— Gothic I: `52224`<br/>
— Gothic II: `52224`<br/>
**ZenKit Class:** `VTriggerUntouch`

A trigger which fires an `OnTrigger` event to its [`triggerTarget`](#triggerTarget) if any `OnUntouch` event is emitted
from an inanimate object within the object's bounding box.

<ul class="sp-list">
<li class="sp-type"><a href="../zCVob/">zCVob</a></li>
<li class="sp-type">
<span>zCTriggerUntouch</span>
<ul class="sp-list">
<li class="sp-string"><a href="#triggerTarget">triggerTarget</a> = ""</li>
</ul>
</li>
</ul>

## Properties

<a name="triggerTarget" class="t-str"></a> `triggerTarget`

: The name of VObject to send the `OnTrigger` events to.


## Sources

The help file for the Spacer, found [here](https://wiki.worldofgothic.de/doku.php?id=spacer:hilfedatei).
16 changes: 8 additions & 8 deletions examples/load_zen.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright © 2022-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#include "zenkit/Vfs.hh"
#include "zenkit/World.hh"

#include <phoenix/archive.hh>

#include <iostream>
Expand Down Expand Up @@ -28,15 +31,12 @@ int main(int argc, char** argv) {
return -1;
}

auto buf = phoenix::buffer::mmap(argv[1]);
auto archive = phoenix::archive_reader::open(buf);
auto& header = archive->get_header();
zenkit::Vfs vfs;
vfs.mount_disk(argv[1]);

std::cout << "Archiver: " << header.archiver << "\n"
<< "User: " << header.user << "\n"
<< "Timestamp: " << header.date << "\n"
<< "Entries:\n";
zenkit::World wld;

print_entries(archive);
auto rd = vfs.find("NEWWORLD.ZEN")->open_read();
wld.load(rd.get());
return 0;
}
20 changes: 14 additions & 6 deletions include/zenkit/vobs/Trigger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -473,21 +473,29 @@ namespace zenkit {
[[nodiscard]] ZKAPI uint16_t get_version_identifier(GameVersion game) const override;
};

/// \brief A trigger which fires an `OnTrigger` event to its #target if any `OnUntouch` event is emitted from
/// an inanimate object within the object's bounding box.
/// \see https://zk.gothickit.dev/engine/objects/zCTriggerUntouch/
struct VTriggerUntouch : VirtualObject {
ZK_OBJECT(ObjectType::zCTriggerUntouch);

public:
/// \brief The name of VObject to send the `OnTrigger` events to.
/// \see https://zk.gothickit.dev/engine/objects/zCTriggerUntouch/#triggerTarget
std::string target;

/// \brief Parses an untouch trigger VOb the given *ZenGin* archive.
/// \param[out] obj The object to read.
/// \param[in,out] ctx The archive reader to read from.
/// \note After this function returns the position of \p ctx will be at the end of the parsed object.
/// \throws ParserError if parsing fails.
/// \see vob::parse
ZKREM("use ::load()") ZKAPI static void parse(VTriggerUntouch& obj, ReadArchive& ctx, GameVersion version);

/// \brief Load this object from the given archive.
/// \param r The archive to read from;
/// \param version The version of the game the object was made for.
ZKAPI void load(ReadArchive& r, GameVersion version) override;

/// \brief Save this object to the given archive.
/// \param w The archive to save to.
/// \param version The version of the game to save for.
ZKAPI void save(WriteArchive& w, GameVersion version) const override;

[[nodiscard]] ZKAPI uint16_t get_version_identifier(GameVersion game) const override;
};
} // namespace zenkit
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ nav:
- 'oCTriggerScript': 'engine/objects/oCTriggerScript.md'
- 'oCTriggerChangeLevel': 'engine/objects/oCTriggerChangeLevel.md'
- 'zCTriggerWorldStart': 'engine/objects/zCTriggerWorldStart.md'
- 'zCTriggerUntouch': 'engine/objects/zCTriggerUntouch.md'
- 'oCItem': 'engine/objects/oCItem.md'
- 'zCVisual': 'engine/objects/zCVisual.md'
- 'zCDecal': 'engine/objects/zCDecal.md'
Expand Down

0 comments on commit ea95684

Please sign in to comment.