mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 17:12:15 +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
|
@interface Entity: Object
|
||||||
{
|
{
|
||||||
|
int own;
|
||||||
@public
|
@public
|
||||||
entity ent;
|
entity ent;
|
||||||
int own;
|
|
||||||
}
|
}
|
||||||
|
+(Entity *) spawn;
|
||||||
|
+(Entity *) withEntity: (entity) e;
|
||||||
|
|
||||||
- (id) init;
|
- (id) init;
|
||||||
- (id) initWithEntity: (entity) e;
|
- (id) initWithEntity: (entity) e;
|
||||||
|
|
|
@ -15,21 +15,20 @@ int PR_SetField (entity ent, string field, string value) = #0;
|
||||||
|
|
||||||
@implementation Entity
|
@implementation Entity
|
||||||
|
|
||||||
- (void) own
|
|
||||||
{
|
|
||||||
own = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [self initWithEntity: spawn ()];
|
if (!(self = [self initWithEntity: spawn ()])) {
|
||||||
[self own];
|
return nil;
|
||||||
|
}
|
||||||
|
own = 1;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithEntity: (entity)e
|
- (id) initWithEntity: (entity)e
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
ent = e;
|
ent = e;
|
||||||
ent.@this = self;
|
ent.@this = self;
|
||||||
return self;
|
return self;
|
||||||
|
@ -41,6 +40,21 @@ int PR_SetField (entity ent, string field, string value) = #0;
|
||||||
return self;
|
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
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
if (own && ent)
|
if (own && ent)
|
||||||
|
@ -95,7 +109,7 @@ int PR_SetField (entity ent, string field, string value) = #0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ent)
|
if (ent)
|
||||||
[e own];
|
e.own = 1;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue