Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Jan 11, 2024
1 parent f827e00 commit 6ed804c
Show file tree
Hide file tree
Showing 22 changed files with 793 additions and 400 deletions.
51 changes: 51 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 1 addition & 80 deletions assets/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,5 @@
"name": "cereal",
"label": "Cereal"
},
{
"name": "flour",
"label": "Flour"
},
{
"name": "bread",
"label": "Bread"
},
{
"name": "vegetable",
"label": "Vegetable"
},
{
"name": "carcass",
"label": "Carcass"
},
{
"name": "raw-meat",
"label": "Raw meat"
},
{
"name": "meat",
"label": "Meat"
},
{
"name": "tree-log",
"label": "Tree Log"
},
{
"name": "wood-plank",
"label": "Wood Plank"
},
{
"name": "iron-ore",
"label": "Iron Ore"
},
{
"name": "metal",
"label": "Metal"
},
{
"name": "gold",
"label": "Gold"
},
{
"name": "high-tech-product",
"label": "High Tech Product"
},
{
"name": "furniture",
"label": "Furniture"
},
{
"name": "flower",
"label": "Flower"
},
{
"name": "wool",
"label": "Wool"
},
{
"name": "cloth",
"label": "Cloth"
},
{
"name": "oil",
"label": "Oil"
},
{
"name": "coal",
"label": "Coal"
},
{
"name": "electricity",
"label": "Electricity"
},
{
"name": "polyester",
"label": "Polyester"
}

]
4 changes: 2 additions & 2 deletions assets_gui/src/companies.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use common::saveload::Encoder;
use prototypes::GoodsCompanyDescriptionJSON;
use prototypes::GoodsCompanyPrototypeJSON;
use std::io;

pub struct Companies {
pub companies: Vec<GoodsCompanyDescriptionJSON>,
pub companies: Vec<GoodsCompanyPrototypeJSON>,
pub changed: bool,
}

Expand Down
Empty file added base/companies.lua
Empty file.
1 change: 1 addition & 0 deletions base/data.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("items")
113 changes: 113 additions & 0 deletions base/items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
data:extend {
{
type = "item",
name = "job-opening",
label = "Job opening",
optout_exttrade = true
},
{
type = "item",
name = "cereal",
label = "Cereal"
},
{
type = "item",
name = "flour",
label = "Flour"
},
{
type = "item",
name = "bread",
label = "Bread"
},
{
type = "item",
name = "vegetable",
label = "Vegetable"
},
{
type = "item",
name = "carcass",
label = "Carcass"
},
{
type = "item",
name = "raw-meat",
label = "Raw meat"
},
{
type = "item",
name = "meat",
label = "Meat"
},
{
type = "item",
name = "tree-log",
label = "Tree Log"
},
{
type = "item",
name = "wood-plank",
label = "Wood Plank"
},
{
type = "item",
name = "iron-ore",
label = "Iron Ore"
},
{
type = "item",
name = "metal",
label = "Metal"
},
{
type = "item",
name = "gold",
label = "Gold"
},
{
type = "item",
name = "high-tech-product",
label = "High Tech Product"
},
{
type = "item",
name = "furniture",
label = "Furniture"
},
{
type = "item",
name = "flower",
label = "Flower"
},
{
type = "item",
name = "wool",
label = "Wool"
},
{
type = "item",
name = "cloth",
label = "Cloth"
},
{
type = "item",
name = "oil",
label = "Oil"
},
{
type = "item",
name = "coal",
label = "Coal"
},
{
type = "item",
name = "electricity",
label = "Electricity"
},
{
type = "item",
name = "polyester",
label = "Polyester"
}
}
10 changes: 10 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ pub fn fastset_with_capacity<V>(cap: usize) -> FastSet<V> {
FastSet::with_capacity_and_hasher(cap, Default::default())
}

pub type TransparentMap<K, V> = std::collections::HashMap<K, V, TransparentHasherU64>;

pub fn transparentmap_with_capacity<K, V>(cap: usize) -> TransparentMap<K, V> {
TransparentMap::with_capacity_and_hasher(cap, Default::default())
}

pub fn transparentmap<K, V>() -> TransparentMap<K, V> {
TransparentMap::with_hasher(Default::default())
}

#[derive(Default)]
pub struct TransparentHasherU64(u64);

Expand Down
2 changes: 1 addition & 1 deletion common/src/timestep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub const UP_DT: Duration = Duration::from_millis(20);

/// A timestep that can be used to update the game state.
/// It will try to keep a constant update rate.
/// Based on https://gafferongames.com/post/fix_your_timestep/
/// Based on <https://gafferongames.com/post/fix_your_timestep/>
pub struct Timestep {
last_time: Instant,
acc: Duration,
Expand Down
7 changes: 4 additions & 3 deletions geom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ edition = "2021"

[dependencies]
ordered-float = { workspace = true }
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
fnv = "1.0.3"
inline_tweak = "1.0.8"
flat_spatial = { workspace = true }
inline_tweak = "1.0.8"
flat_spatial = { workspace = true }
mlua = "0.9.4"
2 changes: 1 addition & 1 deletion geom/src/aabb3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl AABB3 {

/// as ray is defined by O + tD, return the t values for the entering and exiting intersections
/// Returns a 2-tuple of (t_near, t_far)
/// Adapted from https://gist.github.com/DomNomNom/46bb1ce47f68d255fd5d
/// Adapted from <https://gist.github.com/DomNomNom/46bb1ce47f68d255fd5d>
/// If the ray origin is inside the box, t_near will be zero
#[inline]
pub fn raycast(&self, ray: Ray3) -> Option<(f32, f32)> {
Expand Down
24 changes: 24 additions & 0 deletions geom/src/v2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{Circle, Intersect, Polygon, Radians, Shape, Vec3, Vec3d, AABB, OBB};
use mlua::{FromLua, Value};
use serde::{Deserialize, Deserializer, Serialize};
use std::fmt::{Debug, Display, Formatter};
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -1170,6 +1171,29 @@ impl From<[f64; 2]> for Vec2d {
}
}

impl<'a> FromLua<'a> for Vec2 {
fn from_lua(value: Value<'a>, _: &'a mlua::Lua) -> mlua::Result<Self> {
let t = match value {
Value::Vector(v) => return Ok(Self { x: v.x(), y: v.y() }),
Value::Table(t) => t,
_ => {
return Err(mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: "Vec2",
message: Some("expected a table or vector".to_string()),
})
}
};
if let Ok(x) = t.get(1) {
return Ok(Self { x, y: t.get(2)? });
}

let x = t.get("x")?;
let y = t.get("y")?;
Ok(Vec2::new(x, y))
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading

0 comments on commit 6ed804c

Please sign in to comment.