示例#1
0
        public override bool Execute(string[] args)
        {
            if (args.Length < 1 || args.Length > 2)
            {
                Console.LogError("Incorrect number of arguments!");
                return(false);
            }

            Identifiable.Id id;
            try
            {
                id = (Identifiable.Id)Enum.Parse(typeof(Identifiable.Id), args[0], true);
            }
            catch
            {
                Console.LogError("Invalid ID!");
                return(false);
            }

            int count = 0;

            if (args.Length != 2 || !Int32.TryParse(args[1], out count))
            {
                count = 1;
            }

            var g = SRBehaviour.InstantiateActor(GameContext.Instance.LookupDirector.GetPrefab(id), SceneContext.Instance.PlayerState.model.currRegionSetId);

            for (int i = 0; i < count; i++)
            {
                SceneContext.Instance.PlayerState?.Ammo.MaybeAddToSlot(id, g.GetComponent <Identifiable>());
            }
            GameObject.DestroyImmediate(g);
            return(true);
        }
            private static void spawnObject(Identifiable.Id obj, Transform location)
            {
                GameObject   slotObject = GameContext.Instance.LookupDirector.GetPrefab(obj);
                RegionMember region     = (RegionMember)Traverse.Create(SceneContext.Instance.PlayerZoneTracker).Field("member").GetValue();
                Vector3      vec        = UnityEngine.Random.insideUnitSphere;

                vec.y = Math.Abs(vec.y);
                GameObject gameObject = SRBehaviour.InstantiateActor(slotObject, region.setId, location.position + vec, location.rotation, false);
                Rigidbody  component  = gameObject.GetComponent <Rigidbody>();

                component.AddForce(UnityEngine.Random.insideUnitSphere * 25f);
            }
示例#3
0
文件: Main.cs 项目: Halocaster/SRML
        // Called before GameContext.Awake
        // this is where you want to register stuff (like custom enum values or identifiable id's)
        // and patch anything you want to patch with harmony
        public override void PreLoad()
        {
            Debug.Log("We did it!");
            HarmonyInstance.PatchAll(Assembly.GetExecutingAssembly());


            // this code registers a callback that's run every time a saved game is loaded
            // in this case it spawns a mosaic boom largo
            SRCallbacks.OnSaveGameLoaded += (scenecontext) =>
            {
                var playerModel = SceneContext.Instance.GameModel.GetPlayerModel();
                SRBehaviour.InstantiateActor(
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.MOSAIC_BOOM_LARGO), playerModel.position,
                    playerModel.rotation);
            };
        }
示例#4
0
        public override bool Execute(string[] args)
        {
            if (args.Length < 1 || args.Length > 2)
            {
                Console.LogError("Incorrect number of arguments!");
                return(false);
            }

            Identifiable.Id id;
            GameObject      prefab;

            try
            {
                id     = (Identifiable.Id)Enum.Parse(typeof(Identifiable.Id), args[0], true);
                prefab = GameContext.Instance.LookupDirector.GetPrefab(id);
            }
            catch
            {
                Console.LogError("Invalid ID!");
                return(false);
            }

            int count = 0;

            if (args.Length != 2 || !Int32.TryParse(args[1], out count))
            {
                count = 1;
            }

            for (int i = 0; i < count; i++)
            {
                if (Physics.Raycast(new Ray(Camera.main.transform.position, Camera.main.transform.forward), out var hit))
                {
                    var spawned = SRBehaviour.InstantiateActor(prefab, SceneContext.Instance.Player.GetComponent <RegionMember>().setId, true);
                    spawned.transform.position = hit.point + hit.normal * PhysicsUtil.CalcRad(spawned.GetComponent <Collider>());
                    var delta      = -(hit.point - Camera.main.transform.position).normalized;
                    var newForward = (delta - Vector3.Project(delta, hit.normal)).normalized;
                    spawned.transform.rotation = Quaternion.LookRotation(delta, hit.normal);
                }
            }
            return(true);
        }
示例#5
0
            static void Prefix()
            {
                if (Levels.IsLevel(Levels.WORLD))
                {
                    Transform  playerLoc = SceneContext.Instance.Player.transform;
                    RewardData reward;
                    if (rewardsQueue.TryDequeue(out reward))
                    {
                        switch (reward.action)
                        {
                        case "sound":
                            break;

                        case "inventory_bomb":
                            Ammo ammo = SceneContext.Instance.PlayerState.Ammo;
                            foreach (Slot s in (Slot[])Traverse.Create(ammo).Property("Slots").GetValue())
                            {
                                if (s == null)
                                {
                                    continue;
                                }
                                for (int i = 0; i < s.count; i++)
                                {
                                    GameObject   slotObject = GameContext.Instance.LookupDirector.GetPrefab(s.id);
                                    RegionMember region     = (RegionMember)Traverse.Create(SceneContext.Instance.PlayerZoneTracker).Field("member").GetValue();
                                    GameObject   gameObject = SRBehaviour.InstantiateActor(slotObject, region.setId, playerLoc.position + playerLoc.forward * 0.5f, playerLoc.rotation, false);
                                    Rigidbody    component  = gameObject.GetComponent <Rigidbody>();
                                    component.AddForce((playerLoc.forward * 100f + UnityEngine.Random.insideUnitSphere * 100f) * component.mass);
                                }
                            }
                            ammo.Clear();
                            break;
                        }
                    }
                }
            }