Exemplo n.º 1
0
        public void PurchaseAmmoButton()
        {
            if (detectedFirearm == null || original.M.GetNumTokens() < PanelCost)
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position);
                return;
            }

            else
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position);
                original.M.SubtractTokens(PanelCost);
                original.M.Increment(10, false);

                FVRObject.OTagFirearmRoundPower roundPower = AM.GetRoundPower(detectedFirearm.RoundType);
                int numSpawned = GetRoundsToSpawn(roundPower);

                TNHTweakerLogger.Log("Compatible rounds count for " + detectedFirearm.ObjectWrapper.ItemID + ": " + IM.OD[detectedFirearm.ObjectWrapper.ItemID].CompatibleSingleRounds.Count, TNHTweakerLogger.LogType.General);

                CustomCharacter        character      = LoadedTemplateManager.LoadedCharactersDict[original.M.C];
                MagazineBlacklistEntry blacklistEntry = null;
                if (character.GetMagazineBlacklist().ContainsKey(detectedFirearm.ObjectWrapper.ItemID))
                {
                    blacklistEntry = character.GetMagazineBlacklist()[detectedFirearm.ObjectWrapper.ItemID];
                }

                FVRObject compatibleRound = FirearmUtils.GetCompatibleRounds(detectedFirearm.ObjectWrapper, character.ValidAmmoEras, character.ValidAmmoSets, character.GlobalAmmoBlacklist, blacklistEntry).GetRandom();

                AnvilManager.Run(SpawnRounds(compatibleRound, numSpawned));

                detectedFirearm = null;
                UpdateIcons();
            }
        }
