private void LateUpdate() { if (presentation != null) { // Update transform. transform.localPosition = presentation.Body.Position; transform.localRotation = presentation.Body.Rotation; // Update animation. if (currentCondition != presentation.Condition) { // Clear previous animation. ConditionDescriptor conditionDescriptor; if (currentCondition != null) { conditionDescriptor = Descriptors.ForConditions[currentCondition.Id]; if (conditionDescriptor.AnimationHash.HasValue) { animator.SetBool(conditionDescriptor.AnimationHash.Value, false); } } // Set current animation. currentCondition = presentation.Condition; animator.SetFloat(speedHash, currentCondition.ConditionSpeed); conditionDescriptor = Descriptors.ForConditions[currentCondition.Id]; if (conditionDescriptor.AnimationHash.HasValue) { animator.SetBool(conditionDescriptor.AnimationHash.Value, true); } } } }
// Methods. public string ComposeDescription(IConditionPresentation condition) => descriptionExtractor.Invoke(condition);