Giter Club home page Giter Club logo

dwarfcorp's Introduction

DwarfCorp

DwarfCorp from Completely Fair Games is a single player tycoon/strategy game for PC. In the game, the player manages a corporate colony of dwarves. The dwarves must mine resources, build structures, and contend with the natives to survive.

BEFORE READING

If you're a developer/programmer and have the technical chops to compile C# code on Windows, continue reading. Otherwise, if you just want to play the game, buy the game on Steam or itch.io. You can also try a build on our releases page (above), but these builds will not be updated after the weekend of September 23rd, 2017.

If you're a developer on Linux and Mac, it may be possible to build the game without too much fuss using Mono, provided you have a content package that was first built on Windows. One of our contributors has a solution for this.

The project is financed directly through sales on Steam and itch.io. Since September 2017, all proceeds from sales go directly to our contracted developers.

External Dependencies

To develop DwarfCorp, you need the following libraries.

  • The XNA 4.0 library (not included)
  • Note: If you are running Windows 8 or higher, you will need to use MXA instead. This is included in our repository as a convenience. XNA has gotten very old and support was dropped for it long ago, and we must jump through hoops to get it working.
  • XNA-FNA for cross-platform development (forked)
  • LibNoise.NET (source code included)
  • JSON.NET (source code not included. You should get this through nuget.)

Cross Platform Development

We dont' officially support developing the game on anything other than a Windows machine at the moment. The game is developed using XNA/FNA using the XNA content project, which only supports a windows development environment. That said, the game can be cross compiled for windows/mac using FNA, but only in windows in a Visual Studio environment. Why XNA? Because it was cool when the project started (late 2011/early 2012).

If you're a developer on Linux and Mac, it may be possible to build the game without too much fuss using Mono, provided you have a content package that was first built on Windows. One of our contributors has a solution for this.

Building

To build and run in the game on a windows PC, you must do the following:

Building for XNA on Windows

  1. Download and install Visual Studio. Any version after 2012 will probably work. Our dev team currently uses Visual Studio 2017 Community.
  2. Download and install the XNA Game Studio 4.0 library (or install MXA from our repository if you are running Windows 8 or higher)

INSTALLING MXA

We started developing DwarfCorp in 2012. Back then, XNA was still a supported library in Visual Studio 2010. Ever since then, support has been dropped. So if you want to compile the game in say, Visual Studio 2017 Community, you will need to install the hacked up "MXA". This is a version of XNA that is hacked together to work on newer versions of Windows. We have included this in a folder called "MXA" under the root of our repository. Open that zip file, and install the dependencies one by one (there are 5 in the zip folder).

Note that in 2017, the MXA project seems to have disappeared itself. Newer versions of Visual Studio (2017 and higher) don't seem to work with it. Luckily, there is another hack that you can apply to MXA to get it working with Visual Studio 2017 here:

Note that we have included those hacks in our wiki here: https://github.com/CompletelyFairGames/dwarfcorp/wiki/Installing-MXA-Hacks

Original source is here.

Important note about the MXA Hacks!!

These hacks will install Microsoft.Build.Framework.dll into the global assembly cache (GAC). Since the GAC is no longer used to install Visual Studio dependencies, any upgrade you make to visual studio will break all of your projects after applying this hack. To resolve this issue, you must completely uninstall and reinstall visual studio instead of upgrading it, and then reapply the MXA hacks to get DwarfCorp compiling.

Compiling Build in VS

Once you have Visual Studio and XNA (or MXA) installed, you're ready to compile DwarfCorp.

  1. Open DwarfCorp.sln in Visual Studio
  2. Right-click on DwarfCorpXNA and set it as a StartUp project
  3. Add references to XNA binaries to the DwarfCorpXNA project.
  4. Build LibNoise project
  5. Set the DwarfCorpXNA build mode to Release or Debug
  6. Build DwarfCorpXNA
  7. You're done! Launch the build!

Problems and Solutions with building for XNA on Windows

  • I opened the solution but I don't see anything View->Solution Explorer
  • I can't install xna on windows 10
    • Install xna refresh https://mxa.codeplex.com/releases/view/618279
    • (you may find that google marks this download as malware. We do not endorse this binary but we have a programmer using it and virustotal seems to find no malware scanning the file)
  • I can't download from the mxa website
    • If this happens, we've included a complete copy of MXA in our repository for you to use.
  • 'Unable to find manifest signing certificate in the certificate store'
    • Project->DwarfCorpXNA properties-> Signing-> Create Test Certificate
    • You can use whatever password you want

