using System; using System.Collections.Generic; namespace Leap.Unity { public class HandProxy : HandRepresentation { public HandProxy(HandPool parent, Hand hand, Chirality repChirality, ModelType repType) : base(hand.Id, hand, repChirality, repType) { this.parent = parent; base.RepChirality = repChirality; base.RepType = repType; base.MostRecentHand = hand; } public override void Finish() { if (this.handModels != null) { for (int i = 0; i < this.handModels.Count; i++) { this.handModels[i].FinishHand(); this.parent.ReturnToPool(this.handModels[i]); this.handModels[i] = null; } } this.parent.RemoveHandRepresentation(this); } public override void AddModel(IHandModel model) { if (this.handModels == null) { this.handModels = new List(); } this.handModels.Add(model); if (model.GetLeapHand() == null) { model.SetLeapHand(base.MostRecentHand); model.InitHand(); model.BeginHand(); model.UpdateHand(); } else { model.SetLeapHand(base.MostRecentHand); model.BeginHand(); } } public override void RemoveModel(IHandModel model) { if (this.handModels != null) { model.FinishHand(); this.handModels.Remove(model); } } public override void UpdateRepresentation(Hand hand) { base.UpdateRepresentation(hand); if (this.handModels != null) { for (int i = 0; i < this.handModels.Count; i++) { this.handModels[i].SetLeapHand(hand); this.handModels[i].UpdateHand(); } } } private HandPool parent; public List handModels; } }