Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
bwapi/bwapi/include/BWAPI/Interface.h at main · bwapi/bwapi · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
bwapi
bwapi
Repository navigation
Code
Issues
127
(127)
Pull requests
2
(2)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
bwapi
/
bwapi
/
include
/
BWAPI
/
Interface.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
129 lines (117 loc) · 4.58 KB
main
Breadcrumbs
bwapi
/
bwapi
/
include
/
BWAPI
/
Interface.h
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
129 lines (117 loc) · 4.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#
pragma
once
#
include
<
map
>
#
include
<
list
>
#
include
<
BWAPI/InterfaceEvent.h
>
namespace
BWAPI
{
//
/ <summary>This generalized class allows the application of features that are common to all interface
//
/ classes.</summary>
//
/
//
/ @tparam T
//
/ The class that inherits this interface.
template
<
typename
T >
class
Interface
{
protected:
//
/ @cond HIDDEN
Interface
() =
default
;
virtual
~Interface
() {};
std::map<
int
,
void
*> clientInfo;
std::list< InterfaceEvent<T> > interfaceEvents;
friend
class
GameImpl
;
//
Function manages events and updates it for the given frame
void
updateEvents
()
{
auto
e = interfaceEvents.
begin
();
while
( e != interfaceEvents.
end
() )
{
if
( e->
isFinished
() )
{
e = interfaceEvents.
erase
(e);
}
else
{
e->
execute
(
static_cast
<T*>(
this
));
++e;
}
}
};
//
/ @endcond
public:
//
/ <summary>Retrieves a pointer or value at an index that was stored for this interface using
//
/ setClientInfo.</summary>
//
/
//
/ <param name="key">
//
/ The key containing the value to retrieve. Default is 0.
//
/ </param>
//
/
//
/ @retval nullptr if index is out of bounds.
//
/ @returns The client info at the given index.
//
/ @see setClientInfo
void
*
getClientInfo
(
int
key =
0
)
const
{
//
Retrieve iterator to element at index
auto
result =
this
->
clientInfo
.
find
(key);
//
Return a default value if not found
if
( result ==
this
->
clientInfo
.
end
() )
return
nullptr
;
//
return the desired value
return
result->
second
;
};
template
<
typename
CT
>
CT
getClientInfo
(
int
key =
0
)
const
{
return
(
CT
)(
int
)
this
->
getClientInfo
(key);
};
//
/ <summary>Associates one or more pointers or values with any BWAPI interface.</summary>
//
/
//
/ This client information is managed entirely by the AI module. It is not modified by BWAPI.
//
/ @warning If a pointer to allocated memory is used, then the AI module is responsible for
//
/ deallocating the memory when the game ends.
//
/
//
/ If client info at the given index has already been set, then it will be overwritten.
//
/
//
/ <param name="clientInfo">
//
/ The data to associate with this interface.
//
/ </param>
//
/ <param name="key">
//
/ The key to use for this data. Default is 0.
//
/ </param>
//
/
//
/ @see getClientInfo
template
<
typename
V >
void
setClientInfo
(
const
V &clientInfo,
int
key =
0
)
{
this
->
clientInfo
[key] = (
void
*)clientInfo;
};
//
/ <summary>Registers an event and associates it with the current Interface object.</summary>
//
/ Events can be used to automate tasks (like train X @Marines until Y of them have been
//
/ created by the given @Barracks) or to create user-defined callbacks.
//
/
//
/ <param name="action">
//
/ The action callback to be executed when the event conditions are true. It is of type
//
/ void fn(T *inst) where fn is the function name and inst is a pointer to the instance of
//
/ the object performing the action.
//
/ </param>
//
/ <param name="condition"> (optional)
//
/ The condition callback which will return true if the action is intended to be executed.
//
/ It is of type bool fn(T *inst) where fn is the function name and inst is a pointer to the
//
/ instance of the object performing the check. The condition will always be true if omitted.
//
/ </param>
//
/ <param name="timesToRun"> (optional)
//
/ The number of times to execute the action before the event is removed. If the value is
//
/ negative, then the event will never be removed. The value will be -1 if omitted, causing
//
/ the event to execute until the game ends.
//
/ </param>
//
/ <param name="framesToCheck"> (optional)
//
/ The number of frames to skip between checks. If this value is 0, then a condition check is
//
/ made once per frame. If this value is 1, then the condition for this event is only checked
//
/ every other frame. This value is 0 by default, meaning the event's condition is checked
//
/ every frame.
//
/ </param>
void
registerEvent
(
const
std::function<
void
(T*)> &action,
const
std::function<bool(T*)> &condition = nullptr, int timesToRun = -1, int framesToCheck = 0)
{
interfaceEvents.
push_back
( InterfaceEvent<T>(action,condition,timesToRun,framesToCheck) );
};
};
}
You can’t perform that action at this time.