public void TestConstructorsAndImplicitConversions(int intVal, SceneCommand enumVal)
        {
            Scene sceneFromInt            = intVal;
            Scene sceneFromStringImplicit = intVal.ToString();
            Scene sceneFromEnumImplicit   = enumVal;
            Scene sceneFromEnumExplicit   = new(enumVal);

            // implicit conversions back to int
            Assert.Equal(intVal, (int)sceneFromInt);
            Assert.Equal((int)enumVal, (int)sceneFromStringImplicit);
            Assert.Equal((int)enumVal, (int)sceneFromEnumImplicit);
            Assert.Equal((int)enumVal, (int)sceneFromEnumExplicit);

            // implicit conversions back to enum and then to int
            Assert.Equal(intVal, (int)enumVal);
            Assert.Equal(intVal, (int)(SceneCommand)sceneFromInt);
            Assert.Equal((int)enumVal, (int)(SceneCommand)sceneFromStringImplicit);
            Assert.Equal((int)enumVal, (int)(SceneCommand)sceneFromEnumImplicit);
            Assert.Equal((int)enumVal, (int)(SceneCommand)sceneFromEnumExplicit);

            // all the same?
            Assert.Equal((int)sceneFromEnumExplicit, (int)sceneFromInt);
            Assert.Equal((int)sceneFromEnumExplicit, (int)sceneFromStringImplicit);
            Assert.Equal((int)sceneFromEnumExplicit, (int)sceneFromEnumImplicit);
        }
示例#2
0
    private IEnumerator NextSceneAsync(SceneCommand command)
    {
        fsm.MoveNext(command);
        yield return(StartCoroutine(fsm.Current.LoadScene()));

        yield return(StartCoroutine(fsm.Current.Active()));
    }
示例#3
0
        private void Awake()
        {
            ExecutionContext.IsFlowSuppressed();
            if (SceneManager.GetActiveScene().name != "Menu")
            {
                if (startingMenu)
                {
                    var strMenu = "Menu";

                    Loading(strMenu);
                    startingMenu = false;
                }
                else
                {
                    SceneCommand.ReadScene();
                    LoadLastScene(new SceneDataAccessor(ModuleDB.sceneTable.SceneName, SceneManager.GetActiveScene().name));

                    SetLastScene(new SceneDataAccessor(ModuleDB.sceneTable.SceneName, SceneManager.GetActiveScene().name));

                    SetDontDestroyObject();

                    if (player != null)
                    {
                        SetCoordinate(new CoordinateDataAccessor(player.transform.position));
                    }
                }
            }
            else
            {
                startingMenu = false;
            }
        }
        public override async Task UpdateData(object varRowOfRequest)
        {
            command = (long)varRowOfRequest == 1
                    ? new SceneCommand(Player, Active)
                    : new SceneCommand(Player, Last);

            await SceneCommand.UpdateScene((long)varRowOfRequest);
        }
示例#5
0
        /// <summary>
        ///  Adds a scene command to the active ones on the scene.
        /// </summary>
        /// <param name="command"></param>
        public static void AddSceneCommand(SceneCommand command)
        {
#if UNITY_2017_1_OR_NEWER
            EditorApplication.playModeStateChanged -= PlayStateChangeCallBack;
            EditorApplication.playModeStateChanged += PlayStateChangeCallBack;
#else
            EditorApplication.playmodeStateChanged -= PlayStateChangeCallBack;
            EditorApplication.playmodeStateChanged += PlayStateChangeCallBack;
#endif
            EditorApplication.update -= MonKeyEditorUpdate;
            EditorApplication.update += MonKeyEditorUpdate;

#if UNITY_2019
            SceneView.duringSceneGui -= OnSceneViewGUI;
            SceneView.duringSceneGui += OnSceneViewGUI;
#else
            SceneView.duringSceneGui -= OnSceneViewGUI;
            SceneView.duringSceneGui += OnSceneViewGUI;
#endif
            command.OnActionDone += NotifyActionRemoved;
            int i = 1;
            while (CurrentSceneCommands.Count(_ => _.SceneCommandName == command.SceneCommandName) > 0)
            {
                if (command.SceneCommandName.Contains(i.ToString()))
                {
                    command.SceneCommandName = command.SceneCommandName.Replace((i - 1).ToString(), i.ToString());
                }
                else
                {
                    command.SceneCommandName = command.SceneCommandName + " " + i;
                }

                i++;
            }

            CurrentSceneCommands.Add(command);

            if (!CurrentSceneView)
            {
                CurrentSceneView = SceneView.currentDrawingSceneView;
            }

            if (CurrentSceneView)
            {
                CurrentSceneView.Focus();
            }

            SelectedSceneCommand = command;

            if (MonKeyInternalSettings.Instance.UseSceneCommandAsEditorWindow)
            {
                SceneCommandsWindow.ShowSceneCommandWindow();
            }
        }