Exemplo n.º 2
0
        public static void CreatePopulatedCharacterTemplate(string path)
        {
            try
            {
                TNHTweakerLogger.Log("TNHTweaker -- Creating populated character template file", TNHTweakerLogger.LogType.File);

                path = path + "/PopulatedCharacterTemplate.json";

                if (!File.Exists(path))
                {
                    File.Delete(path);
                }

                using (StreamWriter sw = File.CreateText(path))
                {
                    CustomCharacter character       = new CustomCharacter();
                    string          characterString = JsonConvert.SerializeObject(character, Formatting.Indented, new StringEnumConverter());
                    sw.WriteLine(characterString);
                    sw.Close();
                }
            }

            catch (Exception ex)
            {
                TNHTweakerLogger.LogError(ex.ToString());
            }
        }
        //TODO To choose spawn based on IFF, we need to basically generate spawn points on our own in this method!
        public static TNH_Manager.SosigPatrolSquad GeneratePatrol(TNH_Manager instance, Patrol patrol, List <Vector3> SpawnPoints, List <Vector3> ForwardVectors, List <Vector3> PatrolPoints, int patrolIndex)
        {
            TNH_Manager.SosigPatrolSquad squad = new TNH_Manager.SosigPatrolSquad();
            squad.PatrolPoints = new List <Vector3>(PatrolPoints);

            for (int i = 0; i < patrol.PatrolSize && i < SpawnPoints.Count; i++)
            {
                SosigEnemyTemplate template;

                bool allowAllWeapons;

                //If this is a boss, then we can only spawn it once, so add it to the list of spawned bosses
                if (patrol.IsBoss)
                {
                    TNHTweaker.SpawnedBossIndexes.Add(patrolIndex);
                }

                //Select a sosig template from the custom character patrol
                if (i == 0)
                {
                    template        = IM.Instance.odicSosigObjsByID[(SosigEnemyID)LoadedTemplateManager.SosigIDDict[patrol.LeaderType]];
                    allowAllWeapons = true;
                }

                else
                {
                    template        = IM.Instance.odicSosigObjsByID[(SosigEnemyID)LoadedTemplateManager.SosigIDDict[patrol.EnemyType.GetRandom()]];
                    allowAllWeapons = false;
                }

                CustomCharacter character      = LoadedTemplateManager.LoadedCharactersDict[instance.C];
                SosigTemplate   customTemplate = LoadedTemplateManager.LoadedSosigsDict[template];
                FVRObject       droppedObject  = instance.Prefab_HealthPickupMinor;

                //If squad is set to swarm, the first point they path to should be the players current position
                Sosig sosig;
                if (patrol.SwarmPlayer)
                {
                    squad.PatrolPoints[0] = GM.CurrentPlayerBody.transform.position;
                    sosig = SpawnEnemy(customTemplate, character, SpawnPoints[i], Quaternion.LookRotation(ForwardVectors[i], Vector3.up), instance.AI_Difficulty, patrol.IFFUsed, true, squad.PatrolPoints[0], allowAllWeapons);
                    sosig.SetAssaultSpeed(patrol.AssualtSpeed);
                }
                else
                {
                    sosig = SpawnEnemy(customTemplate, character, SpawnPoints[i], Quaternion.LookRotation(ForwardVectors[i], Vector3.up), instance.AI_Difficulty, patrol.IFFUsed, true, squad.PatrolPoints[0], allowAllWeapons);
                    sosig.SetAssaultSpeed(patrol.AssualtSpeed);
                }

                //Handle patrols dropping health
                if (i == 0 && UnityEngine.Random.value < patrol.DropChance)
                {
                    sosig.Links[1].RegisterSpawnOnDestroy(droppedObject);
                }

                squad.Squad.Add(sosig);
            }

            return(squad);
        }
        public static bool GenerateSentryPatrolPatch(
            List <Vector3> SpawnPoints,
            List <Vector3> ForwardVectors,
            List <Vector3> PatrolPoints,
            TNH_Manager __instance,
            List <TNH_Manager.SosigPatrolSquad> ___m_patrolSquads,
            ref float ___m_timeTilPatrolCanSpawn,
            ref TNH_Manager.SosigPatrolSquad __result
            )
        {
            TNHTweakerLogger.Log("TNHTWEAKER -- Generating a sentry patrol -- There are currently " + ___m_patrolSquads.Count + " patrols active", TNHTweakerLogger.LogType.TNH);

            CustomCharacter character = LoadedTemplateManager.LoadedCharactersDict[__instance.C];
            Level           currLevel = character.GetCurrentLevel(__instance.m_curLevel);

            if (currLevel.Patrols.Count < 1)
            {
                return(false);
            }

            //Get a valid patrol index, and exit if there are no valid patrols
            int patrolIndex = GetValidPatrolIndex(currLevel.Patrols);

            if (patrolIndex == -1)
            {
                TNHTweakerLogger.Log("TNHTWEAKER -- No valid patrols can spawn", TNHTweakerLogger.LogType.TNH);
                ___m_timeTilPatrolCanSpawn = 999;

                //Returning an empty squad is the easiest way to not generate a patrol when no valid ones are found
                //This could cause strange and unpredictable behaviour
                //Good luck!
                __result = new TNH_Manager.SosigPatrolSquad();
                __result.PatrolPoints = new List <Vector3>();
                __result.Squad        = new List <Sosig>();

                return(false);
            }

            TNHTweakerLogger.Log("TNHTWEAKER -- Valid patrol found", TNHTweakerLogger.LogType.TNH);

            Patrol patrol = currLevel.Patrols[patrolIndex];

            TNH_Manager.SosigPatrolSquad squad = GeneratePatrol(__instance, patrol, SpawnPoints, ForwardVectors, PatrolPoints, patrolIndex);

            //We don't add this patrol because it's tracked outside of this method
            //___m_patrolSquads.Add(squad);

            if (__instance.EquipmentMode == TNHSetting_EquipmentMode.Spawnlocking)
            {
                ___m_timeTilPatrolCanSpawn = patrol.PatrolCadence;
            }
            else
            {
                ___m_timeTilPatrolCanSpawn = patrol.PatrolCadenceLimited;
            }

            __result = squad;
            return(false);
        }
Exemplo n.º 5
0
 public void EquipAll(CustomCharacter character)
 {
     EquipHead(character.HeadSprite);
     EquipTop(character.TopSprite);
     EquipBottom(character.BottomSprite);
     EquipMain(character.MainSprite);
     EquipSub(character.SubSprite);
 }