Building for FNA on Windows

  1. Open 'DwarfCorpFNA.sln' in Visual Studio
  2. Build for XNA first. This will create the content files needed by FNA. Do this from within DwarfCorpFNA.sln
  3. Set 'DwarfCorpFNA' as the 'StartUp' project.
  4. Build DwarfCorpFNA.

Project Structure

There are several projects under the main folder:

  • DwarfCorpXNA contains source code for XNA builds of the game.
  • DwarfCorpFNA Contains source code for the FNA build. Most of the files in here are just cross-included from DwarfCorpXNA, but using different linked libraries and compile flags.
  • DwarfCorpContent Contains images, sounds, music, and content configuration files for DwarfCorp. Most assets in this content project may not be redistributed without the consent of Completely Fair Games Ltd.
  • LibNoise Is a fork of LibNosie.NET noise generation library.
  • FNA is a fork of XNA-FNA.

Licensing

The game is released under a modified MIT licensing agreement. That means all source code is free to use, modify and distribute. However, we have explicitly disallowed modification and redistribution of the following game content (which remains proprietary):

  • Images/Textures
  • 3D Models
  • Sound Effects
  • Music

No forks, binary redistributions, or other redistributions of this repository may include the proprietary game content. It is up to the redistributor to provide their own game content. "Source code" may also include raw text files, JSON library files, and XML configuration files (which are not considered proprietary "game content").

It's complicated. If you have a question about the licensing, raise an issue on the repository.

dwarfcorp's People

Contributors

blecki avatar ccajas avatar com1clyf3 avatar cxong avatar droe avatar makeshiftrobot avatar mklingen avatar pyrolitic avatar solsund avatar yueranyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dwarfcorp's Issues

Monolithic class PlayState

This needs to be split up.

My suggestion: Start by separating the 'world' into a simulation class that handles keeping track of the world and the dwarves and factions and what not, if such a thing doesn't already exist.
Then make a class responsible for building the chunks and what not.
And get the particle system initialization out of there.
PlayState should be left as the UI interaction logic and little else.

Move libraries to data files

Currently the static data associated with rooms, voxel types, etc. are mostly generated at runtime with harcoded C# structures. Ideally these should be in data files instead so that we're not tempted to hardcode special cases for different kinds of rooms/entities/voxels.

  • RoomLibrary -- A collection of room types and objects that spawn in the rooms
  • ResourceLibrary -- A collection of the different resource types (wood, stone, etc.) and their properties
  • CraftLibrary -- a collection of objects that can be crafted and the requirements for crafting them
  • VoxelLibrary -- a collection of Voxel types and their metadata
  • PrimitiveLibrary -- a collection of 3D primitives (meshes) generated at runtime for trees, beds, etc.
  • ParticleManager -- a collection of particle effects. (BONUS: could write an editor for these)
  • EntityFactory -- all the entities that can be created in the game. Likely only small parts of this can be converted into data files (perhaps some of the more simple Fixtures)
  • BiomeLibrary -- this has already been converted. A collection of Biomes and their properties.

GameStates are cached

I'm not seeing the benefit to this, and it means that all the menu states need to be re-entrant. It doesn't seem like it would be costly to recreate the auxiliary states on demand. It may also simplify the states themselves.

Also, it does not seem wise to use MainMenuState as both the launch menu and the in game pause menu.

Graphics Initialization Errors

Seemingly at random, when a new game starts one of the following might happen:

  • A dark blue screen is shown, with nothing else besides the GUI
  • Similar to the dark blue screen, except what's shown is a distorted image (as if passing through the refraction shader)

This is probably caused by an initialization error with the render targets.

Remove time forward/backward hacks. Add proper fast-forward button.

Many strategy/tycoon games have a fast-forward button. I think its vital to make the game more enjoyable.

  1. Remove the debug keys for moving time forward and backwards.
  2. Add a speed button to actually make time progress faster. This can be accomplished by modifying DwarfTime.cs to have a speed multiplier. That would have the effect of speeding up both the day/night cycle and all dwarf actions. Care must be taken so that it doesn't ruin the physics simulation or destroy the framerate.

Dwarves freak out cutting trees sometimes.

