Skip to content

Commit

Permalink
add job type for behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Zitronenjoghurt committed Aug 12, 2024
1 parent a4a1433 commit 8e90444
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 312 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cd rust/main_logic
cargo tarpaulin --out Xml --output-dir ../../
- name: Upload to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
30 changes: 0 additions & 30 deletions godot/world_objects/objects/dirt_block.tres

This file was deleted.

30 changes: 0 additions & 30 deletions godot/world_objects/objects/dirt_top.tres

This file was deleted.

48 changes: 0 additions & 48 deletions godot/world_objects/objects/hut.tres

This file was deleted.

34 changes: 0 additions & 34 deletions godot/world_objects/state.gd

This file was deleted.

29 changes: 0 additions & 29 deletions godot/world_objects/tiles/object_tile.gd

This file was deleted.

30 changes: 0 additions & 30 deletions godot/world_objects/types/building/building.gd

This file was deleted.

28 changes: 0 additions & 28 deletions godot/world_objects/types/building/state.gd

This file was deleted.

29 changes: 0 additions & 29 deletions godot/world_objects/types/building/states/housing.gd

This file was deleted.

17 changes: 0 additions & 17 deletions godot/world_objects/types/static/state.gd

This file was deleted.

14 changes: 0 additions & 14 deletions godot/world_objects/types/static/static.gd

This file was deleted.

43 changes: 41 additions & 2 deletions rust/main_logic/src/entities/world_object/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};

use crate::{
entities::display_tile::DisplayTile,
enums::{tile_type::TileType, world_object_id::WorldObjectId},
enums::{job_type::JobType, tile_type::TileType, world_object_id::WorldObjectId},
};

use super::{
Expand All @@ -15,19 +15,48 @@ use super::{
pub trait WorldObjectBehavior {
fn get_id(&self) -> WorldObjectId;
fn set_id(&mut self, id: WorldObjectId);
fn get_current_tile_type(&self) -> TileType;

fn get_housing_capacity(&self) -> u32 {
0
}

fn set_housing_capacity(&mut self, _capacity: u32) {}

fn get_job_type(&self) -> JobType {
JobType::None
}

fn set_job_type(&mut self, _job_type: JobType) {}

fn get_job_production(&self) -> u32 {
0
}

fn set_job_production(&mut self, _job_production: u32) {}

fn get_current_tile_type(&self) -> TileType {
TileType::None
}

fn get_display_tile(&self, location: Vector2i) -> DisplayTile {
DisplayTile {
object_id: self.get_id(),
tile_type: self.get_current_tile_type(),
location,
}
}

fn get_display_tile_gd(&self, location: Vector2i) -> Gd<DisplayTile> {
Gd::from_object(self.get_display_tile(location))
}

fn apply_common_data(&mut self, common_data: Gd<WorldObjectCommonData>) {
self.set_id(common_data.bind().id);
self.set_job_type(common_data.bind().job_type)
}

fn provides_job(&self) -> bool {
self.get_job_type() != JobType::None
}
}

Expand All @@ -52,8 +81,18 @@ impl WorldObjectBehaviorType {
behavior.get_id()
}

pub fn get_job_type(&self) -> JobType {
let behavior = self.get_behavior();
behavior.get_job_type()
}

pub fn get_display_tile_gd(&self, location: Vector2i) -> Gd<DisplayTile> {
let behavior = self.get_behavior();
behavior.get_display_tile_gd(location)
}

pub fn provides_job(&self) -> bool {
let behavior = self.get_behavior();
behavior.provides_job()
}
}
Loading

0 comments on commit 8e90444

Please sign in to comment.