Beispiel #1
0
 public void AddInstance(Run.FixedTimeStamp time, HitlagInstance instance)
 {
     instanceLists.Add(time, instance);
 }
Beispiel #2
0
        private void StoreDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            //TODO: all of these has to make sure if 1. player is alive 2. player is not teleporting 3. player has a item 4. player has a hc
            var InventoryCount = GetCount(self.body);
            var hcGameObject   = self.gameObject;
            var hcHitManager   = hcGameObject.GetComponentInChildren <HitlagManager>()?.gameObject; //check if the component exists or not

            if (InventoryCount <= 0)
            {
                if (hcHitManager)
                {
#if DEBUG
                    TurboEdition._logger.LogWarning(ItemName + " HLM was created, but user lost all items, storeForgiveness is: " + storeForgiveness);
#endif
                    if (!storeForgiveness)
                    {
                        hcGameObject.GetComponentInChildren <HitlagManager>().ReleaseAll(true);
                        return;
                    }
                    hcGameObject.GetComponentInChildren <HitlagManager>().CleanseAll(true);
                    //UnityEngine.Object.Destroy(hcHitManager);
                }
            }
            else
            {
                if (!hcHitManager && self) //creates a manager if user has item and a hc
                {
                    hcHitManager = UnityEngine.Object.Instantiate(hitManager);
                    hcHitManager.GetComponent <NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(self.gameObject);
                    //hcGameObject.GetComponent<HitlagManager>().NetMaxCapacity = storeMaxCapacity;
#if DEBUG
                    TurboEdition._logger.LogWarning(ItemName + " No HLM created, creating one with capacity: " + storeMaxCapacity);
#endif
                }

                if (hcHitManager && self && damageInfo.damage > 0)
                {
#if DEBUG
                    TurboEdition._logger.LogWarning(ItemName + " Theres a HLM, so we are going to delay " + damageInfo.damage + " of damage.");
#endif
                    if (damageInfo.damageType == DamageType.FallDamage && !storesFall)
                    {
#if DEBUG
                        TurboEdition._logger.LogWarning(ItemName + " Damage type was " + damageInfo.damageType + " but storesFall config is " + storesFall);
#endif
                        orig(self, damageInfo);
                        return;
                    }
                    if (damageInfo.dotIndex != DotController.DotIndex.None && !storesDoTs)
                    {
#if DEBUG
                        TurboEdition._logger.LogWarning(ItemName + " Damage type was " + damageInfo.damageType + " but storesDoTs config is " + storesDoTs);
#endif
                        orig(self, damageInfo);
                        return;
                    }
                    //We update the manager with the new delay
                    //This is different to the original idea where each instance of damage would have its own release time based on item count of when the damage was taken. i.e if user gets damaged at 5 delay, loses an item, all delayed damage will be released earlier
                    hcHitManager.GetComponent <HitlagManager>().NetTimeToReleaseAt = (hitlagInitial + (InventoryCount - 1) * hitlagStack);
#if DEBUG
                    TurboEdition._logger.LogWarning(ItemName + " Updated " + hcHitManager + " to have delay of " + (hitlagInitial + (InventoryCount - 1) * hitlagStack));
#endif
                    //We define a new instance
                    var hitInstance = new HitlagInstance
                    {
                        //I wonder if its better to pass these as arguments than doing this, desu.
                        CmpOrig = orig,
                        CmpSelf = self,
                        CmpDI   = damageInfo
                    };
#if DEBUG
                    TurboEdition._logger.LogWarning(ItemName + " Creating a new " + hitInstance);
#endif
                    var component = hcGameObject.GetComponentInChildren <HitlagManager>();
                    component.AddInstance(Run.FixedTimeStamp.now, hitInstance);
                    component.NetTotalDamage += hitInstance.CmpDI.damage;
#if DEBUG
                    TurboEdition._logger.LogWarning(ItemName + " Added it to the list with timestamp " + Run.FixedTimeStamp.now);
#endif
                    return;
                }
#if DEBUG
                TurboEdition._logger.LogWarning(ItemName + " Didn't delay any damage, calling orig.");
#endif
            }
            orig(self, damageInfo);
        }