public RagdollPresetMetadata SavePreset(RagdollPresetMetadata saveOver, string title, string description)
    {
        RagdollPresetMetadata ragdollPresetMetadata = WorkshopRepository.instance.presetRepo.SaveSkinAsPreset(activePlayer, activeCustomization.preset, saveOver, title, description);

        CaptureThumbnail(thumbnailCamera, ragdollPresetMetadata.thumbPath);
        ReloadSkin(activePlayer);
        return(ragdollPresetMetadata);
    }
Ejemplo n.º 2
0
 public void OnDestroy()
 {
     if (boundData != null)
     {
         boundData.ReleaseThumbnailReference();
     }
     boundData = null;
 }
Ejemplo n.º 3
0
    public override void OnGotFocus()
    {
        base.OnGotFocus();
        EventSystem.current.sendNavigationEvents = false;
        RagdollPresetMetadata skin = CustomizationController.instance.GetSkin();

        title.text       = ((targetPreset == null) ? skin.title : targetPreset.title);
        description.text = ((targetPreset == null) ? skin.description : targetPreset.description);
    }
Ejemplo n.º 4
0
		public static NetPlayer SpawnPlayer(uint id, NetHost host, bool isLocal, string skinUserId, uint localCoopIndex, byte[] skinCRC)
		{
			NetPlayer component = Object.Instantiate(Game.instance.playerPrefab).GetComponent<NetPlayer>();
			component.human.player = component;
			component.human.ragdoll = Object.Instantiate(Game.instance.ragdollPrefab.gameObject, component.human.transform, worldPositionStays: false).GetComponent<Ragdoll>();
			component.human.ragdoll.BindBall(component.human.transform);
			component.human.Initialize();
			RagdollPresetMetadata ragdollPresetMetadata;
			if (isLocal)
			{
				ragdollPresetMetadata = GetLocalSkin(localCoopIndex);
			}
			else
			{
				ragdollPresetMetadata = RagdollPresetMetadata.LoadNetSkin(localCoopIndex, skinUserId);
				if (ragdollPresetMetadata != null && !ragdollPresetMetadata.CheckCRC(skinCRC))
				{
					ragdollPresetMetadata = null;
				}
			}
			component.netId = id;
			component.host = host;
			component.localCoopIndex = localCoopIndex;
			component.isLocalPlayer = isLocal;
			component.skin = ragdollPresetMetadata;
			component.skinUserId = skinUserId;
			component.skinCRC = skinCRC;
			if (isLocal && ragdollPresetMetadata != null && isPlayingGame())
			{
				App.StartPlaytimeForItem(ragdollPresetMetadata.workshopId);
			}
			host.AddPlayer(component);
			if (ragdollPresetMetadata != null)
			{
				component.ApplyPreset(ragdollPresetMetadata);
			}
			else
			{
				component.ApplyPreset(PresetRepository.CreateDefaultSkin(), bake: false);
			}
			component.SetupBodies();
			if (isLocal)
			{
				MenuCameraEffects.instance.AddHuman(component);
				Listener.instance.AddHuman(component.human);
				PlayerManager.instance.OnLocalPlayerAdded(component);
			}
			else
			{
				component.cameraController.gameObject.SetActive(value: false);
			}
			if (NetGame.netlog)
			{
				Debug.LogFormat("Spawning {0}", component.netId);
			}
			return component;
		}
Ejemplo n.º 5
0
		public void ApplyPreset(RagdollPresetMetadata preset, bool bake = true)
		{
			if (customization == null)
			{
				customization = human.ragdoll.gameObject.AddComponent<RagdollCustomization>();
			}
			customization.ApplyPreset(preset, forceRebuild: true);
			customization.RebindColors(bake, compress: true);
			customization.ClearOutCachedClipVolumes();
		}
