Exemplo n.º 1
0
        /////////
        /////////  Server-specific stuff
        /////////

        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "BaseTemplate",
                "bodyTemplate.Humanoid",
                template =>
            {
                if (!_prototypeManager.TryIndex(template, out BodyTemplatePrototype templateData))
                {
                    throw new InvalidOperationException("No BodyTemplatePrototype was found with the name " + template + " while loading a BodyTemplate!");     //Should never happen unless you f**k up the prototype.
                }

                _template = new BodyTemplate(templateData);
            },
                () => _template.Name);

            serializer.DataReadWriteFunction(
                "BasePreset",
                "bodyPreset.BasicHuman",
                preset =>
            {
                if (!_prototypeManager.TryIndex(preset, out BodyPresetPrototype presetData))
                {
                    throw new InvalidOperationException("No BodyPresetPrototype was found with the name " + preset + " while loading a BodyPreset!");     //Should never happen unless you f**k up the prototype.
                }

                LoadBodyPreset(new BodyPreset(presetData));
            },
                () => _presetName);
        }
Exemplo n.º 2
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            Air = new GasMixture {
                Temperature = Atmospherics.NormalBodyTemperature
            };

            serializer.DataReadWriteFunction(
                "volume",
                6,
                vol => Air.Volume = vol,
                () => Air.Volume);

            serializer.DataReadWriteFunction(
                "temperature",
                Atmospherics.NormalBodyTemperature,
                temp => Air.Temperature = temp,
                () => Air.Temperature);

            serializer.DataReadWriteFunction(
                "gaspPopupCooldown",
                8f,
                delay => GaspPopupCooldown = TimeSpan.FromSeconds(delay),
                () => GaspPopupCooldown.TotalSeconds);
        }
        /// <inheritdoc />
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction("prototype", null,
                                             value => Prototype = value, () => Prototype);

            serializer.DataReadWriteFunction("stage", 0,
                                             value => Stage = value, () => Stage);
        }
        /// <inheritdoc />
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction("wspd", 4.0f, value => WalkMoveSpeed    = value, () => WalkMoveSpeed);
            serializer.DataReadWriteFunction("rspd", 10.0f, value => SprintMoveSpeed = value, () => SprintMoveSpeed);

            // The velocity and moving directions is usually set from player or AI input,
            // so we don't want to save/load these derived fields.
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            //only save the base speeds - the current speeds are transient.
            serializer.DataReadWriteFunction("wspd", DefaultBaseWalkSpeed, value => BaseWalkSpeed     = value, () => BaseWalkSpeed);
            serializer.DataReadWriteFunction("rspd", DefaultBaseSprintSpeed, value => BaseSprintSpeed = value, () => BaseSprintSpeed);

            // The velocity and moving directions is usually set from player or AI input,
            // so we don't want to save/load these derived fields.
        }
Exemplo n.º 6
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataField(ref _useSound, "useSound", "/Audio/Items/eatfood.ogg");
            serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5));
            serializer.DataField(ref _trashPrototype, "trash", null);

            serializer.DataReadWriteFunction(
                "utensils",
                new List <UtensilType>(),
                types => types.ForEach(type => _utensilsNeeded |= type),
                () =>
            {
                var types = new List <UtensilType>();

                foreach (var type in (UtensilType[])Enum.GetValues(typeof(UtensilType)))
                {
                    if ((_utensilsNeeded & type) != 0)
                    {
                        types.Add(type);
                    }
                }

                return(types);
            });
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "magazineTypes",
                new List <MagazineType>(),
                types => types.ForEach(mag => _magazineTypes |= mag),
                () =>
            {
                var types = new List <MagazineType>();

                foreach (MagazineType mag in Enum.GetValues(typeof(MagazineType)))
                {
                    if ((_magazineTypes & mag) != 0)
                    {
                        types.Add(mag);
                    }
                }

                return(types);
            });
            serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified);
            serializer.DataField(ref _magFillPrototype, "magFillPrototype", null);
            serializer.DataField(ref _autoEjectMag, "autoEjectMag", false);
            serializer.DataField(ref _magNeedsOpenBolt, "magNeedsOpenBolt", false);
            serializer.DataField(ref _soundBoltOpen, "soundBoltOpen", null);
            serializer.DataField(ref _soundBoltClosed, "soundBoltClosed", null);
            serializer.DataField(ref _soundRack, "soundRack", null);
            serializer.DataField(ref _soundMagInsert, "soundMagInsert", null);
            serializer.DataField(ref _soundMagEject, "soundMagEject", null);
            serializer.DataField(ref _soundAutoEject, "soundAutoEject", "/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg");
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "volume",
                0f,
                vol => GasMixture.Volume = vol,
                () => GasMixture.Volume);
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction("keys", new List <string>(),
                                             (list) => FillConfiguration(list, _config, ""),
                                             () => _config.Keys.ToList());

            serializer.DataReadFunction("validation", "^[a-zA-Z0-9 ]*$", value => _validation = new Regex("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled));
        }
Exemplo n.º 10
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            Air = new GasMixture {
                Temperature = Atmospherics.NormalBodyTemperature
            };

            serializer.DataReadWriteFunction(
                "volume",
                6,
                vol => Air.Volume = vol,
                () => Air.Volume);

            serializer.DataReadWriteFunction(
                "temperature",
                Atmospherics.NormalBodyTemperature,
                temp => Air.Temperature = temp,
                () => Air.Temperature);
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "volume",
                6,
                vol => Air.Volume = vol,
                () => Air.Volume);
            serializer.DataField(this, l => l.Pressure, "pressure", 100);
        }
Exemplo n.º 12
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction("tags", new List <string>(),
                                             value =>
            {
                _tags.Clear();
                _tags.UnionWith(value);
            },
                                             () => new List <string>(_tags));
        }
