Example #1
0
 public SkinSubBaker(Wearable skin)
 {
     if (skin.Type != WearableType.Skin)
     {
         throw new ArgumentException(nameof(skin));
     }
     m_SkinColor           = GetSkinColor(skin);
     m_RosyComplexionColor = GetRosyComplexionColor(skin);
     m_LipPinknessColor    = GetLipPinknessColor(skin);
     m_LipstickColor       = GetLipstickColor(skin);
     m_BlushColor          = GetBlushColor(skin);
     m_OutershadowColor    = GetOuterShadowColor(skin);
     m_InnershadowColor    = GetInnerShadowColor(skin);
     m_EyelinerColor       = GetEyelinerColor(skin);
     m_NailpolishColor     = GetNailPolishColor(skin);
     m_Innershadow         = skin.GetParamValueOrDefault(709, 0);
     m_Outershadow         = skin.GetParamValueOrDefault(707, 0);
     skin.Textures.TryGetValue(AvatarTextureIndex.HeadBodypaint, out m_HeadTextureId);
     skin.Textures.TryGetValue(AvatarTextureIndex.UpperBodypaint, out m_UpperTextureId);
     skin.Textures.TryGetValue(AvatarTextureIndex.LowerBodypaint, out m_LowerTextureId);
     if (m_HeadTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_HeadTextureId = UUID.Zero;
     }
     if (m_UpperTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_UpperTextureId = UUID.Zero;
     }
     if (m_LowerTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_LowerTextureId = UUID.Zero;
     }
 }
Example #2
0
        public AlphaMaskSubBaker(Wearable alpha)
        {
            if (alpha.Type != WearableType.Alpha)
            {
                throw new ArgumentException(nameof(alpha));
            }

            alpha.Textures.TryGetValue(AvatarTextureIndex.EyesAlpha, out m_EyesTextureId);
            alpha.Textures.TryGetValue(AvatarTextureIndex.HairAlpha, out m_HairTextureId);
            alpha.Textures.TryGetValue(AvatarTextureIndex.LowerAlpha, out m_LowerbodyTextureId);
            alpha.Textures.TryGetValue(AvatarTextureIndex.UpperAlpha, out m_UpperbodyTextureId);
            alpha.Textures.TryGetValue(AvatarTextureIndex.HeadAlpha, out m_HeadTextureId);
            if (m_EyesTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_EyesTextureId = UUID.Zero;
            }
            if (m_HairTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_HairTextureId = UUID.Zero;
            }
            if (m_LowerbodyTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_LowerbodyTextureId = UUID.Zero;
            }
            if (m_UpperbodyTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_UpperbodyTextureId = UUID.Zero;
            }
            if (m_HeadTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_HeadTextureId = UUID.Zero;
            }
        }
Example #3
0
 public ShapeSubBaker(Wearable shape)
 {
     if (shape.Type != WearableType.Shape)
     {
         throw new ArgumentException(nameof(shape));
     }
 }
Example #4
0
 /// <summary>
 /// Note: this constructor cannot initialize automatically, because the gender is unknown at this point. We only know it when the item is equipped.
 /// </summary>
 public WearableSprite(XElement subElement, Wearable wearable)
 {
     Type = WearableType.Item;
     WearableComponent = wearable;
     SpritePath        = ParseSpritePath(subElement.GetAttributeString("texture", string.Empty));
     SourceElement     = subElement;
 }
Example #5
0
        private static Color3 GetHairColor(Wearable hair)
        {
            var    col = new Color3(0, 0, 0);
            double val;

            if (hair.Params.TryGetValue(112, out val))
            {
                col += CalcColor(val, RainbowHairColors);
            }

            if (hair.Params.TryGetValue(113, out val))
            {
                col += CalcColor(val, RedHairColors);
            }

            if (hair.Params.TryGetValue(114, out val))
            {
                col += CalcColor(val, BlondeHairColors);
            }

            if (hair.Params.TryGetValue(115, out val))
            {
                col += new Color3(val, val, val);
            }

            var alphaCol = (ColorAlpha)col;

            alphaCol.A = hair.Params.TryGetValue(751, out val) ?
                         1 - (val) :
                         0.7;
            return(alphaCol);
        }