示例#6
0
        public async Task SendGroupCommand()
        {
            var scenes = await _client.GetScenesAsync();

            var scene = scenes.First();

            var command = new SceneCommand {
                Scene = scene.Id
            };

            await _client.SendGroupCommandAsync(command, scene.Group);
        }
示例#7
0
        public async Task ApplyScene(string id, CancellationToken cancellationToken)
        {
            SceneCommand sceneCommand = new SceneCommand(id);

            HueResults results = await _hueClient.SendGroupCommandAsync(sceneCommand);

            DefaultHueResult?defaultHueResult = results.Errors.FirstOrDefault();

            if (defaultHueResult != null)
            {
                throw new HueCommandException(defaultHueResult.Error.Description, HttpStatusCode.BadRequest);
            }
        }
示例#8
0
        public Task <DeConzResults> RecallSceneAsync(string sceneId, string groupId = "0")
        {
            if (sceneId == null)
            {
                throw new ArgumentNullException(nameof(sceneId));
            }

            var groupCommand = new SceneCommand()
            {
                Scene = sceneId
            };

            return(this.SendGroupCommandAsync(groupCommand, groupId));
        }
		public void CanConvertToSceneCommand()
		{
			SceneCommand sceneCommand = new SceneCommand();
			sceneCommand.Scene = "test123";

			var json = JsonConvert.SerializeObject(sceneCommand);

			GenericScheduleCommand genericCommand = new GenericScheduleCommand(json);

			Assert.IsTrue(genericCommand.IsSceneCommand());
			Assert.IsNotNull(genericCommand.AsSceneCommand());

			var scene = genericCommand.AsSceneCommand();
			Assert.AreEqual(sceneCommand.Scene, scene.Scene);
		}
        public void CanConvertToSceneCommand()
        {
            SceneCommand sceneCommand = new SceneCommand();

            sceneCommand.Scene = "test123";

            var json = JsonConvert.SerializeObject(sceneCommand);

            GenericScheduleCommand genericCommand = new GenericScheduleCommand(json);

            Assert.True(genericCommand.IsSceneCommand());
            Assert.NotNull(genericCommand.AsSceneCommand());

            var scene = genericCommand.AsSceneCommand();

            Assert.Equal(sceneCommand.Scene, scene.Scene);
        }
示例#11
0
        private static void RemoveActor0001(RomFile sceneFile, SceneCommand item)
        {
            BinaryWriter bw          = new BinaryWriter(sceneFile.Stream);
            var          addr        = (IDataCommand)item;
            var          actors      = ((IActorList)item).GetActors();
            var          reducedList = actors.Where(x => x.Actor != 1).ToList();

            bw.BaseStream.Position = item.OffsetFromFile + 1;
            bw.Write((byte)reducedList.Count);

            bw.BaseStream.Position = addr.SegmentAddress.Offset;

            foreach (var actor in reducedList)
            {
                actor.Serialize(bw);
            }
        }
