-
Notifications
You must be signed in to change notification settings - Fork 70
Entity Commands Orders and Actions
This is how the player gives commands to an entity, and how the game handles those orders.
[Feature]Command
class - each featureset that has orders needs one.
OrderableDB
datablob. - each entity that can be ordered needs one.
IOrderHandler
- an interface which handles the orders depending on whether server, client or singleplayer.
OrderableProcessor
- an IHotloop processor which runs every 10 min
Each featureset should have a [feature]Command.cs
which inherits from EntityCommand
The base class EntityCommand
is designed to be sent over the net.
It has an int ActionLanes
which is a bitmask which should be set in the child class
and an bool IsBlocking
which should also be set in the child class. more on these later.
Guid RequestingFactionGuid
is set when the command is constructed in the ui when
the player gives the command
Guid EntityCommandingGuid
is also set when the command is constructed,
and is the entity the player is giving the command to.
DateTime CreatedDate
also set when teh command is constructed and should
be the systemlocal at that point in time.
DateTime ActionedOnDate
is set when the server receves the coammand and actions it.
Entity EntityCommanding
is the actual entity that EntityCommandingGuid references.
this is not a [JsonProperty
] so when command is serialised it's just the guid that gets sent.
bool IsRunning
set to true by the server when the order is being processed.
bool IsFinished
returns true if the command has completed.
This just stores a list of pending orders for an entity.
This interface provides the base for:
StandAloneOrderHandler
- a class which handles orders if running in single
player mode.
NetworkServer
and NetworkClient
classes which handle orders on the server
or client respectively.
These classes
Check whether the order is valid,
Store the order in the Entities OrderableDB.ActionList,
and finaly processes the orderlist for that entity.
This class processes the orderlist for an entity.
Orders do not get processed imediately, instead they get put into a list in the OrderableDB
the OrderableProcessor examines the list, checks if any pending orders can be started depending on the 'ActionLane' an order is in and whether or not it's blocking. A better explanation of how Action lists and blocking work, see this: https://www.youtube.com/watch?v=o6CaB-hmqoE
(really do, watch the whole thing it's quite informitive.)
This class has room to be made more complex fairly easly if we decide we need to do so.
If an order can be Actioned (started) it calls the concrete Command's ActionCommand(Game game)
from there, depending on what the command does, it might create a datablob (see TranslateMoveCommand.cs) and insert it into the Entity's datablob list. this will then get processed as a hotloop or instance process.
Note that you will also need to create a ViewModel and View for the command so the player can give it.
Note that Command and Order, being synonymus is used somewhat interchangably in the code, this should probibly be cleaned up.
Documentation
-
Contribution
-
Design
-
Processes
-
Datatypes
-
Guides and Resources
-
Modding & Json files