예제 #1
0
        /// <summary>
        ///   Generates the code for the reset reward method.
        /// </summary>
        internal void GenerateCode(ObjectTable objectTable)
        {
            Requires.NotNull(objectTable, nameof(objectTable));

            foreach (var obj in objectTable)
            {
                foreach (var fieldInfo in obj.GetType().GetFields(typeof(object)))
                {
                    if (fieldInfo.FieldType == typeof(Reward))
                    {
                        LoadObject(objectTable.GetObjectIdentifier(obj));
                        ResetRewardFields(fieldInfo);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        ///   Generates the <see cref="StateVectorLayout" /> for the <paramref name="objects" />.
        /// </summary>
        /// <param name="model">The model the state vector should be layouted for.</param>
        /// <param name="objects">The objects consisting of state values the state vector layout should be generated for.</param>
        /// <param name="mode">The serialization mode that should be used to generate the state vector layout.</param>
        internal StateVectorLayout GetStateVectorLayout(ModelBase model, ObjectTable objects, SerializationMode mode)
        {
            Requires.NotNull(model, nameof(model));
            Requires.NotNull(objects, nameof(objects));
            Requires.InRange(mode, nameof(mode));

            var layout = new StateVectorLayout();

            foreach (var slot in objects.SelectMany(obj => GetSerializer(obj).GetStateSlotMetadata(obj, objects.GetObjectIdentifier(obj), mode)))
            {
                layout.Add(slot);
            }

            layout.Compact(model, mode);
            return(layout);
        }