Beispiel #1
0
    public static GameObject CreateBackpackCloth(ContainerData ContainerData, Vector3 worldPos, Transform parent = null,
                                                 ClothingVariantType CVT = ClothingVariantType.Default, int variant = -1, GameObject PrefabOverride = null)
    {
        if (Instance.uniBackpack == null)
        {
            Logger.LogError("UniBackPack Prefab not found", Category.SpriteHandler);
            return(null);
        }

        GameObject clothObj;

        if (PrefabOverride != null)
        {
            clothObj = PoolManager.PoolNetworkInstantiate(PrefabOverride, worldPos, parent);
        }
        else
        {
            clothObj = PoolManager.PoolNetworkInstantiate(Instance.uniBackpack, worldPos, parent);
        }

        var _Clothing = clothObj.GetComponent <Clothing>();
        var Item      = clothObj.GetComponent <ItemAttributes>();
        var Storage   = clothObj.GetComponent <StorageObject>();

        _Clothing.SpriteInfo = StaticSpriteHandler.SetupSingleSprite(ContainerData.Sprites.Equipped);
        Item.SetUpFromClothingData(ContainerData.Sprites, ContainerData.ItemAttributes);
        _Clothing.SetSynchronise(ConD: ContainerData);
        Storage.SetUpFromStorageObjectData(ContainerData.StorageData);
        return(clothObj);
    }
Beispiel #2
0
    private static GameObject CreateBackpackCloth(ContainerData ContainerData, Vector3?worldPos = null, Transform parent = null,
                                                  ClothingVariantType CVT = ClothingVariantType.Default, int variant     = -1, GameObject PrefabOverride = null)
    {
        if (uniBackpack == null)
        {
            uniBackpack = GetPrefabByName("UniBackPack");
        }
        if (uniBackpack == null)
        {
            Logger.LogError("UniBackPack Prefab not found", Category.SpriteHandler);
            return(null);
        }

        GameObject clothObj;

        if (PrefabOverride != null && PrefabOverride != uniBackpack)
        {
            clothObj = Spawn.ServerPrefab(PrefabOverride, worldPos, parent).GameObject;
        }
        else
        {
            clothObj = Spawn.ServerPrefab(uniBackpack, worldPos, parent).GameObject;
        }

        var _Clothing = clothObj.GetComponent <Clothing>();
        var Item      = clothObj.GetComponent <ItemAttributes>();

        _Clothing.SpriteInfo = StaticSpriteHandler.SetupSingleSprite(ContainerData.Sprites.Equipped);
        Item.SetUpFromClothingData(ContainerData.Sprites, ContainerData.ItemAttributes);
        _Clothing.SetSynchronise(ConD: ContainerData);
        return(clothObj);
    }
Beispiel #3
0
    public static GameObject CreateHeadsetCloth(HeadsetData headsetData, Vector3 worldPos, Transform parent = null,
                                                ClothingVariantType CVT = ClothingVariantType.Default, int variant = -1, GameObject PrefabOverride = null)
    {
        if (Instance.uniHeadSet == null)
        {
            Logger.LogError("UniHeadSet Prefab not found", Category.SpriteHandler);
            return(null);
        }

        GameObject clothObj;

        if (PrefabOverride != null)
        {
            clothObj = PoolManager.PoolNetworkInstantiate(PrefabOverride, worldPos, parent);
        }
        else
        {
            clothObj = PoolManager.PoolNetworkInstantiate(Instance.uniHeadSet, worldPos, parent);
        }

        var _Clothing = clothObj.GetComponent <Clothing>();
        var Item      = clothObj.GetComponent <ItemAttributes>();
        var Headset   = clothObj.GetComponent <Headset>();

        _Clothing.SpriteInfo = StaticSpriteHandler.SetupSingleSprite(headsetData.Sprites.Equipped);
        _Clothing.SetSynchronise(HD: headsetData);
        Item.SetUpFromClothingData(headsetData.Sprites, headsetData.ItemAttributes);
        Headset.EncryptionKey = headsetData.Key.EncryptionKey;
        return(clothObj);
    }
Beispiel #4
0
 /// <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)));
 }
Beispiel #5
0
    public int ReturnState(ClothingVariantType CVT)
    {
        if (VariantStore.ContainsKey(CVT))
        {
            return(VariantStore[CVT]);
        }

        return(0);
    }
Beispiel #6
0
 /// <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));
 }
Beispiel #7
0
    private static GameObject CreateCloth(ClothingData ClothingData, Vector3?worldPos = null, Transform parent = null,
                                          ClothingVariantType CVT = ClothingVariantType.Default, int variant   = -1, GameObject PrefabOverride = null)
    {
        if (uniCloth == null)
        {
            uniCloth = GetPrefabByName("UniCloth");
        }
        if (uniCloth == null)
        {
            Logger.LogError("UniCloth Prefab not found", Category.SpriteHandler);
            return(null);
        }

        GameObject clothObj;

        if (PrefabOverride != null && PrefabOverride != uniCloth)
        {
            clothObj = Spawn.ServerPrefab(PrefabOverride, worldPos, parent).GameObject;
        }
        else
        {
            clothObj = Spawn.ServerPrefab(uniCloth, worldPos, parent).GameObject;
        }

        var _Clothing = clothObj.GetComponent <Clothing>();
        var Item      = clothObj.GetComponent <ItemAttributes>();

        _Clothing.SpriteInfo = StaticSpriteHandler.SetUpSheetForClothingData(ClothingData, _Clothing);
        _Clothing.SetSynchronise(CD: ClothingData);
        Item.SetUpFromClothingData(ClothingData.Base, ClothingData.ItemAttributes);
        switch (CVT)
        {
        case ClothingVariantType.Default:
            if (variant > -1)
            {
                if (!(ClothingData.Variants.Count >= variant))
                {
                    Item.SetUpFromClothingData(ClothingData.Variants[variant], ClothingData.ItemAttributes);
                }
            }

            break;

        case ClothingVariantType.Skirt:
            Item.SetUpFromClothingData(ClothingData.DressVariant, ClothingData.ItemAttributes);
            break;

        case ClothingVariantType.Tucked:
            Item.SetUpFromClothingData(ClothingData.Base_Adjusted, ClothingData.ItemAttributes);
            break;
        }

        clothObj.name = ClothingData.name;
        return(clothObj);
    }
Beispiel #8
0
 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;
 }
Beispiel #9
0
 /// <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);
     }
 }
Beispiel #10
0
 public void ServerChangeVariant(ClothingVariantType variant)
 {
     variantType = variant;
 }
Beispiel #11
0
 private void SyncSprites(ClothingVariantType oldValue, ClothingVariantType newValue)
 {
     variantType = newValue;
     TryInit();
     RefreshClothingItem();
 }
Beispiel #12
0
 public void SyncType(ClothingVariantType _Type)
 {
     Type = _Type;
 }
Beispiel #13
0
 public void SyncType(ClothingVariantType _Type)
 {
     Type = _Type;
     RefreshAppearance();
 }