void Awake() { state = new CreatureState(); metabolism = new CreatureMetabolism(gameObject, settings.StartingEnergy); size = new CreatureSize(sizeSettings, settings.Size, metabolism, transform); sense = new CreatureSense(senseSettings, settings.SenseRadius, state, metabolism, transform); movement = new CreatureMovement(velocitySettings, settings.Velocity, state, metabolism, sense, transform); creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, settings.Size); }
/// <summary> /// Mutates creature attributes, based on parent creature attributes /// </summary> /// <param name="parent">parent creature</param> public void Mutate(ICreature parent) { float newStartingEnergy = MutateAttribute(parent.StartingEnergy); float newSize = Mathf.Clamp(MutateAttribute(parent.Size), 0.1f, 1000f); float newVelocity = MutateAttribute(parent.Velocity); float newSenseRadius = MutateAttribute(parent.SenseRadius); metabolism = new CreatureMetabolism(gameObject, newStartingEnergy); size = new CreatureSize(sizeSettings, newSize, metabolism, transform); sense = new CreatureSense(senseSettings, newSenseRadius, state, metabolism, transform); movement = new CreatureMovement(velocitySettings, newVelocity, state, metabolism, sense, transform); creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, newSize); }