Exemplo n.º 1
0
            public static void Postfix(Workable __instance)
            {
                try
                {
                    if (Game.Instance == null)
                    {
                        return;
                    }

                    var door = __instance.GetComponent <Door>();

                    if (door != null && !State.DoorIcons.ContainsKey(door))
                    {
                        var icon = IconManager.CreateIcon(door);

                        State.DoorIcons.Add
                        (
                            door,
                            icon
                        );

                        __instance.gameObject.Subscribe((int)GameHashes.LogicEvent, data => IconManager.UpdateIcon(door));
                        __instance.gameObject.Subscribe((int)GameHashes.DoorStateChanged, data => IconManager.UpdateIcon(door));
                        __instance.gameObject.Subscribe((int)GameHashes.CopySettings, data => IconManager.UpdateIcon(door));
                        __instance.gameObject.Subscribe((int)GameHashes.DoorControlStateChanged, data => IconManager.UpdateIcon(door));
                    }
                }
                catch (Exception e)
                {
                    State.Common.Logger.LogOnce("Error while trying to create door icon", e);
                }
            }