Exemplo n.º 6
0
 void Start()
 {
     if (photonView.isMine)
     {
         PlayerData.DressWeared = PlayerManager.Instance.MainCharacter.GetComponent <Flatmate> ().data.Dress;
         customCharacter        = PlayerManager.Instance.custChar;
         ApplyDataToThisView();
     }
 }
        public static void AddCharacterTemplate(CustomCharacter template, Sprite thumbnail)
        {
            CustomCharacters.Add(template);
            LoadedCharactersDict.Add(template.GetCharacter(NewCharacterID, thumbnail), template);

            foreach (EquipmentPool pool in template.EquipmentPools)
            {
                EquipmentPoolDictionary.Add(pool.GetPoolEntry(), pool);
            }

            NewCharacterID += 1;

            TNHTweakerLogger.Log("TNHTweaker -- Character added successfuly : " + template.DisplayName, TNHTweakerLogger.LogType.Character);
        }
        public static void AddCharacterTemplate(TNH_CharacterDef realTemplate)
        {
            CustomCharacter template = new CustomCharacter(realTemplate);

            DefaultCharacters.Add(template);
            LoadedCharactersDict.Add(realTemplate, template);

            foreach (EquipmentPool pool in template.EquipmentPools)
            {
                //Must check for this, since default characters can have references to the same pools
                if (!EquipmentPoolDictionary.ContainsKey(pool.GetPoolEntry()))
                {
                    EquipmentPoolDictionary.Add(pool.GetPoolEntry(), pool);
                }
            }

            TNHTweakerLogger.Log("TNHTweaker -- Character added successfuly : " + realTemplate.DisplayName, TNHTweakerLogger.LogType.Character);
        }
        /// <summary>
        /// Performs a delayed init on the sent list of custom characters, and removes any characters that failed to init
        /// </summary>
        /// <param name="characters"></param>
        /// <param name="isCustom"></param>
        private static void InitCharacters(List <CustomCharacter> characters, bool isCustom)
        {
            for (int i = 0; i < characters.Count; i++)
            {
                CustomCharacter character = characters[i];

                try
                {
                    character.DelayedInit(isCustom);
                }
                catch (Exception e)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load character: " + character.DisplayName + ". Error Output:\n" + e.ToString());
                    characters.RemoveAt(i);
                    LoadedTemplateManager.LoadedCharactersDict.Remove(character.GetCharacter());
                    i -= 1;
                }
            }
        }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        if (photonView.isMine)
        {
            PlayerDataForSocietyParty.DressWeared = PlayerManager.Instance.MainCharacter.GetComponent <Flatmate> ().data.Dress;
            _customChar = PlayerManager.Instance.custChar;

            ApplyDataToThisView();
            playerId        = this.gameObject.GetComponent <PhotonView> ().ownerId;
            PlayerSocietyId = SocietyManager.Instance.myRole;
            if (SocietyPartyManager.Instance.selectedSocietyParty.PlayerId == PlayerPrefs.GetInt("PlayerId"))
            {
                if (!PhotonPlayer.Find(playerId).isMasterClient)
                {
                    PhotonNetwork.SetMasterClient(PhotonPlayer.Find(playerId));
                }
            }
        }
        playerId = this.gameObject.GetComponent <PhotonView> ().ownerId;
    }
Exemplo n.º 11
0
    public IEnumerator GetCharacterData(int PlayerId)
    {
        var encoding = new System.Text.UTF8Encoding();

        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        CustomCharacter             customchar = new CustomCharacter();

        customchar.player_id = PlayerId;
        string json = JsonUtility.ToJson(customchar);

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", json.Length.ToString());

        WWW www = new WWW("http://pinekix.ignivastaging.com/players/getcustomcharacter", encoding.GetBytes(json), postHeader);

//		print ("jsonDtat is ==>> " + json);
        yield return(www);

        if (www.error == null)
        {
            JSONNode _jsnode = JSON.Parse(www.text);
//			print ("www.text ==>> " + www.text);
//			print ("_jsnode ==>> " + _jsnode.ToString ());
            if (_jsnode ["description"].ToString().Contains("inserted") || _jsnode ["status"].ToString().Contains("200"))
            {
//				print ("Success");

                JSONNode data = _jsnode ["data"];

                int playerId = 0;
                int.TryParse(data ["player_id"], out playerId);
                int gender = 0;
                int.TryParse(data ["gender"], out gender);
                int skinTone = 0;
                int.TryParse(data ["skin_tone"], out skinTone);
                var cust_Char = new CustomCharacter();
                cust_Char.player_id = playerId;
                cust_Char.gender    = gender;
                cust_Char.skin_tone = skinTone;
                cust_Char.eyes      = data ["eyes"];
                cust_Char.nose      = data ["nose"];
                cust_Char.lips      = data ["lips"];
                cust_Char.ears      = data ["ears"];
                cust_Char.hair      = data ["hair"];
                cust_Char.shoes     = data ["shoes"];
                cust_Char.clothing  = data ["clothing"];

                if (PlayerId == PlayerPrefs.GetInt("PlayerId"))
                {
                    custChar = cust_Char;

                    PlayerPrefs.SetInt("SkinToneColor", custChar.skin_tone);

                    if (custChar.gender == 0)
                    {
                        PlayerPrefs.SetString("CharacterType", "Female");
                    }
                    else
                    {
                        PlayerPrefs.SetString("CharacterType", "Male");
                    }
                }
                else
                {
                }

                yield return(cust_Char);
            }
            else
            {
//				print ("error" + www.error);
                yield return(null);
            }
        }
        else
        {
            yield return(null);
        }
    }
