#pragma warning restore 649 public GameObject Resolve(SpatialOSEntityInfo entityInfo, EntityManager manager) { var authComponent = ComponentDatabase.GetMetaclass(authComponentId).Authority; return(manager.HasComponent(entityInfo.Entity, authComponent) ? ownedPrefab : unownedPrefab); }
public void OnEntityCreated(SpatialOSEntityInfo entityInfo, GameObject prefab, EntityManager entityManager, EntityGameObjectLinker linker) { Coordinates position = Coordinates.Zero; if (TryGetComponent <Position.Component>(ref entityManager, entityInfo.Entity, out var pos)) { position = pos.Value.Coords; } Quaternion rot = Quaternion.identity; Vector3 scale = Vector3.one; if (TryGetComponent <PostureRoot.Component>(ref entityManager, entityInfo.Entity, out var posture)) { rot = posture.Value.RootTrans.Rotation.ToUnityQuaternion(); scale = posture.Value.RootTrans.Scale.ToUnityVector(); } Dictionary <int, CompressedLocalTransform> boneMap = null; if (TryGetComponent <BoneAnimation.Component>(ref entityManager, entityInfo.Entity, out var anim)) { boneMap = anim.Value.BoneMap; } var gameObject = UnityEngine.Object.Instantiate(prefab, position.ToUnityVector() + this.WorkerOrigin, rot); gameObject.transform.localScale = scale; Type[] types = componentsToAdd; if (boneMap != null) { var container = gameObject.GetComponent <PostureBoneContainer>(); container?.SetTrans(boneMap); } if (this.IsClient == false) { if (TryGetComponent <BaseUnitMovement.Component>(ref entityManager, entityInfo.Entity, out var movement)) { entityManager.AddComponentData <NavPathData>(entityInfo.Entity, NavPathData.CreateData()); entityManager.AddComponentData <MovementData>(entityInfo.Entity, MovementData.CreateData(movement.Value.MoveSpeed, movement.Value.RotSpeed)); } if (TryGetComponent <BaseUnitStatus.Component>(ref entityManager, entityInfo.Entity, out var status)) { if (UnitUtils.IsBuilding(status.Value.Type)) { entityManager.AddComponentData <BuildingData>(entityInfo.Entity, BuildingData.CreateData()); } } } gameObjectsCreated.Add(entityInfo.SpatialOSEntityId, gameObject); gameObject.name = $"{prefab.name}(SpatialOS: {entityInfo.SpatialOSEntityId}, Worker: {this.WorkerType})"; linker.LinkGameObjectToSpatialOSEntity(entityInfo.SpatialOSEntityId, gameObject, types); }
#pragma warning restore 649 public GameObject Resolve(SpatialOSEntityInfo entityInfo, EntityManager manager) { var owningWorkerId = manager.GetComponentData <OwningWorker.Component>(entityInfo.Entity).WorkerId; var myWorkerId = manager.World.GetExistingSystem <WorkerSystem>().WorkerId; return(owningWorkerId == myWorkerId ? ownedPrefab : unownedPrefab); }
public void OnEntityCreated(SpatialOSEntityInfo entityInfo, GameObject prefab, EntityManager entityManager, EntityGameObjectLinker linker) { var gameObject = new GameObject(); gameObject.transform.position = Vector3.one; gameObject.transform.rotation = Quaternion.identity; gameObject.name = $"TestObject(SpatialOS: {entityInfo.SpatialOSEntityId}, Worker: {workerType})"; entityIdToGameObject.Add(entityInfo.SpatialOSEntityId, gameObject); linker.LinkGameObjectToSpatialOSEntity(entityInfo.SpatialOSEntityId, gameObject); }
public void OnEntityCreated(SpatialOSEntityInfo entityInfo, GameObject prefab, EntityManager entityManager, EntityGameObjectLinker linker) { var spatialOSPosition = entityManager.GetComponentData <Position.Component>(entityInfo.Entity); var position = spatialOSPosition.Coords.ToUnityVector() + workerOrigin; var gameObject = Object.Instantiate(prefab, position, Quaternion.identity); gameObject.name = $"{prefab.name}(SpatialOS: {entityInfo.SpatialOSEntityId}, Worker: {workerType})"; entityIdToGameObject.Add(entityInfo.SpatialOSEntityId, gameObject); linker.LinkGameObjectToSpatialOSEntity(entityInfo.SpatialOSEntityId, gameObject, componentsToAdd); }
public void OnEntityCreated(SpatialOSEntityInfo entityInfo, GameObject prefab, EntityManager entityManager, EntityGameObjectLinker linker) { var transformInternal = entityManager.GetComponentData <TransformInternal.Component>(entityInfo.Entity); var position = transformInternal.Location.ToUnityVector() + workerOrigin; var rotation = transformInternal.Rotation.ToUnityQuaternion(); var gameObject = Object.Instantiate(prefab, position, rotation); gameObject.name = $"{prefab.name}(SpatialOS: {entityInfo.SpatialOSEntityId}, Worker: {workerType})"; entityIdToGameObject.Add(entityInfo.SpatialOSEntityId, gameObject); linker.LinkGameObjectToSpatialOSEntity(entityInfo.SpatialOSEntityId, gameObject, componentsToAdd); }
public void OnEntityCreated(SpatialOSEntityInfo entityInfo, GameObject prefab, EntityManager entityManager, EntityGameObjectLinker linker) { Vector3 spawnPosition; switch (entityInfo.EntityType) { case PlayerEntityType: spawnPosition = entityManager.GetComponentData <ServerMovement.Component>(entityInfo.Entity) .Latest.Position.ToVector3(); break; default: spawnPosition = entityManager.GetComponentData <Position.Component>(entityInfo.Entity) .Coords.ToUnityVector(); break; } var gameObject = UnityEngine.Object.Instantiate(prefab, spawnPosition + workerOrigin, Quaternion.identity); gameObjectsCreated.Add(entityInfo.SpatialOSEntityId, gameObject); gameObject.name = $"{prefab.name}(SpatialOS: {entityInfo.SpatialOSEntityId}, Worker: {workerType})"; linker.LinkGameObjectToSpatialOSEntity(entityInfo.SpatialOSEntityId, gameObject, componentsToAdd); }
#pragma warning restore 649 public GameObject Resolve(SpatialOSEntityInfo entityInfo, EntityManager manager) { return(prefab); }
public void OnEntityCreated(SpatialOSEntityInfo entityInfo, GameObject prefab, EntityManager entityManager, EntityGameObjectLinker linker) { throw new NotImplementedException(); }