public override void OnEvent(IEvent e) { EventType type = e.Type(); switch (type) { case EventType.NewEntryAdded: HandleEvent_NewEntryAdded(e.Cast <Event_NewEntryAdded>()); break; case EventType.EntryUpdated: HandleEvent_EntryUpdated(e.Cast <Event_EntryUpdated>()); break; } }
void HandleMovement_Y(IEvent _event) { float Y = _event.Cast <E_Cha_TranslateRequest_Y>().Velocity; transform.position = new Vector3(transform.position.x, transform.position.y + Y, transform.position.z); }
//Jump request Handler private void Handle_RequestY(IEvent _event) { E_Cha_TranslateRequest_Y Y = _event.Cast <E_Cha_TranslateRequest_Y>(); m_Velocity += new Vector3(0, Y.Velocity, 0); _event.HasHandled = true; }
//Event Handlers //--------------------------------------------------------------------- private void Handle_RequestXZ(IEvent _event) { E_Cha_TranslateRequest_XZ req = _event.Cast <E_Cha_TranslateRequest_XZ>(); m_Velocity += req.Translation; _event.HasHandled = true; }
public void Handle_PlayerSpawn(IEvent _event) { E_Player_Spawned Player_Spawned = _event.Cast <E_Player_Spawned>(); ChunkInWorld SpawnCenter = new ChunkInWorld(Player_Spawned.SpawnPos, m_World); //figure out visiable area m_CoverArea = new AreaRect(SpawnCenter.Value, (int)m_PlayerMng.PlayerView); }
//Handle fly private void Handle_Fly(IEvent _event) { var fly = _event.Cast <E_Cha_Fly>(); if (fly.ForceUp > 0) { m_VDrop = 0.0f; } }
private void HandleFly(IEvent _event) { E_Cha_Fly EFly = _event.Cast <E_Cha_Fly>(); m_ForceFront += EFly.ForceFront; Mathf.Clamp(m_ForceFront, 0, 0.5f); m_Communicator.Publish(new E_Cha_TranslateRequest_Y(EFly.ForceUp * 20)); }
private void HandleJump(IEvent _event) { E_Cha_JumpUp EJump = _event.Cast <E_Cha_JumpUp>(); m_IsJumping = true; m_Velocity = EJump.Force; m_Communicator.Publish(new E_Cha_LeaveGround()); }
public override void OnEvent(IEvent e) { EventType type = e.Type(); switch (type) { case EventType.NewEntryAdded: HandleEvent_NewEntryEvent(e.Cast <Event_NewEntryAdded>()); break; case EventType.EntryUpdated: HandleEvent_EntryUpdated(e.Cast <Event_EntryUpdated>()); break; default: Assert.Do("This Event Is Not Expected for this Handler!"); break; } }
public void Find_should_return_hydrated_entity_when_it_has_events() { var entityId = Guid.NewGuid(); var events = new IEvent[] { new CorrectEventSourced.Created { SourceId = entityId, SourceVersion = 1, Value = 1 }, new CorrectEventSourced.Updated { SourceId = entityId, SourceVersion = 2, Value = 20 }, new CorrectEventSourced.Updated { SourceId = entityId, SourceVersion = 3, Value = 30 } }; var commit = new Commit { Id = Guid.NewGuid(), SourceId = entityId, Changes = events }; var eventStoreMock = new Mock <IEventStore>(); eventStoreMock.Setup(eventStore => eventStore.Load(entityId, 0)).Returns(new [] { commit }); var repository = new EventSourcedRepository <CorrectEventSourced>(eventStoreMock.Object); var entity = repository.Find(entityId); entity.Id.Should().Be(entityId); entity.Version.Should().Be(events.Last().SourceVersion); entity.Value.Should().Be(events.Cast <dynamic>().Last().Value); }
void HandleTranslationOrder(IEvent _event) { transform.position += _event.Cast <E_Cha_TranslateOrder>().Translation; m_Communicator.Publish(new E_Cha_HasMoved()); }
private void HandleSuspend(IEvent _event) { E_Cha_Suspend ESuspend = _event.Cast <E_Cha_Suspend>(); this.PublishEvent(new E_Cha_TranslateRequest_Y(ESuspend.Force * 10 * Time.deltaTime)); }