Example #6
0
        public TattooSubBaker(Wearable tattoo)
        {
            if (tattoo.Type != WearableType.Tattoo)
            {
                throw new ArgumentException(nameof(tattoo));
            }

            m_TattooLowerColor = GetTattooLowerColor(tattoo);
            m_TattooUpperColor = GetTattooUpperColor(tattoo);
            tattoo.Textures.TryGetValue(AvatarTextureIndex.HeadTattoo, out m_HeadTattooId);
            tattoo.Textures.TryGetValue(AvatarTextureIndex.UpperTattoo, out m_UpperTattooId);
            tattoo.Textures.TryGetValue(AvatarTextureIndex.LowerTattoo, out m_LowerTattooId);
            if (m_HeadTattooId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_HeadTattooId = UUID.Zero;
            }
            if (m_UpperTattooId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_UpperTattooId = UUID.Zero;
            }
            if (m_LowerTattooId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_LowerTattooId = UUID.Zero;
            }
        }
Example #7
0
        private static Color3 GetTattooLowerColor(Wearable tattoo)
        {
            var    col = new Color3(1, 1, 1);
            double val;

            if (tattoo.Params.TryGetValue(1071, out val))
            {
                col.R = val;
            }
            if (tattoo.Params.TryGetValue(1072, out val))
            {
                col.G = val;
            }
            if (tattoo.Params.TryGetValue(1073, out val))
            {
                col.B = val;
            }

            if (tattoo.Params.TryGetValue(1068, out val))
            {
                col.R = val;
            }
            if (tattoo.Params.TryGetValue(1069, out val))
            {
                col.G = val;
            }
            if (tattoo.Params.TryGetValue(1070, out val))
            {
                col.B = val;
            }

            return(col);
        }
Example #8
0
 /// <summary>
 /// Note: this constructor cannot initialize automatically, because the gender is unknown at this point. We only know it when the item is equipped.
 /// </summary>
 public WearableSprite(XElement subElement, Wearable wearable, int variant = 0)
 {
     Type = WearableType.Item;
     WearableComponent    = wearable;
     Variant              = Math.Max(variant, 0);
     UnassignedSpritePath = ParseSpritePath(subElement.GetAttributeString("texture", string.Empty));
     SourceElement        = subElement;
 }
Example #9
0
        public static AbstractSubBaker CreateSubBaker(this Wearable wearable)
        {
            VisualParamsMapper.CompleteParams(wearable.Params);

            switch (wearable.Type)
            {
            case WearableType.Eyes:
                return(new EyeSubBaker(wearable));

            case WearableType.Skin:
                return(new SkinSubBaker(wearable));

            case WearableType.Hair:
                return(new HairSubBaker(wearable));

            case WearableType.Shape:
                return(new ShapeSubBaker(wearable));

            case WearableType.Tattoo:
                return(new TattooSubBaker(wearable));

            case WearableType.Alpha:
                return(new AlphaMaskSubBaker(wearable));

            case WearableType.Shirt:
                return(new ShirtSubBaker(wearable));

            case WearableType.Jacket:
                return(new JacketSubBaker(wearable));

            case WearableType.Socks:
                return(new SocksSubBaker(wearable));

            case WearableType.Pants:
                return(new PantsSubBaker(wearable));

            case WearableType.Underpants:
                return(new UnderpantsSubBaker(wearable));

            case WearableType.Undershirt:
                return(new UndershirtSubBaker(wearable));

            case WearableType.Shoes:
                return(new ShoesSubBaker(wearable));

            case WearableType.Skirt:
                return(new SkirtSubBaker(wearable));

            case WearableType.Gloves:
                return(new GlovesSubBaker(wearable));

            case WearableType.Universal:
                return(new UniversalSubBaker(wearable));

            default:
                return(null);    /* intentionally returning null here */
            }
        }
    public override void Inlitialize(Item item)
    {
        base.Inlitialize(item);
        Wearable wearData = item as Wearable;

        Type       = wearData.Type;
        Space      = wearData.Space;
        _boneNames = wearData._boneNames;
    }
 public bool PushWearable(Wearable wearable)
 {
     if (!mStack.HasTopItem && Wearable.CanWear(Type, BodyPart, Orientation, wearable.worlditem))
     {
         WIStackError error = WIStackError.None;
         return(Stacks.Push.Item(mStack, wearable.worlditem, ref error));
     }
     return(false);
 }
