Exemple #1
0
        public void OnDisable(SnapshotProvider provider)
        {
            Assert.IsTrue(provider.identifier.IsValid);
            Assert.IsTrue(provider.aggregate.IsValid);

            Assert.IsTrue(this[provider.gameObject].identifier == provider.aggregate);
            Assert.IsTrue(this[provider.gameObject].Find(provider.identifier) == provider);

            if (Application.isPlaying)
            {
                if (Debugger.instance.IsState(Debugger.State.Record))
                {
                    var prefab = provider.GetComponent <Prefab>();
                    if (prefab == null)
                    {
                        throw new MissingComponentException($"Missing '{nameof(Prefab)}' component on object '{provider.gameObject.name}' destroyed while recording. Recorder won't be able to spawn it back.");
                    }
                }

                var aggregate = _aggregates[provider.gameObject];

                aggregate._providers.Remove(provider);

                if (aggregate._providers.Count <= 0)
                {
                    _aggregates.Remove(provider.gameObject);
                }
            }
        }
        Aggregate(SnapshotProvider provider)
        {
            Assert.IsTrue(provider.identifier.IsValid);

            identifier = Identifier <Aggregate> .Create();

            gameObject = provider.gameObject;

            _providers.Add(provider);
        }
            public void Create(SnapshotProvider provider)
            {
                var payload = Buffer.Create(Collections.Allocator.Persistent);

                provider.WriteToStream(payload);

                _providers.Add(new ProviderReference
                {
                    identifier    = provider.identifier,
                    payload       = payload,
                    customPayload = null
                });
            }
Exemple #4
0
        public void OnEnable(SnapshotProvider provider)
        {
            Assert.IsTrue(!provider.identifier.IsValid);
            Assert.IsTrue(!provider.aggregate.IsValid);

            if (Application.isPlaying)
            {
                provider.identifier = Identifier <SnapshotProvider> .Create();

                if (_aggregates.ContainsKey(provider.gameObject))
                {
                    var aggregate = this[provider.gameObject];

                    Assert.IsTrue(aggregate.identifier.IsValid);

                    provider.aggregate = aggregate.identifier;

                    aggregate._providers.Add(provider);
                }
                else
                {
                    var aggregate = Aggregate.Create(provider);

                    this[provider.gameObject] = aggregate;

                    provider.aggregate = aggregate.identifier;

                    if (!Debugger.instance.rewind)
                    {
                        var prefab = provider.GetComponent <Prefab>();

                        if (prefab != null)
                        {
                            var prefabReference = prefab.prefab.gameObject;

                            _prefabReferences[provider.aggregate] = new PrefabReference
                            {
                                gameObject = prefabReference,
                                identifier = provider.identifier
                            };
                        }
                    }
                }

                Assert.IsTrue(provider.aggregate.IsValid);
                Assert.IsTrue(provider.identifier.IsValid);

                Assert.IsTrue(this[provider.gameObject].identifier == provider.aggregate);
                Assert.IsTrue(this[provider.gameObject].Find(provider.identifier) == provider);
            }
        }
 public Variable(SnapshotProvider provider, FieldInfo field, SnapshotAttribute attribute)
 {
     this.provider  = provider;
     this.field     = field;
     this.attribute = attribute;
 }
 public static Aggregate Create(SnapshotProvider provider)
 {
     return(new Aggregate(provider));
 }