Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
AI.h
Go to the documentation of this file.
1/*
2
3AI.h
4
5Core NPC behaviour/artificial intelligence class.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import <Foundation/Foundation.h>
28#import "OOWeakReference.h"
29#import "OOTypes.h"
30
31#define AI_THINK_INTERVAL 0.125
32
33
34@class ShipEntity;
35
36
38{
39@private
40 id _owner; // OOWeakReference to the ShipEntity this is the AI for
41 NSString *ownerDesc; // describes the object this is the AI for
42
43 NSDictionary *stateMachine;
45 NSString *currentState;
46 NSMutableSet *pendingMessages;
47
48 NSMutableArray *aiStack;
49
52
53 NSString *jsScript;
54}
55
56+ (AI *) currentlyRunningAI;
57+ (NSString *) currentlyRunningAIDescription;
58
59- (NSString *) name;
60- (NSString *) associatedJS;
61- (NSString *) state;
62
63- (void) setStateMachine:(NSString *)smName withJSScript:(NSString *)script;
64- (void) setState:(NSString *)stateName;
65
66- (void) setStateMachine:(NSString *)smName afterDelay:(NSTimeInterval)delay;
67- (void) setState:(NSString *)stateName afterDelay:(NSTimeInterval)delay;
68
69- (id) initWithStateMachine:(NSString *) smName andState:(NSString *) stateName;
70
71- (ShipEntity *)owner;
72- (void) setOwner:(ShipEntity *)ship;
73
74- (void) preserveCurrentStateMachine;
75
76- (void) restorePreviousStateMachine;
77
78- (BOOL) hasSuspendedStateMachines;
79- (void) exitStateMachineWithMessage:(NSString *)message;
80
81- (NSUInteger) stackDepth;
82
83// Immediately handle a message. This is the core dispatcher. DebugContext is a textual hint for diagnostics.
84- (void) reactToMessage:(NSString *) message context:(NSString *)debugContext;
85
86- (void) takeAction:(NSString *) action;
87
88- (void) think;
89
90- (void) message:(NSString *) ms;
91- (void) dropMessage:(NSString *) ms;
92- (NSSet *) pendingMessages;
93- (void) debugDumpPendingMessages;
94
95- (void) setNextThinkTime:(OOTimeAbsolute) ntt;
96- (OOTimeAbsolute) nextThinkTime;
97
98- (void) setThinkTimeInterval:(OOTimeDelta) tti;
99- (OOTimeDelta) thinkTimeInterval;
100
101- (void) clearStack;
102
103- (void) clearAllData;
104
105- (void)dumpState;
106
107@end
double OOTimeDelta
Definition OOTypes.h:224
double OOTimeAbsolute
Definition OOTypes.h:223
Definition AI.h:38
NSString * currentState
Definition AI.h:45
NSDictionary * stateMachine
Definition AI.h:43
id _owner
Definition AI.h:40
NSMutableSet * pendingMessages
Definition AI.h:46
NSMutableArray * aiStack
Definition AI.h:48
NSString * ownerDesc
Definition AI.h:41
OOTimeDelta thinkTimeInterval
Definition AI.h:51
OOTimeAbsolute nextThinkTime
Definition AI.h:50
NSString * stateMachineName
Definition AI.h:44
NSString * jsScript
Definition AI.h:53