コード例 #1
0
        public ConceptsDefinitionsVM Post(ConceptsDefinitionsVM vm, string userId)
        {
            using (var db = new LMISEntities())

            {
                try
                {
                    var id         = vm.ConceptDefID;
                    var checkExist = db.ConceptDefs.Count(c => c.ConceptDefTitle == vm.ConceptDefTitle && c.ConceptDefID != vm.ConceptDefID && !c.IsDeleted);
                    if (checkExist > 0)
                    {
                        return(null);
                    }

                    if (id > 0) //Update
                    {
                        var tr = db.ConceptDefs
                                 .Where(r => !r.IsDeleted && r.ConceptDefID == id)
                                 .ToList().Single();

                        tr.ConceptDefDesc  = vm.ConceptDefDesc;
                        tr.ConceptDefTitle = vm.ConceptDefTitle;
                        tr.UpdateUserID    = userId;
                        tr.UpdateDate      = DateTime.UtcNow;
                        tr.LanguageID      = vm.LanguageID;
                    }
                    else //Insert
                    {
                        var tr = new ConceptDef()
                        {
                            ConceptDefDesc  = vm.ConceptDefDesc,
                            ConceptDefTitle = vm.ConceptDefTitle,
                            PostUserId      = userId,
                            PostDate        = DateTime.UtcNow,
                            LanguageID      = vm.LanguageID
                        };

                        db.ConceptDefs.Add(tr);
                        db.SaveChanges();

                        vm.ConceptDefID = tr.ConceptDefID;
                    }

                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    ExceptionDispatchInfo.Capture(ex).Throw();
                }


                return(vm);
            }
        }
コード例 #2
0
        public static void RefuseGuestsUntilWeHaveBeds(Map map)
        {
            if (map == null)
            {
                return;
            }

            var mapComp = map.GetMapComponent();

            mapComp.refuseGuestsUntilWeHaveBeds = true;
            LessonAutoActivator.TeachOpportunity(ConceptDef.Named("GuestBeds"), null, OpportunityType.Important);
        }
コード例 #3
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     _cellCount    = GenRadial.NumCellsInRadius(_fieldRadius);
     _positionLast = parent.Position;
     _radiusLast   = (int)Radius;
     _energySource = EnergySourceUtility.Find(parent);
     _heatSink     = HeatsinkUtility.Find(parent);
     _resistance   = parent.TryGetComp <Comp_ShieldResistance>();
     parent.Map.GetComponent <ShieldManager>().Add(this);
     LessonAutoActivator.TeachOpportunity(ConceptDef.Named("FD_Shields"), OpportunityType.Critical);
 }
コード例 #4
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     LessonAutoActivator.TeachOpportunity(ConceptDef.Named("FD_Shields"), OpportunityType.Critical);
     _powerTrader                 = GetComp <CompPowerTrader>();
     _shield                      = GetComp <Comp_ShieldRadial>();
     _heatSink                    = GetComp <Comp_HeatSink>();
     _heatSink.CanBreakdown       = IsActive;
     _heatSink.MinorBreakdown     = () => BreakdownMessage("fd.shields.incident.minor.title".Translate(), "fd.shields.incident.minor.body".Translate(), DoMinorBreakdown());
     _heatSink.MajorBreakdown     = () => BreakdownMessage("fd.shields.incident.major.title".Translate(), "fd.shields.incident.major.body".Translate(), DoMajorBreakdown());
     _heatSink.CricticalBreakdown = () => BreakdownMessage("fd.shields.incident.critical.title".Translate(), "fd.shields.incident.critical.body".Translate(), DoCriticalBreakdown());
     _activeLastTick              = IsActive();
     base.SpawnSetup(map, respawningAfterLoad);
 }
