/// <summary> /// Initializes it to display the document /// </summary> /// <param name="resultDoc">document to display</param> public void Initialize(Document resultDoc) { if (resultDoc.Get("isClothing").Equals("0")) { prefab = Spawn.GetPrefabByName(resultDoc.Get("name")); Sprite toUse = prefab.GetComponentInChildren <SpriteRenderer>()?.sprite; if (toUse != null) { image.sprite = toUse; } detailText.text = "Prefab"; } else { var newClothingData = Spawn.GetClothDataNamed(resultDoc.Get("name")); if (newClothingData != null) { detailText.text = $"{newClothingData.name}"; clothingData = newClothingData; image.sprite = newClothingData.SpawnerIcon(); } else { detailText.text = "ERROR"; } } titleText.text = resultDoc.Get("name"); }
/// <summary> /// Spawns the cloth with the specifeid cloth data on the server, syncing it to clients /// </summary> /// <param name="clothData">cloth data describing the cloth, should be a subtype of BaseClothData</param> /// <param name="worldPosition">world position to appear at. Defaults to HiddenPos (hidden / invisible)</param> /// <param name="CVT">variant type to spawn this cloth as, defaults to Default</param> /// <param name="variantIndex">variant index to spawn this cloth as, defaults to -1</param> /// <param name="prefabOverride">prefab to use instead of this cloth's default</param> /// <param name="rotation">rotation to spawn with, defaults to Quaternion.identity</param> /// <param name="parent">Parent to spawn under, defaults to no parent. Most things /// should always be spawned under the Objects transform in their matrix. Many objects (due to RegisterTile) /// usually take care of properly parenting themselves when spawned so in many cases you can leave it null.</param> /// <param name="count">number of instances to spawn, defaults to 1</param> /// <param name="scatterRadius">radius to scatter the spawned instances by from their spawn position. Defaults to /// null (no scatter).</param> /// <returns></returns> public static SpawnResult ServerCloth(BaseClothData clothData, Vector3?worldPosition = null, ClothingVariantType CVT = ClothingVariantType.Default, int variantIndex = -1, GameObject prefabOverride = null, Transform parent = null, Quaternion?rotation = null, int count = 1, float?scatterRadius = null) { return(Server( SpawnInfo.Cloth(clothData, worldPosition, CVT, variantIndex, prefabOverride, parent, rotation, count, scatterRadius))); }
/// <summary> /// Spawns the cloth with the specifeid cloth data /// </summary> /// <param name="clothData">cloth data describing the cloth, should be a subtype of BaseClothData</param> /// <param name="worldPosition">world position to appear at. Defaults to HiddenPos (hidden / invisible)</param> /// <param name="CVT">variant type to spawn this cloth as, defaults to Default</param> /// <param name="variantIndex">variant index to spawn this cloth as, defaults to -1</param> /// <param name="prefabOverride">prefab to use instead of this cloth's default</param> /// <param name="rotation">rotation to spawn with, defaults to Quaternion.identity</param> /// <param name="parent">Parent to spawn under, defaults to the matrix at the indicated spawn position, which /// is the correct behavior for most things. </param> /// <param name="count">number of instances to spawn, defaults to 1</param> /// <param name="scatterRadius">radius to scatter the spawned instances by from their spawn position. Defaults to /// null (no scatter).</param> /// <returns></returns> public static SpawnInfo Cloth(BaseClothData clothData, Vector3?worldPosition = null, ClothingVariantType CVT = ClothingVariantType.Default, int variantIndex = -1, GameObject prefabOverride = null, Transform parent = null, Quaternion?rotation = null, int count = 1, float?scatterRadius = null) { return(new SpawnInfo(SpawnableType.Cloth, SpawnType.Default, prefabOverride, clothData, CVT, variantIndex, worldPosition.GetValueOrDefault(TransformState.HiddenPos), DefaultParent(parent, worldPosition), rotation.GetValueOrDefault(Quaternion.identity), scatterRadius, count, null)); }
private SpawnInfo(SpawnableType spawnableType, SpawnType spawnType, GameObject prefab, BaseClothData clothData, ClothingVariantType clothingVariantType, int clothingVariantIndex, Vector3 worldPosition, Transform parent, Quaternion rotation, float?scatterRadius, int count, Occupation occupation, GameObject clonedFrom = null, CharacterSettings characterSettings = null, bool naked = false, bool cancelIfImpassable = false) { SpawnableType = spawnableType; SpawnType = spawnType; PrefabUsed = prefab; ClothData = clothData; ClothingVariantType = clothingVariantType; ClothingVariantIndex = clothingVariantIndex; WorldPosition = worldPosition; Parent = parent; Rotation = rotation; ScatterRadius = scatterRadius; Count = count; Occupation = occupation; ClonedFrom = clonedFrom; CharacterSettings = characterSettings; Naked = naked; CancelIfImpassable = cancelIfImpassable; }
/// <summary> /// Spawns the indicated cloth. /// </summary> /// <param name="ClothingData">data describing the cloth to spawn</param> /// <param name="worldPos"></param> /// <param name="parent"></param> /// <param name="CVT"></param> /// <param name="variant"></param> /// <param name="PrefabOverride">prefab to use instead of the default for this cloth type</param> /// <returns></returns> private static GameObject CreateCloth(BaseClothData clothData, Vector3?worldPos = null, Transform parent = null, ClothingVariantType CVT = ClothingVariantType.Default, int variant = -1, GameObject PrefabOverride = null) { if (clothData is HeadsetData headsetData) { return(CreateHeadsetCloth(headsetData, worldPos, parent, CVT, variant, PrefabOverride)); } else if (clothData is ContainerData containerData) { return(CreateBackpackCloth(containerData, worldPos, parent, CVT, variant, PrefabOverride)); } else if (clothData is ClothingData clothingData) { return(CreateCloth(clothingData, worldPos, parent, CVT, variant, PrefabOverride)); } else { Logger.LogErrorFormat("Unrecognize BaseClothData subtype {0}, please add logic" + " to ClothFactory to handle spawning this type.", Category.ItemSpawn, clothData.GetType().Name); return(null); } }
/// <summary> /// Create a dev spawner document representing the specified clothing /// </summary> /// <param name="data"></param> public static DevSpawnerDocument ForClothing(BaseClothData data) { return(new DevSpawnerDocument(data.name, SpawnableType.Cloth)); }