Skip to content

Commit

Permalink
Rename basic shape types
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatNintendoNerd committed Feb 21, 2024
1 parent 4764700 commit ad97af9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 38 deletions.
4 changes: 2 additions & 2 deletions lvd_lib/src/objects/damage_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};

use crate::{
objects::base::Base,
shape::LvdShape3,
shape::Shape3,
version::{Version, Versioned},
};

Expand All @@ -23,7 +23,7 @@ pub enum DamageShape {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape3>,
shape: Versioned<Shape3>,

/// Boolean flag determining if the damage shape is an attack collision.
#[br(map = |b: u8| b != 0)]
Expand Down
20 changes: 10 additions & 10 deletions lvd_lib/src/objects/enemy_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use crate::{
array::LvdArray,
objects::base::Base,
shape::LvdShape2Array,
shape::ShapeArray2,
tag::Tag,
version::{Version, Versioned},
};
Expand All @@ -26,13 +26,13 @@ pub enum EnemyGenerator {
base: Versioned<Base>,

/// Collection of shapes where enemies can appear from.
appear_shapes: Versioned<LvdShape2Array>,
appear_shapes: Versioned<ShapeArray2>,

/// Collection of shapes for responding to fighter presence.
trigger_shapes: Versioned<LvdShape2Array>,
trigger_shapes: Versioned<ShapeArray2>,

// TODO: Field documentation.
unk1: Versioned<LvdShape2Array>,
unk1: Versioned<ShapeArray2>,

/// Identifier for matching and filtering like objects.
tag: Versioned<Tag>,
Expand All @@ -47,13 +47,13 @@ pub enum EnemyGenerator {
base: Versioned<Base>,

/// Collection of shapes where enemies can appear from.
appear_shapes: Versioned<LvdShape2Array>,
appear_shapes: Versioned<ShapeArray2>,

/// Collection of shapes for responding to fighter presence.
trigger_shapes: Versioned<LvdShape2Array>,
trigger_shapes: Versioned<ShapeArray2>,

// TODO: Field documentation.
unk1: Versioned<LvdShape2Array>,
unk1: Versioned<ShapeArray2>,

/// Identifier for matching and filtering like objects.
tag: Versioned<Tag>,
Expand All @@ -73,13 +73,13 @@ pub enum EnemyGenerator {
base: Versioned<Base>,

/// Collection of shapes where enemies can appear from.
appear_shapes: Versioned<LvdShape2Array>,
appear_shapes: Versioned<ShapeArray2>,

/// Collection of shapes for responding to fighter presence.
trigger_shapes: Versioned<LvdShape2Array>,
trigger_shapes: Versioned<ShapeArray2>,

// TODO: Field documentation.
unk1: Versioned<LvdShape2Array>,
unk1: Versioned<ShapeArray2>,

/// Identifier for matching and filtering like objects.
tag: Versioned<Tag>,
Expand Down
16 changes: 8 additions & 8 deletions lvd_lib/src/objects/field_smash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use crate::{
id::Id,
objects::{base::Base, region::Region},
shape::{LvdPath, LvdShape2, LvdShape3, Rect},
shape::{LvdPath, Rect, Shape2, Shape3},
string::LvdFixedString32,
tag::Tag,
vector::Vector2,
Expand All @@ -27,7 +27,7 @@ pub enum FsItem {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape2>,
shape: Versioned<Shape2>,

/// Identifier for matching and filtering like objects.
tag: Versioned<Tag>,
Expand Down Expand Up @@ -207,7 +207,7 @@ pub enum AreaLight {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape2>,
shape: Versioned<Shape2>,
},

/// `AreaLight` version 2.
Expand All @@ -218,7 +218,7 @@ pub enum AreaLight {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape2>,
shape: Versioned<Shape2>,

// TODO: Field documentation.
unk1: Versioned<LvdFixedString32>,
Expand Down Expand Up @@ -279,7 +279,7 @@ pub enum AreaHint {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape3>,
shape: Versioned<Shape3>,

// TODO: Field documentation.
unk1: i32,
Expand All @@ -303,7 +303,7 @@ pub enum AreaHint {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape3>,
shape: Versioned<Shape3>,

// TODO: Field documentation.
unk1: i32,
Expand All @@ -329,7 +329,7 @@ pub enum AreaHint {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape3>,
shape: Versioned<Shape3>,

// TODO: Field documentation.
unk1: i32,
Expand Down Expand Up @@ -377,7 +377,7 @@ pub enum SplitArea {
base: Versioned<Base>,

/// Shape represented by the object.
shape: Versioned<LvdShape3>,
shape: Versioned<Shape3>,
},
}

Expand Down
6 changes: 3 additions & 3 deletions lvd_lib/src/objects/general_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};

use crate::{
objects::base::Base,
shape::{LvdShape2, LvdShape3},
shape::{Shape2, Shape3},
tag::Tag,
version::{Version, Versioned},
};
Expand All @@ -27,7 +27,7 @@ pub enum GeneralShape2 {
tag: Versioned<Tag>,

/// Shape represented by the object.
shape: Versioned<LvdShape2>,
shape: Versioned<Shape2>,
},
}

Expand Down Expand Up @@ -55,7 +55,7 @@ pub enum GeneralShape3 {
tag: Versioned<Tag>,

/// Shape represented by the object.
shape: Versioned<LvdShape3>,
shape: Versioned<Shape3>,
},
}

Expand Down
4 changes: 2 additions & 2 deletions lvd_lib/src/objects/item_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};

use crate::{
objects::base::Base,
shape::LvdShape2Array,
shape::ShapeArray2,
tag::Tag,
version::{Version, Versioned},
};
Expand All @@ -27,7 +27,7 @@ pub enum ItemPopup {
tag: Versioned<Tag>,

/// Collection of shapes where items will appear from.
shapes: Versioned<LvdShape2Array>,
shapes: Versioned<ShapeArray2>,
},
}

Expand Down
27 changes: 14 additions & 13 deletions lvd_lib/src/shape.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Basic shape types.
//!
//! This module contains the [`LvdShape2`], [`LvdShape2Array`] and [`LvdShape2Element`] types,
//! the [`LvdShape3`] type, the [`LvdPath`] type, and the [`Rect`] type.
//! This module contains the [`Shape2`], [`ShapeArray2`] and [`ShapeArrayElement2`] types,
//! the [`Shape3`] type, the [`LvdPath`] type, and the [`Rect`] type.
use binrw::binrw;

#[cfg(feature = "serde")]
Expand All @@ -18,7 +18,7 @@ use crate::{
#[br(import(_version: u8))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug)]
pub enum LvdShape2 {
pub enum Shape2 {
/// Point shape type.
#[brw(magic = 1u32)]
Point {
Expand Down Expand Up @@ -81,42 +81,43 @@ pub enum LvdShape2 {
},
}

impl Version for LvdShape2 {
impl Version for Shape2 {
fn version(&self) -> u8 {
3
}
}

// TODO: Why is this type necessary for arrays?
/// An element type for a [`LvdShape2Array`].
/// An element type for a [`ShapeArray2`].
#[binrw]
#[br(import(_version: u8))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(Debug)]
pub struct LvdShape2Element(Versioned<LvdShape2>);
pub struct ShapeArrayElement2(Versioned<Shape2>);

impl Version for LvdShape2Element {
impl Version for ShapeArrayElement2 {
fn version(&self) -> u8 {
1
}
}

// TODO: Why is this type necessary for collections of two-dimensional shapes?
/// A collection of two-dimensional shapes.
#[binrw]
#[br(import(version: u8))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug)]
pub enum LvdShape2Array {
/// `LvdShape2Array` version 1.
pub enum ShapeArray2 {
/// `ShapeArray2` version 1.
#[br(pre_assert(version == 1))]
V1 {
/// Collection of two-dimensional shapes.
shapes: Versioned<LvdArray<LvdShape2Element>>,
shapes: Versioned<LvdArray<ShapeArrayElement2>>,
},
}

impl Version for LvdShape2Array {
impl Version for ShapeArray2 {
fn version(&self) -> u8 {
match self {
Self::V1 { .. } => 1,
Expand All @@ -129,7 +130,7 @@ impl Version for LvdShape2Array {
#[br(import(_version: u8))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug)]
pub enum LvdShape3 {
pub enum Shape3 {
/// Box shape type.
#[brw(magic = 1u32)]
Box {
Expand Down Expand Up @@ -210,7 +211,7 @@ pub enum LvdShape3 {
},
}

impl Version for LvdShape3 {
impl Version for Shape3 {
fn version(&self) -> u8 {
1
}
Expand Down

0 comments on commit ad97af9

Please sign in to comment.