public void StartInteraction(FullBodyBipedEffector effector, InteractionObject obj) { if (this.state == BodyIKState.Offline) { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); this.state = BodyIKState.Online; } else if (this.state == BodyIKState.Online || this.state == BodyIKState.Swapping) { // Is this effector already being used? if (this.primaryEffectors.ContainsKey(effector)) { this.PerformSwap(effector, obj); } else { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); } } else if (this.state == BodyIKState.Stopping) { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); this.state = BodyIKState.Online; } }
public void Update() { if (this.state == BodyIKState.Swapping) { if (Time.time > this.swapTimeFinish) { foreach (var kv in this.secondaryEffectors) { this.handlerSecondary.StopInteraction(kv.Key); } this.secondaryEffectors.Clear(); this.state = BodyIKState.Online; } } else if (this.state == BodyIKState.Stopping) { foreach (var kv in this.secondaryEffectors) { this.handlerSecondary.StopInteraction(kv.Key); } this.secondaryEffectors.Clear(); foreach (var kv in this.primaryEffectors) { this.handlerSecondary.StopInteraction(kv.Key); } this.secondaryEffectors.Clear(); if (this.IsActive(this.ikPrimary) == false) { this.state = BodyIKState.Offline; } } }
public void StopInteraction(FullBodyBipedEffector effector) { if (this.primaryEffectors.ContainsKey(effector) == true) { this.primaryEffectors.Remove(effector); this.handlerPrimary.StopInteraction(effector); // If this is our last active effector, shut down if (this.primaryEffectors.Count == 0) { this.state = BodyIKState.Stopping; } } }
public BodyIKController(CrossfadeFBBIK[] iks, float swapTime) { this.primaryEffectors = new Dictionary <FullBodyBipedEffector, InteractionObject>(); this.secondaryEffectors = new Dictionary <FullBodyBipedEffector, InteractionObject>(); this.ikPrimary = iks[0]; this.ikSecondary = iks[1]; this.SwapTime = swapTime; this.handlerPrimary = new CrossfadeInteractionHandler(ikPrimary); this.handlerSecondary = new CrossfadeInteractionHandler(ikSecondary); this.RegisterWithHandler(this.handlerPrimary); this.RegisterWithHandler(this.handlerSecondary); this.state = BodyIKState.Offline; }
private void PerformSwap(FullBodyBipedEffector effector, InteractionObject obj) { // Move all the effectors to the secondary IK solver foreach (var kv in this.primaryEffectors) { if (kv.Key != effector) { this.handlerSecondary.StartInteraction(kv.Key, kv.Value, true); this.secondaryEffectors[kv.Key] = kv.Value; } } this.handlerSecondary.StartInteraction(effector, obj, true); this.secondaryEffectors[effector] = obj; // Swap solvers this.Swap(); // Store the intermediate state float time = Time.time; this.swapTimeFinish = time + this.SwapTime; this.state = BodyIKState.Swapping; }
private void PerformSwap(FullBodyBipedEffector effector, InteractionObject obj) { // Move all the effectors to the secondary IK solver foreach (var kv in this.primaryEffectors) { if (kv.Key != effector) { this.handlerSecondary.StartInteraction(kv.Key, kv.Value, true); this.secondaryEffectors[kv.Key] = kv.Value; } } this.handlerSecondary.StartInteraction(effector, obj, true); this.secondaryEffectors[effector] = obj; // Swap solvers this.Swap(); // Store the intermediate state float time = Time.time; this.swapTimeFinish = time + this.SwapTime; this.state = BodyIKState.Swapping; }
public void Update() { if (this.state == BodyIKState.Swapping) { if (Time.time > this.swapTimeFinish) { foreach (var kv in this.secondaryEffectors) this.handlerSecondary.StopInteraction(kv.Key); this.secondaryEffectors.Clear(); this.state = BodyIKState.Online; } } else if (this.state == BodyIKState.Stopping) { foreach (var kv in this.secondaryEffectors) this.handlerSecondary.StopInteraction(kv.Key); this.secondaryEffectors.Clear(); foreach (var kv in this.primaryEffectors) this.handlerSecondary.StopInteraction(kv.Key); this.secondaryEffectors.Clear(); if (this.IsActive(this.ikPrimary) == false) this.state = BodyIKState.Offline; } }
public void StopInteraction(FullBodyBipedEffector effector) { if (this.primaryEffectors.ContainsKey(effector) == true) { this.primaryEffectors.Remove(effector); this.handlerPrimary.StopInteraction(effector); // If this is our last active effector, shut down if (this.primaryEffectors.Count == 0) this.state = BodyIKState.Stopping; } }
public void StartInteraction(FullBodyBipedEffector effector, InteractionObject obj) { if (this.state == BodyIKState.Offline) { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); this.state = BodyIKState.Online; } else if (this.state == BodyIKState.Online || this.state == BodyIKState.Swapping) { // Is this effector already being used? if (this.primaryEffectors.ContainsKey(effector)) { this.PerformSwap(effector, obj); } else { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); } } else if (this.state == BodyIKState.Stopping) { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); this.state = BodyIKState.Online; } }
public BodyIKController(CrossfadeFBBIK[] iks, float swapTime) { this.primaryEffectors = new Dictionary<FullBodyBipedEffector, InteractionObject>(); this.secondaryEffectors = new Dictionary<FullBodyBipedEffector, InteractionObject>(); this.ikPrimary = iks[0]; this.ikSecondary = iks[1]; this.SwapTime = swapTime; this.handlerPrimary = new CrossfadeInteractionHandler(ikPrimary); this.handlerSecondary = new CrossfadeInteractionHandler(ikSecondary); this.RegisterWithHandler(this.handlerPrimary); this.RegisterWithHandler(this.handlerSecondary); this.state = BodyIKState.Offline; }