Oolite
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 "OOTypes.h"
28#import "OOWeakReference.h"
29#import <Foundation/Foundation.h>
30
31#define AI_THINK_INTERVAL 0.125
32
33@class ShipEntity;
34
35@interface AI : OOWeakRefObject {
36@private
37 id _owner; // OOWeakReference to the ShipEntity this is the AI for
38 NSString* ownerDesc; // describes the object this is the AI for
39
40 NSDictionary* stateMachine;
42 NSString* currentState;
43 NSMutableSet* pendingMessages;
44
45 NSMutableArray* aiStack;
46
49
50 NSString* jsScript;
51}
52
53+ (AI*)currentlyRunningAI;
54+ (NSString*)currentlyRunningAIDescription;
55
56- (NSString*)name;
57- (NSString*)associatedJS;
58- (NSString*)state;
59
60- (void)setStateMachine:(NSString*)smName withJSScript:(NSString*)script;
61- (void)setState:(NSString*)stateName;
62
63- (void)setStateMachine:(NSString*)smName afterDelay:(NSTimeInterval)delay;
64- (void)setState:(NSString*)stateName afterDelay:(NSTimeInterval)delay;
65
66- (id)initWithStateMachine:(NSString*)smName andState:(NSString*)stateName;
67
68- (ShipEntity*)owner;
69- (void)setOwner:(ShipEntity*)ship;
70
71- (void)preserveCurrentStateMachine;
72
73- (void)restorePreviousStateMachine;
74
75- (BOOL)hasSuspendedStateMachines;
76- (void)exitStateMachineWithMessage:(NSString*)message;
77
78- (NSUInteger)stackDepth;
79
80// Immediately handle a message. This is the core dispatcher. DebugContext is a textual hint for diagnostics.
81- (void)reactToMessage:(NSString*)message context:(NSString*)debugContext;
82
83- (void)takeAction:(NSString*)action;
84
85- (void)think;
86
87- (void)message:(NSString*)ms;
88- (void)dropMessage:(NSString*)ms;
91
92- (void)setNextThinkTime:(OOTimeAbsolute)ntt;
94
95- (void)setThinkTimeInterval:(OOTimeDelta)tti;
97
98- (void)clearStack;
99
100- (void)clearAllData;
101
102- (void)dumpState;
103
104@end
double OOTimeDelta
Definition OOTypes.h:193
double OOTimeAbsolute
Definition OOTypes.h:192
Definition AI.h:35
void dumpState()
Definition AI.m:617
NSString * currentState
Definition AI.h:42
NSDictionary * stateMachine
Definition AI.h:40
id _owner
Definition AI.h:37
NSMutableSet * pendingMessages
Definition AI.m:557
void clearStack()
Definition AI.m:604
void debugDumpPendingMessages()
Definition AI.m:566
NSMutableArray * aiStack
Definition AI.h:45
void clearAllData()
Definition AI.m:609
NSString * ownerDesc
Definition AI.h:38
OOTimeDelta thinkTimeInterval
Definition AI.m:599
OOTimeAbsolute nextThinkTime
Definition AI.m:586
NSString * stateMachineName
Definition AI.h:41
NSString * jsScript
Definition AI.h:50