Exemplo n.º 1
0
 private void SetGameObjects()
 {
     firstCutScene.SetActive(true);
     secondCutScene.SetActive(false);
     sceneMainChar.SetActive(false);
     mainCharController = sceneMainChar.GetComponent <NpcControl>();
     mainCharController.isCoroutineStarted = false;
 }
 // Start is called before the first frame update
 void Start()
 {
     vomitSystem.SetActive(false);
     secondCutScene.SetActive(false);
     sceneMainChar.SetActive(false);
     ActivateSceneObjs();
     colaStartPos       = cola.transform.position;
     colastartRot       = cola.transform.rotation;
     mainCharController = sceneMainChar.GetComponent <NpcControl>();
     mainCharController.isCoroutineStarted = false;
 }
Exemplo n.º 3
0
        void OnPlayerInit(BasePlayer player)
        {
            PetInfo info;

            if (SaveNpcList.TryGetValue(player.userID.ToString(), out info) && info.NeedToSpawn)
            {
                Puts("Loading pet...");
                BaseEntity pet = GameManager.server.CreateEntity(StringPool.Get(info.prefabID), new Vector3(info.x, info.y, info.z));
                if (pet != null)
                {
                    NpcControl comp = player.gameObject.AddComponent <NpcControl>();
                    pet.Spawn(true);
                    comp.npc       = pet.gameObject.AddComponent <NpcAI>();
                    comp.npc.owner = comp;
                    comp.npc.inventory.Load(ProtoBuf.ItemContainer.Deserialize(info.inventory));
                    info.NeedToSpawn = false;
                }
            }
        }
Exemplo n.º 4
0
        void pet(BasePlayer player, string command, string[] args)
        {
            if (!UsePermission || HasPermission(player, "cannpc"))
            {
                NpcControl comp = player.GetComponent <NpcControl>() ?? player.gameObject.AddComponent <NpcControl>();
                if (args.Length > 0)
                {
                    switch (args[0])
                    {
                    case "free":
                        if (comp.npc)
                        {
                            GameObject.Destroy(comp.npc);
                            SendReply(player, NpcFree);
                        }
                        else
                        {
                            SendReply(player, NotNpc);
                        }
                        break;

                    case "draw":
                        if (GlobalDraw)
                        {
                            if (comp.DrawEnabled)
                            {
                                comp.DrawEnabled = false;
                                SendReply(player, DrawDis);
                            }
                            else
                            {
                                comp.DrawEnabled = true;
                                SendReply(player, DrawEn);
                            }
                        }
                        else
                        {
                            SendReply(player, DrawSysDis);
                        }
                        break;

                    case "sleep":
                        if (comp.npc)
                        {
                            SendReply(player, SleepMsg);
                            comp.npc.action = Act.Sleep;
                        }
                        else
                        {
                            SendReply(player, NotNpc);
                        }
                        break;

                    case "info":
                        if (comp.npc)
                        {
                            NPCMetabolism meta = comp.npc.RustMetabolism;
                            SendReply(player, InfoMsg
                                      .Replace("{health}", Math.Round(comp.npc.Base.health * 100 / comp.npc.Base.MaxHealth()).ToString())
                                      .Replace("{hunger}", Math.Round(meta.hydration.value * 100 / meta.hydration.max).ToString())
                                      .Replace("{thirst}", Math.Round(meta.calories.value * 100 / meta.calories.max).ToString())
                                      .Replace("{sleep}", Math.Round(meta.sleep.value * 100 / meta.sleep.max).ToString())
                                      .Replace("{stamina}", Math.Round(meta.stamina.value * 100 / meta.stamina.max).ToString()));
                        }
                        else
                        {
                            SendReply(player, NotNpc);
                        }
                        break;
                    }
                }
                else
                {
                    if (comp.enabled)
                    {
                        comp.enabled = false;
                        SendReply(player, DeactivatedMsg);
                    }
                    else
                    {
                        comp.enabled = true;
                        SendReply(player, ActivatedMsg);
                    }
                }
            }
            else
            {
                SendReply(player, NoPermMsg);
            }
        }