예제 #1
0
        public static void Postfix(Ammo __instance, bool __result, Identifiable.Id id, Identifiable identifiable,
                                   int slotIdx, int count, bool overflow)
        {
            if (!__result)
            {
                return;
            }

            if (AmmoIdentifier.TryGetIdentifier(__instance, out var identifier))
            {
                if (identifiable && ExtendedData.IsRegistered(identifiable.gameObject))
                {
                    var ammo = PersistentAmmoManager.GetPersistentAmmoForAmmo(__instance.ammoModel);
                    for (int i = 0; i < count; i++)
                    {
                        ammo.DataModel.slots[slotIdx]
                        .PushTop(ExtendedData.extendedActorData[identifiable.GetActorId()]);
                    }
                }
                else
                {
                    if (!PersistentAmmoManager.HasPersistentAmmo(identifier))
                    {
                        return;
                    }
                    var ammo = PersistentAmmoManager.PersistentAmmoData[identifier];
                    for (int i = 0; i < count; i++)
                    {
                        ammo.DataModel.slots[slotIdx].PushTop(null);
                    }
                }
            }
        }
예제 #2
0
        public static void Prefix(GameModel __instance, long actorId, GameObject gameObj, bool skipNotify)
        {
            var potentialTag = PersistentAmmoManager.GetPotentialDataTag(gameObj);

            if (potentialTag != null)
            {
                ExtendedData.extendedActorData[actorId] = potentialTag;
            }
        }
예제 #3
0
 public static void Postfix(Ammo __instance, int amount)
 {
     if (AmmoIdentifier.TryGetIdentifier(__instance, out var identifier))
     {
         if (PersistentAmmoManager.HasPersistentAmmo(identifier))
         {
             PersistentAmmoManager.OnAmmoDecrement(identifier, __instance.selectedAmmoIdx, amount);
         }
     }
 }
예제 #4
0
        public static void Prefix(GameModel __instance, long actorId, GameObject gameObj, bool skipNotify)
        {
            var potentialTag = PersistentAmmoManager.GetPotentialDataTag(gameObj);

            if (potentialTag != null)
            {
                ExtendedData.preparedData[DataIdentifier.GetActorIdentifier(actorId)] = new ExtendedData.PreparedData()
                {
                    SourceType = ExtendedData.PreparedData.PreparationSource.AMMO, Data = potentialTag
                };
            }
        }
예제 #5
0
 public static void Postfix(Ammo __instance, int idx, bool __result)
 {
     if (idx < __instance.ammoModel.usableSlots)
     {
         if (AmmoIdentifier.TryGetIdentifier(__instance, out var identifier))
         {
             if (PersistentAmmoManager.HasPersistentAmmo(identifier))
             {
                 PersistentAmmoManager.PersistentAmmoData[identifier].OnSelected(__instance.GetSelectedId(), __instance.selectedAmmoIdx);
             }
         }
     }
 }
예제 #6
0
        public static void Postfix(Ammo __instance, GameObject __result)
        {
            if (!__result)
            {
                return;
            }

            if ((new StackFrame(2)).GetMethod().DeclaringType == typeof(VacColorAnimator))
            {
                return;
            }

            if (AmmoIdentifier.TryGetIdentifier(__instance, out var identifier))
            {
                if (PersistentAmmoManager.HasPersistentAmmo(identifier))
                {
                    PersistentAmmoManager.PersistentAmmoData[identifier].OnSelected(Identifiable.GetId(__result), __instance.selectedAmmoIdx);
                }
            }
        }
예제 #7
0
        public static void Postfix(Ammo __instance, bool __result, Identifiable.Id id, Identifiable identifiable)
        {
            if (!__result)
            {
                return;
            }

            if (AmmoIdentifier.TryGetIdentifier(__instance, out var identifier))
            {
                var count = -1;
                for (int i = 0; i < __instance.Slots.Length; i++)
                {
                    if (__instance.Slots[i]?.id == id)
                    {
                        count = i;
                        break;
                    }
                }

                if (count == -1)
                {
                    throw new Exception();
                }
                if (identifiable && ExtendedData.HasExtendedData(identifiable.gameObject))
                {
                    var ammo = PersistentAmmoManager.GetPersistentAmmoForAmmo(__instance.ammoModel);
                    ammo.DataModel.slots[count].PushTop(ExtendedData.ReadDataFromGameObject(identifiable.gameObject));
                    ammo.Sync();
                }
                else
                {
                    if (!PersistentAmmoManager.HasPersistentAmmo(identifier))
                    {
                        return;
                    }
                    var ammo = PersistentAmmoManager.GetPersistentAmmoForAmmo(__instance.ammoModel);
                    ammo.DataModel.slots[count].PushTop(null);
                    ammo.Sync();
                }
            }
        }
예제 #8
0
        public static void Postfix(Ammo __instance, bool __result, Identifiable.Id id, Identifiable identifiable,
                                   int slotIdx, int count, bool overflow)
        {
            if (!__result)
            {
                return;
            }

            if (AmmoIdentifier.TryGetIdentifier(__instance, out var identifier))
            {
                if (identifiable && ExtendedData.HasExtendedData(identifiable.gameObject))
                {
                    var ammo = PersistentAmmoManager.GetPersistentAmmoForAmmo(__instance.ammoModel);
                    if (ammo == null)
                    {
                        return;
                    }
                    for (int i = 0; i < count; i++)
                    {
                        ammo.DataModel.slots[slotIdx]
                        .PushTop(ExtendedData.ReadDataFromGameObject(identifiable.gameObject));
                    }
                    ammo.Sync();
                }
                else
                {
                    if (!PersistentAmmoManager.HasPersistentAmmo(identifier))
                    {
                        return;
                    }
                    var ammo = PersistentAmmoManager.PersistentAmmoData[identifier];
                    for (int i = 0; i < count; i++)
                    {
                        ammo.DataModel.slots[slotIdx].PushTop(null);
                    }
                    ammo.Sync();
                }
            }
        }
예제 #9
0
 public static void Postfix(GameModel gameModel)
 {
     //ExtendedData.CullIfNotValid(gameModel);
     PersistentAmmoManager.SyncAll();
 }