Beispiel #1
0
        private void DestroyThing(Thing thing, int hostId = 0)
        {
            var id = thing.thingIDNumber;

            if (hostId != 0 || ThingsIDDic.TryGetValue(id, out hostId))
            {
                ThingsIDDicRev.Remove(hostId);
            }
            ThingsIDDic.Remove(id);
            ThingsObjDic.Remove(id);
            thing.Destroy();
        }
Beispiel #2
0
        public void UIEventNewJob(Pawn pawn, Job job) //если job == null значит команда стоять и не двигаться Wait_Combat
        {
            try
            {
                int id;
                if (!AttackerPawns.TryGetValue(pawn, out id))
                {
                    if (MainHelper.DebugMode && pawn.Label == "Douglas, Клерк")
                    {
                        Loger.Log("AttackUpdate UIEventNewJob Out of event " + pawn.Label + " " + pawn.thingIDNumber.ToString());
                    }
                    return;
                }
                var comm = new AttackPawnCommand()
                {
                    HostPawnID = id
                };

                if (job != null)
                {
                    if (job.targetA.HasThing)
                    {
                        int tid;
                        if (!ThingsIDDic.TryGetValue(job.targetA.Thing.thingIDNumber, out tid))
                        {
                            if (MainHelper.DebugMode && pawn.Label == "Douglas, Клерк")
                            {
                                Loger.Log("AttackUpdate UIEventNewJob Error " + pawn.Label + " ThingID " + job.targetA.Thing.Label + " " + job.targetA.Thing.thingIDNumber.ToString());
                            }
                            return;
                        }
                        comm.TargetID = tid;
                    }
                    else
                    {
                        comm.TargetPos = new IntVec3S(job.targetA.Cell);
                    }

                    if (job.def == JobDefOf.AttackStatic)
                    {
                        comm.Command = AttackPawnCommand.PawnCommand.Attack;
                    }
                    else if (job.def == JobDefOf.AttackMelee)
                    {
                        comm.Command = AttackPawnCommand.PawnCommand.AttackMelee;
                    }
                    else if (job.def == JobDefOf.Goto)
                    {
                        comm.Command = AttackPawnCommand.PawnCommand.Goto;
                    }
                    else
                    {
                        if (MainHelper.DebugMode && pawn.Label == "Douglas, Клерк")
                        {
                            Loger.Log("AttackUpdate UIEventNewJob " + pawn.Label + " job=" + (job == null ? "null" : job.def.defName.ToString()) + " -> ignore");
                        }
                        return; //левые команды игнорятся, но перед ними идет отмена предыдущего с job == null
                        //comm.Command = AttackPawnCommand.PawnCommand.Wait_Combat;
                    }
                }
                else
                {
                    if (MainHelper.DebugMode && pawn.Label == "Douglas, Клерк")
                    {
                        Loger.Log("AttackUpdate UIEventNewJob " + pawn.Label + " job=" + (job == null ? "null" : job.def.defName.ToString()) + " -> ignore2");
                    }
                    return;
                    //comm.Command = AttackPawnCommand.PawnCommand.Wait_Combat;
                }

                if (MainHelper.DebugMode && pawn.Label == "Douglas, Клерк")
                {
                    Loger.Log("AttackUpdate UIEventNewJob " + pawn.Label + " job=" + (job == null ? "null" : job.def.defName.ToString()) + " -> " + comm.Command.ToString());
                }

                ToSendCommand[id] = comm;
            }
            catch (Exception exp)
            {
                Loger.Log("AttackUpdate UIEventNewJob " + exp.ToString());
            }
        }