108 lines
3.3 KiB
C#
108 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
using WI;
|
|
using System.Reflection;
|
|
using System.Linq;
|
|
using Best.HTTP.Shared.PlatformSupport.IL2CPP;
|
|
using Unity.VisualScripting;
|
|
|
|
namespace CHN
|
|
{
|
|
public class LibraryManager : MonoBehaviour, ISingle
|
|
{
|
|
public Action<HashSet<Machine>> onLibraryFilterigComplete;
|
|
public HashSet<Machine> filteringMachine = new();
|
|
public Action<UI_LibraryButton> onClickButton;
|
|
public Action<string[]> onUpdateMachineFilters;
|
|
[SerializeField]
|
|
private Machine[] machines;
|
|
|
|
public void MatchingMachine(List<StandardInfo> standardInfos, string[] machineFilters)
|
|
{
|
|
var building = FindSingle<Building>();
|
|
machines = building.floors.SelectMany(f => f.machines).ToArray();
|
|
foreach (var info in standardInfos)
|
|
{
|
|
var p = machines.Where(x => x.code.Equals(info.code)).FirstOrDefault();
|
|
if (p == null)
|
|
continue;
|
|
p.typeOptions = info.filterInfo;
|
|
}
|
|
onUpdateMachineFilters?.Invoke(machineFilters);
|
|
}
|
|
|
|
public void LibraryFiltering(string options)
|
|
{
|
|
filteringMachine.Clear();
|
|
foreach (var machine in machines)
|
|
{
|
|
if (machine.typeOptions.Contains(options))
|
|
{
|
|
filteringMachine.Add(machine);
|
|
}
|
|
}
|
|
onLibraryFilterigComplete?.Invoke(filteringMachine);
|
|
}
|
|
|
|
public void ResetAllMachinesHighLight()
|
|
{
|
|
foreach (var machine in machines)
|
|
{
|
|
machine.DeactivateTranslucent();
|
|
machine.StopFlash();
|
|
}
|
|
}
|
|
|
|
public void ActivateMachinesHighlight(UI_LibraryButton libraryButton)
|
|
{
|
|
ResetAllMachinesHighLight();
|
|
|
|
foreach (Machine machine in machines)
|
|
{
|
|
if (libraryButton.machine != machine)
|
|
{
|
|
machine.ActivateTranslucent();
|
|
}
|
|
else
|
|
{
|
|
machine.StartFlash();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void MachineActive(Machine machine, bool value)
|
|
{
|
|
machine.gameObject.SetActive(value);
|
|
}
|
|
|
|
public void SetTargetPosToMachine(UI_LibraryButton libraryButton)
|
|
{
|
|
OrbitalController controller = FindSingle<OrbitalController>();
|
|
if (controller.viewMode != ViewMode.PerspectiveView)
|
|
{
|
|
controller.SetViewMode(ViewMode.PerspectiveView);
|
|
}
|
|
|
|
var building = FindSingle<Building>();
|
|
int changeFloor = building.floors[0].floorIndex;
|
|
|
|
int libraryMachineFloor = libraryButton.machine.GetMachineFloorIndex();
|
|
if (libraryMachineFloor > changeFloor)
|
|
{
|
|
changeFloor = libraryMachineFloor;
|
|
}
|
|
|
|
var centerPos = libraryButton.machine.centerPos;
|
|
|
|
var slider = FindSingle<Canvas_Right>().panel_floorcontrol;
|
|
slider.ChangeValueFromOutside(changeFloor);
|
|
|
|
controller.option.currentDistance = 20f;
|
|
controller.SetTargetPos(centerPos);
|
|
}
|
|
}
|
|
}
|
|
|