Ejemplo n.º 1
0
        private bool InternalCreate(Core.Version version, ClientFeatures features)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            if (this.Loaded)
            {
                return(true);
            }

            if (features == ClientFeatures.None || features == ClientFeatures.Transparency)
            {
                features |= version.Value >= (ushort)DatFormat.Format_755 ? ClientFeatures.PatternZ : features;
                features |= version.Value >= (ushort)DatFormat.Format_960 ? ClientFeatures.Extended : features;
                features |= version.Value >= (ushort)DatFormat.Format_1050 ? ClientFeatures.FrameDurations : features;
                features |= version.Value >= (ushort)DatFormat.Format_1057 ? ClientFeatures.FrameGroups : features;
            }

            this.Version        = version;
            this.ClientFeatures = features;
            this.Items.Add(100, ThingType.Create(100, ThingCategory.Item));
            this.ItemCount = 100;
            this.Outfits.Add(1, ThingType.Create(1, ThingCategory.Outfit));
            this.OutfitCount = 1;
            this.Effects.Add(1, ThingType.Create(1, ThingCategory.Effect));
            this.EffectCount = 1;
            this.Missiles.Add(1, ThingType.Create(1, ThingCategory.Missile));
            this.MissileCount = 1;
            this.Changed      = true;
            this.Loaded       = true;
            this.Disposed     = false;
            return(true);
        }
Ejemplo n.º 2
0
        private ThingType InternalRemoveThing(ushort id, ThingCategory category)
        {
            if (id == 0 || category == ThingCategory.Invalid || !this.HasThing(id, category))
            {
                return(null);
            }

            ThingType changedThing = null;

            if (category == ThingCategory.Item)
            {
                changedThing = this.Items[id];

                if (id == this.ItemCount && id != 100)
                {
                    this.ItemCount = (ushort)(this.ItemCount - 1);
                    this.Items.Remove(id);
                }
                else
                {
                    this.Items[id] = ThingType.Create(id, category);
                }
            }
            else if (category == ThingCategory.Outfit)
            {
                changedThing = this.Outfits[id];

                if (id == this.OutfitCount && id != 1)
                {
                    this.OutfitCount = (ushort)(this.OutfitCount - 1);
                    this.Outfits.Remove(id);
                }
                else
                {
                    this.Outfits[id] = ThingType.Create(id, category);
                }
            }
            else if (category == ThingCategory.Effect)
            {
                changedThing = this.Effects[id];

                if (id == this.EffectCount && id != 1)
                {
                    this.EffectCount = (ushort)(this.EffectCount - 1);
                    this.Effects.Remove(id);
                }
                else
                {
                    this.Effects[id] = ThingType.Create(id, category);
                }
            }
            else if (category == ThingCategory.Missile)
            {
                changedThing = this.Missiles[id];

                if (id == this.MissileCount && id != 1)
                {
                    this.MissileCount = (ushort)(this.MissileCount - 1);
                    this.Missiles.Remove(id);
                }
                else
                {
                    this.Missiles[id] = ThingType.Create(id, category);
                }
            }

            return(changedThing);
        }