Exemplo n.º 1
0
                public new void Enter(IemStateManager.StateManager sm)
                {
                    TargetPracticeStateManager gsm = (TargetPracticeStateManager)sm;

                    gsm.partition = new IemObjectPlacement.CopyPastePlacement(
                        "tp_v1_" + gsm.eg.difficultyLevel, gsm.location);

                    ResearchTable researchtable = IemUtils.FindComponentNearestToLocation <ResearchTable>(
                        gsm.location, 50);
                    Vector3 playerstart = researchtable.transform.position;

                    researchtable.Kill(BaseNetworkable.DestroyMode.None);
                    RepairBench repairbench = IemUtils.FindComponentNearestToLocation <RepairBench>(
                        gsm.location, 50);
                    Vector3 playerlook = repairbench.transform.position;

                    repairbench.Kill(BaseNetworkable.DestroyMode.None);

                    me.Puts("player start location is " + playerstart);
                    me.Puts("player look location is " + playerlook);
                    me.Puts("swutcged " + IemUtils.SwitchTypesToTarget <BaseOven>(gsm.location));

                    gsm.eg.player.inventory.Strip();

                    EntitiesTakingDamage += gsm.eg.PlayerImmortal;

                    IemUtils.MovePlayerToTeamLocation(gsm.eg.player,
                                                      playerstart);

                    Vector3    relativePos = playerstart - playerlook;
                    Quaternion rotation    = Quaternion.LookRotation(relativePos);

                    gsm.eg.player.transform.rotation = rotation;

                    IemUtils.SetMetabolismValues(gsm.eg.player);
                    IemUtils.ClearInventory(gsm.eg.player);

                    IemUI.CreateGameBanner(gsm.eg.player, "GAME LOBBY");

                    IemUtils.PlaySound(gsm.eg.player);

                    gsm.eg.returnZone = new IemUtils.ReturnZone(playerstart, gsm.eg.player);

                    IemUI.Confirm(gsm.eg.player, $"Weclome to target practice\n" +
                                  $"Knock down the targets to proceed to the next level.\n" +
                                  $"each level timer will start when you fire the first shot", "Start Shootin'",
                                  gsm.proceedAction);

                    gsm.eg.targets = IemUtils.FindComponentsNearToLocation <ReactiveTarget>(gsm.location, 50);
                    me.Puts("targets count is " + gsm.eg.targets.Count());
                }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a crafter from the given research table.
        /// </summary>
        /// <param name="researchTable">The research table to replace.</param>
        /// <returns></returns>
        public static Crafter CreateCrafter(ResearchTable researchTable)
        {
            var recyclerEntity = GameManager.server.CreateEntity(Constants.StaticRecyclerPrefab, researchTable.ServerPosition, researchTable.ServerRotation);
            var recycler       = recyclerEntity.GetComponent <Recycler>();

            recyclerEntity.OwnerID = researchTable.OwnerID;             // Copy ownership to recycler.
            recyclerEntity.Spawn();

            // Drop all items in research table onto the ground
            if (researchTable.inventory.AnyItems())
            {
                researchTable.inventory.Drop(Constants.ItemDropPrefab, researchTable.ServerPosition + new Vector3(0, 1.5f, 0), researchTable.ServerRotation);
            }

            // Remove original research table.
            researchTable.Kill();

            var crafter = CreateCrafter(recycler);

            return(crafter);
        }