コード例 #5
0
        private static void TryActivateTutorial(ConceptDef def, OpportunityType opr)
        {
            if (!triggeredTutorials.Contains(def))
            {
                if (opr >= OpportunityType.Important || IsReady())
                {
                    lastTutorTime = Time.time;

                    LessonAutoActivator.TeachOpportunity(def, opr);
                    triggeredTutorials.Add(def);
                }
            }
        }
コード例 #6
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     _cellCount    = GenRadial.NumCellsInRadius(_fieldRadius);
     _positionLast = parent.Position;
     _radiusLast   = (int)Radius;
     parent.Map.GetComponent <ShieldManager>().Add(this);
     LessonAutoActivator.TeachOpportunity(ConceptDef.Named("FD_Shields"), OpportunityType.Critical);
     if (_id == null)
     {
         _id = NextId;
     }
 }
コード例 #7
0
        public static void Recruit(Pawn guest, int recruitPenalty, bool forced)
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named("RecruitGuest"), KnowledgeAmount.Total);

            if (forced)
            {
                GainThought(guest, ThoughtDef.Named("GuestRecruitmentForced"));
            }

            Find.LetterStack.ReceiveLetter(labelRecruitSuccess, (forced ? txtForcedRecruit : txtRecruitSuccess).Translate(guest), LetterDefOf.PositiveEvent, guest, guest.Faction);

            AngerFactionMembers(guest);
            RecruitingSuccess(guest, recruitPenalty);
        }
コード例 #8
0
        public Thought_Memory GiveObservedThought()
        {
            string     concept    = string.Format("RRY_Concept_{0}s", pawn.def.label);
            string     thought    = string.Format("RRY_Observed_{0}", pawn.def.label);
            ConceptDef conceptDef = null;
            ThoughtDef thoughtDef = null;
            Thought_MemoryObservation observation = null;

            thoughtDef = DefDatabase <ThoughtDef> .GetNamedSilentFail(thought);

            conceptDef = DefDatabase <ConceptDef> .GetNamedSilentFail(concept);

            lastSpottedTick = Find.TickManager.TicksGame;
            if (conceptDef != null && !pawn.isXenomorph() && !pawn.isNeomorph())
            {
                if (PlayerKnowledgeDatabase.IsComplete(conceptDef))
                {
                    if (thoughtDef != null)
                    {
                        observation = (Thought_MemoryObservation)ThoughtMaker.MakeThought(thoughtDef);
                    }
                    //   LessonAutoActivator.TeachOpportunity(conceptDef, OpportunityType.Important);
                }
                else
                {
                    thoughtDef = DefDatabase <ThoughtDef> .GetNamedSilentFail(thought);

                    if (thoughtDef != null)
                    {
                        observation = (Thought_MemoryObservation)ThoughtMaker.MakeThought(thoughtDef);
                    }
                }
            }
            else
            {
                thoughtDef = DefDatabase <ThoughtDef> .GetNamedSilentFail(thought);

                if (thoughtDef != null)
                {
                    observation = (Thought_MemoryObservation)ThoughtMaker.MakeThought(thoughtDef);
                }
            }
            if (observation != null)
            {
                observation.Target = this.parent;
                return(observation);
            }

            return(null);
        }