示例#12
0
        public static void Export(string file, ORom.Build build)
        {
            OFileTable rom = new OFileTable(file, build);
            Scene      spirit;

            ExportModifiedScene(rom, out spirit, "06_h");
            RoomListCommand roomCommand = (RoomListCommand)spirit.Header[HeaderCommands.RoomList];

            for (int i = 0; i < 29; i++)
            {
                BinaryReader br;

                Room sRoom = new Room(Game.OcarinaOfTime, roomCommand.RoomAddresses[i]);
                Room beta  = new Room(Game.OcarinaOfTime, new FileAddress());
                br = new BinaryReader(rom.GetFile(sRoom.VirtualAddress));

                sRoom.Header.Load(br, 0);
                beta.Header.Load(br, SpiritHack.GetBetaRoomSetupOffset(0, i));

                List <SceneCommand> cmd       = beta.Header.Commands();
                SceneCommand        objectCmd = sRoom.Header[HeaderCommands.ObjectList];
                int index = cmd.FindIndex(x => x.Code == (int)HeaderCommands.ActorList);

                if (index > -1)
                {
                    cmd.Insert(index, objectCmd);
                }

                using (BinaryWriter bw = new BinaryWriter(new FileStream($"r/06_{i:D2}", FileMode.CreateNew)))
                {
                    beta.Header.WriteHeader(bw);
                    br.BaseStream.Position = bw.BaseStream.Position;

                    while (br.BaseStream.Position < br.BaseStream.Length)
                    {
                        bw.Write(br.ReadUInt32());
                    }
                }
            }
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.StartObject)
            {
                JObject jObject = JObject.Load(reader);

                //Check if it is a scene command
                if (jObject["scene"] != null || jObject["Scene"] != null)
                {
                    var sceneTarget = new SceneCommand();
                    // Populate the object properties
                    serializer.Populate(jObject.CreateReader(), sceneTarget);
                    return(sceneTarget);
                }

                // Populate the object properties
                var target = new LightCommand();
                serializer.Populate(jObject.CreateReader(), target);
                return(target);
            }

            return(serializer.Deserialize <LightCommand>(reader));
        }
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
      if (reader.TokenType == JsonToken.StartObject)
      {
        JObject jObject = JObject.Load(reader);

        //Check if it is a scene command
        if (jObject["scene"] != null || jObject["Scene"] != null)
        {
          var sceneTarget = new SceneCommand();
          // Populate the object properties
          serializer.Populate(jObject.CreateReader(), sceneTarget);
          return sceneTarget;
        }

        // Populate the object properties
        var target = new LightCommand();
        serializer.Populate(jObject.CreateReader(), target);
        return target;
      }
     
      return serializer.Deserialize<LightCommand>(reader);
    }
示例#15
0
 public Scene(SceneCommand scene)
 {
     _scene = scene;
 }