Ejemplo n.º 6
0
 public void LoadFromPreset(RagdollPresetMetadata preset)
 {
     ReleaseBaseTexture();
     savePath = FileTools.Combine(preset.folder, part.ToString() + ".png");
     textureLoadSuppressed = preset.GetPart(part).suppressCustomTexture;
     if (!textureLoadSuppressed)
     {
         RagdollPresetPartMetadata ragdollPresetPartMetadata = preset.GetPart(part);
         if (ragdollPresetPartMetadata != null && ragdollPresetPartMetadata.bytes != null)
         {
             ChangeBaseTexture(FileTools.TextureFromBytes(part.ToString(), ragdollPresetPartMetadata.bytes), isAsset: false);
         }
         else if (!string.IsNullOrEmpty(savePath))
         {
             bool      isAsset;
             Texture2D newRes = FileTools.ReadTexture(savePath, out isAsset);
             ChangeBaseTexture(newRes, isAsset);
         }
         if (baseTexture != null)
         {
             baseTexture.Compress(highQuality: true);
             baseTexture.Apply(updateMipmaps: true);
         }
     }
     if (model.meta.metaPath.StartsWith("builtin"))
     {
         if (baseTexture == null)
         {
             ChangeBaseTexture(HFFResources.instance.FindTextureResource("SkinTextures/" + model.meta.modelPrefab.name + "Color"), isAsset: true);
         }
         if (model.maskTexture == null)
         {
             ChangeMaskTexture(HFFResources.instance.FindTextureResource("SkinTextures/" + model.meta.modelPrefab.name + "Mask"), isAsset: true);
         }
     }
     if (baseTexture != null)
     {
         width           = baseTexture.width;
         height          = baseTexture.height;
         paintingEnabled = true;
     }
     else if (model.maskTexture != null)
     {
         width           = model.maskTexture.width;
         height          = model.maskTexture.height;
         paintingEnabled = true;
     }
     else
     {
         width           = (height = 2048);
         paintingEnabled = true;
     }
 }
Ejemplo n.º 7
0
    public void ApplyPresetColors(RagdollPresetMetadata preset, bool bake, bool compress)
    {
        string b = FileTools.Combine(preset.folder, part.ToString() + ".png");
        bool   suppressCustomTexture = preset.GetPart(part).suppressCustomTexture;

        if (savePath != b || textureLoadSuppressed != suppressCustomTexture)
        {
            LoadFromPreset(preset);
        }
        RagdollPresetPartMetadata ragdollPresetPartMetadata = preset.GetPart(part);

        ApplyColors(HexConverter.HexToColor(ragdollPresetPartMetadata.color1, default(Color)), HexConverter.HexToColor(ragdollPresetPartMetadata.color2, default(Color)), HexConverter.HexToColor(ragdollPresetPartMetadata.color3, default(Color)), bake, compress);
    }
Ejemplo n.º 8
0
    private void OnSelect(ListViewItem item)
    {
        CustomizationPresetMenuItem customizationPresetMenuItem = item as CustomizationPresetMenuItem;

        if (selectedMenuItem != null)
        {
            selectedMenuItem.SetActive(active: false);
        }
        selectedMenuItem = customizationPresetMenuItem;
        selectedMenuItem.SetActive(active: true);
        selectedItem = (item.data as RagdollPresetMetadata);
        if (mode == CustomizationPresetMenuMode.Load)
        {
            CustomizationController.instance.LoadPreset(selectedItem);
        }
        BindButtons();
    }
Ejemplo n.º 9
0
 private void ApplyPreset(RagdollPresetMetadata preset, bool bake = true)
 {
     if (customization == null)
     {
         customization = ragdoll.gameObject.AddComponent <RagdollCustomization>();
     }
     customization.ApplyPreset(preset, forceRebuild: true);
     customization.RebindColors(bake, compress: true);
     RigClipVolume[] componentsInChildren = GetComponentsInChildren <RigClipVolume>();
     if (customization.main != null)
     {
         RagdollModelSkinnedMesh[] componentsInChildren2 = customization.main.GetComponentsInChildren <RagdollModelSkinnedMesh>();
         for (int i = 0; i < componentsInChildren2.Length; i++)
         {
             componentsInChildren2[i].Clip(componentsInChildren);
         }
     }
 }
