<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Yetibyte.Himalaya.Graphics;

namespace Yetibyte.Himalaya.GameElements {
	
	public abstract class Actor : GameEntity, IDraw {
		
		// Fields
		
		// Properties
		
		public Sprite Sprite { get; set; }
        public SpriteAnimator Animator { get; set; }
        public int RenderLayer { get; set; }

        /// <summary>
        /// If set to true, the Update method of <see cref="Animator"/> will not be called automatically.
        /// </summary>
        public bool IgnoreAnimator { get; set; } = false;

        // Constructor

        protected Actor(Scene scene, string name, Vector2 position, Sprite sprite, SpriteAnimator animator = null, GameEntity parentEntity = null) : base(scene, name, position, parentEntity) {

        }
        
        // Methods

        public override void Update(GameTime gameTime, float globalTimeScale) {

            base.Update(gameTime, globalTimeScale);

            if(!IgnoreAnimator)
                Animator.Update(gameTime, globalTimeScale);

        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime) {

            Sprite.Draw(spriteBatch, Position, Rotation, RenderLayer);

        }

    }
	
}<commit_msg>fixed lack of null check for sprite and animator<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Yetibyte.Himalaya.Graphics;

namespace Yetibyte.Himalaya.GameElements {
	
	public abstract class Actor : GameEntity, IDraw {
		
		// Fields
		
		// Properties
		
		public Sprite Sprite { get; set; }
        public SpriteAnimator Animator { get; set; }
        public int RenderLayer { get; set; }

        /// <summary>
        /// If set to true, the Update method of <see cref="Animator"/> will not be called automatically.
        /// </summary>
        public bool IgnoreAnimator { get; set; } = false;

        // Constructor

        protected Actor(Scene scene, string name, Vector2 position, Sprite sprite, SpriteAnimator animator = null, GameEntity parentEntity = null) : base(scene, name, position, parentEntity) {

        }
        
        // Methods

        public override void Update(GameTime gameTime, float globalTimeScale) {

            base.Update(gameTime, globalTimeScale);

            if(!IgnoreAnimator)
                Animator?.Update(gameTime, globalTimeScale);

        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime) {

            Sprite?.Draw(spriteBatch, Position, Rotation, RenderLayer);

        }

    }
	
}
{'fraction_non_alphanumeric': 0.09087577867350678, 'fraction_numerical': 0.0007328691828508611, 'mean_word_length': 2.5779816513761467, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5778586', 'n_tokens_mistral': 783, 'n_tokens_neox': 720, 'n_words': 214}