Пример #1
0
 public override void OnRemove()
 {
     isValid = false;
     if (usedNPC != null)
     {
         ColonyManager.RemoveJobs(this);
         usedNPC.ClearJob();
         usedNPC = null;
     }
 }
Пример #2
0
        private static string InfectNPC(Colony c)
        {
            string sickNPC = null;

            if (Pipliz.Random.NextFloat(0.0f, 1.0f) <= Configuration.ChanceOfDiseaseSpread)
            {
                foreach (NPCBase follower in c.Followers)
                {
                    if (!follower.Job.NPCType.Equals(SickJob.SickNPCType))
                    {
                        if (follower.Job != null)
                        {
                            follower.Job.NPC = null;
                            follower.ClearJob();
                        }

                        //Create the sickjob, save the old job so it can be reset with the NPC is health again and if it is available.  Init job and assign the NPC to the sickjob.
                        SickJob sickjob = new SickJob();
                        sickjob.OldJob = (Job)follower.Job;
                        sickjob.InitializeJob(follower.Colony.Owner, follower.Position, follower.ID);
                        sickjob.OnAssignedNPC(follower);
                        follower.TakeJob(sickjob);

                        //add job so it will be saved and loaded with server restarts
                        ColonyManager.AddJobs(sickjob);

                        //Make old job available
                        JobTracker.Add(sickjob.OldJob);

                        //Set so the name of the old job can be returned
                        sickNPC = follower.Job.NPCType.ToString();

                        break;
                    }
                }
            }
            return(sickNPC);
        }