public TriggerColliderGenerator(TriggerApi triggerApi, TriggerComponent component, TriggerColliderComponent colliderComponent, TriggerMeshComponent meshComponent)
 {
     _api               = triggerApi;
     _component         = component;
     _meshComponent     = meshComponent;
     _colliderComponent = colliderComponent;
 }
Пример #2
0
        public void RegisterTrigger(Trigger trigger, Entity entity, GameObject go)
        {
            var triggerApi = new TriggerApi(trigger, entity, this);

            _tableApi.Triggers[trigger.Name] = triggerApi;
            _initializables.Add(triggerApi);
            _hittables[entity] = triggerApi;
        }
Пример #3
0
        void IApiInitializable.OnInit(BallManager ballManager)
        {
            // playfield elements
            _entryKicker = TableApi.Kicker(Data.EntryKicker);
            _exitKicker  = TableApi.Kicker(Data.ExitKicker);
            _jamTrigger  = TableApi.Trigger(Data.JamSwitch);

            // setup entry kicker handler
            if (_entryKicker != null)
            {
                _entryKicker.Hit += OnEntryKickerHit;
            }

            // in case we need also need to handle jam events here, uncomment
            // if (_jamTrigger != null) {
            //  _jamTrigger.Hit += OnJamTriggerHit;
            //  _jamTrigger.UnHit += OnJamTriggerUnHit;
            // }

            // create switches to hook up
            _ballSwitches = new DeviceSwitch[Data.SwitchCount];
            foreach (var sw in Item.AvailableSwitches)
            {
                if (int.TryParse(sw.Id, out var id))
                {
                    _ballSwitches[id - 1] = CreateSwitch(false);
                    _switchLookup[sw.Id]  = _ballSwitches[id - 1];
                }
                else if (sw.Id == Trough.JamSwitchId)
                {
                    // we short-wire the jam trigger to the switch, so we don't care about it here,
                    // all the jam trigger does push its switch events to the gamelogic engine. in
                    // case we need to hook into the jam trigger logic here, uncomment those two
                    // lines and and relay the events manually to the engine.
                    //_jamSwitch = CreateSwitch(false);
                    //_switchLookup[sw.Id] = _jamSwitch;
                }
                else
                {
                    Logger.Warn($"Unknown switch ID {sw.Id}");
                }
            }

            // setup eject coil
            _ejectCoil = new TroughEjectCoil(this);

            // finally, emit the event for anyone else to chew on
            Init?.Invoke(this, EventArgs.Empty);
        }