예제 #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);
        }
예제 #2
0
        /// <summary>
        ///    Copy BodyTemplate and BodyPart data into a common data class that the client can read.
        /// </summary>
        private BodyScannerInterfaceState PrepareBodyScannerInterfaceState(BodyTemplate template, Dictionary <string, BodyPart> bodyParts)
        {
            Dictionary <string, BodyScannerBodyPartData> partsData = new Dictionary <string, BodyScannerBodyPartData>();

            foreach (var(slotname, bpart) in bodyParts)
            {
                List <BodyScannerMechanismData> mechanismData = new List <BodyScannerMechanismData>();
                foreach (var mech in bpart.Mechanisms)
                {
                    mechanismData.Add(new BodyScannerMechanismData(mech.Name, mech.Description, mech.RSIPath, mech.RSIState, mech.MaxDurability, mech.CurrentDurability));
                }
                partsData.Add(slotname, new BodyScannerBodyPartData(bpart.Name, bpart.RSIPath, bpart.RSIState, bpart.MaxDurability, bpart.CurrentDurability, mechanismData));
            }
            BodyScannerTemplateData templateData = new BodyScannerTemplateData(template.Name, template.Slots);

            return(new BodyScannerInterfaceState(partsData, templateData));
        }
        /////////
        /////////  Server-specific stuff
        /////////

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

            string templateName = null;

            serializer.DataField(ref templateName, "BaseTemplate", "bodyTemplate.Humanoid");
            if (serializer.Reading)
            {
                if (!_prototypeManager.TryIndex(templateName, out BodyTemplatePrototype templateData))
                {
                    throw new InvalidOperationException("No BodyTemplatePrototype was found with the name " + templateName + " while loading a BodyTemplate!"); //Should never happen unless you f**k up the prototype.
                }
                string presetName = null;
                serializer.DataField(ref presetName, "BasePreset", "bodyPreset.BasicHuman");
                if (!_prototypeManager.TryIndex(presetName, out BodyPresetPrototype presetData))
                {
                    throw new InvalidOperationException("No BodyPresetPrototype was found with the name " + presetName + " while loading a BodyPreset!"); //Should never happen unless you f**k up the prototype.
                }
                _template = new BodyTemplate(templateData);
                LoadBodyPreset(new BodyPreset(presetData));
            }
        }
예제 #4
0
 public bool Equals(BodyTemplate other)
 {
     return(GetHashCode() == other.GetHashCode());
 }