Exemplo n.º 12
0
        private void DefineCharacter(byte[] character, CustomCharacter characterNum)
        {
            //http://www.bitwizard.nl/wiki/index.php/Lcd_protocol_1.6
            //http://code.google.com/p/arduino/source/browse/trunk/libraries/LiquidCrystal/LiquidCrystal.h

            byte screenDirectDefineCharCommand = (byte)(0x40 | ((byte)characterNum << 3));

            byte[] buf = new byte[2];
            buf[0] = (byte)WriteCommand.ScreenDirect;
            buf[1] = screenDirectDefineCharCommand;

            WriteToDevice(buf);
            WriteToDevice(character);
            Write8BitRegister(WriteCommand.MoveCursor, 0);
        }
Exemplo n.º 13
0
 public static string StringForCharacter(CustomCharacter character)
 {
     return Encoding.ASCII.GetString(new byte[] { (byte)character });
 }
Exemplo n.º 14
0
        public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            if (handle is not IDirectoryHandle dir)
            {
                throw new ArgumentException("Could not load character! Character should point to a folder holding the character.json and thumb.png");
            }


            try
            {
                CustomCharacter character = null;
                Sprite          thumbnail = null;

                foreach (IFileHandle file in dir.GetFiles())
                {
                    if (file.Path.EndsWith("character.json"))
                    {
                        string charString = stage.ImmediateReaders.Get <string>()(file);
                        JsonSerializerSettings settings = new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        };
                        character = JsonConvert.DeserializeObject <CustomCharacter>(charString, settings);
                    }
                    else if (file.Path.EndsWith("thumb.png"))
                    {
                        thumbnail = TNHTweakerUtils.LoadSprite(file);
                    }
                }

                if (character == null)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load custom character! No character.json file found");
                    return;
                }

                else if (thumbnail == null)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load custom character! No thumb.png file found");
                    return;
                }

                //Now we want to load the icons for each pool
                foreach (IFileHandle iconFile in dir.GetFiles())
                {
                    foreach (EquipmentPool pool in character.EquipmentPools)
                    {
                        if (iconFile.Path.EndsWith(pool.IconName))
                        {
                            pool.GetPoolEntry().TableDef.Icon = TNHTweakerUtils.LoadSprite(iconFile);
                        }
                    }
                }


                TNHTweakerLogger.Log("TNHTweaker -- Character loaded successfuly : " + character.DisplayName, TNHTweakerLogger.LogType.File);

                LoadedTemplateManager.AddCharacterTemplate(character, thumbnail);
            }
            catch (Exception e)
            {
                TNHTweakerLogger.LogError("Failed to load setup assets for character! Caused Error: " + e.ToString());
            }
        }
Exemplo n.º 15
0
    /*
     * //Methods sets the values of which player is AI and which not, should only be called on the Character selection scene
     * public void SaveAIPlayers(bool firstPlayer, bool secondPlayer, bool thirdPlayer, bool fourthPlayer )
     * {
     *  PlayerPrefs.SetString(PLAYER_1_AI, firstPlayer.ToString());
     *  PlayerPrefs.SetString(PLAYER_2_AI, secondPlayer.ToString());
     *  PlayerPrefs.SetString(PLAYER_3_AI, thirdPlayer.ToString());
     *  PlayerPrefs.SetString(PLAYER_4_AI, fourthPlayer.ToString());
     *
     *  //Example of how to retrieve them
     *  bool player1_AI = PlayerPrefs.GetString(PLAYER_1_AI).Equals("True");
     *  print("AI player value === " + player1_AI.ToString());
     * }
     */


    /*
     * private void GetPlayerControlScheme(string playerId)
     * {
     *  int inputDeviceId = PlayerPrefs.GetInt(INPUT_DEVICE_PLAYER + playerId);
     *  string controlScheme = PlayerPrefs.GetString(CONTROL_SCHEME_PLAYER + playerId);
     *
     *  //var playerInput = PlayerInput.Instantiate( controlScheme, inputDeviceId);
     *
     * }
     */

    public void SaveCustomCharacter(CustomCharacter customCharacter)
    {
        customCharacterList.Add(customCharacter);
    }
