Example #1
0
        public SfmlApp()
        {
            InitGame();
            _window = InitGui();

            ColoredString.Write("You wake up in an Unknown world.");
        }
Example #2
0
        public static bool On(BaseEvent evt, BaseEvent parent = null)
        {
            // Prepare event, filling in PreEvent, OnEvent, PostEvent, etc
            foreach (var c in evt.Item.Components)
            {
                (c as IActionComponent)?.GetActions(evt.Item, evt, EUseSource.Item);
            }

            if (evt.Target != null)
            {
                foreach (var c in evt.Target.Components)
                {
                    (c as IActionComponent)?.GetActions(evt.Target, evt, EUseSource.Target);
                }
                foreach (var e in evt.Target.ListSubEntities())
                {
                    foreach (var c in e.Components)
                    {
                        (c as IActionComponent)?.GetActions(e, evt, EUseSource.TargetItem);
                    }
                }
            }

            if (evt.User != null)
            {
                foreach (var c in evt.User.Components)
                {
                    (c as IActionComponent)?.GetActions(evt.User, evt, EUseSource.User);
                }
                foreach (var e in evt.User.ListSubEntities())
                {
                    foreach (var c in e.Components)
                    {
                        (c as IActionComponent)?.GetActions(e, evt, EUseSource.UserItem);
                    }
                }
            }

            // == Execute the event ==
            //evt.PreEventCheck?.Invoke(evt);
            foreach (var check in evt.OnEventCheck)
            {
                var str = check.Invoke(evt);
                if (str != null)
                {
                    ColoredString.Write(str.CleanUp());
                    return(false);
                }
            }
            evt.PreEvent?.Invoke(evt);
            evt.OnEvent?.Invoke(evt);
            evt.PostEvent?.Invoke(evt);

            // == Logging ==
            var message = evt.GetMessage(parent != null) + evt.PostMessage;

            if (parent != null)
            {
                parent.PostMessage += message;
            }
            else
            {
                ColoredString.Write(message.CleanUp());                 //TODO: Color
            }
            return(true);
        }