public ReceptaclePivot AddPivot(Transform pivotTransform) { Transform newPivotTransform = pivotTransform; ReceptaclePivot newPivot = newPivotTransform.gameObject.AddComponent <ReceptaclePivot> (); newPivot.ParentReceptacle = this; newPivot.State = new ReceptaclePivotState(); newPivot.State.InheritParentSettings = true; newPivot.State.Index = State.PivotStates.Count; Pivots.Add(newPivot); State.PivotStates.Add(newPivot.State); newPivot.OnInitialized(); worlditem.StackContainer.SetNumStacks(Pivots.Count); return(newPivot); }
public override void OnInitialized() { worlditem.OnGainPlayerFocus += OnGainPlayerFocus; worlditem.OnPlayerUse += OnPlayerUse; worlditem.OnVisible += OnVisible; worlditem.OnActive += OnActive; //if we're a container, make sure the container uses the right settings Container container = worlditem.GetOrAdd <Container> (); worlditem.StackContainer.Mode = WIStackMode.Receptacle; container.CanUseToOpen = false; container.CanOpen = false; if (State.PivotStates.Count > 0) { //load the pivots from the states for (int i = 0; i < State.PivotStates.Count; i++) { ReceptaclePivot pivot = Pivots [i]; pivot.ParentReceptacle = this; pivot.State = State.PivotStates [i]; pivot.State.Index = i; pivot.OnInitialized(); } } else { //this is our first time loading, load the pivot states //from the actual pivot objects int pivotIndex = 0; for (int i = 0; i < Pivots.Count; i++) { ReceptaclePivot pivot = Pivots [i]; // child.GetComponent <ReceptaclePivot> (); pivot.ParentReceptacle = this; pivot.State.Offset = new STransform(pivot.transform, true); pivot.State.Index = pivotIndex; pivot.OnInitialized(); State.PivotStates.Add(pivot.State); pivotIndex++; } } worlditem.StackContainer.SetNumStacks(Pivots.Count); }