2020-04-18 20:26:43 +00:00
|
|
|
use crate::{
|
2021-08-15 11:45:50 +00:00
|
|
|
assets::{self, AssetExt, Error},
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
comp::{
|
|
|
|
self, agent, humanoid,
|
2022-03-31 08:34:28 +00:00
|
|
|
inventory::loadout_builder::{LoadoutBuilder, LoadoutSpec},
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
Alignment, Body, Item,
|
|
|
|
},
|
2021-09-22 02:25:14 +00:00
|
|
|
lottery::LootSpec,
|
2020-11-23 15:39:03 +00:00
|
|
|
npc::{self, NPC_NAMES},
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
trade::SiteInformation,
|
2022-08-08 22:15:45 +00:00
|
|
|
rtsim,
|
2020-04-18 20:26:43 +00:00
|
|
|
};
|
2022-08-08 22:15:45 +00:00
|
|
|
use enum_map::EnumMap;
|
2021-06-06 15:55:04 +00:00
|
|
|
use serde::Deserialize;
|
2020-04-19 03:56:14 +00:00
|
|
|
use vek::*;
|
2020-04-18 20:26:43 +00:00
|
|
|
|
2022-09-08 19:51:02 +00:00
|
|
|
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
|
2021-10-11 10:40:59 +00:00
|
|
|
pub enum NameKind {
|
2021-07-11 18:24:44 +00:00
|
|
|
Name(String),
|
|
|
|
Automatic,
|
2021-07-04 14:55:52 +00:00
|
|
|
Uninit,
|
2021-06-08 21:58:15 +00:00
|
|
|
}
|
|
|
|
|
2022-09-08 19:51:02 +00:00
|
|
|
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
|
2021-10-11 10:40:59 +00:00
|
|
|
pub enum BodyBuilder {
|
2021-07-11 18:24:44 +00:00
|
|
|
RandomWith(String),
|
|
|
|
Exact(Body),
|
2021-07-10 18:44:53 +00:00
|
|
|
Uninit,
|
2021-06-08 22:07:48 +00:00
|
|
|
}
|
|
|
|
|
2021-07-04 14:55:52 +00:00
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
2021-10-11 10:40:59 +00:00
|
|
|
pub enum AlignmentMark {
|
2021-07-04 14:55:52 +00:00
|
|
|
Alignment(Alignment),
|
|
|
|
Uninit,
|
|
|
|
}
|
|
|
|
|
2021-07-29 09:22:14 +00:00
|
|
|
impl Default for AlignmentMark {
|
|
|
|
fn default() -> Self { Self::Alignment(Alignment::Wild) }
|
|
|
|
}
|
|
|
|
|
2022-02-20 16:22:53 +00:00
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
2022-03-31 08:34:28 +00:00
|
|
|
pub enum LoadoutKind {
|
2022-02-20 16:22:53 +00:00
|
|
|
FromBody,
|
|
|
|
Asset(String),
|
2022-04-07 15:22:27 +00:00
|
|
|
Inline(Box<LoadoutSpec>),
|
2022-02-20 16:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
|
|
pub struct InventorySpec {
|
2022-03-31 08:34:28 +00:00
|
|
|
loadout: LoadoutKind,
|
2022-02-20 16:22:53 +00:00
|
|
|
#[serde(default)]
|
|
|
|
items: Vec<(u32, String)>,
|
|
|
|
}
|
|
|
|
|
2021-07-11 18:24:44 +00:00
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
2021-10-11 10:40:59 +00:00
|
|
|
pub enum Meta {
|
2021-07-11 18:24:44 +00:00
|
|
|
SkillSetAsset(String),
|
|
|
|
}
|
|
|
|
|
2021-07-28 16:19:10 +00:00
|
|
|
// FIXME: currently this is used for both base definition
|
|
|
|
// and extension manifest.
|
|
|
|
// This is why all fields have Uninit kind which is means
|
|
|
|
// that this field should be either Default or Unchanged
|
|
|
|
// depending on how it is used.
|
|
|
|
//
|
2022-07-15 16:59:37 +00:00
|
|
|
// When we will use extension manifests more, it would be nicer to
|
2021-07-28 16:19:10 +00:00
|
|
|
// split EntityBase and EntityExtension to different structs.
|
|
|
|
//
|
|
|
|
// Fields which have Uninit enum kind
|
|
|
|
// should be optional (or renamed to Unchanged) in EntityExtension
|
|
|
|
// and required (or renamed to Default) in EntityBase
|
|
|
|
/// Struct for EntityInfo manifest.
|
|
|
|
///
|
2022-07-15 16:59:37 +00:00
|
|
|
/// Intended to use with .ron files as base definition or
|
2021-07-28 16:19:10 +00:00
|
|
|
/// in rare cases as extension manifest.
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
/// Pure data struct, doesn't do anything until evaluated with EntityInfo.
|
|
|
|
///
|
2021-07-28 16:19:10 +00:00
|
|
|
/// Check assets/common/entity/template.ron or other examples.
|
|
|
|
///
|
|
|
|
/// # Example
|
|
|
|
/// ```
|
|
|
|
/// use vek::Vec3;
|
|
|
|
/// use veloren_common::generation::EntityInfo;
|
|
|
|
///
|
|
|
|
/// // create new EntityInfo at dummy position
|
|
|
|
/// // and fill it with template config
|
|
|
|
/// let dummy_position = Vec3::new(0.0, 0.0, 0.0);
|
2022-01-27 22:01:00 +00:00
|
|
|
/// // rng is required because some elements may be randomly generated
|
|
|
|
/// let mut dummy_rng = rand::thread_rng();
|
|
|
|
/// let entity =
|
|
|
|
/// EntityInfo::at(dummy_position).with_asset_expect("common.entity.template", &mut dummy_rng);
|
2021-07-28 16:19:10 +00:00
|
|
|
/// ```
|
2021-07-11 11:28:56 +00:00
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
2022-04-04 08:44:19 +00:00
|
|
|
#[serde(deny_unknown_fields)]
|
2021-07-11 11:28:56 +00:00
|
|
|
pub struct EntityConfig {
|
2021-07-28 16:19:10 +00:00
|
|
|
/// Name of Entity
|
|
|
|
/// Can be Name(String) with given name
|
|
|
|
/// or Automatic which will call automatic name depend on Body
|
|
|
|
/// or Uninit (means it should be specified somewhere in code)
|
2021-10-11 10:40:59 +00:00
|
|
|
// Hidden, because its behaviour depends on `body` field.
|
2021-07-11 18:24:44 +00:00
|
|
|
name: NameKind,
|
2021-07-28 16:19:10 +00:00
|
|
|
|
|
|
|
/// Body
|
|
|
|
/// Can be Exact (Body with all fields e.g BodyType, Species, Hair color and
|
|
|
|
/// such) or RandomWith (will generate random body or species)
|
|
|
|
/// or Uninit (means it should be specified somewhere in code)
|
2021-10-11 10:40:59 +00:00
|
|
|
pub body: BodyBuilder,
|
2021-07-28 16:19:10 +00:00
|
|
|
|
|
|
|
/// Alignment, can be Uninit
|
2021-10-11 10:40:59 +00:00
|
|
|
pub alignment: AlignmentMark,
|
2021-07-28 16:19:10 +00:00
|
|
|
|
|
|
|
/// Loot
|
2021-09-22 02:25:14 +00:00
|
|
|
/// See LootSpec in lottery
|
2021-10-02 16:08:40 +00:00
|
|
|
pub loot: LootSpec<String>,
|
2021-07-28 16:19:10 +00:00
|
|
|
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
/// Loadout & Inventory
|
2022-02-20 16:22:53 +00:00
|
|
|
/// Check docs for `InventorySpec` struct in this file.
|
|
|
|
pub inventory: InventorySpec,
|
2021-07-28 16:19:10 +00:00
|
|
|
|
|
|
|
/// Meta Info for optional fields
|
|
|
|
/// Possible fields:
|
|
|
|
/// SkillSetAsset(String) with asset_specifier for skillset
|
2021-07-29 09:22:14 +00:00
|
|
|
#[serde(default)]
|
2021-10-11 10:40:59 +00:00
|
|
|
pub meta: Vec<Meta>,
|
2021-06-06 15:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl assets::Asset for EntityConfig {
|
|
|
|
type Loader = assets::RonLoader;
|
|
|
|
|
|
|
|
const EXTENSION: &'static str = "ron";
|
2020-04-18 20:26:43 +00:00
|
|
|
}
|
2020-01-25 02:15:15 +00:00
|
|
|
|
2021-07-11 11:28:56 +00:00
|
|
|
impl EntityConfig {
|
2022-01-27 20:30:26 +00:00
|
|
|
pub fn from_asset_expect_owned(asset_specifier: &str) -> Self {
|
2021-07-11 11:28:56 +00:00
|
|
|
Self::load_owned(asset_specifier)
|
2021-09-18 23:09:25 +00:00
|
|
|
.unwrap_or_else(|e| panic!("Failed to load {}. Error: {:?}", asset_specifier, e))
|
2021-07-11 11:28:56 +00:00
|
|
|
}
|
2021-10-11 10:40:59 +00:00
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2021-10-11 10:40:59 +00:00
|
|
|
pub fn with_body(mut self, body: BodyBuilder) -> Self {
|
|
|
|
self.body = body;
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
2021-07-11 11:28:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 11:45:50 +00:00
|
|
|
/// Return all entity config specifiers
|
|
|
|
pub fn try_all_entity_configs() -> Result<Vec<String>, Error> {
|
|
|
|
let configs = assets::load_dir::<EntityConfig>("common.entity", true)?;
|
2022-12-04 22:00:10 +00:00
|
|
|
Ok(configs.ids().map(|id| id.to_string()).collect())
|
2021-08-15 11:45:50 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 08:18:35 +00:00
|
|
|
#[derive(Clone)]
|
2020-01-25 02:15:15 +00:00
|
|
|
pub struct EntityInfo {
|
2020-01-22 03:12:17 +00:00
|
|
|
pub pos: Vec3<f32>,
|
2020-04-17 20:58:36 +00:00
|
|
|
pub is_waypoint: bool, // Edge case, overrides everything else
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
// Agent
|
2020-07-05 12:39:28 +00:00
|
|
|
pub has_agency: bool,
|
2020-04-17 20:58:36 +00:00
|
|
|
pub alignment: Alignment,
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
pub agent_mark: Option<agent::Mark>,
|
2022-02-11 06:23:09 +00:00
|
|
|
pub no_flee: bool,
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
// Stats
|
2020-04-18 20:26:43 +00:00
|
|
|
pub body: Body,
|
|
|
|
pub name: Option<String>,
|
2020-05-15 15:05:50 +00:00
|
|
|
pub scale: f32,
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
// Loot
|
2021-09-27 17:36:18 +00:00
|
|
|
pub loot: LootSpec<String>,
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
// Loadout
|
|
|
|
pub inventory: Vec<(u32, Item)>,
|
2022-01-23 16:07:54 +00:00
|
|
|
pub loadout: LoadoutBuilder,
|
2022-07-15 12:08:04 +00:00
|
|
|
pub make_loadout: Option<fn(LoadoutBuilder, Option<&SiteInformation>) -> LoadoutBuilder>,
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
// Skills
|
2021-06-07 21:58:05 +00:00
|
|
|
pub skillset_asset: Option<String>,
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
|
|
|
|
// Not implemented
|
2020-11-22 12:39:59 +00:00
|
|
|
pub pet: Option<Box<EntityInfo>>,
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
|
|
|
|
// Economy
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
// we can't use DHashMap, do we want to move that into common?
|
2022-07-15 12:08:04 +00:00
|
|
|
pub trading_information: Option<SiteInformation>,
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
//Option<hashbrown::HashMap<crate::trade::Good, (f32, f32)>>, /* price and available amount */
|
2020-04-17 20:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl EntityInfo {
|
|
|
|
pub fn at(pos: Vec3<f32>) -> Self {
|
|
|
|
Self {
|
|
|
|
pos,
|
|
|
|
is_waypoint: false,
|
2020-07-05 12:39:28 +00:00
|
|
|
has_agency: true,
|
2020-04-17 20:58:36 +00:00
|
|
|
alignment: Alignment::Wild,
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
agent_mark: None,
|
2020-04-18 20:26:43 +00:00
|
|
|
body: Body::Humanoid(humanoid::Body::random()),
|
|
|
|
name: None,
|
2020-05-15 15:05:50 +00:00
|
|
|
scale: 1.0,
|
2021-09-27 17:36:18 +00:00
|
|
|
loot: LootSpec::Nothing,
|
2022-01-27 12:47:46 +00:00
|
|
|
inventory: Vec::new(),
|
2022-01-23 16:07:54 +00:00
|
|
|
loadout: LoadoutBuilder::empty(),
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
make_loadout: None,
|
2021-06-07 21:58:05 +00:00
|
|
|
skillset_asset: None,
|
2020-11-22 12:39:59 +00:00
|
|
|
pet: None,
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
trading_information: None,
|
2022-02-11 06:23:09 +00:00
|
|
|
no_flee: false,
|
2020-04-17 20:58:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 16:40:58 +00:00
|
|
|
/// Helper function for applying config from asset
|
|
|
|
/// with specified Rng for managing loadout.
|
|
|
|
#[must_use]
|
2022-01-27 20:30:26 +00:00
|
|
|
pub fn with_asset_expect<R>(self, asset_specifier: &str, loadout_rng: &mut R) -> Self
|
2022-01-23 16:40:58 +00:00
|
|
|
where
|
|
|
|
R: rand::Rng,
|
|
|
|
{
|
2021-12-12 19:01:52 +00:00
|
|
|
let config = EntityConfig::load_expect_cloned(asset_specifier);
|
2021-06-06 15:55:04 +00:00
|
|
|
|
2022-01-23 16:40:58 +00:00
|
|
|
self.with_entity_config(config, Some(asset_specifier), loadout_rng)
|
2021-06-06 15:55:04 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 10:40:59 +00:00
|
|
|
/// Evaluate and apply EntityConfig
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2022-01-23 16:40:58 +00:00
|
|
|
pub fn with_entity_config<R>(
|
|
|
|
mut self,
|
|
|
|
config: EntityConfig,
|
|
|
|
config_asset: Option<&str>,
|
2022-01-27 20:30:26 +00:00
|
|
|
loadout_rng: &mut R,
|
2022-01-23 16:40:58 +00:00
|
|
|
) -> Self
|
|
|
|
where
|
|
|
|
R: rand::Rng,
|
|
|
|
{
|
2021-06-06 15:55:04 +00:00
|
|
|
let EntityConfig {
|
|
|
|
name,
|
2021-06-08 21:58:15 +00:00
|
|
|
body,
|
2021-07-04 14:55:52 +00:00
|
|
|
alignment,
|
2022-02-20 16:22:53 +00:00
|
|
|
inventory,
|
2021-06-08 22:07:48 +00:00
|
|
|
loot,
|
2021-07-10 20:51:29 +00:00
|
|
|
meta,
|
2021-06-06 15:55:04 +00:00
|
|
|
} = config;
|
|
|
|
|
2021-07-04 14:55:52 +00:00
|
|
|
match body {
|
|
|
|
BodyBuilder::RandomWith(string) => {
|
|
|
|
let npc::NpcBody(_body_kind, mut body_creator) =
|
|
|
|
string.parse::<npc::NpcBody>().unwrap_or_else(|err| {
|
|
|
|
panic!("failed to parse body {:?}. Err: {:?}", &string, err)
|
|
|
|
});
|
|
|
|
let body = body_creator();
|
|
|
|
self = self.with_body(body);
|
|
|
|
},
|
|
|
|
BodyBuilder::Exact(body) => {
|
|
|
|
self = self.with_body(body);
|
|
|
|
},
|
|
|
|
BodyBuilder::Uninit => {},
|
|
|
|
}
|
|
|
|
|
2021-07-11 18:24:44 +00:00
|
|
|
// NOTE: set name after body, as it's used with automatic name
|
|
|
|
match name {
|
|
|
|
NameKind::Name(name) => {
|
|
|
|
self = self.with_name(name);
|
|
|
|
},
|
|
|
|
NameKind::Automatic => {
|
|
|
|
self = self.with_automatic_name();
|
|
|
|
},
|
|
|
|
NameKind::Uninit => {},
|
|
|
|
}
|
|
|
|
|
2021-07-04 14:55:52 +00:00
|
|
|
if let AlignmentMark::Alignment(alignment) = alignment {
|
|
|
|
self = self.with_alignment(alignment);
|
2021-06-08 21:58:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 02:25:14 +00:00
|
|
|
self = self.with_loot_drop(loot);
|
2021-06-08 22:07:48 +00:00
|
|
|
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
// NOTE: set loadout after body, as it's used with default equipement
|
2022-02-20 16:22:53 +00:00
|
|
|
self = self.with_inventory(inventory, config_asset, loadout_rng);
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
|
|
|
|
for field in meta {
|
|
|
|
match field {
|
|
|
|
Meta::SkillSetAsset(asset) => {
|
|
|
|
self = self.with_skillset_asset(asset);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2022-02-20 16:22:53 +00:00
|
|
|
/// Return EntityInfo with LoadoutBuilder and items overwritten
|
2022-01-27 12:47:46 +00:00
|
|
|
// NOTE: helper function, think twice before exposing it
|
|
|
|
#[must_use]
|
2022-02-20 16:22:53 +00:00
|
|
|
fn with_inventory<R>(
|
2022-01-23 16:40:58 +00:00
|
|
|
mut self,
|
2022-02-20 16:22:53 +00:00
|
|
|
inventory: InventorySpec,
|
2022-01-23 16:40:58 +00:00
|
|
|
config_asset: Option<&str>,
|
2022-01-27 20:30:26 +00:00
|
|
|
rng: &mut R,
|
2022-01-23 16:40:58 +00:00
|
|
|
) -> Self
|
|
|
|
where
|
|
|
|
R: rand::Rng,
|
|
|
|
{
|
2022-02-20 16:22:53 +00:00
|
|
|
let config_asset = config_asset.unwrap_or("???");
|
|
|
|
let InventorySpec { loadout, items } = inventory;
|
|
|
|
|
|
|
|
// FIXME: this shouldn't always overwrite
|
|
|
|
// inventory. Think about this when we get to
|
|
|
|
// entity config inheritance.
|
|
|
|
self.inventory = items
|
|
|
|
.into_iter()
|
|
|
|
.map(|(num, i)| (num, Item::new_from_asset_expect(&i)))
|
|
|
|
.collect();
|
|
|
|
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
match loadout {
|
2022-03-31 08:34:28 +00:00
|
|
|
LoadoutKind::FromBody => {
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
self = self.with_default_equip();
|
|
|
|
},
|
2022-03-31 08:34:28 +00:00
|
|
|
LoadoutKind::Asset(loadout) => {
|
2022-02-20 16:22:53 +00:00
|
|
|
let loadout = LoadoutBuilder::from_asset(&loadout, rng).unwrap_or_else(|e| {
|
|
|
|
panic!("failed to load loadout for {config_asset}: {e:?}");
|
|
|
|
});
|
|
|
|
self.loadout = loadout;
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
},
|
2022-03-31 08:34:28 +00:00
|
|
|
LoadoutKind::Inline(loadout_spec) => {
|
2022-02-20 16:22:53 +00:00
|
|
|
let loadout =
|
2022-04-07 15:22:27 +00:00
|
|
|
LoadoutBuilder::from_loadout_spec(*loadout_spec, rng).unwrap_or_else(|e| {
|
2022-02-20 16:22:53 +00:00
|
|
|
panic!("failed to load loadout for {config_asset}: {e:?}");
|
|
|
|
});
|
|
|
|
self.loadout = loadout;
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return EntityInfo with LoadoutBuilder overwritten
|
2022-01-27 12:47:46 +00:00
|
|
|
// NOTE: helper function, think twice before exposing it
|
|
|
|
#[must_use]
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
fn with_default_equip(mut self) -> Self {
|
|
|
|
let loadout_builder = LoadoutBuilder::from_default(&self.body);
|
2022-01-23 16:07:54 +00:00
|
|
|
self.loadout = loadout_builder;
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-04-17 20:58:36 +00:00
|
|
|
pub fn do_if(mut self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self {
|
|
|
|
if cond {
|
|
|
|
self = f(self);
|
|
|
|
}
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-04-17 20:58:36 +00:00
|
|
|
pub fn into_waypoint(mut self) -> Self {
|
|
|
|
self.is_waypoint = true;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-04-17 20:58:36 +00:00
|
|
|
pub fn with_alignment(mut self, alignment: Alignment) -> Self {
|
|
|
|
self.alignment = alignment;
|
|
|
|
self
|
|
|
|
}
|
2020-04-18 20:26:43 +00:00
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-04-18 20:26:43 +00:00
|
|
|
pub fn with_body(mut self, body: Body) -> Self {
|
|
|
|
self.body = body;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-07-05 12:39:28 +00:00
|
|
|
pub fn with_name(mut self, name: impl Into<String>) -> Self {
|
|
|
|
self.name = Some(name.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-07-05 12:39:28 +00:00
|
|
|
pub fn with_agency(mut self, agency: bool) -> Self {
|
|
|
|
self.has_agency = agency;
|
2020-04-18 20:26:43 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
pub fn with_agent_mark(mut self, agent_mark: agent::Mark) -> Self {
|
|
|
|
self.agent_mark = Some(agent_mark);
|
|
|
|
self
|
|
|
|
}
|
2022-08-15 10:02:38 +00:00
|
|
|
|
|
|
|
#[must_use]
|
|
|
|
pub fn with_maybe_agent_mark(mut self, agent_mark: Option<agent::Mark>) -> Self {
|
|
|
|
self.agent_mark = agent_mark;
|
|
|
|
self
|
|
|
|
}
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2021-09-22 02:25:14 +00:00
|
|
|
pub fn with_loot_drop(mut self, loot_drop: LootSpec<String>) -> Self {
|
2021-09-27 17:36:18 +00:00
|
|
|
self.loot = loot_drop;
|
2020-05-15 15:05:50 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-05-15 15:05:50 +00:00
|
|
|
pub fn with_scale(mut self, scale: f32) -> Self {
|
|
|
|
self.scale = scale;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
pub fn with_lazy_loadout(
|
|
|
|
mut self,
|
2022-07-15 12:08:04 +00:00
|
|
|
creator: fn(LoadoutBuilder, Option<&SiteInformation>) -> LoadoutBuilder,
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
) -> Self {
|
|
|
|
self.make_loadout = Some(creator);
|
2020-11-21 00:25:33 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2021-06-07 21:58:05 +00:00
|
|
|
pub fn with_skillset_asset(mut self, asset: String) -> Self {
|
|
|
|
self.skillset_asset = Some(asset);
|
Split LodoutBuilder::build_loadout
LoadoutBuilder::build_loadout is a function which has four parameters
and 3 of them are Option<>, and although fourth (body) isn't Option<>,
it's optional too because it is used only in some combinations of
another arguments.
Because these combinations produces quirky code flow, it will be better
to split it to different methods.
So we did following changes to remove it and rewrite code that was using it
to use better methods.
* Introduce LoadoutPreset as new LoadoutConfig, currently it's only used
in Summon ability, because SummonInfo uses Copy and we can't specify
String for specifying asset path for loadout.
Everything else is rewritten to use asset path to create loadouts.
* More builder methods for LoadoutBuilder.
Namely:
- from_default which is used in server/src/cmd.rs in "/spawn" command.
- with_default_equipment, with_default_maintool to use default
loadout for specific body
- with_preset to use LoadoutPreset
* Add new make_loadout field with `fn (loadout_builder, trading_info) -> loadout_builder`
to EntityInfo which allows to lazily construct loadout without
modifying LoadoutBuilder code
* Fix Merchants not having trade site
We had heuristic that if something has Merchant LoadoutConfig - it's
merchant, which can be false, especially if we create Merchant loadout
lazily
As side note, we do same check for Guards and it fails too.
Too fix it, we introduce new agent::Mark, which explicitly specifies
kind of agent for entity
* `LoadoutBuilder::build_loadout` was written in a such way that depending
on main_tool you will have different loadout. Turns out it was this
way only for Adlets though and this behaviour is reproduced by specifying
different loadouts directly in world code.
2021-06-05 18:05:31 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-04-18 20:26:43 +00:00
|
|
|
pub fn with_automatic_name(mut self) -> Self {
|
2020-12-12 22:14:24 +00:00
|
|
|
let npc_names = NPC_NAMES.read();
|
2021-08-16 14:31:42 +00:00
|
|
|
let name = match &self.body {
|
2020-12-12 22:14:24 +00:00
|
|
|
Body::Humanoid(body) => Some(get_npc_name(&npc_names.humanoid, body.species)),
|
2020-04-19 03:56:14 +00:00
|
|
|
Body::QuadrupedMedium(body) => {
|
2020-12-12 22:14:24 +00:00
|
|
|
Some(get_npc_name(&npc_names.quadruped_medium, body.species))
|
2020-04-19 03:56:14 +00:00
|
|
|
},
|
2020-12-12 22:14:24 +00:00
|
|
|
Body::BirdMedium(body) => Some(get_npc_name(&npc_names.bird_medium, body.species)),
|
2021-04-02 00:04:32 +00:00
|
|
|
Body::BirdLarge(body) => Some(get_npc_name(&npc_names.bird_large, body.species)),
|
2020-12-12 22:14:24 +00:00
|
|
|
Body::FishSmall(body) => Some(get_npc_name(&npc_names.fish_small, body.species)),
|
|
|
|
Body::FishMedium(body) => Some(get_npc_name(&npc_names.fish_medium, body.species)),
|
|
|
|
Body::Theropod(body) => Some(get_npc_name(&npc_names.theropod, body.species)),
|
2020-04-19 03:56:14 +00:00
|
|
|
Body::QuadrupedSmall(body) => {
|
2020-12-12 22:14:24 +00:00
|
|
|
Some(get_npc_name(&npc_names.quadruped_small, body.species))
|
2020-04-19 03:56:14 +00:00
|
|
|
},
|
2020-12-12 22:14:24 +00:00
|
|
|
Body::Dragon(body) => Some(get_npc_name(&npc_names.dragon, body.species)),
|
|
|
|
Body::QuadrupedLow(body) => Some(get_npc_name(&npc_names.quadruped_low, body.species)),
|
|
|
|
Body::Golem(body) => Some(get_npc_name(&npc_names.golem, body.species)),
|
|
|
|
Body::BipedLarge(body) => Some(get_npc_name(&npc_names.biped_large, body.species)),
|
2021-07-25 15:16:57 +00:00
|
|
|
Body::Arthropod(body) => Some(get_npc_name(&npc_names.arthropod, body.species)),
|
2020-04-18 20:26:43 +00:00
|
|
|
_ => None,
|
2021-08-16 14:31:42 +00:00
|
|
|
};
|
|
|
|
self.name = name.map(str::to_owned);
|
2020-04-18 20:26:43 +00:00
|
|
|
self
|
|
|
|
}
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
/// map contains price+amount
|
|
|
|
#[must_use]
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
pub fn with_economy(mut self, e: &SiteInformation) -> Self {
|
|
|
|
self.trading_information = Some(e.clone());
|
|
|
|
self
|
|
|
|
}
|
2022-02-11 06:23:09 +00:00
|
|
|
|
2022-08-15 10:02:38 +00:00
|
|
|
/// map contains price+amount
|
|
|
|
#[must_use]
|
|
|
|
pub fn with_maybe_economy(mut self, e: Option<&SiteInformation>) -> Self {
|
|
|
|
self.trading_information = e.cloned();
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2022-02-11 06:23:09 +00:00
|
|
|
#[must_use]
|
|
|
|
pub fn with_no_flee(mut self) -> Self {
|
|
|
|
self.no_flee = true;
|
|
|
|
self
|
|
|
|
}
|
2020-01-22 03:12:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct ChunkSupplement {
|
2020-01-25 02:15:15 +00:00
|
|
|
pub entities: Vec<EntityInfo>,
|
2022-08-08 22:15:45 +00:00
|
|
|
pub rtsim_max_resources: EnumMap<rtsim::ChunkResource, usize>,
|
2020-01-25 02:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ChunkSupplement {
|
2020-04-17 23:29:01 +00:00
|
|
|
pub fn add_entity(&mut self, entity: EntityInfo) { self.entities.push(entity); }
|
2020-01-22 03:12:17 +00:00
|
|
|
}
|
2020-04-18 20:26:43 +00:00
|
|
|
|
2020-04-23 14:01:37 +00:00
|
|
|
pub fn get_npc_name<
|
2020-04-18 20:26:43 +00:00
|
|
|
'a,
|
|
|
|
Species,
|
|
|
|
SpeciesData: for<'b> core::ops::Index<&'b Species, Output = npc::SpeciesNames>,
|
|
|
|
>(
|
|
|
|
body_data: &'a comp::BodyData<npc::BodyNames, SpeciesData>,
|
|
|
|
species: Species,
|
|
|
|
) -> &'a str {
|
|
|
|
&body_data.species[&species].generic
|
|
|
|
}
|
2021-06-06 15:55:04 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2022-04-03 11:58:13 +00:00
|
|
|
use crate::SkillSetBuilder;
|
2021-07-16 21:45:53 +00:00
|
|
|
use hashbrown::HashMap;
|
|
|
|
|
|
|
|
#[derive(Debug, Eq, Hash, PartialEq)]
|
|
|
|
enum MetaId {
|
|
|
|
SkillSetAsset,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Meta {
|
|
|
|
fn id(&self) -> MetaId {
|
|
|
|
match self {
|
|
|
|
Meta::SkillSetAsset(_) => MetaId::SkillSetAsset,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-22 02:25:14 +00:00
|
|
|
#[cfg(test)]
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
fn validate_body(body: &BodyBuilder, config_asset: &str) {
|
2021-07-16 21:45:53 +00:00
|
|
|
match body {
|
|
|
|
BodyBuilder::RandomWith(string) => {
|
|
|
|
let npc::NpcBody(_body_kind, mut body_creator) =
|
|
|
|
string.parse::<npc::NpcBody>().unwrap_or_else(|err| {
|
|
|
|
panic!(
|
|
|
|
"failed to parse body {:?} in {}. Err: {:?}",
|
|
|
|
&string, config_asset, err
|
|
|
|
)
|
|
|
|
});
|
|
|
|
let _ = body_creator();
|
|
|
|
},
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
BodyBuilder::Uninit | BodyBuilder::Exact { .. } => {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2022-02-20 16:22:53 +00:00
|
|
|
fn validate_inventory(inventory: InventorySpec, body: &BodyBuilder, config_asset: &str) {
|
2022-04-03 11:58:13 +00:00
|
|
|
let InventorySpec { loadout, items } = inventory;
|
|
|
|
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
match loadout {
|
|
|
|
LoadoutKind::FromBody => {
|
|
|
|
if body.clone() == BodyBuilder::Uninit {
|
2021-07-16 21:45:53 +00:00
|
|
|
// there is a big chance to call automatic name
|
|
|
|
// when body is yet undefined
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
panic!("Used FromBody loadout with Uninit body in {}", config_asset);
|
|
|
|
}
|
|
|
|
},
|
2022-04-03 11:58:13 +00:00
|
|
|
LoadoutKind::Asset(asset) => {
|
|
|
|
let loadout =
|
|
|
|
LoadoutSpec::load_cloned(&asset).expect("failed to load loadout asset");
|
|
|
|
loadout
|
2022-04-04 08:44:19 +00:00
|
|
|
.validate(vec![asset])
|
2022-04-03 11:58:13 +00:00
|
|
|
.unwrap_or_else(|e| panic!("Config {config_asset} is broken: {e:?}"));
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
},
|
2022-04-03 11:58:13 +00:00
|
|
|
LoadoutKind::Inline(spec) => {
|
|
|
|
spec.validate(Vec::new())
|
|
|
|
.unwrap_or_else(|e| panic!("Config {config_asset} is broken: {e:?}"));
|
2021-07-16 21:45:53 +00:00
|
|
|
},
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-03 11:58:13 +00:00
|
|
|
// TODO: check for number of items
|
|
|
|
//
|
|
|
|
// 1) just with 16 default slots?
|
|
|
|
// - well, keep in mind that not every item can stack to infinite amount
|
|
|
|
//
|
|
|
|
// 2) discover total capacity from loadout?
|
|
|
|
for (num, item_str) in items {
|
|
|
|
let item = Item::new_from_asset(&item_str);
|
|
|
|
let mut item = item.unwrap_or_else(|err| {
|
|
|
|
panic!("can't load {} in {}: {:?}", item_str, config_asset, err);
|
|
|
|
});
|
|
|
|
item.set_amount(num).unwrap_or_else(|err| {
|
|
|
|
panic!(
|
|
|
|
"can't set amount {} for {} in {}: {:?}",
|
|
|
|
num, item_str, config_asset, err
|
|
|
|
);
|
|
|
|
});
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
fn validate_name(name: NameKind, body: BodyBuilder, config_asset: &str) {
|
|
|
|
if name == NameKind::Automatic && body == BodyBuilder::Uninit {
|
|
|
|
// there is a big chance to call automatic name
|
|
|
|
// when body is yet undefined
|
|
|
|
//
|
|
|
|
// use .with_automatic_name() in code explicitly
|
|
|
|
panic!("Used Automatic name with Uninit body in {}", config_asset);
|
2021-07-16 21:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-22 02:25:14 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
fn validate_loot(loot: LootSpec<String>, _config_asset: &str) {
|
|
|
|
use crate::lottery;
|
|
|
|
lottery::tests::validate_loot_spec(&loot);
|
2021-07-16 21:45:53 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 02:25:14 +00:00
|
|
|
#[cfg(test)]
|
2021-07-16 21:45:53 +00:00
|
|
|
fn validate_meta(meta: Vec<Meta>, config_asset: &str) {
|
|
|
|
let mut meta_counter = HashMap::new();
|
|
|
|
for field in meta {
|
|
|
|
meta_counter
|
|
|
|
.entry(field.id())
|
|
|
|
.and_modify(|c| *c += 1)
|
|
|
|
.or_insert(1);
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
|
2021-07-16 21:45:53 +00:00
|
|
|
match field {
|
|
|
|
Meta::SkillSetAsset(asset) => {
|
2022-07-15 12:08:04 +00:00
|
|
|
drop(SkillSetBuilder::from_asset_expect(&asset));
|
2021-07-16 21:45:53 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (meta_id, counter) in meta_counter {
|
|
|
|
if counter > 1 {
|
|
|
|
panic!("Duplicate {:?} in {}", meta_id, config_asset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-06 15:55:04 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_all_entity_assets() {
|
2021-08-15 11:45:50 +00:00
|
|
|
// Get list of entity configs, load everything, validate content.
|
|
|
|
let entity_configs =
|
|
|
|
try_all_entity_configs().expect("Failed to access entity configs directory");
|
|
|
|
for config_asset in entity_configs {
|
2021-06-07 21:58:05 +00:00
|
|
|
let EntityConfig {
|
2021-07-10 20:51:29 +00:00
|
|
|
body,
|
2022-02-20 16:22:53 +00:00
|
|
|
inventory,
|
2021-07-11 18:24:44 +00:00
|
|
|
name,
|
2021-07-16 21:45:53 +00:00
|
|
|
loot,
|
2021-07-10 20:51:29 +00:00
|
|
|
meta,
|
2021-07-04 14:55:52 +00:00
|
|
|
alignment: _alignment, // can't fail if serialized, it's a boring enum
|
2022-01-27 20:30:26 +00:00
|
|
|
} = EntityConfig::from_asset_expect_owned(&config_asset);
|
2021-06-07 21:58:05 +00:00
|
|
|
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
validate_body(&body, &config_asset);
|
|
|
|
// body dependent stuff
|
2022-02-20 16:22:53 +00:00
|
|
|
validate_inventory(inventory, &body, &config_asset);
|
Loadout Update. EntityInfo part
EntityConfig changes:
+ Add LoadoutKind instead of Hands + Meta::LoadoutAsset.
+ Allows for random loadout asset and inventory.
```
pub enum LoadoutAsset {
Loadout(String),
Choice(Vec<(f32, String)>),
}
pub enum LoadoutKind {
FromBody,
Asset(LoadoutAsset),
Hands(Hands),
Extended {
hands: Hands,
base_asset: LoadoutAsset,
inventory: Vec<(u32, String)>,
},
}
```
EntityInfo:
Remove
- pub main_tool: Option<Item>,
- pub second_tool: Option<Item>,
- pub loadout_asset: Option<String>,
Add
+ pub inventory: Vec<(u32, Item)>,
+ pub loadout: Option<LoadoutBuilder>,
2022-01-23 13:52:42 +00:00
|
|
|
validate_name(name, body, &config_asset);
|
|
|
|
// misc
|
2021-08-15 11:45:50 +00:00
|
|
|
validate_loot(loot, &config_asset);
|
|
|
|
validate_meta(meta, &config_asset);
|
2021-06-06 15:55:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|