private void OnDirectionChanged(WorkableReactable.AllowedDirection allowed_direction) { if (reactable != null) { reactable.allowedDirection = allowed_direction; } }
protected override void OnPrefabInit() { base.OnPrefabInit(); allowedDirection = WorkableReactable.AllowedDirection.Any; directionInfos = new DirectionInfo[3] { new DirectionInfo { allowLeft = true, allowRight = true, iconName = "action_direction_both", name = (string)UI.USERMENUACTIONS.WORKABLE_DIRECTION_BOTH.NAME, tooltip = (string)UI.USERMENUACTIONS.WORKABLE_DIRECTION_BOTH.TOOLTIP }, new DirectionInfo { allowLeft = true, allowRight = false, iconName = "action_direction_left", name = (string)UI.USERMENUACTIONS.WORKABLE_DIRECTION_LEFT.NAME, tooltip = (string)UI.USERMENUACTIONS.WORKABLE_DIRECTION_LEFT.TOOLTIP }, new DirectionInfo { allowLeft = false, allowRight = true, iconName = "action_direction_right", name = (string)UI.USERMENUACTIONS.WORKABLE_DIRECTION_RIGHT.NAME, tooltip = (string)UI.USERMENUACTIONS.WORKABLE_DIRECTION_RIGHT.TOOLTIP } }; GetComponent <KSelectable>().AddStatusItem(Db.Get().BuildingStatusItems.DirectionControl, this); }
private void SetAllowedDirection(WorkableReactable.AllowedDirection new_direction) { KBatchedAnimController component = GetComponent <KBatchedAnimController>(); DirectionInfo directionInfo = directionInfos[(int)new_direction]; bool flag = directionInfo.allowLeft && directionInfo.allowRight; bool is_visible = !flag && directionInfo.allowLeft; bool is_visible2 = !flag && directionInfo.allowRight; component.SetSymbolVisiblity("arrow2", flag); component.SetSymbolVisiblity("arrow_left", is_visible); component.SetSymbolVisiblity("arrow_right", is_visible2); if (new_direction != allowedDirection) { allowedDirection = new_direction; if (onDirectionChanged != null) { onDirectionChanged(allowedDirection); } } }