protected override void DoAction(CATContext context) { var gobj = cinemachineFreeLookCam.First(context); if (gobj == null) { return; } cam = gobj.GetComponentInChildren <CinemachineFreeLook>(); if (cam == null) { return; } setXCached = setX.GetValue(context); setYCached = setY.GetValue(context); if (setXCached) { originalXAxisName = cam.m_XAxis.m_InputAxisName; cam.m_XAxis.m_InputAxisName = newXAxisName.GetValue(context); } if (setYCached) { originalYAxisName = cam.m_YAxis.m_InputAxisName; cam.m_YAxis.m_InputAxisName = newYAxisName.GetValue(context); } }
public override Deferred Run(CATContext context) { if (IsRunning) { return(base.Run(context)); } Deferred result = base.Run(context); axis = inputAxisName.GetValue(context); if (string.IsNullOrEmpty(axis)) { Stop(); return(result); } GameObject gobj = cinemachineFreeLookCam.First(context); if (gobj == null) { Stop(); return(result); } cam = gobj.GetComponentInChildren <CinemachineFreeLook>(); if (cam == null) { Stop(); return(result); } if (!CinemachineCore.Instance.IsLive(cam)) { Stop(); return(result); } bailRot = bailOnRotate.GetValue(context); bailMov = bailOnMove.GetValue(context); rotToleranceDot = subjectRotateTolerance.GetValue(context).AngleToDot(); moveToleranceSqr = subjectMoveTolerance.GetValue(context); moveToleranceSqr *= moveToleranceSqr; //camTransform = CinemachineCore.Instance.GetActiveBrain(0).OutputCamera.transform; centerX = centerXAxis.GetValue(context); centerY = centerYAxis.GetValue(context); originalXActive = cam.m_XAxis.m_Recentering.m_enabled; originalYActive = cam.m_YAxis.m_Recentering.m_enabled; originalCenterTimeX = cam.m_XAxis.m_Recentering.m_RecenteringTime; originalCenterTimeY = cam.m_YAxis.m_Recentering.m_RecenteringTime; originalWaitTimeX = cam.m_XAxis.m_Recentering.m_WaitTime; originalWaitTimeY = cam.m_YAxis.m_Recentering.m_WaitTime; if (!(centerX && centerY)) { Stop(); } return(result); }
public override Deferred Run(CATContext context) { if (IsRunning) { return(base.Run(context)); } var result = base.Run(context); // Connect camera and event listener, or quit var gobj = cinemachineFreeLookCam.First(context); if (gobj == null) { Stop(); return(result); } cam = gobj.GetComponentInChildren <CinemachineFreeLook>(); if (cam == null) { Stop(); return(result); } gobj = catEventManager.First(context); if (gobj == null) { Stop(); return(result); } evtMan = gobj.GetComponentInChildren <CATEventManager>(); if (evtMan == null) { Stop(); return(result); } // Sanitize distance minimum and maximum speed = inputSpeed.GetValue(context); min = minimumDistance.GetValue(context); if (min < 0f) { min = 0.0001f; } max = maximumDistance.GetValue(context); if (max < min) { max = min; } // Subscribe to event subscription = evtMan.Subscribe(inputEvent.ToString(), OnInput); return(result); }
public override Deferred StartListening(CATContext context, TriggerCallback callback) { if (IsListening) { return(base.StartListening(context, callback)); } var dfrd = base.StartListening(context, callback); _brain = CinemachineCore.Instance.GetActiveBrain(0); _brain.m_CameraCutEvent.AddListener(OnCut); return(dfrd); }
public override bool Stop() { if (waitToResetCoroutine != null) { StopCoroutine(waitToResetCoroutine); waitToResetCoroutine = null; } if (cam != null) { ResetCamSettings(); } cachedContext = null; return(base.Stop()); }
protected override void DoAction(CATContext context) { var gobj = vcam.First(context); if (gobj == null) { return; } cam = gobj.GetComponentInChildren <CinemachineVirtualCameraBase>(); if (cam == null) { return; } originalPriority = cam.Priority; cam.Priority = newPriority.GetValue(context); }
protected override void DoAction(CATContext context) { // Get unique skeletons var ors = new List <SkeletonAnimator>(); var tions = new List <SkeletonAnimation>(); var uniqueSkeletons = new HashSet <Spine.Skeleton>(); if (includeChildren.GetValue(context)) { target.WithTargets(context, gobj => { ors.AddRange(gobj.GetComponentsInChildren <SkeletonAnimator>()); tions.AddRange(gobj.GetComponentsInChildren <SkeletonAnimation>()); }); } else { target.WithTargets(context, gobj => { ors.Add(gobj.GetComponent <SkeletonAnimator>()); tions.Add(gobj.GetComponent <SkeletonAnimation>()); }); } for (var i = 0; i < ors.Count; ++i) { uniqueSkeletons.Add(ors[i].skeleton); } for (var i = 0; i < tions.Count; ++i) { uniqueSkeletons.Add(tions[i].skeleton); } // Flip all collected skeletons Spine.Skeleton[] skeletons = new Spine.Skeleton[uniqueSkeletons.Count]; uniqueSkeletons.CopyTo(skeletons); for (var i = 0; i < uniqueSkeletons.Count; ++i) { var skel = skeletons[i]; if (setFlipX.GetValue(context)) { skel.FlipX = flipXNewValue.GetValue(context); } if (setFlipY.GetValue(context)) { skel.FlipY = flipYNewValue.GetValue(context); } } }
protected override void DoAction(CATContext context) { var gobj = cinemachineFreeLookCam.First(context); if (gobj == null) { return; } cam = gobj.GetComponentInChildren <CinemachineFreeLook>(); if (cam == null) { return; } bool add = additive.GetValue(context); for (var i = 0; i < 3; ++i) { originalRadius[i] = cam.m_Orbits[i].m_Radius; originalHeight[i] = cam.m_Orbits[i].m_Height; if ((setRadius & IndexToSelection(i)) != 0) { if (add) { cam.m_Orbits[i].m_Radius += newRadius.GetValue(context); } else { cam.m_Orbits[i].m_Radius = newRadius.GetValue(context); } } if ((setHeight & IndexToSelection(i)) != 0) { if (add) { cam.m_Orbits[i].m_Height = newHeight.GetValue(context); } else { cam.m_Orbits[i].m_Height += newHeight.GetValue(context); } } } }
protected override void DoAction(CATContext context) { GameObject gobj = cinemachineTargetGroup.First(context); if (gobj == null) { return; } CinemachineTargetGroup group = gobj.GetComponentInChildren <CinemachineTargetGroup>(); if (group == null) { return; } var all = cinemachineTargetGroup.GetTargets(context); if (all == null || all.Count < 1) { return; } float cachedWeight = weight.GetValue(context); float cachedRadius = radius.GetValue(context); switch (operation) { case EditOperation.Add: for (var i = 0; i < all.Count; ++i) { group.AddMember(all[i].transform, cachedWeight, cachedRadius); } break; case EditOperation.Remove: for (var i = 0; i < all.Count; ++i) { group.RemoveMember(all[i].transform); } break; default: throw new System.NotImplementedException("Unhandled EditOperation in " + name + ": " + operation); } }
bool stopCalled; // In some situations Spine will fire multiple events when the animation is done (End / Complete distinction) but we only need one public override Deferred Run(CATContext context) { if (IsRunning) { return(base.Run(context)); } stopCalled = false; Deferred dfrd = base.Run(context); HashSet <SkeletonAnimation> uniqueSkeletons = new HashSet <SkeletonAnimation>(); target.WithTargets(context, delegate(GameObject obj) { var skels = includeChildren.value ? obj.GetComponentsInChildren <SkeletonAnimation>() : new SkeletonAnimation[] { obj.GetComponent <SkeletonAnimation>() }; for (var i = 0; i < skels.Length; ++i) { if (skels[i] == null) { continue; } uniqueSkeletons.Add(skels[i]); } }); targetSkeletons = new SkeletonAnimation[uniqueSkeletons.Count]; uniqueSkeletons.CopyTo(targetSkeletons); for (var i = 0; i < targetSkeletons.Length; ++i) { targetSkeletons[i].AnimationState.SetEmptyAnimation(trackNumber.value, 0); targetSkeletons[i].AnimationState.SetAnimation(trackNumber.value, animationName.value, loop.value); } /* Stop this action in animation callbacks. See http://esotericsoftware.com/spine-unity-events * TODO: Presently, this game doesn't need to be able to account for multiple targets with animations potentially finishing at different times, * so I am going to just stop on the first one's callback. This should be changed for a release of CAT. Also should consider the case that the * skeletons could be destroyed before the callback is called. Also, might the provided animationName change while the CAT is running? * Not sure about that last one. */ var aniState = targetSkeletons[0].AnimationState; animationEnd = (trackEntry) => { if (stopCalled) { return; } Debug.Log("animationEnd entered. " + trackEntry.Animation.Name); // Ignore events on non-targeted tracks if (trackEntry.TrackIndex != trackNumber.value) { return; } // See above TODO; for CAT release, don't just stop based on the first one if (targetSkeletons[0] == null) { //Debug.Log("Stop! No SkeletonAnimator on target."); Stop(); } else if (trackEntry.Animation.Name == animationName.value) { //Debug.Log("Stop! Animation ended."); Stop(); } }; animationEnd += (trackentry) => { aniState.End -= animationEnd; }; animationComplete = (trackEntry) => { if (stopCalled) { return; } Debug.Log("animationComplete entered. " + trackEntry.Animation.Name); if (trackEntry.TrackIndex != trackNumber.value) { return; } //Debug.Log("Stop! Animation complete."); Stop(); }; animationComplete += (trackEntry) => { aniState.Complete -= animationComplete; }; aniState.End += animationEnd; if (!loop.value) { aniState.Complete += animationComplete; } return(dfrd); }
public OEEController(IHostingEnvironment hostingEnvironment, CATContext context) { _hostingEnvironment = hostingEnvironment; _context = context; }
//TODO: make sure it works on both directions public void RunAction(string path, CATContext context) { RpcRunAction(path); }
public void ChangeState(string state, CATContext context) { RpcChangeState(state); }