private void OnEntityWorldPositionChanged(object sender, PropertyChangedEventArgs <EntityWorldPos> e) { var generator = AttachedObject.GetComponent <ClientboundPacketComponent>().GetGenerator(); // Update Collider var pos = e.NewValue; var box = new Cuboid(new Point3d(pos.X, pos.Z, pos.Y), new Size(0.6f, 0.6f, 1.75f)); AttachedObject.SetLocalValue(ColliderComponent.ColliderShapeProperty, box); // Check if we need to send UpdateViewPosition packet. If the player walk cross chunk borders, send it. var oldChunkPos = e.OldValue.ToChunkWorldPos(); var newChunkPos = e.NewValue.ToChunkWorldPos(); if (oldChunkPos != newChunkPos) { generator.UpdateViewPosition(newChunkPos.X, newChunkPos.Z); } // Broadcast to trackers _broadcastComponent = _broadcastComponent ?? AttachedObject.GetComponent <ChunkEventBroadcastComponent>(); _broadcastComponent.GetGenerator(AttachedObject) .EntityRelativeMove( AttachedObject.EntityId, GetDelta(e.OldValue.X, e.NewValue.X), GetDelta(e.OldValue.Y, e.NewValue.Y), GetDelta(e.OldValue.Z, e.NewValue.Z), AttachedObject.GetValue(EntityOnGroundComponent.IsOnGroundProperty)); }
private void OnEntityHeadYawChanged(object sender, PropertyChangedEventArgs <float> e) { _broadcastComponent = _broadcastComponent ?? AttachedObject.GetComponent <ChunkEventBroadcastComponent>(); _broadcastComponent.GetGenerator(AttachedObject) .EntityHeadLook( AttachedObject.EntityId, GetAngle(e.NewValue)); }
private void OnEntityPitchChanged(object sender, PropertyChangedEventArgs <float> e) { var yaw = AttachedObject.GetValue(EntityLookComponent.YawProperty); var pitch = AttachedObject.GetValue(EntityLookComponent.PitchProperty); _broadcastComponent = _broadcastComponent ?? AttachedObject.GetComponent <ChunkEventBroadcastComponent>(); _broadcastComponent.GetGenerator(AttachedObject) .EntityLook( AttachedObject.EntityId, GetAngle(yaw), GetAngle(pitch), AttachedObject.GetValue(EntityOnGroundComponent.IsOnGroundProperty)); }
private void OnEntityWorldPositionChanged(object sender, PropertyChangedEventArgs <EntityWorldPos> e) { var pos = e.NewValue; var box = new Cuboid(new Point3d(pos.X, pos.Z, pos.Y), new Size(0.6f, 0.6f, 1.75f)); AttachedObject.SetLocalValue(ColliderComponent.ColliderShapeProperty, box); _broadcastComponent = _broadcastComponent ?? AttachedObject.GetComponent <ChunkEventBroadcastComponent>(); _broadcastComponent.GetGenerator(AttachedObject) .EntityRelativeMove( AttachedObject.EntityId, GetDelta(e.OldValue.X, e.NewValue.X), GetDelta(e.OldValue.Y, e.NewValue.Y), GetDelta(e.OldValue.Z, e.NewValue.Z), AttachedObject.GetValue(EntityOnGroundComponent.IsOnGroundProperty)); }