public void Handle(GameServerEvents.TickEvent @event) { foreach (var metric in Metrics) { metric.Value.Decrease(@event.DeltaTime); } }
public void Handle_Always_ShouldDecreaseMetrics() { var serverDelta = 2.0f; var animal = AnimalBuilder.NewInstance() .AddMetric(new Happiness(0.0f, 1.0f)) .AddMetric(new Hunger(0.0f, -1.0f)) .Build(); var tickEvent = new GameServerEvents.TickEvent { DeltaTime = serverDelta }; animal.Handle(tickEvent); Assert.Equal(-2.0f, animal.Metrics[MetricType.Happiness].Value); Assert.Equal(2.0f, animal.Metrics[MetricType.Hunger].Value); animal.Handle(tickEvent); Assert.Equal(-4.0f, animal.Metrics[MetricType.Happiness].Value); Assert.Equal(4.0f, animal.Metrics[MetricType.Hunger].Value); }