Ejemplo n.º 1
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var numLocomotorTemplates = reader.ReadUInt16();

            for (var i = 0; i < numLocomotorTemplates; i++)
            {
                var locomotorTemplateName = reader.ReadAsciiString();

                var locomotorTemplate = _gameObject.GameContext.AssetLoadContext.AssetStore.LocomotorTemplates.GetByName(locomotorTemplateName);

                var locomotor = new Locomotor(_gameObject, locomotorTemplate, 100);

                locomotor.Load(reader);

                _locomotors.Add(locomotor);
            }

            _surfaces = reader.ReadEnumFlags <Surfaces>();

            var unknownBool1 = reader.ReadBoolean();

            if (unknownBool1 != false)
            {
                throw new InvalidDataException();
            }
        }
Ejemplo n.º 2
0
        public void Persist(StatePersister reader)
        {
            if (reader.Mode == StatePersistMode.Read)
            {
                _locomotors.Clear();
            }

            reader.PersistVersion(1);

            var numLocomotorTemplates = (ushort)_locomotors.Count;

            reader.PersistUInt16(ref numLocomotorTemplates, "NumLocomotors");

            reader.BeginArray("Locomotors");
            if (reader.Mode == StatePersistMode.Read)
            {
                for (var i = 0; i < numLocomotorTemplates; i++)
                {
                    reader.BeginObject();

                    var locomotorTemplateName = "";
                    reader.PersistAsciiString(ref locomotorTemplateName, "TemplateName");

                    var locomotorTemplate = reader.AssetStore.LocomotorTemplates.GetByName(locomotorTemplateName);

                    var locomotor = new Locomotor(_gameObject, locomotorTemplate, 100);

                    reader.PersistObject(locomotor);

                    _locomotors.Add(locomotor);

                    reader.EndArray();
                }
            }
            else
            {
                foreach (var locomotor in _locomotors)
                {
                    reader.BeginObject();

                    var templateName = locomotor.LocomotorTemplate.Name;
                    reader.PersistAsciiString(ref templateName);

                    reader.PersistObject(locomotor);

                    reader.EndObject();
                }
            }
            reader.EndArray();

            reader.PersistEnumFlags(ref _surfaces);

            reader.SkipUnknownBytes(1);
        }
Ejemplo n.º 3
0
        internal void SetLocomotor(LocomotorSetType type)
        {
            if (!_locomotors.TryGetValue(type, out var locomotor))
            {
                var locomotorSet = GameObject.Definition.LocomotorSets.Find(x => x.Condition == type);
                locomotor = (locomotorSet != null)
                    ? new Locomotor(GameObject, locomotorSet)
                    : null;
            }

            _currentLocomotor = locomotor;
        }