public void CannotRemoveReadOnlyEventFromInheritingEntity()
        {
            bool collectionChanged = false;

            Entity parent = new Entity() { Name = "parent" };

            Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            parentEvent.SetProperty("Trigger", new Value("test"));
            parent.AddEvent(parentEvent);

            Entity child = new Entity();
            child.AddPrototype(parent);

            child.Events.CollectionChanged += (o, e) => collectionChanged = true;

            AbstractEvent childEvent = child.Events.Single();
            child.RemoveEvent(childEvent);

            Assert.IsFalse(collectionChanged);
            Assert.AreEqual(1, child.Events.Count);
        }
        public void CannotSetReadOnlyEventProperty()
        {
            Entity parent = new Entity() { Name = "parent" };

            Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
            parentEvent.SetProperty("Trigger", new Value("test", true));
            parent.AddEvent(parentEvent);

            Entity child = new Entity();
            child.AddPrototype(parent);

            AbstractProperty childProperty = child.Events.Single().GetProperty("Trigger");
            childProperty.Value = new Value("test2", true);

            Assert.AreEqual("test", childProperty.Value.Reader.GetStrValue());
        }
 private Event CreateEvent(ParseTreeNode node)
 {
     Event evt = new Event(game.GetPlugin(grammar.GetName(node)));
     foreach (Tuple<string, object> property in GetProperties(node))
     {
         ParseTreeNode propertyNode = (ParseTreeNode)property.Item2;
         evt.SetProperty(property.Item1, new Value(getStrVal(propertyNode)));
     }
     foreach (ParseTreeNode actionNode in grammar.GetOfType(node, grammar.Actions)) CreateStatement(actionNode, evt, null);
     return evt;
 }
        public void SetEventProperty()
        {
            bool propertyChanged = false;

            Event evt = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));

            AbstractProperty property = evt.GetProperty("Trigger");
            property.PropertyChanged += (o, e) => propertyChanged |= (e.PropertyName == "Value");

            evt.SetProperty("Trigger", new Value("test", true));

            Assert.IsTrue(propertyChanged);
            Assert.AreEqual("test", property.Value.Reader.GetStrValue());
        }
        public Event DeepCopy()
        {
            Event copy = new Event(Plugin);

            foreach (AbstractProperty property in Properties)
            {
                copy.SetProperty(property.Name, property.Value);
            }

            foreach (AbstractStatement statement in Statements)
            {
                copy.AddStatement(statement.DeepCopyStatement());
            }

            return copy;
        }