Give a dwarf a tree to cut down and some of the time they will lose their mind and refuse to do any work at all until you cancel the command. It appears to happen when you try to cut down a tree too close to another but I've had it happen with a tree in a clearing by itself.

When a dwarf gets this bug you can tell almost instantly because the dwarf will not be moving full speed but will almost appear to stutter, like he's accelerating then sliding to a stop over and over. If it does get to a tree it will stop standing right next to it almost like it's stuck by Xeno's Paradox and can't cross that remaining distance. If that poor dwarf has to jump up a block on the way to a tree they'll just quiver while touching the block.

It also sometimes appears that dwarves stuck in this loop do not fully accept their job because you can assign all four starting dwarves with "Chop" to a huge line of trees and multiple will attempt to cut down the same tree and lock up in this way instead of each one taking a different tree.

Finish making WorldManager non-static

  • Move WorldManager out of PlayState and into DwarfGame
  • Remove all static fields in WorldManager
  • Remove all static references to DwarfGame.WorldManager in...
  • Components
  • Entities
  • Scripts
  • Tools
  • GUI
  • GameStates
  • Remove static reference of WorldManager from DwarfGame

BodySelector inconsistent

Objects can be consistently selected when they are on the left side of the screen, but not on the right side of the screen. This was discovered while dealing with #19

Monogame port

I got the project to compile and run under monogame and I am listing the issues I encountered here just in case someone else wants to try a port.

  • All shaders need to be upgraded to SM 4.0. For all of them, a simple change from _2_0 to _4_0 was enough and allowed them to compile.
  • Setting up the new content project is tedious.
  • One new compile error on a call to SetVertexBuffers. Wrap first argument in a VB binding.
  • Delete the existing reference to JSON and install the current version through nuget.
  • Add a 'color' deserializer to the special JSON deserializers. I based it off the vector3 deserializer, with anther element. It was quite easy.

New gui issues

