コード例 #1
0
ファイル: ArmedBoats.cs プロジェクト: Wujaszkun/Armed-Boats
            private void SpawnGuns()
            {
                var rotation = mainBoat.transform.rotation;
                var position = mainBoat.transform.position;

                BaseEntity entity = GameManager.server.CreateEntity("assets/prefabs/npc/autoturret/autoturret_deployed.prefab", position, rotation, true);

                entity.SetParent(mainBoat, 0);
                entity.transform.localPosition    = new Vector3(0f, 1.2f, 4.2f);
                entity.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
                entity?.Spawn();

                turret = entity.GetComponent <AutoTurret>();
                turret.SetPeacekeepermode(true);
                turret.InitializeControl(null);
                turret.UpdateFromInput(100, 0);
                turret.isLootable = false;
                turret.dropChance = 0;

                spawnedEntities.Add(entity);

                turret.inventory.Clear();

                ItemManager.CreateByName("lmg.m249", 1).MoveToContainer(turret.inventory, 0);
                ItemManager.CreateByName("ammo.rifle", 1000).MoveToContainer(turret.inventory, 1);

                turret.UpdateAttachedWeapon();
                turret.Reload();
            }