mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
[ruamoko] Clean up Entity a little
Hide own, and add some class spawn methods.
This commit is contained in:
parent
7a481039f8
commit
2dc806cff5
2 changed files with 27 additions and 11 deletions
|
@ -34,10 +34,12 @@
|
|||
|
||||
@interface Entity: Object
|
||||
{
|
||||
int own;
|
||||
@public
|
||||
entity ent;
|
||||
int own;
|
||||
entity ent;
|
||||
}
|
||||
+(Entity *) spawn;
|
||||
+(Entity *) withEntity: (entity) e;
|
||||
|
||||
- (id) init;
|
||||
- (id) initWithEntity: (entity) e;
|
||||
|
|
|
@ -15,21 +15,20 @@ int PR_SetField (entity ent, string field, string value) = #0;
|
|||
|
||||
@implementation Entity
|
||||
|
||||
- (void) own
|
||||
{
|
||||
own = 1;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [self initWithEntity: spawn ()];
|
||||
[self own];
|
||||
if (!(self = [self initWithEntity: spawn ()])) {
|
||||
return nil;
|
||||
}
|
||||
own = 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithEntity: (entity)e
|
||||
{
|
||||
self = [super init];
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
ent = e;
|
||||
ent.@this = self;
|
||||
return self;
|
||||
|
@ -41,6 +40,21 @@ int PR_SetField (entity ent, string field, string value) = #0;
|
|||
return self;
|
||||
}
|
||||
|
||||
+(Entity *) spawn
|
||||
{
|
||||
return [[[self alloc] init] autorelease];
|
||||
}
|
||||
|
||||
+(Entity *) withEntity: (entity) e
|
||||
{
|
||||
return [[[self alloc] initWithEntity: e] autorelease];
|
||||
}
|
||||
|
||||
+(Entity *) withEntity: (entity) e fromPlist: (plitem_t *) dict
|
||||
{
|
||||
return [[[self alloc] initWithEntity: e fromPlist: dict] autorelease];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (own && ent)
|
||||
|
@ -95,7 +109,7 @@ int PR_SetField (entity ent, string field, string value) = #0;
|
|||
}
|
||||
}
|
||||
if (ent)
|
||||
[e own];
|
||||
e.own = 1;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue