protected override void OnInitialize() { base.OnInitialize(); Camera = Camera ?? GetViewport().GetCamera(); Distance = InitialDistance; OnActiveStateChange .Do(v => _viewInput.Active = v) .Do(v => _zoomInput.Active = v) .Subscribe() .AddTo(this); ViewInput .Select(v => v * 0.05f) .Subscribe(v => Rotation -= v) .AddTo(this); ZoomInput .Subscribe(v => Distance -= v * 0.05f) .AddTo(this); OnActiveStateChange .Where(v => v) .Skip(Active ? 1 : 0) .Subscribe(_ => Distance = DistanceRange.Min + 0.1f) .AddTo(this); }
protected override void OnInitialize() { base.OnInitialize(); _boneIndex = Skeleton.FindBone(PositionBone); Debug.Assert(_boneIndex != -1, $"Failed to find a bone named '{PositionBone}'."); _initialTransform = Skeleton.GetBoneTransform(_boneIndex); AnimationManager.OnBeforeAdvance .Where(_ => Valid) .Subscribe(_ => OnBeforeAnimation()) .AddTo(this); AnimationManager.OnAdvance .Subscribe(OnAnimation) .AddTo(this); OnActiveStateChange .Where(v => !v && Valid) .Subscribe(_ => ResetAnimations()) .AddTo(this); AnimationManager.Player .GetAnimationList() .Select(AnimationManager.Player.GetAnimation) .Where(a => a.Loop) .ToList() .ForEach(AddTrack); Reset(); }
protected override void PostConstruct() { base.PostConstruct(); OnActiveStateChange .Where(v => !v && Valid) .TakeUntil(Disposed.Where(identity)) .Subscribe(_ => ResetAnimations(), this); }
protected override void OnInitialize() { base.OnInitialize(); Camera = Camera ?? GetViewport().GetCamera(); ViewInput .Select(v => v * 0.05f) .Subscribe(v => Rotation -= v) .AddTo(this); ZoomInput .Subscribe(v => Distance -= v * 0.05f) .AddTo(this); OnActiveStateChange .Where(v => v) .Subscribe(_ => Distance = InitialDistance) .AddTo(this); }