Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOCharacter(Private) Category Reference

Instance Methods

(id) - initWithGenSeed:andOriginalSystem:
 
(void) - setCharacterFromDictionary:
 
(void) - setOriginSystem:
 
(Random_Seed- genSeed
 

Detailed Description

Definition at line 34 of file OOCharacter.m.

Method Documentation

◆ genSeed

- (Random_Seed) genSeed

Extends class OOCharacter.

Definition at line 1 of file OOCharacter.m.

346{
347 return _genSeed;
348}

◆ initWithGenSeed:andOriginalSystem:

- (id) initWithGenSeed: (Random_Seed) characterSeed
andOriginalSystem: (OOSystemID) systemSeed 

Extends class OOCharacter.

Definition at line 1 of file OOCharacter.m.

70 :(Random_Seed)characterSeed andOriginalSystem:(OOSystemID)system
71{
72 if ((self = [super init]))
73 {
74 // do character set-up
75 _genSeed = characterSeed;
76 _originSystem = system;
77
78 [self basicSetUp];
79 }
80 return self;
81}
int16_t OOSystemID
Definition OOTypes.h:211
struct Random_Seed Random_Seed

◆ setCharacterFromDictionary:

- (void) setCharacterFromDictionary: (NSDictionary *) dict

Extends class OOCharacter.

Definition at line 1 of file OOCharacter.m.

450 :(NSDictionary *)dict
451{
452 id origin = nil;
453 Random_Seed seed;
454
455 origin = [dict objectForKey:@"origin"];
456 if ([origin isKindOfClass:[NSNumber class]] ||
457 ([origin respondsToSelector:@selector(intValue)] && ([origin intValue] != 0 || [origin isEqual:@"0"])))
458 {
459 // Number or numerical string
460 [self setOriginSystem:[origin intValue]];
461 }
462 else if ([origin isKindOfClass:[NSString class]])
463 {
464 OOSystemID sys = [UNIVERSE findSystemFromName:origin];
465 if (sys < 0)
466 {
467 OOLogERR(@"character.load.unknownSystem", @"could not find a system named '%@' in this galaxy.", origin);
468 [self setOriginSystem:(ranrot_rand() & 0xff)];
469 }
470 else
471 {
472 [self setOriginSystem:sys];
473 }
474 }
475 else
476 {
477 // no origin defined, select one at random.
478 [self setOriginSystem:(ranrot_rand() & 0xff)];
479 }
480
481 if ([dict objectForKey:@"random_seed"])
482 {
483 seed = RandomSeedFromString([dict oo_stringForKey:@"random_seed"]); // returns kNilRandomSeed on failure
484 }
485 else
486 {
487 seed.a = (ranrot_rand() & 0xff);
488 seed.b = (ranrot_rand() & 0xff);
489 seed.c = (ranrot_rand() & 0xff);
490 seed.d = (ranrot_rand() & 0xff);
491 seed.e = (ranrot_rand() & 0xff);
492 seed.f = (ranrot_rand() & 0xff);
493 }
494 [self setGenSeed:seed];
495 [self basicSetUp];
496
497 if ([dict oo_stringForKey:@"role"]) [self castInRole:[dict oo_stringForKey:@"role"]];
498 if ([dict oo_stringForKey:@"name"]) [self setName:[dict oo_stringForKey:@"name"]];
499 if ([dict oo_stringForKey:@"short_description"]) [self setShortDescription:[dict oo_stringForKey:@"short_description"]];
500 if ([dict objectForKey:@"legal_status"]) [self setLegalStatus:[dict oo_intForKey:@"legal_status"]];
501 if ([dict objectForKey:@"bounty"]) [self setLegalStatus:[dict oo_intForKey:@"bounty"]];
502 if ([dict objectForKey:@"insurance"]) [self setInsuranceCredits:[dict oo_unsignedLongLongForKey:@"insurance"]];
503 if ([dict oo_stringForKey:@"script"]) [self setCharacterScript:[dict oo_stringForKey:@"script"]];
504 if ([dict oo_arrayForKey:@"script_actions"]) [self setLegacyScript:[dict oo_arrayForKey:@"script_actions"]];
505
506}
#define OOLogERR(class, format,...)
Definition OOLogging.h:112
return nil
Random_Seed RandomSeedFromString(NSString *abcdefString)
voidpf uLong int origin
Definition ioapi.h:140
#define ranrot_rand()

◆ setOriginSystem:

- (void) setOriginSystem: (OOSystemID) value

Extends class OOCharacter.

Definition at line 1 of file OOCharacter.m.

396 :(OOSystemID)value
397{
398 _originSystem = value;
399}

The documentation for this category was generated from the following file: