Economy ECS API base
This commit is contained in:
commit
c8b6287b76
527
ECSAPI/.gitignore
vendored
Normal file
527
ECSAPI/.gitignore
vendored
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
|
||||||
|
out/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/clion,cmake,visualstudio,visualstudiocode,c++
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=clion,cmake,visualstudio,visualstudiocode,c++
|
||||||
|
|
||||||
|
### C++ ###
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
|
||||||
|
### CLion ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### CLion Patch ###
|
||||||
|
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||||
|
|
||||||
|
# *.iml
|
||||||
|
# modules.xml
|
||||||
|
# .idea/misc.xml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||||
|
.idea/**/sonarlint/
|
||||||
|
|
||||||
|
# SonarQube Plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||||
|
.idea/**/sonarIssues.xml
|
||||||
|
|
||||||
|
# Markdown Navigator plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||||
|
.idea/**/markdown-navigator.xml
|
||||||
|
.idea/**/markdown-navigator-enh.xml
|
||||||
|
.idea/**/markdown-navigator/
|
||||||
|
|
||||||
|
# Cache file creation bug
|
||||||
|
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||||
|
.idea/$CACHE_FILE$
|
||||||
|
|
||||||
|
# CodeStream plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||||
|
.idea/codestream.xml
|
||||||
|
|
||||||
|
### CMake ###
|
||||||
|
CMakeLists.txt.user
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles
|
||||||
|
CMakeScripts
|
||||||
|
Testing
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
install_manifest.txt
|
||||||
|
compile_commands.json
|
||||||
|
CTestTestfile.cmake
|
||||||
|
_deps
|
||||||
|
|
||||||
|
### CMake Patch ###
|
||||||
|
# External projects
|
||||||
|
*-prefix/
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
|
||||||
|
### VisualStudio ###
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.iobj
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*[.json, .xml, .info]
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/clion,cmake,visualstudio,visualstudiocode,c++
|
||||||
12
ECSAPI/.vscode/launch.json
vendored
Normal file
12
ECSAPI/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "cmake",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug portfile(s)",
|
||||||
|
"cmakeDebugType": "external",
|
||||||
|
"pipeName": "\\\\.\\pipe\\vcpkg_ext_portfile_dbg",
|
||||||
|
"preLaunchTask": "Debug vcpkg commands"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
16
ECSAPI/CMakeLists.txt
Normal file
16
ECSAPI/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
cmake_minimum_required (VERSION 3.8)
|
||||||
|
|
||||||
|
if (POLICY CMP0141)
|
||||||
|
cmake_policy(SET CMP0141 NEW)
|
||||||
|
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
project ("ECSAPI")
|
||||||
|
|
||||||
|
add_subdirectory ("Economy")
|
||||||
|
add_subdirectory ("Economy/test")
|
||||||
|
|
||||||
|
add_subdirectory ("ECS")
|
||||||
62
ECSAPI/CMakePresets.json
Normal file
62
ECSAPI/CMakePresets.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "windows-base",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
||||||
|
"installDir": "${sourceDir}/out/install/${presetName}",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "cl.exe",
|
||||||
|
"CMAKE_CXX_COMPILER": "cl.exe",
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-debug",
|
||||||
|
"displayName": "x64 Debug",
|
||||||
|
"inherits": "windows-base",
|
||||||
|
"architecture": {
|
||||||
|
"value": "x64",
|
||||||
|
"strategy": "external"
|
||||||
|
},
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-release",
|
||||||
|
"displayName": "x64 Release",
|
||||||
|
"inherits": "x64-debug",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x86-debug",
|
||||||
|
"displayName": "x86 Debug",
|
||||||
|
"inherits": "windows-base",
|
||||||
|
"architecture": {
|
||||||
|
"value": "x86",
|
||||||
|
"strategy": "external"
|
||||||
|
},
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x86-release",
|
||||||
|
"displayName": "x86 Release",
|
||||||
|
"inherits": "x86-debug",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
12
ECSAPI/CMakeUserPresets.json
Normal file
12
ECSAPI/CMakeUserPresets.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "DEBUG",
|
||||||
|
"inherits": "x64-debug",
|
||||||
|
"environment": {
|
||||||
|
"VCPKG_ROOT": "E:/vcpkg/vcpkg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
26
ECSAPI/ECS/CMakeLists.txt
Normal file
26
ECSAPI/ECS/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
project(ECS)
|
||||||
|
|
||||||
|
# List sources
|
||||||
|
|
||||||
|
set(HEADERS "ECS.h" "world.h")
|
||||||
|
set(SOURCES "ECS.cpp" "world.cpp")
|
||||||
|
|
||||||
|
list(TRANSFORM HEADERS PREPEND "include/")
|
||||||
|
list(TRANSFORM SOURCES PREPEND "src/")
|
||||||
|
|
||||||
|
# Find dependencies
|
||||||
|
find_package(EnTT CONFIG REQUIRED)
|
||||||
|
|
||||||
|
# Link library
|
||||||
|
|
||||||
|
add_library (ECS SHARED ${HEADERS} ${SOURCES})
|
||||||
|
|
||||||
|
target_link_libraries(ECS PRIVATE Economy::Economy)
|
||||||
|
target_link_libraries(ECS PRIVATE EnTT::EnTT)
|
||||||
|
|
||||||
|
target_include_directories(ECS PUBLIC include/)
|
||||||
|
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
|
set_property(TARGET ECS PROPERTY CXX_STANDARD 20)
|
||||||
|
endif()
|
||||||
11
ECSAPI/ECS/include/ECS.h
Normal file
11
ECSAPI/ECS/include/ECS.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// API to control world multithreaded processing in real time
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
|
||||||
|
}
|
||||||
28
ECSAPI/ECS/include/world.h
Normal file
28
ECSAPI/ECS/include/world.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <entt/entt.hpp>
|
||||||
|
#include "defines.h"
|
||||||
|
#include "enterprise_defaults.h"
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
class world
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
entt::registry registry;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// Run every registered system
|
||||||
|
/// </summary>
|
||||||
|
void update();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register new enterprise entity in specified state
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action">represents type of activity that enterprise do every tick</param>
|
||||||
|
/// <param name="state">is ID of state entity where enterprise will be placed</param>
|
||||||
|
/// <param name="defaults">is initial properties of enterprise</param>
|
||||||
|
void spawn_enterprise(const bool is_building, const ACTION_TYPE action, const entt::entity state, const enterprise_defaults defaults);
|
||||||
|
};
|
||||||
|
}
|
||||||
20
ECSAPI/ECS/src/ECS.cpp
Normal file
20
ECSAPI/ECS/src/ECS.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "ECS.h"
|
||||||
|
#include "world.h"
|
||||||
|
|
||||||
|
|
||||||
|
static ee_ecs::world world;
|
||||||
|
|
||||||
|
void ee_ecs::init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ee_ecs::start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ee_ecs::stop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
36
ECSAPI/ECS/src/world.cpp
Normal file
36
ECSAPI/ECS/src/world.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include "world.h"
|
||||||
|
#include "systems.h"
|
||||||
|
#include "components/enterprise.h"
|
||||||
|
#include "components/miner.h"
|
||||||
|
|
||||||
|
void ee_ecs::world::update()
|
||||||
|
{
|
||||||
|
mining(this->registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ee_ecs::world::spawn_enterprise(const bool is_building, const ACTION_TYPE action, const entt::entity state, const enterprise_defaults defaults)
|
||||||
|
{
|
||||||
|
entt::entity entity = this->registry.create();
|
||||||
|
|
||||||
|
auto &enterprise_c = this->registry.emplace<enterprise>(entity);
|
||||||
|
enterprise_c.is_building = is_building;
|
||||||
|
enterprise_c.state = state;
|
||||||
|
|
||||||
|
auto &container_c = this->registry.emplace<container>(entity);
|
||||||
|
container_c = defaults.container;
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case ACTION_TYPE::MINING:
|
||||||
|
{
|
||||||
|
auto& miner_c = this->registry.emplace<miner>(entity);
|
||||||
|
miner_c.resource = defaults.resource_target;
|
||||||
|
miner_c.value = defaults.base_efficiency_flat;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
ECSAPI/Economy/CMakeLists.txt
Normal file
32
ECSAPI/Economy/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
project(Economy)
|
||||||
|
|
||||||
|
# List sources
|
||||||
|
|
||||||
|
set(HEADERS "defines.h" "enterprise_defaults.h" "systems.h")
|
||||||
|
set(HEADERS_COMPONENTS "container.h" "enterprise.h" "miner.h" "producer.h" "tags.h")
|
||||||
|
|
||||||
|
set(SOURCES "Economy.cpp")
|
||||||
|
set(SOURCES_SYSTEMS "mining.cpp")
|
||||||
|
|
||||||
|
list(TRANSFORM HEADERS PREPEND "include/")
|
||||||
|
list(TRANSFORM HEADERS_COMPONENTS PREPEND "include/components/")
|
||||||
|
|
||||||
|
list(TRANSFORM SOURCES PREPEND "src/")
|
||||||
|
list(TRANSFORM SOURCES_SYSTEMS PREPEND "src/systems/")
|
||||||
|
|
||||||
|
# Find dependencies
|
||||||
|
|
||||||
|
find_package(EnTT CONFIG REQUIRED)
|
||||||
|
|
||||||
|
# Link library
|
||||||
|
|
||||||
|
add_library(Economy SHARED ${HEADERS} ${HEADERS_COMPONENTS} ${SOURCES} ${SOURCES_SYSTEMS})
|
||||||
|
add_library(Economy::Economy ALIAS Economy)
|
||||||
|
|
||||||
|
target_link_libraries(Economy PRIVATE EnTT::EnTT)
|
||||||
|
|
||||||
|
target_include_directories(Economy PUBLIC include/)
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
|
set_property(TARGET Economy PROPERTY CXX_STANDARD 20)
|
||||||
|
endif()
|
||||||
19
ECSAPI/Economy/include/components/container.h
Normal file
19
ECSAPI/Economy/include/components/container.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../defines.h"
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
struct container
|
||||||
|
{
|
||||||
|
double capacity = 0.;
|
||||||
|
double total = 0.;
|
||||||
|
std::unordered_map<RESOURCE_TYPE, double> content;
|
||||||
|
|
||||||
|
void add(RESOURCE_TYPE type, double delta)
|
||||||
|
{
|
||||||
|
content[type] += delta;
|
||||||
|
total += delta;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
12
ECSAPI/Economy/include/components/enterprise.h
Normal file
12
ECSAPI/Economy/include/components/enterprise.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <entt/entt.hpp>
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
struct enterprise
|
||||||
|
{
|
||||||
|
bool is_building = false;
|
||||||
|
|
||||||
|
entt::entity state;
|
||||||
|
};
|
||||||
|
}
|
||||||
12
ECSAPI/Economy/include/components/miner.h
Normal file
12
ECSAPI/Economy/include/components/miner.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../defines.h"
|
||||||
|
#include <entt/entt.hpp>
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
struct miner
|
||||||
|
{
|
||||||
|
RESOURCE_TYPE resource = RESOURCE_TYPE::NONE;
|
||||||
|
double value = 0.;
|
||||||
|
};
|
||||||
|
}
|
||||||
9
ECSAPI/Economy/include/components/producer.h
Normal file
9
ECSAPI/Economy/include/components/producer.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
struct producer
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
8
ECSAPI/Economy/include/components/tags.h
Normal file
8
ECSAPI/Economy/include/components/tags.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
|
||||||
|
struct state {};
|
||||||
|
|
||||||
|
}
|
||||||
82
ECSAPI/Economy/include/defines.h
Normal file
82
ECSAPI/Economy/include/defines.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
const double TOLERANCE = 0.001;
|
||||||
|
|
||||||
|
enum struct ACTION_TYPE : unsigned char
|
||||||
|
{
|
||||||
|
MINING,
|
||||||
|
PRODUCTION,
|
||||||
|
DELIVERY,
|
||||||
|
CONTAIN,
|
||||||
|
DESTRUCTION,
|
||||||
|
BUILD,
|
||||||
|
TRADE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum struct CONTAINABLE_TYPE : unsigned char
|
||||||
|
{
|
||||||
|
RESOURCE,
|
||||||
|
GOODS,
|
||||||
|
SERVICE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum struct RESOURCE_TYPE : unsigned char
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
|
||||||
|
AGRICULTURE,
|
||||||
|
MEAT,
|
||||||
|
COTTON,
|
||||||
|
LEATHER,
|
||||||
|
WOOL,
|
||||||
|
TIMBER,
|
||||||
|
COAL,
|
||||||
|
OIL,
|
||||||
|
GAS,
|
||||||
|
IRON,
|
||||||
|
COPPER,
|
||||||
|
LITHIUM,
|
||||||
|
URANIUM,
|
||||||
|
GOLD,
|
||||||
|
|
||||||
|
FERTILIZER,
|
||||||
|
FABRIC,
|
||||||
|
FURNITURE,
|
||||||
|
LUXURY,
|
||||||
|
CLOTHING,
|
||||||
|
ALCOHOL,
|
||||||
|
PAPER,
|
||||||
|
GLASS,
|
||||||
|
PLASTIC,
|
||||||
|
CEMENT,
|
||||||
|
STEEL,
|
||||||
|
FUEL,
|
||||||
|
AVIATION_FUEL,
|
||||||
|
ROCKET_FUEL,
|
||||||
|
ENGINES,
|
||||||
|
ELECTRICITY,
|
||||||
|
AUTOMOBILE,
|
||||||
|
AIRPLANE,
|
||||||
|
HELICOPTER,
|
||||||
|
PHONE,
|
||||||
|
TRUCK,
|
||||||
|
CONSTRUCTION_EQUIPMENT,
|
||||||
|
PROCESSOR,
|
||||||
|
COMPUTER,
|
||||||
|
ELECTRONIC,
|
||||||
|
SEMICONDUCTOR,
|
||||||
|
BATTERY,
|
||||||
|
SYNTHETIC_RUBBER,
|
||||||
|
SYNTHETIC_FABRIC,
|
||||||
|
MACHINE_TOOLS,
|
||||||
|
MODERN_MACHINE_TOOLS,
|
||||||
|
POLYMERS,
|
||||||
|
MILITARY_EQUIPMENT,
|
||||||
|
MEDICINES,
|
||||||
|
TACTICAL_MISSILES,
|
||||||
|
NUCLEAR_MISSILES,
|
||||||
|
OIL_GAS
|
||||||
|
};
|
||||||
|
}
|
||||||
13
ECSAPI/Economy/include/enterprise_defaults.h
Normal file
13
ECSAPI/Economy/include/enterprise_defaults.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "components/container.h"
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
struct enterprise_defaults
|
||||||
|
{
|
||||||
|
container container;
|
||||||
|
|
||||||
|
RESOURCE_TYPE resource_target;
|
||||||
|
double base_efficiency_flat;
|
||||||
|
};
|
||||||
|
}
|
||||||
27
ECSAPI/Economy/include/resources_exchange.h
Normal file
27
ECSAPI/Economy/include/resources_exchange.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Rules for resources exchange in base before modifiers applying
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <unordered_map>
|
||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
struct exchange_rule
|
||||||
|
{
|
||||||
|
double out_value;
|
||||||
|
|
||||||
|
std::unordered_map<RESOURCE_TYPE, double> consume;
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::unordered_map<RESOURCE_TYPE, exchange_rule> resources_exchange = {
|
||||||
|
{
|
||||||
|
RESOURCE_TYPE::FABRIC,
|
||||||
|
exchange_rule {
|
||||||
|
.out_value = 2.,
|
||||||
|
.consume = {
|
||||||
|
{RESOURCE_TYPE::WOOL, 3.}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
7
ECSAPI/Economy/include/systems.h
Normal file
7
ECSAPI/Economy/include/systems.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <entt/entt.hpp>
|
||||||
|
|
||||||
|
namespace ee_ecs
|
||||||
|
{
|
||||||
|
void mining(entt::registry& registry);
|
||||||
|
}
|
||||||
0
ECSAPI/Economy/src/Economy.cpp
Normal file
0
ECSAPI/Economy/src/Economy.cpp
Normal file
26
ECSAPI/Economy/src/systems/mining.cpp
Normal file
26
ECSAPI/Economy/src/systems/mining.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "systems.h"
|
||||||
|
#include "components/miner.h"
|
||||||
|
#include "components/container.h"
|
||||||
|
#include "components/enterprise.h"
|
||||||
|
|
||||||
|
void ee_ecs::mining(entt::registry ®istry)
|
||||||
|
{
|
||||||
|
auto miners = registry.view<enterprise, miner, container>();
|
||||||
|
|
||||||
|
for (auto [entity, enterprise, miner, local_storage]: miners.each())
|
||||||
|
{
|
||||||
|
container& state = registry.get<container>(enterprise.state);
|
||||||
|
|
||||||
|
if (!state.content.contains(miner.resource) || state.content[miner.resource] < TOLERANCE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double mined_value = miner.value;
|
||||||
|
if (local_storage.total + mined_value > local_storage.capacity)
|
||||||
|
mined_value = local_storage.capacity - local_storage.total;
|
||||||
|
if (mined_value > state.content[miner.resource])
|
||||||
|
mined_value = state.content[miner.resource];
|
||||||
|
|
||||||
|
local_storage.add(miner.resource, mined_value);
|
||||||
|
state.add(miner.resource, -mined_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
ECSAPI/Economy/test/CMakeLists.txt
Normal file
27
ECSAPI/Economy/test/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# List sources
|
||||||
|
|
||||||
|
set(SOURCES "test_conf.h" "main.cpp" "systems/mining.cpp")
|
||||||
|
|
||||||
|
# Find dependencies
|
||||||
|
|
||||||
|
find_package(GTest CONFIG REQUIRED)
|
||||||
|
|
||||||
|
# Link
|
||||||
|
|
||||||
|
include(GoogleTest)
|
||||||
|
|
||||||
|
add_executable(economy_tests ${SOURCES})
|
||||||
|
target_link_libraries(economy_tests PRIVATE GTest::gtest_main)
|
||||||
|
target_link_libraries(economy_tests PRIVATE Economy::Economy)
|
||||||
|
|
||||||
|
# Test
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET economy_tests POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:economy_tests> $<TARGET_FILE_DIR:economy_tests>
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
gtest_discover_tests(economy_tests)
|
||||||
8
ECSAPI/Economy/test/main.cpp
Normal file
8
ECSAPI/Economy/test/main.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
89
ECSAPI/Economy/test/systems/mining.cpp
Normal file
89
ECSAPI/Economy/test/systems/mining.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "components/container.h"
|
||||||
|
#include "components/miner.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "../test_conf.h"
|
||||||
|
#include "systems.h"
|
||||||
|
|
||||||
|
TEST_F(SystemsTest, MiningNormal)
|
||||||
|
{
|
||||||
|
ee_ecs::container &state_container = registry.get<ee_ecs::container>(state);
|
||||||
|
ee_ecs::container &miner_container = registry.get<ee_ecs::container>(miner);
|
||||||
|
ee_ecs::miner &miner_miner = registry.get<ee_ecs::miner>(miner);
|
||||||
|
|
||||||
|
state_container.capacity = 15.0;
|
||||||
|
state_container.add(ee_ecs::RESOURCE_TYPE::COAL, 10.0);
|
||||||
|
|
||||||
|
miner_container.capacity = 5.0;
|
||||||
|
miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL;
|
||||||
|
miner_miner.value = 0.1;
|
||||||
|
|
||||||
|
ee_ecs::mining(registry);
|
||||||
|
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.total, 9.9);
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 9.9);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.total, 0.1);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SystemsTest, MiningEmptyState)
|
||||||
|
{
|
||||||
|
ee_ecs::container &state_container = registry.get<ee_ecs::container>(state);
|
||||||
|
ee_ecs::container &miner_container = registry.get<ee_ecs::container>(miner);
|
||||||
|
ee_ecs::miner &miner_miner = registry.get<ee_ecs::miner>(miner);
|
||||||
|
|
||||||
|
state_container.capacity = 15.0;
|
||||||
|
|
||||||
|
miner_container.capacity = 5.0;
|
||||||
|
miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL;
|
||||||
|
miner_miner.value = 0.1;
|
||||||
|
|
||||||
|
ee_ecs::mining(registry);
|
||||||
|
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.total, 0.0);
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.0);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.total, 0.0);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SystemsTest, MiningPoorState)
|
||||||
|
{
|
||||||
|
ee_ecs::container &state_container = registry.get<ee_ecs::container>(state);
|
||||||
|
ee_ecs::container &miner_container = registry.get<ee_ecs::container>(miner);
|
||||||
|
ee_ecs::miner &miner_miner = registry.get<ee_ecs::miner>(miner);
|
||||||
|
|
||||||
|
state_container.capacity = 15.0;
|
||||||
|
state_container.add(ee_ecs::RESOURCE_TYPE::COAL, 0.05);
|
||||||
|
|
||||||
|
miner_container.capacity = 5.0;
|
||||||
|
miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL;
|
||||||
|
miner_miner.value = 0.1;
|
||||||
|
|
||||||
|
ee_ecs::mining(registry);
|
||||||
|
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.total, 0.0);
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.0);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.total, 0.05);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SystemsTest, MiningReachCap)
|
||||||
|
{
|
||||||
|
ee_ecs::container &state_container = registry.get<ee_ecs::container>(state);
|
||||||
|
ee_ecs::container &miner_container = registry.get<ee_ecs::container>(miner);
|
||||||
|
ee_ecs::miner &miner_miner = registry.get<ee_ecs::miner>(miner);
|
||||||
|
|
||||||
|
state_container.capacity = 15.0;
|
||||||
|
state_container.add(ee_ecs::RESOURCE_TYPE::COAL, 10.0);
|
||||||
|
|
||||||
|
miner_container.capacity = 0.05;
|
||||||
|
miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL;
|
||||||
|
miner_miner.value = 0.1;
|
||||||
|
|
||||||
|
ee_ecs::mining(registry);
|
||||||
|
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.total, 9.95);
|
||||||
|
ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 9.95);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.total, 0.05);
|
||||||
|
ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.05);
|
||||||
|
}
|
||||||
33
ECSAPI/Economy/test/test_conf.h
Normal file
33
ECSAPI/Economy/test/test_conf.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include "components/container.h"
|
||||||
|
#include "components/enterprise.h"
|
||||||
|
#include "components/miner.h"
|
||||||
|
#include "components/tags.h"
|
||||||
|
#include <entt/entt.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
struct SystemsTest : testing::Test
|
||||||
|
{
|
||||||
|
entt::registry registry;
|
||||||
|
|
||||||
|
entt::entity state;
|
||||||
|
|
||||||
|
entt::entity miner;
|
||||||
|
|
||||||
|
void SetUp()
|
||||||
|
{
|
||||||
|
// Create state
|
||||||
|
state = registry.create();
|
||||||
|
registry.emplace<ee_ecs::state>(state);
|
||||||
|
registry.emplace<ee_ecs::container>(state);
|
||||||
|
|
||||||
|
// Create miner enterprise
|
||||||
|
miner = registry.create();
|
||||||
|
registry.emplace<ee_ecs::enterprise>(miner, false, state);
|
||||||
|
registry.emplace<ee_ecs::miner>(miner);
|
||||||
|
registry.emplace<ee_ecs::container>(miner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
14
ECSAPI/vcpkg-configuration.json
Normal file
14
ECSAPI/vcpkg-configuration.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"default-registry": {
|
||||||
|
"kind": "git",
|
||||||
|
"baseline": "0cb95c860ea83aafc1b24350510b30dec535989a",
|
||||||
|
"repository": "https://github.com/microsoft/vcpkg"
|
||||||
|
},
|
||||||
|
"registries": [
|
||||||
|
{
|
||||||
|
"kind": "artifact",
|
||||||
|
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
|
||||||
|
"name": "microsoft"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
ECSAPI/vcpkg.json
Normal file
6
ECSAPI/vcpkg.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"dependencies": [
|
||||||
|
"entt",
|
||||||
|
"gtest"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user