Example #12
0
        public virtual IActionResult WearablePost([FromBody] Wearable name, [FromHeader][Required()] string Authorization)
        {
            if (!ModelState.IsValid)
            {
                var error = ModelState.SelectMany(x => x.Value.Errors).First();
                if (error.ErrorMessage != null && error.ErrorMessage != String.Empty)
                {
                    return(BadRequest(error.ErrorMessage));
                }
                else if (error.Exception?.Message != null)
                {
                    return(BadRequest("Faulty input"));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            if (Authorization != settings.testToken)
            {
                return(BadRequest("Not allowed"));
            }
            long   newWearableID = 0;
            string errorMessage  = "";

            try
            {
                DatabaseInterface.DBWearable dBWearable = new DatabaseInterface.DBWearable();
                if (!dBWearable.AddWearable(name.PersonId, name.ThingId, ref errorMessage, ref newWearableID))
                {
                    return(BadRequest("Internal Server Error:" + errorMessage));
                }
            }
            catch (Exception e)
            {
                return(BadRequest("Internal Server Error:" + e.Message));
            }


            //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(200, default(GeneralResponse));

            //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(0, default(ErrorResponse));


            string exampleJson = null;

            exampleJson = "{\n  \"success\" : true,\n  \"newid\" : " + newWearableID.ToString() + "\n}";

            var example = exampleJson != null
            ? JsonConvert.DeserializeObject <GeneralPostResponse>(exampleJson)
            : default(GeneralPostResponse);

            //TODO: Change the data returned
            return(new ObjectResult(example));
        }
Example #13
0
    public bool IsFootwear()
    {
        Wearable component = entityPrefab.Get().GetComponent <Wearable>();

        if (component != null && (component.occupationOver & (Wearable.OccupationSlots.LeftFoot | Wearable.OccupationSlots.RightFoot)) != 0)
        {
            return(true);
        }
        return(false);
    }
Example #14
0
    /// <summary>
    /// Deletes a wearable.
    /// </summary>
    /// <param name="id">Wearable Id</param>
    /// <param name="editorMode">Is in editor mode or not.</param>
    public void DeleteWearable(Guid id, bool editorMode)
    {
        Wearable wearable = _wearables.Find(w => w.Id == id);

        if (wearable != null)
        {
            RemoveWearable(wearable.WearableType, editorMode);
            _wearables.RemoveAll(w => w.Id == id);
        }
    }
Example #15
0
    private bool IsHeadgear()
    {
        Wearable component = entityPrefab.Get().GetComponent <Wearable>();

        if (component != null && (component.occupationOver & (Wearable.OccupationSlots.HeadTop | Wearable.OccupationSlots.Face | Wearable.OccupationSlots.HeadBack)) != 0)
        {
            return(true);
        }
        return(false);
    }
Example #16
0
 public bool Wear(Wearable wearable)
 {
     for (int i = 0; i < GUIInventoryInterface.Get.ClothingInterface.Squares.Count; i++)
     {
         if (GUIInventoryInterface.Get.ClothingInterface.Squares[i].PushWearable(wearable))
         {
             return(true);
         }
     }
     return(false);
 }
    public static void JsonObject(Packet packet)
    {
        int id = packet.ReadInt();

        if (!GameManager.players.ContainsKey(id))
        {
            return;
        }

        string json = packet.ReadString();
        JsonSerializerSettings settings = new JsonSerializerSettings {
            TypeNameHandling = TypeNameHandling.All
        };
        NetEntity jsonObj = JsonConvert.DeserializeObject <NetEntity>(json, settings);

        if (jsonObj is NetAnimator)
        {
            GameManager.players[id].Animator.Set(jsonObj as NetAnimator);
            return;
        }
        if (jsonObj is BuildingData)
        {
            GameManager.instance.SpawnStructure(jsonObj as BuildingData);
            return;
        }
        if (jsonObj is NetItem)
        {
            NetItem netItem = jsonObj as NetItem;
            if (netItem is Netwearable)
            {
                Netwearable netWear = netItem as Netwearable;
                Wearable    wear    = new Wearable();
                wear.Initialize(netWear);
                GameManager.instance.ChangeInventory(id, wear);
            }
            if (netItem is NetHoldable)
            {
                NetHoldable netHold = netItem as NetHoldable;
                Holdable    hold    = new Holdable();
                hold.Initialize(netHold);
                GameManager.instance.ChangeInventory(id, hold);
            }
            return;
        }
        if (jsonObj is NetLoot)
        {
            NetLoot netLoot = jsonObj as NetLoot;
            GameManager.instance.CheckLoot(netLoot);
        }
        if (jsonObj is NetInventory)
        {
            Debug.Log("update inventory");
        }
    }
    public bool CanExistWith(ItemModWearable wearable)
    {
        if (Object.op_Equality((Object)wearable, (Object)null))
        {
            return(true);
        }
        Wearable targetWearable1 = this.targetWearable;
        Wearable targetWearable2 = wearable.targetWearable;

        return((targetWearable1.occupationOver & targetWearable2.occupationOver) == (Wearable.OccupationSlots) 0 && (targetWearable1.occupationUnder & targetWearable2.occupationUnder) == (Wearable.OccupationSlots) 0);
    }
Example #19
0
        private static ColorAlpha GetRosyComplexionColor(Wearable skin)
        {
            double     value;
            ColorAlpha color = ColorAlpha.FromRgba(198, 71, 71, 0);

            /* Rosy complextion */
            if (skin.Params.TryGetValue(116, out value))
            {
                color.A = value.LimitRange(0, 1);
            }

            return(color);
        }
Example #20
0
        private static ColorAlpha GetLipPinknessColor(Wearable skin)
        {
            double     value;
            ColorAlpha color = ColorAlpha.FromRgba(220, 115, 115, 0);

            /* Lip pinkness */
            if (skin.Params.TryGetValue(117, out value))
            {
                color.A = value.LimitRange(0, 1) * 0.5;
            }

            return(color);
        }
Example #21
0
File: Raw.cs Project: dritory/Janus
    public static Actor DeserializeActor(string s, int id)
    {
        actor = new Actor();
        actor.initialize(id);
        activeEffects  = new List <Effect>();
        passiveEffects = new List <Effect>();
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '[')
            {
                int    j = i + 1;
                string t = string.Empty;
                while (s[j] != ']')
                {
                    t += s[j].ToString();
                    j++;
                }
                i += j - 1 - i;
                addToken(t);
            }
            if (s[i] == '/' && s[i - 1] == '/' && i + 1 < s.Length)
            {
                while (s[i] != '\n' && i < s.Length)
                {
                    i++;
                }
            }
        }



        if (passiveEffects.Count > 0 || activeEffects.Count > 0)
        {
            Wearable item = (Wearable)actor.getComponent(typeof(Wearable));
            if (item != null)
            {
                item.activeEffects  = activeEffects;
                item.passiveEffects = passiveEffects;
            }
            else
            {
                Pickable p = (Pickable)actor.getComponent(typeof(Pickable));
                if (p != null)
                {
                    p.activeEffects = activeEffects;
                }
            }
        }

        return(actor);
    }
