private static void LoadDisplay(GameObject LoadedObject, SavedDisplay save) { Display display = LoadedObject.GetComponentInChildren <Display>(); display.DisplayColor = save.Color; }
public static SavedObjectV2 CreateSavedObjectFrom(ObjectInfo worldsave) { //SavedObjectV2 newsavedobject = SaveManager.ObjectTypeToSavedObjectType(save.ObjectType); SavedObjectV2 newsavedobject = null; switch (worldsave.ComponentType) { case ComponentType.CustomObject: newsavedobject = new SavedCustomObject(); CreateCustomSavedObject((SavedCustomObject)newsavedobject, worldsave); break; case ComponentType.CircuitBoard: CircuitBoard board = worldsave.GetComponent <CircuitBoard>(); newsavedobject = new SavedCircuitBoard { x = board.x, z = board.z, color = board.GetBoardColor }; break; case ComponentType.Wire: InputInputConnection IIConnection = worldsave.GetComponent <InputInputConnection>(); newsavedobject = new SavedWire { InputInput = IIConnection, length = worldsave.transform.localScale.z }; break; case ComponentType.Button: newsavedobject = new SavedButton(); break; case ComponentType.PanelButton: newsavedobject = new SavedPanelButton(); break; case ComponentType.Delayer: Delayer delayer = worldsave.GetComponent <Delayer>(); newsavedobject = new SavedDelayer { OutputOn = delayer.Output.On, DelayCount = delayer.DelayCount }; break; case ComponentType.Display: Display display = worldsave.GetComponentInChildren <Display>(); newsavedobject = new SavedDisplay { Color = display.DisplayColor }; break; case ComponentType.PanelDisplay: Display paneldisplay = worldsave.GetComponentInChildren <Display>(); newsavedobject = new SavedPanelDisplay { Color = paneldisplay.DisplayColor }; break; case ComponentType.Inverter: Inverter notgate = worldsave.GetComponent <Inverter>(); newsavedobject = new SavedInverter { OutputOn = notgate.Output.On }; break; case ComponentType.Label: Label label = worldsave.GetComponent <Label>(); newsavedobject = new SavedLabel { text = label.text.text, FontSize = label.text.fontSize }; break; case ComponentType.PanelLabel: Label panellabel = worldsave.GetComponent <Label>(); newsavedobject = new SavedPanelLabel { text = panellabel.text.text, FontSize = panellabel.text.fontSize }; break; case ComponentType.Switch: // SWITCH-F*****G-CEPTION Switch circuitswitch = worldsave.GetComponentInChildren <Switch>(); newsavedobject = new SavedSwitch { on = circuitswitch.On }; break; case ComponentType.PanelSwitch: Switch panelswitch = worldsave.GetComponentInChildren <Switch>(); newsavedobject = new SavedPanelSwitch { on = panelswitch.On }; break; case ComponentType.Peg: newsavedobject = new SavedPeg(); break; case ComponentType.ThroughPeg: newsavedobject = new SavedThroughPeg(); break; case ComponentType.Blotter: Blotter blotter = worldsave.GetComponent <Blotter>(); newsavedobject = new SavedBlotter { OutputOn = blotter.Output.On }; break; case ComponentType.ThroughBlotter: Blotter throughblotter = worldsave.GetComponent <Blotter>(); newsavedobject = new SavedThroughBlotter { OutputOn = throughblotter.Output.On }; break; case ComponentType.ColorDisplay: newsavedobject = new SavedColorDisplay(); break; case ComponentType.PanelColorDisplay: newsavedobject = new SavedPanelColorDisplay(); break; case ComponentType.Noisemaker: Noisemaker noisemaker = worldsave.GetComponentInChildren <Noisemaker>(); newsavedobject = new SavedNoisemaker { ToneFrequency = noisemaker.ToneFrequency }; break; case ComponentType.SnappingPeg: newsavedobject = new SavedSnappingPeg(); break; case ComponentType.Mount: newsavedobject = new SavedMount(); break; case ComponentType.VerticalSnappingPeg: newsavedobject = new SavedVerticalSnappingPeg(); break; case ComponentType.none: Debug.LogError("BIG ERROR tried to save a component with no type!"); break; } newsavedobject.LocalPosition = worldsave.transform.localPosition; newsavedobject.LocalEulerAngles = worldsave.transform.localEulerAngles; if (newsavedobject.CanHaveChildren) { newsavedobject.Children = FindChildSaves(worldsave); } return(newsavedobject); }