Exemplo n.º 16
0
    //Call this and pass your player minifid as well as the player id
    //Assuming that players id are 1, 2, 3, 4
    public void ApplyPlayerCustomization(GameObject player, int playerId)
    {
        if (playerId < 1 || playerId > 4 || customCharacterList.Count == 0)
        {
            return;
        }

        //Base Minifig and corresponding custom deisgn
        var             minifigComponent = player.transform.Find("Minifig Character").transform.Find("Geo_grp");
        CustomCharacter customCharacter  = customCharacterList[playerId - 1];

        //Hair / Hat
        var hairComponent = player.transform.Find(
            "Minifig Character/jointScaleOffset_grp/Joint_grp/detachSpine/spine01/spine02/spine03/spine04/spine05/spine06/spine07/neck/head/hat_loc/m85974(Clone)/Shell"
            );
        var hair = hairComponent.GetComponent <MeshFilter>();

        hair.mesh = customCharacter.hair;

        //Hair / Hat Color
        var hairColor = hairComponent.GetComponent <MeshRenderer>();

        hairColor.material = customCharacter.hairColor;



        //Face tone
        var playerComponents = minifigComponent.transform.Find("Head");
        var faceTone         = minifigComponent.transform.Find("Head").GetComponent <SkinnedMeshRenderer>();

        faceTone.material = customCharacter.faceTone;

        //Face
        var face = minifigComponent.transform.Find("Face").GetComponent <SkinnedMeshRenderer>();

        face.material = customCharacter.face;

        //Upper body
        playerComponents = minifigComponent.transform.Find("Torso");

        var torsoBack = playerComponents.transform.Find("Torso_Back").GetComponent <SkinnedMeshRenderer>();

        torsoBack.material = customCharacter.upperBody_back;

        var torsoFront = playerComponents.transform.Find("Torso_Front").GetComponent <SkinnedMeshRenderer>();

        torsoFront.material = customCharacter.upperBody_front;

        var torsoMain = playerComponents.transform.Find("Torso_main").GetComponent <SkinnedMeshRenderer>();

        torsoMain.material = customCharacter.upperBody_main;

        //Arms
        playerComponents = minifigComponent.transform.Find("Arm_Left");

        var armLeftFront = playerComponents.transform.Find("Arm_L_Front").GetComponent <SkinnedMeshRenderer>();

        armLeftFront.material = customCharacter.leftArm_front;

        var armLeftMain = playerComponents.transform.Find("Arm_L_Main").GetComponent <SkinnedMeshRenderer>();

        armLeftMain.material = customCharacter.leftArm_main;

        playerComponents = minifigComponent.transform.Find("Arm_Right");

        var armRightFront = playerComponents.transform.Find("Arm_R_Front").GetComponent <SkinnedMeshRenderer>();

        armRightFront.material = customCharacter.leftArm_front;

        var armRightMain = playerComponents.transform.Find("Arm_R_Main").GetComponent <SkinnedMeshRenderer>();

        armRightMain.material = customCharacter.leftArm_main;

        //Hands
        var handLeft = minifigComponent.transform.Find("Hand_Left").GetComponent <SkinnedMeshRenderer>();

        handLeft.material = customCharacter.left_hand;

        var handRight = minifigComponent.transform.Find("Hand_Right").GetComponent <SkinnedMeshRenderer>();

        handRight.material = customCharacter.right_hand;

        //Hips
        playerComponents = minifigComponent.transform.Find("Hip");

        var hipCrotch = playerComponents.transform.Find("Hip_Crotch").GetComponent <SkinnedMeshRenderer>();

        hipCrotch.material = customCharacter.hip_crotch;

        var hipFront = playerComponents.transform.Find("Hip_Front").GetComponent <SkinnedMeshRenderer>();

        hipFront.material = customCharacter.hip_front;

        var hipMain = playerComponents.transform.Find("Hip_Main").GetComponent <SkinnedMeshRenderer>();

        hipMain.material = customCharacter.hip_main;

        //Legs
        //Left
        playerComponents = minifigComponent.transform.Find("Leg_Left");

        var legLeftFront = playerComponents.transform.Find("Leg_L_Front").GetComponent <SkinnedMeshRenderer>();

        legLeftFront.material = customCharacter.leftleg_front;

        var legLeftSide = playerComponents.transform.Find("Leg_L_Side").GetComponent <SkinnedMeshRenderer>();

        legLeftSide.material = customCharacter.leftleg_side;

        var legLeftMain = playerComponents.transform.Find("Leg_L_Main").GetComponent <SkinnedMeshRenderer>();

        legLeftMain.material = customCharacter.leftleg_main;

        //Left Foot
        var legLeftFoot = playerComponents.transform.Find("Leg_L_Foot").GetComponent <SkinnedMeshRenderer>();

        legLeftFoot.material = customCharacter.left_foot;


        //Right
        playerComponents = minifigComponent.transform.Find("Leg_Right");

        var rightLeftFront = playerComponents.transform.Find("Leg_R_Front").GetComponent <SkinnedMeshRenderer>();

        rightLeftFront.material = customCharacter.rightleg_front;

        var rightLeftSide = playerComponents.transform.Find("Leg_R_Side").GetComponent <SkinnedMeshRenderer>();

        rightLeftSide.material = customCharacter.rightleg_side;

        var rightLeftMain = playerComponents.transform.Find("Leg_R_Main").GetComponent <SkinnedMeshRenderer>();

        rightLeftMain.material = customCharacter.rightleg_main;

        //Right Foot
        var rightLeftFoot = playerComponents.transform.Find("Leg_R_Foot").GetComponent <SkinnedMeshRenderer>();

        rightLeftFoot.material = customCharacter.right_foot;
    }
 public static Sosig SpawnEnemy(SosigTemplate template, CustomCharacter character, Transform spawnLocation, TNHModifier_AIDifficulty difficulty, int IFF, bool isAssault, Vector3 pointOfInterest, bool allowAllWeapons)
 {
     return(SpawnEnemy(template, character, spawnLocation.position, spawnLocation.rotation, difficulty, IFF, isAssault, pointOfInterest, allowAllWeapons));
 }