Playstate:

  • Hotkeys for time forward and backward not working. Pause hotkey not working. Minimap hotkey not working.
  • Time panel has both forward, backward and pause buttons visible now with no highlights to show which is being used.
  • screen briefly purple when starting game (likely this means whatever render target you're writing to the screen hasn't been initialized to yet before the first draw call)
  • Wood background panel on tray getting stretched instead of wrapped.
  • Main text now black instead of white with black stroke, making it unreadable.
  • Pushing the "Options" button on the top right causes an InvalidOperationException in Widget.cs
  • Tool buttons not highlighting when depressed
  • Mouse is drawn over old mouse. Perhaps new mouse should be hidden until GUI fully replaced.
  • No more tooltips on PlayState widgets.
  • Cooking button now gone (has wrong icon, and pushing it doesn't reveal cooking menu)
  • Number keys no longer correspond to appropriate tools in the tool bar on the bottom right (should be row-major order)

In general:

  • No more mouse over events. (highlighting)
  • Mouse scale is now 1x instead of 2x
  • Sliders not responding to drag events.
  • Widget backgrounds are stretched instead of wrapped (should be a simple fix in the shader).

Better feedback during mining/building/selecting

Low hanging fruit: while the player is dragging and selecting stuff, show them what they are going to select/mine/build while they are dragging for more feedback. Right now, there is no feedback until the player releases the mouse. This is especially useful while mining unseen blocks.

  • While dragging the mouse over blocks, display the blocks that are to be mined/selected/built (including invisible blocks)
  • While dragging the mouse over entities, highlight them
  • While dragging to build objects, display ghost items. Display something red/bad when the player can't build there.
  • While dragging to build rooms, display the objects that will populate the room.

Dwarves can gain experience from cancelled tasks.

Select dwarves, tell them to dig a tile then after they start moving cancel the dig tile task. They keep walking to the target, get there and find nothing to do. For some reason this gains them +10 XP.

Musket dwarves have to be right next to an opponent to start to fire.

I tried to shoot down a bird with a Musket Dwarf and despite the bird flying nearly right overhead he couldn't shoot. So I cancelled the bird attack and went to attack a Deer instead. He had to walk all the way up to the deer so he was nearly touching it then stopped and entered a firing state.

Once he hit the deer the deer started running much faster and the dwarf continued to fire at the deer even when he was on the other side of the map. He did eventually stop firing on his own but I do not know if he killed the deer or hit some manner of auto cancellation.

Make camera more intuitive

Right now its an FPS camera (holding shift rotates around the camera center) because I personally found that intuitive -- but most playtesters have found it confusing. Switch to an orbit camera that instead rotates around the voxel selected by the mouse. Have scroll wheel zoom in and out instead of up and down.

Bonus:

  • Add camera rotation buttons that rotate the camera around the up axis by 90 degree increments, keeping the center focused on the selected voxel.

  • Allow dragging the camera using the middle mouse button.

Frustum culling slow

My recent analysis of the game performance reveals we are spending 22% of every frame simply finding the entities that are within the camera frustum (FrustumCullLocatableComponents). This causes huge performance hits in dense environments like jungles. It is by far the single largest function call in the game. This should be made faster.

Runescape UF Font error during build

Building the DwarfCorpXNA project requires the Runescape UF font to be installed on the users OS.

If you add the font to the build somewhere I guess you could either script the font install or enhance the build instructions in the repo.

Dwarves can easily get stuck.

All you have to do to shut a brand new game down is accidently dig two blocks deep with all three digging dwarves. Because dwarves can only dig tiles one square away this means a dwarf can not do the essential upwards diagonal dig required to craft a makeshift staircase back out.

Your only options are not pretty. You can dig a small trench then have the game build a Wall in the pit for them to use as a stepping stone back out. That is assuming you have anything in your stockpile. If you don't then you have to dig a 3x3 area for a stockpile then try to build out using your builder, who is now stuck until it works.

If somehow you dig into a cave and fall more than one block down this is still theoretically possible but is tremendously difficult to do. I managed to make three steps up before my dwarves would refuse to go any higher despite the ceiling having empty space to jump into.

A lot of this could be solved by letting dwarves dig diagonally up, so long as the block above them is already missing. Then they could construct their own stairs without all the extra steps, assuming they don't refuse to climb as well.

Dwarves get stuck while trying to mine unreachable blocks

Sometimes the dwarf will fall into a pit or something while trying to mine a block, then lose track of the block. It will then freeze up and not do anything unless the mining action is canceled. I've tried numerous checks to prevent this from happening (for one they will only try to mine it a few times before giving up), but it persists.

Sound and music initialized too late.

Initializing the SoundManager class currently doesn't happen until inside PlayState which stops sounds from being used until the game has entered into that state. This stops the ability to have music at the main menu or any sort of GUI button click sounds before fully loading a world.

A new location is needed for this initialization.

Mac OSX launch problems

I am willing to be a macOS tester for you guys, I noticed the mac builds are problematic. Really would like to see them rock. I have experience in software development professionally and know how to write bug reports and gather data.

Most recent cross-platform build won't even launch.

Specs:
macOS 10.12.1
2.7GHz i7
16GB DDR3
SSD HDD

Fix project structure

  1. FNA solution is currently broken and unmaintained.
  2. DwarfCorpXNA, DwarfCorpFNAand DwarfCorpCore are different projects. DwarfCorpXNA/FNA only link to DwarfCorpCore. This is silly. DwarfCorpCore should be deleted entirely. DwarfCorpXNA and DwarfCorpFNA should live in the same directories as one another and share the same code.

Fog of war is broken

Inconsistencies in the way fog of war works. If a dwarf mines into a cave and reveals the cave from the top, fog of war is never revealed. If the dwarf mines in through the side, it is revealed. Probably a logical error in the flood fill.

Input dropped during poor performance

The game uses a polling system and generates mouse and keyboard events from them. This means that it is easy to drop mouse clicks and key presses when performance is degraded. These should be switched to use the underlying OS message queues. For example, on windows, you can use a message filter to catch the actual mouse events, even when performance is degraded.

OS support will also allow proper detection of the actual symbol the player typed, rather than relying on a hardcoded if-else block that only works for American keyboards. See https://github.com/Blecki/GnomeColony/blob/master/GnomeColony/Gem/Common/KeyboardMessageFilter.cs for an example implementation handling keyboards.

I have this implemented for the windows version, including mouse events, and ready to go.

Loading doesn't work

To release alpha 2.0, we will have to fix saving/loading again. Right now it just crashes. This goes for both loading games and loading worlds.

Drawer3D slow

Performance needs to be improved for Drawer3D. The lowest hanging fruit will be not regenerating geometry every frame for selected voxels. After that we could gain a lot by using a shader to draw thick lines rather than generating geometry on the CPU.

Camera can not move when pointing straight up/down.

Camera movement seems to be based on rotational angle even when not in RotationalMode. This causes the math to fail when we are pointing straight up or down.

Right/Left movement fails completely and Forward/Backward fails when not holding Shift.

Make GUI work in FNA

Currently the new GUI is broken in FNA due to reliance on windows forms. This makes the game unplayable on osx and linux. Re-write the input layer to use SDL for the FNA version of the game.

Dwarves are not very smart about digging downwards.

Trying to craft a little 3-block wide zig-zag staircase into a cliff has shown that dwarves will jump off of blocks above a block that is marked and try to mine it on their way past. Sometimes this will oddly work even if the block is two above them and one over. Other times they will just fall right past it and will either enter a semi-inifinite loop of walking back up above and jumping down or they will just lock into place under the tile and refuse to do any more work.

They appear to think they are actually mining the block despite failing the call to strike it.

They can also try to do this same thing by stepping off a block to the side before they fall. I had all three miner dwarves lock up this way despite me choosing the perfectly reachable block just to the right of it as well.

Finish refactoring Creature Constructors

It looks like the Creature constructor and EntityFactory code are in the process of being refactored to loading CreatureDef objects from JSON. This seems nice and can eliminate quite a bit of redundant code.

Doesn't seem like a high priority issue but since the code is already written, we should probably bring all the creatures over to using CreatureDef eventually.

Mass Voxel selection can miss perfectly valid targets.

Selecting voxels using the new method that only selects currently visible voxels can leave gaps in the selection.

In the example picture look at the row where the mouse cursor is found. Those seven in that row are not selected and will not be destroyed. The little three block row the dwarves are standing on in the shot also had this issue. Near the very top are a few more that are surrounded on all sides except for the top face and are not selected.

Three rows up there is exactly the same voxel formation (a voxel blocked on all sides except for towards the camera) happening except those are selected just fine.

image

Alpha 2.0 Playtesting Issues

Going to check these as I fix them.

  • Sometimes, can't select craftsdwarves. On spawn, craftsdwarves are not selectable
  • Dwarves only have first names (not last names) when generated
  • When chopping trees, dwarves sometimes get stuck in infinite replanning loops
  • Wandering to random rooms should be removed, it makes dwarves less likely to respond to commands
  • When a new employee is hired, its spritesheet isn't initialized yet, so if you click on that employee in the "employees" screen before going to the playstate screen, the game crashes.
  • After the above was fixed, size of sprite source rectangle is not correct for the newly hired employee. Only persists until a single call to PlayState.Update has been made.
  • first two rooms built in my playthrough, stockpile and mushroom farm, not recognized by games as rooms
    --stockpile - still usable for storage, no room outline, can't be destroyed via build menu
    --mushroom farm - no farm button, no room outline, can't be destroyed via build menu
    --next room built was via god mode - all rooms from that one on worked fine
  • pausing causes farm icons to freeze relative to screen
  • multiple dwarves work same farm tile, causing only one farmable to pop up
  • draw order of farm button - appears in front of windows (god mode, at least)
  • all spells are researched already
  • units get stuck in walls (wizard dwarf couldn't jump out of pit - fighting an enemy freed him)
  • enemies spawn on edge of world / are able to fall off edge of world
  • elves were stuck in air playing fall animation on edge of cliff? is it possible that rounded-off dirt voxels on cliff edges had something to do with it?
  • sfx may fall off too quickly with distance
  • not really a bug - dwarves freak out when trying to mine cliff faces above them
  • Sometimes, when dwarves are piled up on one another (such as when they are chopping trees), the force they apply to each other becomes infinite, and they teleport to the end of the world.
  • Camera padding should be made smaller so the player can't see the edge of the world
  • Only 5 dwarves can be assigned mining tasks at once.
  • 320x240 is a ridiculous resolution. Set the minimum to 800x600
  • Trees are not getting added to the collision manager properly
  • Different combinations of opening/closing the options menu with either the top right button or Escape put the game into a state where it can't be unpaused.
  • When the game is paused, killing a dwarf results in the stock price falling forever!?
  • When the game is paused, selling an item causes the stock price to rise forever
  • Entering the buy menu, selling/buying something, then hiring an employee results in the "shopping cart" being invisible, and buying/selling becomes impossible
  • Pushing "End" kills the game instantly. This is undesirabe behavior outside of debug builds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.