Example #22
0
        void UpCycleCombine(MessageUpCycleClothes messageUpCycleClothes)
        {
            Wearable[] wearables = new Wearable[2] {
                messageUpCycleClothes.Wearable1, messageUpCycleClothes.Wearable2
            };

            foreach (var chosenWearable in wearables)
            {
                //TODO fix
                //chosenWearable.Amount -= 1;
                // chosenWearable.Value.SetAmount(chosenWearable.Value.Amount - 1);
            }
            EventBroker.Instance().SendMessage(new MessageUpCycleClothes(messageUpCycleClothes.Wearable1, messageUpCycleClothes.Wearable2));
        }
Example #23
0
        public EyeSubBaker(Wearable eyes)
        {
            if (eyes.Type != WearableType.Eyes)
            {
                throw new ArgumentException(nameof(eyes));
            }

            m_EyeColor = GetEyeColor(eyes);
            eyes.Textures.TryGetValue(AvatarTextureIndex.EyesIris, out m_EyeTextureId);
            if (m_EyeTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_EyeTextureId = UUID.Zero;
            }
        }
    public void SaveInventory(Dictionary <string, ItemSlot> slots) // save inherited data for wearable/holdable data as well
    {
        NetInventory      playerSaveData = new NetInventory();
        List <Wearable>   wearables      = new List <Wearable>();
        List <Holdable>   holdables      = new List <Holdable>();
        List <Consumable> consumables    = new List <Consumable>();
        List <Misc>       miscs          = new List <Misc>();

        foreach (var itemSlot in slots)
        {
            if (itemSlot.Value.RuntimeItem.Item is Wearable)
            {
                Wearable wearable = ScriptableObject.CreateInstance(typeof(Wearable)) as Wearable;
                wearable.Initialize(itemSlot.Value.RuntimeItem.Item, itemSlot.Key);
                wearables.Add(wearable);
            }
            if (itemSlot.Value.RuntimeItem.Item is Holdable)
            {
                Holdable holdable = ScriptableObject.CreateInstance(typeof(Holdable)) as Holdable;
                holdable.Initialize(itemSlot.Value.RuntimeItem.Item, itemSlot.Key);
                holdables.Add(holdable);
            }
            if (itemSlot.Value.RuntimeItem.Item is Consumable)
            {
                Consumable consumable = ScriptableObject.CreateInstance(typeof(Consumable)) as Consumable;
                consumable.Initialize(itemSlot.Value.RuntimeItem.Item, itemSlot.Key);
                consumables.Add(consumable);
            }
            if (itemSlot.Value.RuntimeItem.Item is Misc)
            {
                Misc misc = ScriptableObject.CreateInstance(typeof(Misc)) as Misc;
                misc.Initialize(itemSlot.Value.RuntimeItem.Item, itemSlot.Key);
                miscs.Add(misc);
            }
        }

        playerSaveData.Wearables  = wearables.ToArray();
        playerSaveData.Holdables  = holdables.ToArray();
        playerSaveData.Consumable = consumables.ToArray();
        playerSaveData.Misc       = miscs.ToArray();

        JsonSerializerSettings settings = new JsonSerializerSettings {
            TypeNameHandling = TypeNameHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        };
        string json = JsonConvert.SerializeObject(playerSaveData, settings);

        File.WriteAllText(Application.persistentDataPath + "/GAPData.json", json);
        Debug.Log($"Saved inventory to: {Application.persistentDataPath}/GAPData.json");
    }