Exemplo n.º 13
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "hands",
                new List <string>(),
                hands => hands.ForEach(slot => _hands.Add(slot, null)),
                () => _hands.Keys.ToList());

            serializer.DataField(this, x => ActiveIndex, "defaultHand", _hands.Keys.LastOrDefault());
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "deadThreshold",
                100,
                t => DeadThreshold = t,
                () => DeadThreshold ?? -1);

            serializer.DataField(this, ruinable => ruinable.DestroySound, "destroySound", string.Empty);
        }
Exemplo n.º 15
0
 /// <inheritdoc />
 public void ExposeData(ObjectSerializer serializer)
 {
     serializer.DataReadWriteFunction(
         "reagents",
         new List <ReagentQuantity>(),
         quantities =>
     {
         _contents   = quantities;
         TotalVolume = ReagentUnit.New(0);
         quantities.ForEach(reagent => TotalVolume += reagent.Quantity);
     },
         () => _contents);
 }
Exemplo n.º 16
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "thresholds",
                new Dictionary <int, IMobState>(),
                thresholds =>
            {
                _lowestToHighestStates = new SortedDictionary <int, IMobState>(thresholds);
            },
                () => new Dictionary <int, IMobState>(_lowestToHighestStates));
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "baseTemplate",
                "bodyTemplate.Humanoid",
                template =>
            {
                if (!_prototypeManager.TryIndex(template, out BodyTemplatePrototype prototype))
                {
                    // Invalid prototype
                    throw new InvalidOperationException(
                        $"No {nameof(BodyTemplatePrototype)} found with name {template}");
                }

                Template = new BodyTemplate();
                Template.Initialize(prototype);
            },
                () => Template.Name);

            serializer.DataReadWriteFunction(
                "basePreset",
                "bodyPreset.BasicHuman",
                preset =>
            {
                if (!_prototypeManager.TryIndex(preset, out BodyPresetPrototype prototype))
                {
                    // Invalid prototype
                    throw new InvalidOperationException(
                        $"No {nameof(BodyPresetPrototype)} found with name {preset}");
                }

                Preset = new BodyPreset();
                Preset.Initialize(prototype);
            },
                () => _presetName);
        }
Exemplo n.º 18
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction("access", new List <List <string> >(),
                                             v =>
            {
                if (v.Count != 0)
                {
                    _accessLists.Clear();
                    _accessLists.AddRange(v.Select(a => new HashSet <string>(a)));
                }
            },
                                             () => _accessLists.Select(p => new List <string>(p)).ToList());
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified);
            serializer.DataReadWriteFunction(
                "capacity",
                6,
                cap => _ammoSlots = new IEntity[cap],
                () => _ammoSlots.Length);
            serializer.DataField(ref _fillPrototype, "fillPrototype", null);

            // Sounds
            serializer.DataField(ref _soundEject, "soundEject", "/Audio/Weapons/Guns/MagOut/revolver_magout.ogg");
            serializer.DataField(ref _soundInsert, "soundInsert", "/Audio/Weapons/Guns/MagIn/revolver_magin.ogg");
            serializer.DataField(ref _soundSpin, "soundSpin", "/Audio/Weapons/Guns/Misc/revolver_spin.ogg");
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "technologies",
                new List <string>(),
                techs =>
            {
                var prototypeManager = IoCManager.Resolve <IPrototypeManager>();

                foreach (var id in techs)
                {
                    if (prototypeManager.TryIndex(id, out TechnologyPrototype tech))
                    {
                        _technologies.Add(tech);
                    }
                }
            }, GetTechnologyIdList);
        }
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "deadThreshold",
                100,
                t =>
            {
                if (t == null)
                {
                    return;
                }

                Thresholds[DamageState.Dead] = t.Value;
            },
                () => Thresholds.TryGetValue(DamageState.Dead, out var value) ? value : (int?)null);

            serializer.DataField(this, ruinable => ruinable.DestroySound, "destroySound", string.Empty);
        }
Exemplo n.º 22
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "recipes",
                new List <string>(),
                recipes =>
            {
                var prototypeManager = IoCManager.Resolve <IPrototypeManager>();

                foreach (var id in recipes)
                {
                    if (prototypeManager.TryIndex(id, out LatheRecipePrototype recipe))
                    {
                        _recipes.Add(recipe);
                    }
                }
            },
                GetRecipeIdList);
        }
Exemplo n.º 23
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "factions",
                new List <Faction>(),
                factions => factions.ForEach(faction => Factions |= faction),
                () =>
            {
                var writeFactions = new List <Faction>();
                foreach (Faction fac in Enum.GetValues(typeof(Faction)))
                {
                    if ((Factions & fac) != 0)
                    {
                        writeFactions.Add(fac);
                    }
                }

                return(writeFactions);
            });
        }
Exemplo n.º 24
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction(
                "products",
                new List <string>(),
                products =>
            {
                var prototypeManager = IoCManager.Resolve <IPrototypeManager>();

                _products.Clear();
                foreach (var id in products)
                {
                    if (!prototypeManager.TryIndex(id, out CargoProductPrototype product))
                    {
                        continue;
                    }

                    _products.Add(product);
                }
            },
                GetProductIdList);
        }
 public override void ExposeData(ObjectSerializer serializer)
 {
     base.ExposeData(serializer);
     serializer.DataReadWriteFunction("range", SharedInteractionSystem.InteractionRange / 1.4f, value => Range = value, () => Range);
 }
Exemplo n.º 26
0
        /// <inheritdoc />
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataReadWriteFunction("context", InputContextContainer.DefaultContextName, value => ContextName = value, () => ContextName);
        }