コード例 #1
0
ファイル: Plugin.cs プロジェクト: Shepkiswal/DSPDestructVideo
 /// <summary>
 /// Unity声明周期,开始,Patch游戏和载入字符帧数据
 /// </summary>
 void Start()
 {
     Harmony.CreateAndPatchAll(typeof(Plugin));
     VideoChars.LoadFrameData();
 }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: Shepkiswal/DSPDestructVideo
        public static bool DetermineDestructPreviewsPatch(PlayerAction_Build __instance)
        {
            var _this = __instance;

            if (Input.GetKey(KeyCode.LeftArrow))
            {
                VideoChars.SpeedDown();
                _this.cursorText = VideoChars.GetSpeedConfig().title;
                return(true);
            }
            else if (Input.GetKey(KeyCode.RightArrow))
            {
                VideoChars.SpeedUp();
                _this.cursorText = VideoChars.GetSpeedConfig().title;
                return(true);
            }
            if (!Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.DownArrow))
            {
                return(true);
            }

            if (Input.GetKey(KeyCode.UpArrow))
            {
                VideoChars.isOpenInversion = true;
                _this.cursorText           = VideoChars.GetSpeedConfig().title + "倒放";
            }
            else if (Input.GetKey(KeyCode.DownArrow))
            {
                VideoChars.isOpenInversion = false;
                _this.cursorText           = VideoChars.GetSpeedConfig().title;
            }


            if (loadBeltList.Count() != 0)
            {
                _this.ClearBuildPreviews();
                List <int>        removeList = VideoChars.GetCurrentFrameData();
                List <EntityData> beltList   = new List <EntityData>();
                for (int i = 0; i < loadBeltList.Count; i++)
                {
                    beltList.Add(loadBeltList[i]);
                }
                for (int i = removeList.Count - 1; i >= 0; i--)
                {
                    //Debug.Log(i);
                    beltList.RemoveAt(removeList[i]);
                }

                CustomDestructPreviews(__instance, beltList);
                VideoChars.PlayNextFrame();
                return(false);
            }
            else
            {
                /*if (!VFInput.onGUI)
                 * {
                 *  UICursor.SetCursor(ECursor.Delete);
                 * }*/
                _this.previewPose.position = Vector3.zero;
                _this.previewPose.rotation = Quaternion.identity;
                PlanetFactory factory = Traverse.Create(_this).Field("factory").GetValue <PlanetFactory>();

                if (_this.castObjId != 0)
                {
                    ItemProto itemProto = Traverse.Create(_this).Method("GetItemProto", _this.castObjId).GetValue <ItemProto>();
                    if (itemProto != null)
                    {
                        _this.ClearBuildPreviews();
                        List <EntityData> beltList;
                        if (factory.entityPool[_this.castObjId].beltId != 0)
                        {
                            var path = GetPathByBeltId(factory, factory.entityPool[_this.castObjId].beltId);
                            beltList = GetBletsByPath(factory, path);
                        }
                        else
                        {
                            beltList = GetEntitysByProto(factory, itemProto);
                        }
                        loadBeltList = beltList;
                        CustomDestructPreviews(__instance, beltList);
                    }
                    else
                    {
                        _this.ClearBuildPreviews();
                    }
                }
                else
                {
                    _this.ClearBuildPreviews();
                }
                return(false);
            }
        }