Exemplo n.º 18
0
 public void WriteButtonSymbol(CustomCharacter character, ButtonSymbolPosition button)
 {
     WriteString(I2CUIDevice.StringForCharacter(character), 1, (byte)button);
 }
        public static Sosig SpawnEnemy(SosigTemplate template, CustomCharacter character, Vector3 spawnLocation, Quaternion spawnRotation, TNHModifier_AIDifficulty difficulty, int IFF, bool isAssault, Vector3 pointOfInterest, bool allowAllWeapons)
        {
            if (character.ForceAllAgentWeapons)
            {
                allowAllWeapons = true;
            }

            TNHTweakerLogger.Log("TNHTWEAKER -- Spawning sosig: " + template.SosigEnemyID, TNHTweakerLogger.LogType.TNH);

            //Create the sosig object
            GameObject sosigPrefab    = UnityEngine.Object.Instantiate(IM.OD[template.SosigPrefabs.GetRandom <string>()].GetGameObject(), spawnLocation, spawnRotation);
            Sosig      sosigComponent = sosigPrefab.GetComponentInChildren <Sosig>();

            //Fill out the sosigs config based on the difficulty
            SosigConfig config;

            if (difficulty == TNHModifier_AIDifficulty.Arcade && template.ConfigsEasy.Count > 0)
            {
                config = template.ConfigsEasy.GetRandom <SosigConfig>();
            }
            else if (template.Configs.Count > 0)
            {
                config = template.Configs.GetRandom <SosigConfig>();
            }
            else
            {
                TNHTweakerLogger.LogError("TNHTweaker -- Sosig did not have normal difficulty config when playing on normal difficulty! Not spawning this enemy!");
                return(null);
            }

            sosigComponent.Configure(config.GetConfigTemplate());
            sosigComponent.SetIFF(IFF);

            //Setup the sosigs inventory
            sosigComponent.Inventory.Init();
            sosigComponent.Inventory.FillAllAmmo();
            sosigComponent.InitHands();

            //Equip the sosigs weapons
            if (template.WeaponOptions.Count > 0)
            {
                GameObject weaponPrefab = IM.OD[template.WeaponOptions.GetRandom <string>()].GetGameObject();
                EquipSosigWeapon(sosigComponent, weaponPrefab, difficulty);
            }

            if (template.WeaponOptionsSecondary.Count > 0 && allowAllWeapons && template.SecondaryChance >= UnityEngine.Random.value)
            {
                GameObject weaponPrefab = IM.OD[template.WeaponOptionsSecondary.GetRandom <string>()].GetGameObject();
                EquipSosigWeapon(sosigComponent, weaponPrefab, difficulty);
            }

            if (template.WeaponOptionsTertiary.Count > 0 && allowAllWeapons && template.TertiaryChance >= UnityEngine.Random.value)
            {
                GameObject weaponPrefab = IM.OD[template.WeaponOptionsTertiary.GetRandom <string>()].GetGameObject();
                EquipSosigWeapon(sosigComponent, weaponPrefab, difficulty);
            }

            //Equip clothing to the sosig
            OutfitConfig outfitConfig = template.OutfitConfigs.GetRandom <OutfitConfig>();

            if (outfitConfig.Chance_Headwear >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Headwear, sosigComponent.Links[0], outfitConfig.ForceWearAllHead);
            }

            if (outfitConfig.Chance_Facewear >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Facewear, sosigComponent.Links[0], outfitConfig.ForceWearAllFace);
            }

            if (outfitConfig.Chance_Eyewear >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Eyewear, sosigComponent.Links[0], outfitConfig.ForceWearAllEye);
            }

            if (outfitConfig.Chance_Torsowear >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Torsowear, sosigComponent.Links[1], outfitConfig.ForceWearAllTorso);
            }

            if (outfitConfig.Chance_Pantswear >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Pantswear, sosigComponent.Links[2], outfitConfig.ForceWearAllPants);
            }

            if (outfitConfig.Chance_Pantswear_Lower >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Pantswear_Lower, sosigComponent.Links[3], outfitConfig.ForceWearAllPantsLower);
            }

            if (outfitConfig.Chance_Backpacks >= UnityEngine.Random.value)
            {
                EquipSosigClothing(outfitConfig.Backpacks, sosigComponent.Links[1], outfitConfig.ForceWearAllBackpacks);
            }


            //Setup the sosigs orders
            if (isAssault)
            {
                sosigComponent.CurrentOrder  = Sosig.SosigOrder.Assault;
                sosigComponent.FallbackOrder = Sosig.SosigOrder.Assault;
                sosigComponent.CommandAssaultPoint(pointOfInterest);
            }
            else
            {
                sosigComponent.CurrentOrder  = Sosig.SosigOrder.Wander;
                sosigComponent.FallbackOrder = Sosig.SosigOrder.Wander;
                sosigComponent.CommandGuardPoint(pointOfInterest, true);
                sosigComponent.SetDominantGuardDirection(UnityEngine.Random.onUnitSphere);
            }
            sosigComponent.SetGuardInvestigateDistanceThreshold(25f);

            //Handle sosig dropping custom loot
            if (UnityEngine.Random.value < template.DroppedLootChance && template.DroppedObjectPool != null)
            {
                SosigLinkLootWrapper component = sosigComponent.Links[2].gameObject.AddComponent <SosigLinkLootWrapper>();
                component.shouldDropOnCleanup = !character.DisableCleanupSosigDrops;
                component.group = template.DroppedObjectPool;
            }

            return(sosigComponent);
        }
