update to 3.0.0

This commit is contained in:
SamSWAT 2022-06-26 18:50:55 +03:00
parent 5487b01900
commit 6f42748d06
3 changed files with 24 additions and 15 deletions

View File

@ -1,6 +1,7 @@
using EFT.Interactive;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;
@ -41,6 +42,12 @@ namespace SamSWAT.HeliCrash
Choppa = assetLoadRequest.allAssets[0] as GameObject;
if (Choppa == null)
{
Debug.LogError("[SamSWAT.HeliCrash]: failed to load asset");
return;
}
HeliLocation = HeliCrashLocation();
Choppa = Instantiate(Choppa, HeliLocation.Position, Quaternion.Euler(HeliLocation.Rotation));
UH60Bundle.Unload(false);
@ -54,7 +61,9 @@ namespace SamSWAT.HeliCrash
airdropcrates.Add(crate.GetComponentInChildren<LootableContainer>());
}
ChoppaContainer.ItemOwner = PickRandom(airdropcrates).ItemOwner;
FieldInfo itemOwner = typeof(LootableContainer).GetField("ItemOwner");
object items = itemOwner.GetValue(PickRandom(airdropcrates));
itemOwner.SetValue(ChoppaContainer, items);
//fpscamera = GameObject.Find("FPS Camera");
}
@ -64,31 +73,31 @@ namespace SamSWAT.HeliCrash
{
case "bigmap":
{
return PickRandom(Plugin.heliCrashSites.Customs);
return PickRandom(Plugin.HeliCrashLocations.Customs);
}
case "Interchange":
{
return PickRandom(Plugin.heliCrashSites.Interchange);
return PickRandom(Plugin.HeliCrashLocations.Interchange);
}
case "RezervBase":
{
return PickRandom(Plugin.heliCrashSites.Rezerv);
return PickRandom(Plugin.HeliCrashLocations.Rezerv);
}
case "Shoreline":
{
return PickRandom(Plugin.heliCrashSites.Shoreline);
return PickRandom(Plugin.HeliCrashLocations.Shoreline);
}
case "Woods":
{
return PickRandom(Plugin.heliCrashSites.Woods);
return PickRandom(Plugin.HeliCrashLocations.Woods);
}
case "Lighthouse":
{
return PickRandom(Plugin.heliCrashSites.Lighthouse);
return PickRandom(Plugin.HeliCrashLocations.Lighthouse);
}
case "develop":
{
return PickRandom(Plugin.heliCrashSites.Develop);
return PickRandom(Plugin.HeliCrashLocations.Develop);
}
default: return new Location();
}

View File

@ -18,12 +18,12 @@ namespace SamSWAT.HeliCrash
public static void PatchPostFix()
{
var gameWorld = Singleton<GameWorld>.Instance;
var points = LocationScene.GetAll<AirdropPoint>().Any();
var location = gameWorld.RegisteredPlayers[0].Location;
var crashAvailable = LocationScene.GetAll<AirdropPoint>().Any();
string location = gameWorld.RegisteredPlayers[0].Location;
if (gameWorld != null && points && WillHeliCrash())
if (gameWorld != null && crashAvailable && WillHeliCrash())
{
var heliCrash = gameWorld.gameObject.GetOrAddComponent<HeliCrash>();
var heliCrash = gameWorld.gameObject.AddComponent<HeliCrash>();
heliCrash.Init(location);
}
}

View File

@ -5,11 +5,11 @@ using System.IO;
namespace SamSWAT.HeliCrash
{
[BepInPlugin("com.SamSWAT.HeliCrash", "SamSWAT.HeliCrash", "1.0.0")]
[BepInPlugin("com.SamSWAT.HeliCrash", "SamSWAT.HeliCrash", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
public static HeliCrashLocations HeliCrashLocations;
internal static string Directory;
public static HeliCrashLocations heliCrashSites;
internal static ConfigEntry<int> HeliCrashChance;
private void Awake()
@ -17,7 +17,7 @@ namespace SamSWAT.HeliCrash
Directory = Path.Combine(BepInEx.Paths.PluginPath, "SamSWAT.HeliCrash/").Replace("\\", "/");
new HeliCrashPatch().Enable();
var json = new StreamReader(Directory + "HeliCrashLocations.json").ReadToEnd();
heliCrashSites = JsonConvert.DeserializeObject<HeliCrashLocations>(json);
HeliCrashLocations = JsonConvert.DeserializeObject<HeliCrashLocations>(json);
HeliCrashChance = Config.Bind(
"Main Settings",