public override BaseCorpse OnCreateCorpse(HTNPlayer target)
 {
     if (this.DeathEffect.isValid)
     {
         Effect.server.Run(this.DeathEffect.resourcePath, (BaseEntity)target, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
     }
     using (TimeWarning.New("Create corpse", 0.1f))
     {
         NPCPlayerCorpse npcPlayerCorpse = target.DropCorpse("assets/prefabs/npc/murderer/murderer_corpse.prefab") as NPCPlayerCorpse;
         if (Object.op_Implicit((Object)npcPlayerCorpse))
         {
             if (Object.op_Inequality((Object)target.AiDomain, (Object)null) && Object.op_Inequality((Object)target.AiDomain.NavAgent, (Object)null) && target.AiDomain.NavAgent.get_isOnNavMesh())
             {
                 ((Component)npcPlayerCorpse).get_transform().set_position(Vector3.op_Addition(((Component)npcPlayerCorpse).get_transform().get_position(), Vector3.op_Multiply(Vector3.get_down(), target.AiDomain.NavAgent.get_baseOffset())));
             }
             npcPlayerCorpse.SetLootableIn(2f);
             npcPlayerCorpse.SetFlag(BaseEntity.Flags.Reserved5, target.HasPlayerFlag(BasePlayer.PlayerFlags.DisplaySash), false, true);
             npcPlayerCorpse.SetFlag(BaseEntity.Flags.Reserved2, true, false, true);
             for (int index = 0; index < target.inventory.containerWear.itemList.Count; ++index)
             {
                 Item obj = target.inventory.containerWear.itemList[index];
                 if (obj != null && obj.info.shortname == "gloweyes")
                 {
                     target.inventory.containerWear.Remove(obj);
                     break;
                 }
             }
             npcPlayerCorpse.TakeFrom(target.inventory.containerMain, target.inventory.containerWear, target.inventory.containerBelt);
             npcPlayerCorpse.playerName    = target.displayName;
             npcPlayerCorpse.playerSteamID = target.userID;
             npcPlayerCorpse.Spawn();
             npcPlayerCorpse.TakeChildren((BaseEntity)target);
             foreach (ItemContainer container in npcPlayerCorpse.containers)
             {
                 container.Clear();
             }
             if (this.Loot.Length != 0)
             {
                 foreach (LootContainer.LootSpawnSlot lootSpawnSlot in this.Loot)
                 {
                     for (int index = 0; index < lootSpawnSlot.numberToSpawn; ++index)
                     {
                         if ((double)Random.Range(0.0f, 1f) <= (double)lootSpawnSlot.probability)
                         {
                             lootSpawnSlot.definition.SpawnIntoContainer(npcPlayerCorpse.containers[0]);
                         }
                     }
                 }
             }
         }
         return((BaseCorpse)npcPlayerCorpse);
     }
 }
Пример #2
0
        public override BaseCorpse OnCreateCorpse(HTNPlayer target)
        {
            int        i;
            BaseCorpse baseCorpse;

            if (this.DeathEffect.isValid)
            {
                Effect.server.Run(this.DeathEffect.resourcePath, target, 0, Vector3.zero, Vector3.zero, null, false);
            }
            using (TimeWarning timeWarning = TimeWarning.New("Create corpse", 0.1f))
            {
                NPCPlayerCorpse navAgent = target.DropCorpse("assets/prefabs/npc/scientist/scientist_corpse.prefab") as NPCPlayerCorpse;
                if (navAgent)
                {
                    if (target.AiDomain != null && target.AiDomain.NavAgent != null && target.AiDomain.NavAgent.isOnNavMesh)
                    {
                        navAgent.transform.position = navAgent.transform.position + (Vector3.down * target.AiDomain.NavAgent.baseOffset);
                    }
                    navAgent.SetLootableIn(2f);
                    navAgent.SetFlag(BaseEntity.Flags.Reserved5, target.HasPlayerFlag(BasePlayer.PlayerFlags.DisplaySash), false, true);
                    navAgent.SetFlag(BaseEntity.Flags.Reserved2, true, false, true);
                    navAgent.TakeFrom(new ItemContainer[] { target.inventory.containerMain, target.inventory.containerWear, target.inventory.containerBelt });
                    navAgent.playerName    = target.displayName;
                    navAgent.playerSteamID = target.userID;
                    navAgent.Spawn();
                    navAgent.TakeChildren(target);
                    ItemContainer[] itemContainerArray = navAgent.containers;
                    for (i = 0; i < (int)itemContainerArray.Length; i++)
                    {
                        itemContainerArray[i].Clear();
                    }
                    if (this.Loot.Length != 0)
                    {
                        LootContainer.LootSpawnSlot[] loot = this.Loot;
                        for (i = 0; i < (int)loot.Length; i++)
                        {
                            LootContainer.LootSpawnSlot lootSpawnSlot = loot[i];
                            for (int j = 0; j < lootSpawnSlot.numberToSpawn; j++)
                            {
                                if (UnityEngine.Random.Range(0f, 1f) <= lootSpawnSlot.probability)
                                {
                                    lootSpawnSlot.definition.SpawnIntoContainer(navAgent.containers[0]);
                                }
                            }
                        }
                    }
                }
                baseCorpse = navAgent;
            }
            return(baseCorpse);
        }