Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
CR again
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Balaji <[email protected]>
  • Loading branch information
Paul Balaji committed Apr 2, 2020
1 parent 44feefa commit 6ba791f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

## Added

- Added component result type filters to QBI queries. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)
- Added new methods to `Snapshot` utility class. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)
- `GetNextEntityId()` returns the next available entity ID.
- `AddEntity(EntityId entityId, EntityTemplate entityTemplate)` adds an entity to the snapshot with a given entity ID.
Expand All @@ -22,6 +21,7 @@

## Internal

- Added component result type filters to playground QBI queries. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)
- Replaced `InitUISystem` with the `InitUIBehaviour` script on the `Character` prefab. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)

## `0.3.4` - 2020-03-16
Expand Down
12 changes: 10 additions & 2 deletions workers/unity/Assets/Playground/Config/EntityTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public static EntityTemplate CreateCubeEntityTemplate(Vector3 location)

TransformSynchronizationHelper.AddTransformSynchronizationComponents(template, WorkerUtils.UnityGameLogic, Quaternion.identity, location);

var query = InterestQuery.Query(Constraint.RelativeCylinder(radius: CheckoutRadius));
var query = InterestQuery.Query(Constraint.RelativeCylinder(radius: CheckoutRadius)).FilterResults(new[]
{
Position.ComponentId, Metadata.ComponentId, TransformInternal.ComponentId
});

var interest = InterestTemplate.Create()
.AddQueries<Position.Component>(query);
template.AddComponent(interest.ToSnapshot());
Expand All @@ -100,7 +104,11 @@ public static EntityTemplate CreateSpinnerEntityTemplate(Coordinates coords)
template.AddComponent(new SpinnerColor.Snapshot(Color.BLUE), WorkerUtils.UnityGameLogic);
template.AddComponent(new SpinnerRotation.Snapshot(), WorkerUtils.UnityGameLogic);

var query = InterestQuery.Query(Constraint.RelativeCylinder(radius: CheckoutRadius));
var query = InterestQuery.Query(Constraint.RelativeCylinder(radius: CheckoutRadius)).FilterResults(new[]
{
Position.ComponentId, Metadata.ComponentId, TransformInternal.ComponentId
});

var interest = InterestTemplate.Create()
.AddQueries<Position.Component>(query);
template.AddComponent(interest.ToSnapshot());
Expand Down
11 changes: 4 additions & 7 deletions workers/unity/Assets/Playground/Scripts/UI/InitUIBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
using Improbable.Gdk.Core;
using Improbable.Gdk.Subscriptions;
using Playground;
using Playground.Scripts.UI;
using UnityEngine;

namespace Assets.Playground.Scripts.UI
namespace Playground.Scripts.UI
{
public class InitUIBehaviour : MonoBehaviour
{
[Require] private PlayerInputWriter playerInput;
[Require] private ScoreReader score;
[Require] private LauncherReader launcher;

[SerializeField] private Object uiPrefab;
[SerializeField] private GameObject uiPrefab;
private UIComponent uiComponent;

private void OnEnable()
{
var inst = (GameObject) Instantiate(uiPrefab, Vector3.zero, Quaternion.identity);
var inst = Instantiate(uiPrefab, Vector3.zero, Quaternion.identity);

uiComponent = inst.GetComponent<UIComponent>();
uiComponent.TestText.text = $"Energy: {launcher.Data.EnergyLeft}";
Expand All @@ -30,7 +27,7 @@ private void OnDisable()
{
if (uiComponent != null)
{
UnityObjectDestroyer.Destroy(uiComponent.gameObject);
Destroy(uiComponent.gameObject);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public EntityId AddEntity(EntityTemplate entityTemplate)
/// </summary>
/// <param name="entityId">The entity ID of the entity to be added to the snapshot</param>
/// <param name="entityTemplate">The entity to be added to the snapshot.</param>
/// <remarks>
/// You should obtain `entityId` using the `GetNextEntityId()` method, otherwise you could be given
/// invalid entity IDs.
/// </remarks>
public void AddEntity(EntityId entityId, EntityTemplate entityTemplate)
{
entities[entityId] = entityTemplate.GetEntity();
Expand Down

0 comments on commit 6ba791f

Please sign in to comment.