/// <summary> /// Auto-matches the coils provided by the gamelogic engine with the /// coils on the playfield. /// </summary> /// <param name="engineCoils">List of coils provided by the gamelogic engine</param> /// <param name="tableComponent">Table component</param> public void PopulateCoils(GamelogicEngineCoil[] engineCoils, TableComponent tableComponent) { var coilDevices = tableComponent.GetComponentsInChildren <ICoilDeviceComponent>(); var lamps = tableComponent.GetComponentsInChildren <ILampDeviceComponent>().OrderBy(LampTypePriority).ToArray(); foreach (var engineCoil in GetCoils(engineCoils)) { var coilMapping = Coils.FirstOrDefault(mappingsCoilData => mappingsCoilData.Id == engineCoil.Id); if (coilMapping != null || engineCoil.IsUnused) { continue; } var destination = GuessCoilDestination(engineCoil, lamps); var description = string.IsNullOrEmpty(engineCoil.Description) ? string.Empty : engineCoil.Description; var deviceAdded = false; if (destination == CoilDestination.Playfield) { foreach (var device in GuessCoilDevices(coilDevices, engineCoil)) { var matchedDevice = device; var deviceItem = GuessCoilDeviceItem(engineCoil, matchedDevice); // if there was a device match, device has only one item and there was a hint that didn't match, clear the device. if (deviceItem == null && !string.IsNullOrEmpty(engineCoil.DeviceItemHint) && matchedDevice.AvailableCoils.Count() == 1) { matchedDevice = null; } AddCoil(new CoilMapping { Id = engineCoil.Id, Description = description, Destination = destination, Device = matchedDevice, DeviceItem = deviceItem != null ? deviceItem.Id : string.Empty, }); deviceAdded = true; } } if (!deviceAdded) { AddCoil(new CoilMapping { Id = engineCoil.Id, Description = description, Destination = destination, Device = null, DeviceItem = string.Empty, }); } } }
/// <summary> /// Auto-matches the lamps provided by the gamelogic engine with the /// lamps on the playfield. /// </summary> /// <param name="engineLamps">List of lamps provided by the gamelogic engine</param> /// <param name="tableComponent">Table component</param> public void PopulateLamps(GamelogicEngineLamp[] engineLamps, TableComponent tableComponent) { var lamps = tableComponent.GetComponentsInChildren <ILampDeviceComponent>().OrderBy(LampTypePriority).ToArray(); foreach (var engineLamp in GetLamps(engineLamps)) { var lampMapping = Lamps.FirstOrDefault(mappingsLampData => mappingsLampData.Id == engineLamp.Id && mappingsLampData.Channel == engineLamp.Channel && !mappingsLampData.IsCoil); if (lampMapping != null) { continue; } var description = string.IsNullOrEmpty(engineLamp.Description) ? string.Empty : engineLamp.Description; var deviceAdded = false; foreach (var device in GuessLampDevices(lamps, engineLamp)) { var deviceItem = GuessLampDeviceItem(engineLamp, device); AddLamp(new LampMapping { Id = engineLamp.Id, Channel = engineLamp.Channel, Source = engineLamp.Source, Description = description, Device = device, DeviceItem = deviceItem != null ? deviceItem.Id : string.Empty, Type = engineLamp.Type, FadingSteps = engineLamp.FadingSteps, }); deviceAdded = true; } if (!deviceAdded) { AddLamp(new LampMapping { Id = engineLamp.Id, Channel = engineLamp.Channel, Source = engineLamp.Source, Description = description, Device = null, DeviceItem = string.Empty, Type = engineLamp.Type, FadingSteps = engineLamp.FadingSteps, }); } } }
public void PopulateWires(GamelogicEngineWire[] engineWires, TableComponent tableComponent) { foreach (var engineWire in engineWires) { var srcMapping = Switches.FirstOrDefault(switchMapping => switchMapping.Id == engineWire.SourceId); if (srcMapping == null) { continue; } switch (engineWire.DestinationType) { case DestinationType.Coil: { var destMapping = Coils.FirstOrDefault(coilMapping => coilMapping.Id == engineWire.DestinationId); if (destMapping != null) { AddWire(new WireMapping(engineWire.Description, srcMapping, destMapping).Dynamic().WithId()); } break; } case DestinationType.Lamp: { var destMapping = Lamps.FirstOrDefault(lampMapping => lampMapping.Id == engineWire.DestinationId && lampMapping.Source == LampSource.Lamp); if (destMapping != null) { AddWire(new WireMapping(engineWire.Description, srcMapping, destMapping).Dynamic().WithId()); } break; } case DestinationType.GI: { var destMapping = Lamps.FirstOrDefault(lampMapping => lampMapping.Id == engineWire.DestinationId && lampMapping.Source == LampSource.GI); if (destMapping != null) { AddWire(new WireMapping(engineWire.Description, srcMapping, destMapping).Dynamic().WithId()); } break; } default: throw new ArgumentOutOfRangeException(); } } }
public void Init(TableComponent tableComponent, BallManager ballManager) { _ballManager = ballManager; _entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; _flipperDataQuery = _entityManager.CreateEntityQuery( ComponentType.ReadOnly <FlipperMovementData>(), ComponentType.ReadOnly <FlipperStaticData>(), ComponentType.ReadOnly <SolenoidStateData>() ); _ballDataQuery = _entityManager.CreateEntityQuery(ComponentType.ReadOnly <BallData>()); _visualPinballSimulationSystemGroup = _entityManager.World.GetOrCreateSystem <VisualPinballSimulationSystemGroup>(); var simulateCycleSystemGroup = _entityManager.World.GetOrCreateSystem <SimulateCycleSystemGroup>(); _visualPinballSimulationSystemGroup.Enabled = true; simulateCycleSystemGroup.PhysicsEngine = this; // needed for flipper status update we don't do in all engines var transform = tableComponent.gameObject.transform; _worldToLocal = transform.worldToLocalMatrix; }
public void PopulateSwitches(GamelogicEngineSwitch[] engineSwitches, TableComponent tableComponent) { var switchDevices = tableComponent.GetComponentsInChildren <ISwitchDeviceComponent>(); foreach (var engineSwitch in GetSwitchIds(engineSwitches)) { var switchMapping = Switches.FirstOrDefault(mappingsSwitchData => mappingsSwitchData.Id == engineSwitch.Id); if (switchMapping != null) { continue; } var description = engineSwitch.Description ?? string.Empty; var source = GuessSwitchSource(engineSwitch); var inputActionMap = source == SwitchSource.InputSystem ? string.IsNullOrEmpty(engineSwitch.InputMapHint) ? InputConstants.MapCabinetSwitches : engineSwitch.InputMapHint : string.Empty; var inputAction = source == SwitchSource.InputSystem ? string.IsNullOrEmpty(engineSwitch.InputActionHint) ? string.Empty : engineSwitch.InputActionHint : string.Empty; bool deviceAdded = false; if (source == SwitchSource.Playfield) { foreach (var device in GuessSwitchDevices(switchDevices, engineSwitch)) { var matchedDevice = device; var deviceItem = GuessSwitchDeviceItem(engineSwitch, matchedDevice); // if there was a device match, device has only one item and there was a hint that didn't match, clear the device. if (deviceItem == null && !string.IsNullOrEmpty(engineSwitch.DeviceItemHint) && matchedDevice.AvailableSwitches.Count() == 1) { matchedDevice = null; } AddSwitch(new SwitchMapping { Id = engineSwitch.Id, IsNormallyClosed = engineSwitch.NormallyClosed, Description = description, Source = source, InputActionMap = inputActionMap, InputAction = inputAction, Device = matchedDevice, DeviceItem = deviceItem != null ? deviceItem.Id : string.Empty, Constant = engineSwitch.ConstantHint == SwitchConstantHint.AlwaysOpen ? SwitchConstant.Open : SwitchConstant.Closed }); deviceAdded = true; } } if (!deviceAdded) { AddSwitch(new SwitchMapping { Id = engineSwitch.Id, IsNormallyClosed = engineSwitch.NormallyClosed, Description = description, Source = source, InputActionMap = inputActionMap, InputAction = inputAction, Device = null, DeviceItem = string.Empty, Constant = engineSwitch.ConstantHint == SwitchConstantHint.AlwaysOpen ? SwitchConstant.Open : SwitchConstant.Closed }); } } }
public void Awake(TableComponent tableComponent, IGamelogicEngine gamelogicEngine, InputManager inputManager) { _tableComponent = tableComponent; _gamelogicEngine = gamelogicEngine; _inputManager = inputManager; }
public SceneTableContainer(TableComponent ta) { _tableComponent = ta; }
protected void OnInit(BallManager ballManager) { BallManager = ballManager; TableComponent = GameObject.GetComponentInParent <TableComponent>(); }