diff options
| author | Arne Dußin | 2020-12-21 01:22:15 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-12-21 21:15:55 +0100 |
| commit | d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch) | |
| tree | e5633f4d3b18472922c943d759e9f58722ba4405 /src/map/wall.rs | |
| parent | 48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff) | |
| download | graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip | |
Add previously missing docs where appropriate
Diffstat (limited to 'src/map/wall.rs')
| -rw-r--r-- | src/map/wall.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/map/wall.rs b/src/map/wall.rs index d18096b..f1748bb 100644 --- a/src/map/wall.rs +++ b/src/map/wall.rs @@ -1,14 +1,23 @@ +//! Walls, solid barriers that are generally unscaleable. +//! +//! This interpretation is generally up to the GM to decide, but generally speaking, a wall cannot be +//! crossed by a player. If special conditions apply (for instance, when the player wants to scale the +//! wall), a check is necessary. If a check is not necessary, then maybe you were not thinking about +//! a wall. + use super::Mappable; use crate::colours::DEFAULT_COLOURS; use crate::math::{LineSegment, Rect, Vec2}; use crate::transform::Transform; use crate::transformable::NonRigidTransformable; +use nalgebra::Matrix3; use raylib::drawing::{RaylibDraw, RaylibDrawHandle}; use std::ops::{Deref, DerefMut}; -use nalgebra::{Matrix3, Point2}; +/// The data which defines a wall segment completely for serialisation. pub type WallData = LineSegment<f64>; +/// A solid wall a player cannot go through, except if special conditions apply. pub struct Wall { data: WallData, selected: bool, @@ -17,6 +26,7 @@ pub struct Wall { } impl Wall { + /// Create a new wall from the deserialised data and information known from internal sources. pub fn from_data(data: WallData, round_start: bool, round_end: bool) -> Self { Self { data, @@ -26,6 +36,7 @@ impl Wall { } } + /// Get the internal data for serialisation pub fn data(&self) -> &WallData { &self.data } @@ -94,12 +105,8 @@ impl Mappable for Wall { impl NonRigidTransformable for Wall { fn apply_matrix(&mut self, matrix: &Matrix3<f64>) { - self.data.start = matrix - .transform_point(&self.data.start.into()) - .into(); - self.data.end = matrix - .transform_point(&self.data.end.into()) - .into(); + self.data.start = matrix.transform_point(&self.data.start.into()).into(); + self.data.end = matrix.transform_point(&self.data.end.into()).into(); } } |
