public IEnumerator Transform_initialises_on_enable_and_resets_on_disable() { // Load up prefab that already has TransformSynchronization behaviour var testTransformPrefab = Resources.Load <GameObject>("TransformTestObject"); createdGameObject = CreateAndLinkGameObject(EntityId, testTransformPrefab, Vector3.zero, Quaternion.identity); var transformSyncBehaviour = createdGameObject.GetComponent <Improbable.Gdk.TransformSynchronization.TransformSynchronization>(); // TransformSync script applies strategies in a coroutine that yields at least one and up to two times. // We yield twice in the test to be extra sure that the strategies are applied and that `initialised` is set. yield return(null); yield return(null); Assert.IsTrue(transformSyncBehaviour.enabled); Assert.IsNotNull(GetPrivateField <EntityManager>(transformSyncBehaviour, "entityManager")); Assert.IsTrue(GetPrivateField <bool>(transformSyncBehaviour, "initialised")); ConnectionHandler.RemoveComponent(EntityId, TransformInternal.ComponentId); ReceiveSystem.Update(); RequireLifecycleSystem.Update(); Assert.IsFalse(transformSyncBehaviour.enabled); Assert.AreEqual(GetPrivateField <EntityManager>(transformSyncBehaviour, "entityManager"), default(EntityManager)); Assert.IsFalse(GetPrivateField <bool>(transformSyncBehaviour, "initialised")); }
public override void Setup() { base.Setup(); var template = new EntityTemplate(); template.AddComponent(new Position.Snapshot(), "worker"); ConnectionHandler.CreateEntity(EntityId, template); ReceiveSystem.Update(); }
public void Injection_happens_if_inherited_constraints_are_satisfied() { ReceiveSystem.Update(); createdGameObject = CreateAndLinkGameObjectWithComponent <InheritanceBehaviour>(EntityId); var inheritanceBehaviour = createdGameObject.GetComponent <InheritanceBehaviour>(); Assert.IsTrue(inheritanceBehaviour.enabled); Assert.IsNotNull(inheritanceBehaviour.OwnReader); }
public void Monobehaviour_is_disabled_with_non_matching_WorkerType_and_satisfied_requireable() { ConnectionHandler.ChangeAuthority(EntityId, Position.ComponentId, Authority.Authoritative); ReceiveSystem.Update(); createdGameObject = CreateAndLinkGameObjectWithComponent <NonMatchingWorkerTypeWithRequireable>(EntityId); var behaviour = createdGameObject.GetComponent <NonMatchingWorkerTypeWithRequireable>(); Assert.IsFalse(behaviour.enabled); Assert.IsNull(behaviour.Writer); }
public void Writer_is_injected_when_entity_component_is_checked_out_and_authoritative() { ConnectionHandler.ChangeAuthority(EntityId, Position.ComponentId, Authority.Authoritative); ReceiveSystem.Update(); createdGameObject = CreateAndLinkGameObjectWithComponent <PositionWriterBehaviour>(EntityId); var writerBehaviour = createdGameObject.GetComponent <PositionWriterBehaviour>(); Assert.IsTrue(writerBehaviour.enabled); Assert.IsNotNull(writerBehaviour.Writer); }
public void Injection_happens_if_all_constraints_are_satisfied() { ConnectionHandler.ChangeAuthority(EntityId, Position.ComponentId, Authority.Authoritative); ReceiveSystem.Update(); createdGameObject = CreateAndLinkGameObjectWithComponent <CompositeBehaviour>(EntityId); var compositeBehaviour = createdGameObject.GetComponent <CompositeBehaviour>(); Assert.IsTrue(compositeBehaviour.enabled); Assert.IsNotNull(compositeBehaviour.Reader); Assert.IsNotNull(compositeBehaviour.Writer); }