Пример #1
0
        public CachedTranslationFactory(ITranslationFactory baseTranslationFactory)
        {
            baseTranslationFactory.TranslationChanged += (sender, args) =>
            {
                ClearCache();
                TranslationChanged?.Invoke(this, args);
            };

            _baseTranslationFactory = baseTranslationFactory;
        }
Пример #2
0
        private void SetNewPosition()
        {
            double destinyX = ((firstSensorX - sensorX) * movementMultiplier);
            double destinyY = ((firstSensorY - sensorY) * movementMultiplier);

            CalculateTranslationX(destinyX);
            CalculateTranslationY(destinyY);

            TranslationChanged?.Invoke(translationX, translationY);
        }
Пример #3
0
        public void OnTranslationChanged(TranslationChanged message)
        {
            var component = message.Component;
            var velocity  = (IVelocity)Manager.GetComponent(component.Entity, ComponentSystem.Manager.GetComponentTypeId <IVelocity>());
            var delta     = velocity != null ? velocity.LinearVelocity : Vector2.Zero;

            foreach (IIndexable indexable in Manager.GetComponents(component.Entity, IndexableTypeId))
            {
                var bounds = indexable.ComputeWorldBounds();
                if (_trees[indexable.IndexId].Update(bounds, delta, indexable.Id))
                {
                    // Mark as changed.
                    _changed[indexable.IndexId].Add(component.Id);
                }
            }
        }
        private void ExecuteApplicationSettingsCommand(object o)
        {
            var settings = _settingsProvider.Settings;

            var interaction = new ApplicationSettingsInteraction(settings.Copy(), _settingsProvider.GpoSettings);

            _interactionInvoker.Invoke(interaction);

            if (interaction.Success)
            {
                _settingsManager.ApplyAndSaveSettings(interaction.Settings);
            }

            TranslationChanged?.Invoke(this, new EventArgs());

            LoggingHelper.ChangeLogLevel(interaction.Settings.ApplicationSettings.LoggingLevel);
        }
Пример #5
0
        public void OnTranslationChanged(TranslationChanged message)
        {
            // Only remove entities marked for removal.
            var cellDeath = (CellDeath)Manager.GetComponent(message.Component.Entity, CellDeath.TypeId);

            if (cellDeath == null)
            {
                return;
            }

            // Check our new cell after the position change.
            if (cellDeath.IsForSubCell)
            {
                var cellId = GetSubCellIdFromCoordinates(message.CurrentPosition);

                // If the cell changed, check if we're out of bounds.
                if (!IsSubCellActive(cellId))
                {
                    // Dead space, kill it.
                    var deathSystem = (DeathSystem)Manager.GetSystem(DeathSystem.TypeId);
                    deathSystem.MarkForRemoval(message.Component.Entity);
                }
            }
            else
            {
                var cellId = GetCellIdFromCoordinates(message.CurrentPosition);

                // If the cell changed, check if we're out of bounds.
                if (!IsCellActive(cellId))
                {
                    // Dead space, kill it.
                    var deathSystem = (DeathSystem)Manager.GetSystem(DeathSystem.TypeId);
                    deathSystem.MarkForRemoval(message.Component.Entity);
                }
            }
        }
Пример #6
0
 protected virtual void OnTranslationChanged([NotNull] TranslationChangedEventArgs e)
 {
     TranslationChanged?.Invoke(this, e);
 }