-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerializedTablesContainer.cs
89 lines (80 loc) · 2.75 KB
/
SerializedTablesContainer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) 2019-2020 Vladimir Popov zor1994@gmail.com https://github.com/ZorPastaman/Event-Based-Blackboard
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using UnityEngine;
using Zor.EventBasedBlackboard.Core;
namespace Zor.EventBasedBlackboard.Serialization
{
/// <summary>
/// Container of serialized properties for a <see cref="Zor.EventBasedBlackboard.Core.Blackboard"/>.
/// </summary>
[CreateAssetMenu(menuName = "Event Based Blackboard/Serialized Tables Container", fileName = "SerializedTablesContainer", order = 445)]
public sealed class SerializedTablesContainer : SerializedContainer
{
#pragma warning disable CS0649
[SerializeField, HideInInspector] private SerializedTable_Base[] m_SerializedTables;
#pragma warning restore CS0649
/// <summary>
/// How many serialized tables are contained.
/// </summary>
public int serializedTablesCount
{
[MethodImpl(MethodImplOptions.AggressiveInlining), Pure]
get => m_SerializedTables.Length;
}
/// <summary>
/// Gets a <see cref="SerializedTable_Base"/> at the index <paramref name="index"/>.
/// </summary>
/// <param name="index"></param>
/// <returns><see cref="SerializedTable_Base"/> at the index <paramref name="index"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining), Pure]
public SerializedTable_Base GetSerializedTable(int index)
{
return m_SerializedTables[index];
}
/// <summary>
/// Sets the serialized table <paramref name="serializedTable"/> at the index <paramref name="index"/>.
/// </summary>
/// <param name="serializedTable"></param>
/// <param name="index"></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSerializedTable([NotNull] SerializedTable_Base serializedTable, int index)
{
m_SerializedTables[index] = serializedTable;
}
/// <summary>
/// Sets the serialized tables.
/// </summary>
/// <param name="serializedTables"></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetSerializedTables([NotNull] SerializedTable_Base[] serializedTables)
{
m_SerializedTables = serializedTables;
}
/// <inheritdoc/>
/// <remarks>
/// This method doesn't call <see cref="Zor.EventBasedBlackboard.Core.Blackboard.Flush"/>
/// </remarks>
public override void Apply(Blackboard blackboard)
{
for (int i = 0, count = m_SerializedTables.Length; i < count; ++i)
{
SerializedTable_Base table = m_SerializedTables[i];
if (table != null)
{
table.Apply(blackboard);
}
}
}
/// <inheritdoc/>
public override void GetKeys(List<(string, Type)> keys)
{
for (int i = 0, count = m_SerializedTables.Length; i < count; ++i)
{
m_SerializedTables[i].GetKeys(keys);
}
}
}
}