示例#16
0
 public static string ToMockedSceneEvent(this SceneCommand scene)
 {
     return(((Scene)scene).ToMockedSceneEvent(32027, 1));
 }
        public void TestGetHashCode(int expected, SceneCommand inputVal)
        {
            Scene scene = new(inputVal);

            Assert.Equal(new Scene((SceneCommand)expected).GetHashCode(), scene.GetHashCode());
        }
        public void TestToString(string expectedInvariant, string expectedEn, string expectedDe, SceneCommand inputVal)
        {
            Scene scene = new(inputVal);

            Assert.Equal(expectedInvariant, scene.ToString());

            Assert.Equal(expectedEn, scene.ToString("d", CultureInfo.CreateSpecificCulture("en")));
            Assert.Equal(expectedDe, scene.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")));
        }
示例#19
0
 public void SceneControl(int scene_id, SceneCommand scene_command)
 {
     this.SceneController.SendKey(scene_id, scene_command);
 }
示例#20
0
 public override async void ReadData()
 {
     await SceneCommand.ReadScene();
 }
示例#21
0
        public void TestGetHashCode(int expected, SceneCommand inputVal)
        {
            Scene scene = new Scene(inputVal);

            Assert.Equal(HashCode.Combine(expected), scene.GetHashCode());
        }
示例#22
0
 public void GoToNextSceneAsync(SceneCommand command)
 {
     StartCoroutine(fsm.Current.UnloadScene());
     StartCoroutine(NextSceneAsync(command));
 }
示例#23
0
        public void TestToString(string expected, SceneCommand inputVal)
        {
            Scene scene = new Scene(inputVal);

            Assert.Equal(expected, scene.ToString());
        }
示例#24
0
        private static void SceneCommandSceneViewInterface()
        {
            if (!ShouldShowSceneGUI)
            {
                return;
            }

            if (MonKeyInternalSettings.Instance.UseSceneCommandAsEditorWindow)
            {
                return;
            }

            if (!MonkeyStyle.Instance.SearchFieldBackgroundTex)
            {
                MonkeyStyle.Instance.PostInstanceCreation();
            }

            float width = Mathf.Clamp(SceneView.currentDrawingSceneView.position.width * 0.2f,
                                      SceneGUIMinWidth, SceneGUIMaxWidth);
            float height = Mathf.Clamp(SceneView.currentDrawingSceneView.position.height * 0.2f,
                                       SceneGUIMinHeight, SceneGUIMaxHeight);

            Handles.BeginGUI();
            GUILayout.BeginArea(new Rect(SceneView.currentDrawingSceneView.position.width - width,
                                         SceneView.currentDrawingSceneView.position.height - height, width, height),
                                new GUIStyle()
            {
                normal = { background = MonkeyStyle.Instance.WindowBackgroundTex }
            });
            GUILayout.BeginVertical(new GUIStyle()
            {
                margin = new RectOffset(0, 4, 0, 5)
            });

            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);

            GUILayout.BeginVertical(new GUIStyle()
            {
                margin = new RectOffset(0, 2, 0, 5)
            });

            GUILayout.BeginHorizontal();
            GUILayout.Label("", MonkeyStyle.Instance.SmallMonkey);

            GUILayout.BeginHorizontal(new GUIStyle()
            {
                margin = new RectOffset(5, 5, 0, 0)
            });
            GUILayout.Label("Active Scene Commands", MonkeyStyle.Instance.VariableHelpTextStyle);
            GUILayout.EndHorizontal();

            GUILayout.EndHorizontal();

            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);

            GUI.skin = MonkeyStyle.Instance.MonkeyScrollBarStyle;

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, new GUIStyle()
            {
                margin = new RectOffset(4, 2, 0, 2),
                normal = { background = MonkeyStyle.Instance.ResultFieldTex },
            }, GUILayout.Height(60));

            foreach (var command in CurrentSceneCommands)
            {
                try
                {
                    if (command.Hidden)
                    {
                        continue;
                    }

                    GUILayout.BeginVertical();
                    GUILayout.BeginHorizontal(new GUIStyle()
                    {
                        padding = new RectOffset(5, 5, 2, 2),
                        normal  = { background = MonkeyStyle.Instance.ResultFieldTex }
                    }, GUILayout.Height(25));

                    GUILayout.BeginVertical(
                        new GUIStyle()
                    {
                        margin = new RectOffset(0, 0, 2, 0)
                    },
                        GUILayout.ExpandHeight(true));
                    string commandTitle = command.SceneCommandName
                                          .Colored(MonkeyStyle.Instance.SearchResultTextColor).Bold();
                    if (command == SelectedSceneCommand)
                    {
                        commandTitle = commandTitle.Insert(0, "|".Colored(MonkeyStyle.Instance.WarningColor).Bold());
                    }

                    GUILayout.Label(commandTitle,
                                    MonkeyStyle.Instance.SceneCommandHelpStyle);
                    GUILayout.EndVertical();

                    GUILayout.FlexibleSpace();

                    GUILayout.BeginVertical(new GUIStyle()
                    {
                        padding = new RectOffset(5, 5, 2, 2),
                        normal  =
                        {
                            background = overCross
                                ? MonkeyStyle.Instance.BlackTex
                                : MonkeyStyle.Instance.HelpVariableTex
                        },
                        hover = { background = MonkeyStyle.Instance.BlackTex }
                    });

                    GUILayout.FlexibleSpace();

                    bool pressed = GUILayout.Button(" X "
                                                    .Colored(MonkeyStyle.Instance.WarningColor).Bold(),
                                                    MonkeyStyle.Instance.SceneCommandCrossStyle, GUILayout.ExpandWidth(true));
                    GUILayout.FlexibleSpace();

                    GUILayout.EndVertical();
                    overCross = GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition);

                    if (pressed)
                    {
                        command.Stop();
                        Event.current.Use();
                    }

                    /* if (command is ConfirmedCommand)
                     * confirmedAction = true;*/

                    GUILayout.EndHorizontal();

                    GUILayout.Label("", MonkeyStyle.Instance.HorizontalSearchResultLine1Style);
                    GUILayout.Label("", MonkeyStyle.Instance.HorizontalSearchResultLine2Style);
                    GUILayout.Label("", MonkeyStyle.Instance.HorizontalSearchResultLine3Style);

                    GUILayout.EndVertical();

                    if (Event.current.type == EventType.MouseDown &&
                        GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                    {
                        SelectedSceneCommand = command == SelectedSceneCommand ? null : command;
                        Event.current.Use();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("An Error was caught when using a command, sorry about that :( " +
                                   "Please report the exception under on MonKey's Discord channel");
                    Debug.LogException(e);
                    //stop the command if it encountered an exception
                    command.Stop();
                }
            }

            GUILayout.EndScrollView();

            GUI.skin = MonkeyStyle.Instance.DefaultStyle;
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);
            GUILayout.EndVertical();

            GUILayout.EndVertical();

            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);
            GUILayout.EndArea();

            if (SelectedSceneCommand != null && !SelectedSceneCommand.HideGUI)
            {
                SelectedSceneCommand.DisplayCommandPanel(width, height);
            }

            Handles.EndGUI();
            return;
        }
示例#25
0
 private static void NotifyActionRemoved(SceneCommand command)
 {
     ToRemove.Add(command);
 }