Exemplo n.º 20
0
    //Creates a custom player with the current selections
    private void SavePlayerCustomization()
    {
        //Create new blueprint for customization
        CustomCharacter player = new CustomCharacter();

        //Head
        //Hair
        GameObject hair       = GameObject.Find("Hair");
        ChangeHair hairScript = hair.GetComponent <ChangeHair>();

        player.hair = hairScript.GetCurrentSelection();

        //Hat
        GameObject  hat       = GameObject.Find("Hats");
        Accessories hatScript = hat.GetComponent <Accessories>();

        player.hat = hatScript.GetCurrentSelection();

        //Hat-hair color
        GameObject       haircolor       = GameObject.Find("Hair-/HatColor");
        ChangeHairColour haircolorScript = haircolor.GetComponent <ChangeHairColour>();

        player.hairColor = haircolorScript.GetCurrentSelection();

        //Face
        GameObject faces      = GameObject.Find("FaceGesture");
        ChangeFace faceScript = faces.GetComponent <ChangeFace>();

        player.face = faceScript.GetCurrentSelection();

        //Face tone
        GameObject     faceTone       = GameObject.Find("FaceTone");
        ChangeFaceTone faceToneScript = faceTone.GetComponent <ChangeFaceTone>();

        player.faceTone = faceToneScript.GetCurrentSelection();

        //Upper body
        GameObject      upperBody       = GameObject.Find("UpperBody");
        ChangeUpperBody upperBodyScript = upperBody.GetComponent <ChangeUpperBody>();

        player.upperBody_front = upperBodyScript.GetCurrentSelection(ChangeUpperBody.UpperBodyOptions.TorsoFront);
        player.upperBody_back  = upperBodyScript.GetCurrentSelection(ChangeUpperBody.UpperBodyOptions.TorsoBack);
        player.upperBody_main  = upperBodyScript.GetCurrentSelection(ChangeUpperBody.UpperBodyOptions.TorsoMain);

        //Arms
        GameObject arms       = GameObject.Find("Arms");
        ChangeArms armsScript = arms.GetComponent <ChangeArms>();

        player.leftArm_front  = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.LeftArmFront);
        player.leftArm_main   = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.LeftArmMain);
        player.rightArm_front = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.RightArmFront);
        player.rightArm_main  = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.RightArmMain);

        //Hands
        GameObject  hands       = GameObject.Find("Hands");
        ChangeHands handsScript = hands.GetComponent <ChangeHands>();

        player.left_hand  = handsScript.GetCurrentSelection(ChangeHands.HandOptions.LeftHand);
        player.right_hand = handsScript.GetCurrentSelection(ChangeHands.HandOptions.RighHand);

        //Hips
        GameObject hip       = GameObject.Find("HipSelection");
        ChangeHip  hipScript = hip.GetComponent <ChangeHip>();

        player.hip_crotch = hipScript.GetCurrentSelection(ChangeHip.HipOptions.HipCrotch);
        player.hip_front  = hipScript.GetCurrentSelection(ChangeHip.HipOptions.HipFront);
        player.hip_main   = hipScript.GetCurrentSelection(ChangeHip.HipOptions.HipMain);

        //Legs
        GameObject legs       = GameObject.Find("Legs");
        ChangeLegs legsScript = legs.GetComponent <ChangeLegs>();

        player.leftleg_front = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.LeftLegFront);
        player.leftleg_side  = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.LeftLegSide);
        player.leftleg_main  = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.LeftLegMain);

        player.rightleg_front = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.RightLegFront);
        player.rightleg_side  = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.RightLegSide);
        player.rightleg_main  = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.RightLegMain);

        //Feet
        GameObject feet       = GameObject.Find("Feet");
        ChangeFeet feetScript = feet.GetComponent <ChangeFeet>();

        player.right_foot = feetScript.GetCurrentSelection(ChangeFeet.FeetOptions.RightFoot);
        player.left_foot  = feetScript.GetCurrentSelection(ChangeFeet.FeetOptions.LeftFoot);

        player.playerId = characterIndex;

        //Save character into InputManager
        InputManager.Instance.SaveCustomCharacter(player);
    }
        public static bool GenerateValidPatrolReplacement(TNH_PatrolChallenge P, int curStandardIndex, int excludeHoldIndex, bool isStart, TNH_Manager __instance, TNH_Progression.Level ___m_curLevel, List <TNH_Manager.SosigPatrolSquad> ___m_patrolSquads, ref float ___m_timeTilPatrolCanSpawn)
        {
            TNHTweakerLogger.Log("TNHTWEAKER -- Generating a patrol -- There are currently " + ___m_patrolSquads.Count + " patrols active", TNHTweakerLogger.LogType.TNH);

            if (P.Patrols.Count < 1)
            {
                return(false);
            }

            CustomCharacter character = LoadedTemplateManager.LoadedCharactersDict[__instance.C];
            Level           currLevel = character.GetCurrentLevel(__instance.m_curLevel);

            //Get a valid patrol index, and exit if there are no valid patrols
            int patrolIndex = GetValidPatrolIndex(currLevel.Patrols);

            if (patrolIndex == -1)
            {
                TNHTweakerLogger.Log("TNHTWEAKER -- No valid patrols can spawn", TNHTweakerLogger.LogType.TNH);
                ___m_timeTilPatrolCanSpawn = 999;
                return(false);
            }

            TNHTweakerLogger.Log("TNHTWEAKER -- Valid patrol found", TNHTweakerLogger.LogType.TNH);

            Patrol patrol = currLevel.Patrols[patrolIndex];

            List <int> validLocations = new List <int>();
            float      minDist        = __instance.TAHReticle.Range * 1.2f;

            //Get a safe starting point for the patrol to spawn
            TNH_SafePositionMatrix.PositionEntry startingEntry;
            if (isStart)
            {
                startingEntry = __instance.SafePosMatrix.Entries_SupplyPoints[curStandardIndex];
            }
            else
            {
                startingEntry = __instance.SafePosMatrix.Entries_HoldPoints[curStandardIndex];
            }


            for (int i = 0; i < startingEntry.SafePositions_HoldPoints.Count; i++)
            {
                if (i != excludeHoldIndex && startingEntry.SafePositions_HoldPoints[i])
                {
                    float playerDist = Vector3.Distance(GM.CurrentPlayerBody.transform.position, __instance.HoldPoints[i].transform.position);
                    if (playerDist > minDist)
                    {
                        validLocations.Add(i);
                    }
                }
            }


            if (validLocations.Count < 1)
            {
                return(false);
            }
            validLocations.Shuffle();

            TNH_Manager.SosigPatrolSquad squad = GeneratePatrol(validLocations[0], __instance, patrol, patrolIndex);
            ___m_patrolSquads.Add(squad);

            if (__instance.EquipmentMode == TNHSetting_EquipmentMode.Spawnlocking)
            {
                ___m_timeTilPatrolCanSpawn = patrol.PatrolCadence;
            }
            else
            {
                ___m_timeTilPatrolCanSpawn = patrol.PatrolCadenceLimited;
            }

            return(false);
        }