Ejemplo n.º 1
0
        public void RegisterRandomEventsTrigger(ScriptObject node)
        {
            if (node.Children.Count > 0)
            {
                foreach (var scriptObject in node.Children)
                {
                    int result;
                    if (int.TryParse(scriptObject.Name, out result))
                    {
                        var e = scriptObject.GetStringValue();
                        // found a random event...
                        if (Core.Instance.Get(ScriptContext.Event, e) != null)
                        {
                            var n = new trigger_event();
                            if (e == "abduct_outcome.1001")
                            {
                            }

                            n.id       = e;
                            n.Function = node;
                            n.Topmost  = node.Topmost;
                            ReferenceManager.Instance.AddConnection(n.Topmost, n.Function, e);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void RegisterTrigger(ScriptObject node)
        {
            if (node.Children.Count > 0)
            {
                var idNodes       = node.Children.Where(a => a.Name == "id");
                var dayNodes      = node.Children.Where(a => a.Name == "days");
                var onActionNodes = node.Children.Where(a => a.Name == "on_action");
                var n             = new trigger_event();

                if (dayNodes.Any())
                {
                    var val = dayNodes.First().GetStringValue();
                    if (val == null)
                    {
                        var c = dayNodes.First().Children;
                        n.days_from = c[0].Name;
                        n.days_to   = c[1].Name;
                    }
                    else
                    {
                        n.days_from = val;
                        n.days_to   = val;
                    }
                }

                string on_action = null;
                string id        = null;

                if (idNodes.Any())
                {
                    id = idNodes.First().GetStringValue();
                }
                if (onActionNodes.Any())
                {
                    on_action = onActionNodes.First().GetStringValue();
                }

                n.on_action = on_action;
                n.Topmost   = node.Topmost;
                n.Function  = node;
                n.id        = id;
                ReferenceManager.Instance.AddConnection(n.Topmost, n.Function, on_action != null ? on_action : id);
            }
            else
            {
                var n = new trigger_event();

                n.Topmost   = node.Topmost;
                n.Function  = node;
                n.days_from = null;
                n.days_to   = null;
                n.id        = node.GetStringValue();
                ReferenceManager.Instance.AddConnection(n.Topmost, n.Function, node.GetStringValue());
            }
        }
Ejemplo n.º 3
0
        public void RegisterFirstValidEventsTrigger(ScriptObject node)
        {
            if (node.Children.Count > 0)
            {
                foreach (var scriptObject in node.Children)
                {
                    int result;

                    {
                        var e = scriptObject.Name;
                        // found a random event...
                        if (Core.Instance.Get(ScriptContext.Event, e) != null)
                        {
                            var n = new trigger_event();

                            n.id       = e;
                            n.Function = node;
                            n.Topmost  = node.Topmost;
                            ReferenceManager.Instance.AddConnection(n.Topmost, n.Function, e);
                        }
                    }
                }
            }
        }