Beispiel #1
0
        public bool CycleFromOSD(OSD osd)
        {
            OSDMap map = osd as OSDMap;

            if (map == null)
            {
                return(false);
            }
            if (!map.TryGetValue("type", out OSD tmp))
            {
                return(false);
            }
            string type = tmp.AsString();

            if (type != "daycycle")
            {
                return(false);
            }
            Cycle = new DayCycle();
            Cycle.FromOSD(map);

            InvalidateCaches();

            return(true);
        }
Beispiel #2
0
        public void FromOSD(OSD osd)
        {
            OSDMap map = osd as OSDMap;

            if (map == null)
            {
                return;
            }

            OSD otmp;

            if (map.TryGetValue("day_cycle", out otmp) && otmp is OSDMap)
            {
                Cycle = new DayCycle();
                Cycle.FromOSD(otmp as OSDMap);
            }
            if (Cycle == null)
            {
                Cycle = new DayCycle();
            }

            if (map.TryGetValue("day_length", out otmp))
            {
                DayLength = otmp;
            }
            if (map.TryGetValue("day_offset", out otmp))
            {
                DayOffset = otmp;
            }
            if (map.TryGetValue("flags", out otmp))
            {
                Flags = otmp;
            }
            if (map.TryGetValue("env_version", out otmp))
            {
                version = otmp;
            }
            else
            {
                ++version;
            }

            if (map.TryGetValue("track_altitudes", out otmp) && otmp is OSDArray)
            {
                OSDArray alt = otmp as OSDArray;

                for (int i = 0; i < alt.Count && i < 3; ++i)
                {
                    Altitudes[i] = alt[i];
                }

                SortAltitudes();
            }

            IsLegacy = false;
            InvalidateCaches();
        }
Beispiel #3
0
        public bool FromAssetOSD(string name, OSD osd)
        {
            OSDMap map = osd as OSDMap;

            if (map == null)
            {
                return(false);
            }
            if (!map.TryGetValue("type", out OSD tmp))
            {
                return(false);
            }
            string type = tmp.AsString();

            bool ok = false;

            if (type == "water")
            {
                if (Cycle == null)
                {
                    Cycle = new DayCycle();
                }
                ok = Cycle.replaceWaterFromOSD(name, map);
            }
            else
            {
                if (type == "daycycle")
                {
                    Cycle = new DayCycle();
                    Cycle.FromOSD(map);
                    ok = true;
                }
                else if (type == "sky")
                {
                    if (Cycle == null)
                    {
                        Cycle = new DayCycle();
                    }
                    ok = Cycle.replaceSkyFromOSD(name, map);
                }
            }
            if (ok && !string.IsNullOrWhiteSpace(name))
            {
                Cycle.Name = name;
            }

            InvalidateCaches();
            return(ok);
        }