public DCLBuilderInWorldEntity CreateEmptyEntity(ParcelScene parcelScene, Vector3 entryPoint, Vector3 editionGOPosition, bool notifyEntityList = true) { IDCLEntity newEntity = parcelScene.CreateEntity(Guid.NewGuid().ToString()); DCLTransform.model.position = WorldStateUtils.ConvertUnityToScenePosition(entryPoint, parcelScene); Vector3 pointToLookAt = Camera.main.transform.position; pointToLookAt.y = editionGOPosition.y; Quaternion lookOnLook = Quaternion.LookRotation(editionGOPosition - pointToLookAt); DCLTransform.model.rotation = lookOnLook; DCLTransform.model.scale = newEntity.gameObject.transform.lossyScale; parcelScene.EntityComponentCreateOrUpdateWithModel(newEntity.entityId, CLASS_ID_COMPONENT.TRANSFORM, DCLTransform.model); DCLBuilderInWorldEntity convertedEntity = SetupEntityToEdit(newEntity, true); hudController?.UpdateSceneLimitInfo(); if (notifyEntityList) { EntityListChanged(); } return(convertedEntity); }
public static BIWEntity CreateSmartItemEntity(BIWEntityHandler entityHandler, ParcelScene scene, SmartItemComponent.Model model = null) { if (model == null) { model = new SmartItemComponent.Model(); } BIWEntity entity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); scene.EntityComponentCreateOrUpdateWithModel(entity.rootEntity.entityId, CLASS_ID_COMPONENT.SMART_ITEM, model); return(entity); }
/// <summary> /// Instantiates an entity with an AvatarShape component, with randomized wearables, at the given position /// </summary> /// <param name="position">The world position of the randomized bot</param> void InstantiateBot(Vector3 position) { string entityId = "BOT-" + instantiatedBots.Count; AvatarModel avatarModel = new AvatarModel() { id = entityId, name = entityId, hairColor = Color.white, eyeColor = Color.white, skinColor = Color.white, bodyShape = Random.Range(0, 2) == 0 ? WearableLiterals.BodyShapes.FEMALE : WearableLiterals.BodyShapes.MALE, wearables = GetRandomizedWearablesSet() }; globalScene.CreateEntity(entityId); globalScene.EntityComponentCreateOrUpdateWithModel(entityId, CLASS_ID_COMPONENT.AVATAR_SHAPE, avatarModel); UpdateEntityTransform(globalScene, entityId, position, Quaternion.identity, Vector3.one); instantiatedBots.Add(entityId); }