Ejemplo n.º 10
0
    public void ApplySkin(string skin)
    {
        if (string.IsNullOrEmpty(skin))
        {
            ragdoll.gameObject.SetActive(value: false);
            return;
        }
        Transform transform = skins.Find(skin.ToLowerInvariant());

        if (transform != null)
        {
            ragdoll.gameObject.SetActive(value: true);
            SkinnedDollPreset     component             = transform.GetComponent <SkinnedDollPreset>();
            RagdollPresetMetadata ragdollPresetMetadata = new RagdollPresetMetadata();
            ragdollPresetMetadata.folder   = null;
            ragdollPresetMetadata.itemType = WorkshopItemType.RagdollPreset;
            ragdollPresetMetadata.main     = new RagdollPresetPartMetadata
            {
                modelPath = ((!string.IsNullOrEmpty(component.full)) ? ("builtin:" + component.full) : "builtin:HumanDefaultBody")
            };
            ragdollPresetMetadata.head = new RagdollPresetPartMetadata
            {
                modelPath = ((!string.IsNullOrEmpty(component.head)) ? ("builtin:" + component.head) : "builtin:HumanHardHat")
            };
            ragdollPresetMetadata.upperBody = ((!string.IsNullOrEmpty(component.upper)) ? new RagdollPresetPartMetadata
            {
                modelPath = "builtin:" + component.upper
            } : null);
            ragdollPresetMetadata.lowerBody = ((!string.IsNullOrEmpty(component.lower)) ? new RagdollPresetPartMetadata
            {
                modelPath = "builtin:" + component.lower
            } : null);
            RagdollPresetMetadata ragdollPresetMetadata2 = ragdollPresetMetadata;
            if (!string.IsNullOrEmpty(component.full) && string.IsNullOrEmpty(component.head))
            {
                ragdollPresetMetadata2.head = null;
            }
            ApplyPreset(ragdollPresetMetadata2, bake: false);
        }
        else
        {
            ragdoll.gameObject.SetActive(value: false);
        }
    }
Ejemplo n.º 11
0
    public override void Bind(int index, object data)
    {
        base.Bind(index, data);
        RagdollPresetMetadata ragdollPresetMetadata = data as RagdollPresetMetadata;

        if (ragdollPresetMetadata != null)
        {
            if (labelComponent == null)
            {
                OnEnable();
            }
            if (labelIsUIText)
            {
                ((Text)labelComponent).text = ragdollPresetMetadata.title;
            }
            else
            {
                ((TextMeshProUGUI)labelComponent).text = ragdollPresetMetadata.title;
            }
            image.texture = ragdollPresetMetadata.thumbnailTexture;
        }
        normalTemplate.SetActive(ragdollPresetMetadata != null);
        newSlotTemplate.SetActive(ragdollPresetMetadata == null);
        MenuButton component = GetComponent <MenuButton>();

        if (ragdollPresetMetadata == null)
        {
            component.SetLabel(newSlotLabel);
        }
        else if (labelIsUIText)
        {
            component.SetLabel((Text)labelComponent);
        }
        else
        {
            component.SetLabel((TextMeshProUGUI)labelComponent);
        }
        if (boundData != null)
        {
            boundData.ReleaseThumbnailReference();
        }
        boundData = ragdollPresetMetadata;
    }