コード例 #9
0
        private static void RecruitingSuccess(Pawn guest)
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named("RecruitGuest"), KnowledgeAmount.Total);

            Find.LetterStack.ReceiveLetter(labelRecruitSuccess, String.Format(txtRecruitSuccess, guest), LetterType.Good, guest);

            if (guest.Faction != Faction.OfPlayer)
            {
                if (guest.Faction != null)
                {
                    guest.Faction.AffectGoodwillWith(Faction.OfPlayer, -guest.RecruitPenalty());
                    if (guest.RecruitPenalty() >= 1)
                    {
                        //Log.Message("txtRecruitFactionAnger");
                        string message;
                        if (guest.Faction.leader != null)
                        {
                            message = String.Format(txtRecruitFactionAnger, guest.Faction.leader.Name, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefAnger, message, LetterType.BadNonUrgent);
                        }
                        else
                        {
                            message = String.Format(txtRecruitFactionAngerLeaderless, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionAnger, message, LetterType.BadNonUrgent);
                        }
                    }
                    else if (guest.RecruitPenalty() <= -1)
                    {
                        //Log.Message("txtRecruitFactionPlease");
                        string message;
                        if (guest.Faction.leader != null)
                        {
                            message = String.Format(txtRecruitFactionPlease, guest.Faction.leader.Name, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefPlease, message, LetterType.Good);
                        }
                        else
                        {
                            message = String.Format(txtRecruitFactionPleaseLeaderless, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionPlease, message, LetterType.Good);
                        }
                    }
                }
                guest.Adopt();
            }
            var taleParams = new object[] { guest.MapHeld.mapPawns.FreeColonistsSpawned.RandomElement(), guest };

            TaleRecorder.RecordTale(TaleDef.Named("Recruited"), taleParams);
        }
コード例 #10
0
        private void LeaveVerySatisfied(Pawn pawn, float score)
        {
            if (pawn.inventory.innerContainer.Count == 0 || Settings.disableGifts)
            {
                return;
            }

            var dropped = GetLoot(pawn, (score + 10) * 1.5f);

            if (dropped.Count == 0)
            {
                return;
            }
            var itemNames = GenText.ToCommaList(dropped.Select(GetItemName));

            var text = "VisitorVerySatisfied".Translate(pawn.Name.ToStringShort, pawn.Possessive(), pawn.ProSubjCap(), itemNames);

            Messages.Message(text, dropped.First(), MessageTypeDefOf.PositiveEvent);

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named("Hospitality"), KnowledgeAmount.Total);
        }
コード例 #11
0
 public override void ProcessInput(Event ev)
 {
     if (compAmmo == null)
     {
         Log.Error("Command_Reload without ammo comp");
         return;
     }
     if (compAmmo.UseAmmo &&
         (compAmmo.CompInventory != null || compAmmo.turret != null) ||
         action == null)
     {
         Find.WindowStack.Add(MakeAmmoMenu());
     }
     else if (compAmmo.SelectedAmmo != compAmmo.CurrentAmmo || compAmmo.CurMagCount < compAmmo.Props.magazineSize)
     {
         base.ProcessInput(ev);
     }
     // Show we learned something by clicking this
     if (!tutorTag.NullOrEmpty())
     {
         PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named(tutorTag), KnowledgeAmount.Total);
     }
 }
コード例 #12
0
        private void PlaceFlag()
        {
            var def = ThingDef.Named("VisitorFlag");

            Data.visitorFlag = (VisitorFlag)GenSpawn.Spawn(def, FlagLoc, Map);
            //Data.visitorFlag.SetFaction(lord.faction);
            var pawn = lord.ownedPawns.FirstOrDefault();

            Data.visitorFlag.SetLord(lord);
            if (pawn == null)
            {
                return;
            }

            Data.visitorFlag.SetColor(PawnNameColorUtility.PawnNameColorOf(pawn));

            // Lessons
            LessonAutoActivator.TeachOpportunity(ConceptDef.Named("GuestBeds"), Data.visitorFlag, OpportunityType.Important);
            if (PlayerHasSkilledNegotiator)
            {
                LessonAutoActivator.TeachOpportunity(ConceptDef.Named("RecruitGuest"), Data.visitorFlag, OpportunityType.GoodToKnow);
            }
        }
コード例 #13
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     LessonAutoActivator.TeachOpportunity(ConceptDef.Named("TM_Portals"), OpportunityType.GoodToKnow);
 }
コード例 #14
0
 public override void PostMake()
 {
     base.PostMake();
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named("GuestBeds"), KnowledgeAmount.Total);
 }
コード例 #15
0
 public static bool ReturnTrue(ConceptDef conc)
 {
     return(true);
 }