Skip to content

Commit

Permalink
1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
theLeaxx committed Dec 25, 2024
1 parent 28aa694 commit 0720dad
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions DeliveryJob/DeliveryJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DeliveryJob : Mod
public override string ModName => "Delivery Job";
public override string ModAuthor => "Leaxx";
public override string ModDescription => "Adds a fun side activity involving picking up & dropping off boxes to various houses in other cities!";
public override string ModVersion => "1.1";
public override string ModVersion => "1.2";
public override string GitHubLink => "https://github.com/Jalopy-Mods/DeliveryJob";
public override WhenToInit WhenToInit => WhenToInit.InGame;
public override List<(string, string, string)> Dependencies => new List<(string, string, string)>()
Expand Down Expand Up @@ -85,6 +85,9 @@ private void PrePopulateDictionary()

private void StartChangesDelay(string startLocation, string endLocation, int distance)
{
if (!gameObject.activeSelf)
return;

if(endLocation == "Berlin")
return;

Expand Down Expand Up @@ -677,7 +680,10 @@ public override void OnDisable()

public void LoadData()
{
if(SceneManager.GetActiveScene().buildIndex != 3)
if (!gameObject.activeSelf)
return;

if (SceneManager.GetActiveScene().buildIndex != 3)
return;

saveData.Clear();
Expand Down Expand Up @@ -731,7 +737,10 @@ public void LoadData()

public void SaveAll()
{
if(saveData.Count == 0)
if (!gameObject.activeSelf)
return;

if (saveData.Count == 0)
return;

if (!Directory.Exists(Path.Combine(Application.persistentDataPath, @"DeliveryJob")))
Expand Down Expand Up @@ -779,19 +788,24 @@ void Awake()

private void Save()
{
var objPickupC = GetComponent<ObjectPickupC>();

if(objPickupC == null)
if(gameObject?.GetComponent<ObjectPickupC>() == null)
return;

if(objPickupC.inventoryPlacedAt == null)
var objPickupC = gameObject.GetComponent<ObjectPickupC>();

if (objPickupC.inventoryPlacedAt == null)
return;

var deliveryJob = FindObjectOfType<DeliveryJob.DeliveryJob>();

deliveryJob?.saveData.Add(objPickupC.inventoryPlacedAt.localPosition, DeliveryBoxSave.TupleToString((pay, houseNumber, city)));
}

public void UnSubscribeEvent()
{
EventsManager.Instance.OnCustomObjectsSaved -= Save;
}

private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.GetComponent<DropoffZoneData>())
Expand Down Expand Up @@ -833,6 +847,7 @@ public void CompleteDelivery(DeliveryBoxData box)
if (alreadyDeliveredBoxes.Contains(box))
return;

box.UnSubscribeEvent();
box.GetComponent<ObjectPickupC>().glowMaterial = box.GetComponent<ObjectPickupC>().startMaterial;
FindObjectOfType<WalletC>().TotalWealth += box.pay;
FindObjectOfType<WalletC>().UpdateWealth();
Expand Down

0 comments on commit 0720dad

Please sign in to comment.