Ejemplo n.º 12
0
    public override void OnGotFocus()
    {
        base.OnGotFocus();
        if (deleteSelectedOnLoad)
        {
            deleteSelectedOnLoad = false;
            CustomizationController.instance.DeletePreset(selectedItem);
            dontReload = true;
            int num = items.IndexOf(selectedItem);
            items.Remove(selectedItem);
            if (num >= items.Count)
            {
                num = items.Count - 1;
            }
            if (items.Count > 0)
            {
                selectedItem = items[num];
            }
            else
            {
                selectedItem = null;
            }
            if (mode == CustomizationPresetMenuMode.Save && items.Count < 128 && (items.Count < 1 || items[items.Count - 1] != null))
            {
                items.Add(null);
            }
        }
        bool flag = true;

        if (!flag && showSubscribed)
        {
            showSubscribed = false;
        }
        showSubscribedButton.SetActive(mode == CustomizationPresetMenuMode.Load && !showSubscribed && flag);
        loadMyTitle.SetActive(mode == CustomizationPresetMenuMode.Load && !showSubscribed);
        bool flag2 = mode == CustomizationPresetMenuMode.Load && showSubscribed;

        showMyButton.SetActive(flag2);
        loadSubscribedTitle.SetActive(flag2);
        openWorkshopButton.SetActive(flag2);
        InCustomizationPresetMenu = flag2;
        saveTitle.SetActive(mode != CustomizationPresetMenuMode.Load);
        noSubscriptionsMessage.SetActive(value: false);
        offlineMessage.SetActive(value: false);
        noPresetsMessage.SetActive(value: false);
        list.onSelect       = OnSelect;
        list.onPointerClick = OnPointerClick;
        list.onSubmit       = OnSubmit;
        bool flag3 = false;

        flag3 = SteamUser.BLoggedOn();
        if (!dontReload)
        {
            if (mode == CustomizationPresetMenuMode.Load)
            {
                WorkshopRepository.instance.ReloadLocalPresets();
                if (!WorkshopRepository.instance.ReloadSubscriptions())
                {
                }
                items = new List <RagdollPresetMetadata>();
                if (showSubscribed)
                {
                    if (flag3)
                    {
                        items.AddRange(WorkshopRepository.instance.presetRepo.BySource(WorkshopItemSource.Subscription));
                    }
                }
                else
                {
                    items.AddRange(WorkshopRepository.instance.presetRepo.BySource(WorkshopItemSource.LocalWorkshop));
                }
            }
            else
            {
                WorkshopRepository.instance.ReloadLocalPresets();
                WorkshopRepository.instance.ReloadSubscriptions();
                items = new List <RagdollPresetMetadata>();
                items.AddRange(WorkshopRepository.instance.presetRepo.BySource(WorkshopItemSource.LocalWorkshop));
                if (items.Count < 128)
                {
                    items.Add(null);
                }
            }
            selectedItem = null;
            string skinPresetReference = CustomizationController.instance.GetSkinPresetReference();
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i] != null && items[i].folder.Equals(skinPresetReference))
                {
                    selectedItem = items[i];
                }
            }
        }
        CustomizationController.instance.cameraController.FocusCharacterModel();
        dontReload = false;
        if (items.Count == 0)
        {
            list.Bind(items);
            if (!flag3)
            {
                offlineMessage.SetActive(value: true);
            }
            else if (showSubscribed)
            {
                noSubscriptionsMessage.SetActive(value: true);
            }
            else
            {
                noPresetsMessage.SetActive(value: true);
            }
            BindButtons();
            EventSystem.current.SetSelectedGameObject(GetComponentInChildren <Selectable>().gameObject);
        }
        else
        {
            list.Bind(items);
            int num2 = items.IndexOf(selectedItem);
            if (num2 < 0)
            {
                num2 = 0;
            }
            list.FocusItem(num2);
        }
        PageLeftButton.SetActive(list.isCarousel);
        PageRightButton.SetActive(list.isCarousel);
    }
Ejemplo n.º 13
0
		public void ApplySkin(byte[] bytes)
		{
			skin = RagdollPresetMetadata.Deserialize(bytes);
			skin.SaveNetSkin(localCoopIndex, skinUserId);
			ApplyPreset(skin);
		}
 public void DeletePreset(RagdollPresetMetadata preset)
 {
     WorkshopRepository.instance.presetRepo.DeletePreset(preset);
 }
 public void LoadPreset(RagdollPresetMetadata preset)
 {
     activeCustomization.ApplyPreset(preset);
     activeCustomization.RebindColors(bake: false);
 }