Example #25
0
 public ShoesSubBaker(Wearable shoes)
 {
     if (shoes.Type != WearableType.Shoes)
     {
         throw new ArgumentException(nameof(shoes));
     }
     m_Color          = GetShoeColor(shoes);
     m_ShoeHeight     = shoes.GetParamValueOrDefault(1052, 0.1);
     m_ShoeHeightBump = shoes.GetParamValueOrDefault(1055, 0.1);
     shoes.Textures.TryGetValue(AvatarTextureIndex.LowerShoes, out m_TextureId);
     if (m_TextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_TextureId = UUID.Zero;
     }
 }
Example #26
0
        private static Color3 GetEyeColor(Wearable eyes)
        {
            var    col = new Color3(0, 0, 0);
            double val;

            if (eyes.Params.TryGetValue(99, out val))
            {
                col += CalcColor(val, EyeColors);
            }
            if (eyes.Params.TryGetValue(98, out val))
            {
                col += new Color3(val, val, val);
            }
            return(col);
        }
Example #27
0
        public HairSubBaker(Wearable hair)
        {
            if (hair.Type != WearableType.Hair)
            {
                throw new ArgumentException(nameof(hair));
            }

            hair.Textures.TryGetValue(AvatarTextureIndex.Hair, out m_HairTextureId);
            if (m_HairTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_HairTextureId = UUID.Zero;
            }

            m_HairColor = (ColorAlpha)GetHairColor(hair);
        }
Example #28
0
        public SocksSubBaker(Wearable socks)
        {
            if (socks.Type != WearableType.Socks)
            {
                throw new ArgumentException(nameof(socks));
            }

            m_Color           = GetSocksColor(socks);
            m_SocksLength     = socks.GetParamValueOrDefault(617, 0.35);
            m_SocksLengthBump = socks.GetMinParamOrDefault(0.35, 1050, 1051);
            socks.Textures.TryGetValue(AvatarTextureIndex.LowerSocks, out m_TextureId);
            if (m_TextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_TextureId = UUID.Zero;
            }
        }
Example #29
0
    /// <summary>
    /// Adds a new wearable.
    /// </summary>
    /// <param name="wearable">Wearable object.</param>
    public void AddWearable(Wearable wearable)
    {
        if (wearable == null)
        {
            return;
        }
        if (_wearables == null)
        {
            _wearables = new List <Wearable>();
        }

        if (!_wearables.Exists(w => w.Id == wearable.Id || w.Name == wearable.Name))
        {
            _wearables.Add(wearable);
        }
    }
Example #30
0
        private static ColorAlpha GetInnerShadowColor(Wearable skin)
        {
            double value;
            var    color = (ColorAlpha)InnerShadowColors[0];

            if (!skin.Params.TryGetValue(712, out value))
            {
                color = (ColorAlpha)CalcColor(value, InnerShadowColors);
            }
            if (!skin.Params.TryGetValue(713, out value))
            {
                value = 0.7;
            }
            color.A = value * 0.2;

            return(color);
        }