Esempio n. 1
0
 public static E TriggerADSR(double t0, double e0, double attack, double decay, Amplitude sustainLevel, double sustainDuration, double release)
 => (t)
 => !HasElapsed(t0, t, attack) ? Attack(t0, e0, attack)(t)
             : !HasElapsed(t0 + attack, t, decay) ? Decay(t0 + attack, e0, decay, sustainLevel)(t)
             : !HasElapsed(t0 + attack + decay, t, sustainDuration) ? Sustain(sustainLevel)(t)
             : !HasElapsed(t0 + attack + decay + sustainDuration, t, release) ? Release(t0 + attack + decay + sustainDuration, Normalize(sustainLevel), release)(t)
             : Mute()(t);
Esempio n. 2
0
        public async Task <ActionResult> Save(DecayViewModel model)
        {
            using (DecayServiceClient client = new DecayServiceClient())
            {
                Decay obj = new Decay()
                {
                    Key = new DecayKey()
                    {
                        Code   = model.Code.ToUpper(),
                        Object = model.Object
                    },
                    Type        = model.Type,
                    Value       = model.Value ?? 0,
                    Description = model.Description,
                    IsUsed      = model.IsUsed,
                    Editor      = User.Identity.Name,
                    EditTime    = DateTime.Now,
                    CreateTime  = DateTime.Now,
                    Creator     = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(ZPVMResources.StringResource.Decay_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
        private void ResolveDecays(AdministrationToolViewModel viewModel)
        {
            var cleanup = new List <Guid>();

            foreach (var child in _contentLoader.Get <PageData>(ContentReference.StartPage).GetDescendants(2))
            {
                if (child is ISearchConfigurableParent)
                {
                    var decay = new Decay(child.ContentGuid);
                    cleanup.Add(child.ContentGuid);

                    _decayRepository.CreateIfNotExisting(decay, m => m.ContentGuid == decay.ContentGuid);
                }
            }

            foreach (var decay in _decayRepository.ReadAll())
            {
                if (!cleanup.Contains(decay.ContentGuid))
                {
                    _decayRepository.Delete(decay);
                    continue;
                }

                viewModel.Decays.Add(new AdministrationToolViewModel.DecayViewModel
                {
                    Model      = decay,
                    Name       = ResolveContentName(decay.ContentGuid),
                    Breadcrumb = ResolveBreadcrumb(decay.ContentGuid)
                });
            }
        }
Esempio n. 4
0
 /// <summary>Convert this isotope to another.</summary>
 /// <param name="decayModeBitflag">Bitflag of an isotope mutation.</param>
 /// <param name="nucleonCount">Nucleon count (<em>A</em>) of the product.</param>
 /// <returns>Proton count (<em>Z</em>) of the product. The number of nucleons of the product is returned in <b>nucleonCount</b>.</returns>
 public int Transmute(Decay decayModeBitflag, out int nucleonCount)
 {
     nucleonCount = A;
     if (decayModeBitflag == Decay.Alpha)
     {
         nucleonCount -= 4;
         return(Z - 2);
     }
     else if (decayModeBitflag == Decay.ECap2)
     {
         return(Z - 2);
     }
     else if (decayModeBitflag == Decay.BetaPlus || decayModeBitflag == Decay.ECap1)
     {
         return(Z - 1);
     }
     else if (decayModeBitflag == Decay.BetaMinus)
     {
         return(Z + 1);
     }
     else if (decayModeBitflag == Decay.Beta2)
     {
         return(Z + 2);
     }
     else if (decayModeBitflag == Decay.NEmit)
     {
         --nucleonCount;
     }
     return(Z);
 }
Esempio n. 5
0
    protected override void Activate(Drip drip, PlayerController player)
    {
        Decay decay = Instantiate(shield_, player.transform.position, Util.LookAt(Camera.main.ScreenToWorldPoint(Input.mousePosition) - player.transform.position))
                      .AddComponent <Decay>();

        decay.decay_               = 0.1f;
        decay.renderer_            = decay.GetComponentInChildren <SpriteRenderer>();
        decay.transform.localScale = Vector3.one * 2;
    }
Esempio n. 6
0
    private void Place(Vector3 pos, Vector2 dir)
    {
        Decay decay = Instantiate(shield_, pos, Util.LookAt(dir))
                      .AddComponent <Decay>();

        decay.decay_               = 0.1f;
        decay.renderer_            = decay.GetComponentInChildren <SpriteRenderer>();
        decay.transform.localScale = Vector3.one * 2;
    }
Esempio n. 7
0
        /// <summary>
        /// Creates a new E-greedy selection policy
        /// </summary>
        /// <param name="epsilon">The probability that a random action will be selected</param>
        /// <param name="random">The random generator</param>
        /// <param name="decayFn">The decay function for epsilon. If null, epsilon is not decayed.</param>
        public EGreedy(double epsilon, Random random, Decay decayFn = null)
        {
            if (epsilon < 0)
            {
                throw new ArgumentException("Expected epsilon to be >= 0.", "epsilon");
            }

            this.epsilon = epsilon;
            this.random  = random;
            this.decayFn = decayFn;
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a new Softmax selection policy
        /// </summary>
        /// <param name="tau">The temperature</param>
        /// <param name="random">The random generator</param>
        /// <param name="decayFn">The decay function for epsilon. If null, epsilon is not decayed.</param>
        public Softmax(double tau, Random random, Decay decayFn = null)
        {
            if (tau < 0)
            {
                throw new ArgumentException("Expected tau to be >= 0.", "tau");
            }

            this.tau     = tau;
            this.random  = random;
            this.decayFn = decayFn;
        }
Esempio n. 9
0
        object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hit)
        {
            if (entity == null || hit == null)
            {
                return(null);
            }

            object externalResult = Interface.CallHook("CanEntityTakeDamage", new object[] { entity, hit });

            if (externalResult != null)
            {
                if ((bool)externalResult == false)
                {
                    return(false);
                }

                return(null);
            }

            if (hit.damageTypes.Has(Rust.DamageType.Decay))
            {
                return(Decay.AlterDecayDamage(entity, hit));
            }

            User attacker = null;
            User defender = entity.GetComponent <User>();

            if (hit.InitiatorPlayer != null)
            {
                attacker = hit.InitiatorPlayer.GetComponent <User>();
            }

            // A player is being injured by something other than a player/NPC.
            if (attacker == null && defender != null)
            {
                return(Pvp.HandleIncidentalDamage(defender, hit));
            }

            // One player is damaging another player.
            if (attacker != null && defender != null)
            {
                return(Pvp.HandleDamageBetweenPlayers(attacker, defender, hit));
            }

            // A player is damaging a structure.
            if (attacker != null && defender == null)
            {
                return(Raiding.HandleDamageAgainstStructure(attacker, entity, hit));
            }

            // A structure is taking damage from something that isn't a player.
            return(Raiding.HandleIncidentalDamage(entity, hit));
        }
Esempio n. 10
0
    private void RPC_OpenDoor(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract())
        {
            return;
        }
        if (!this.canHandOpen)
        {
            return;
        }
        if (base.IsOpen())
        {
            return;
        }
        if (base.IsBusy())
        {
            return;
        }
        if (base.IsLocked())
        {
            return;
        }
        BaseLock slot = base.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (slot != null)
        {
            if (!slot.OnTryToOpen(rpc.player))
            {
                return;
            }
            if (slot.IsLocked() && UnityEngine.Time.realtimeSinceStartup - this.decayResetTimeLast > 60f)
            {
                BuildingBlock buildingBlock = base.FindLinkedEntity <BuildingBlock>();
                if (!buildingBlock)
                {
                    Decay.RadialDecayTouch(base.transform.position, 40f, 2097408);
                }
                else
                {
                    Decay.BuildingDecayTouch(buildingBlock);
                }
                this.decayResetTimeLast = UnityEngine.Time.realtimeSinceStartup;
            }
        }
        base.SetFlag(BaseEntity.Flags.Open, true, false, true);
        base.SendNetworkUpdateImmediate(false);
        if (this.isSecurityDoor && this.NavMeshLink != null)
        {
            this.SetNavMeshLinkEnabled(true);
        }
        Interface.CallHook("OnDoorOpened", this, rpc.player);
    }
Esempio n. 11
0
 public override void ServerInit()
 {
     base.ServerInit();
     decayVariance = UnityEngine.Random.Range(0.95f, 1f);
     decay         = PrefabAttribute.server.Find <Decay>(prefabID);
     decayPoints   = PrefabAttribute.server.FindAll <DecayPoint>(prefabID);
     upkeep        = PrefabAttribute.server.Find <Upkeep>(prefabID);
     BuildingManager.server.Add(this);
     if (!Rust.Application.isLoadingSave)
     {
         BuildingManager.server.CheckMerge(this);
     }
     lastDecayTick = UnityEngine.Time.time;
 }
Esempio n. 12
0
 public override void ServerInit()
 {
     base.ServerInit();
     this.decayVariance = Random.Range(0.95f, 1f);
     this.decay         = PrefabAttribute.server.Find <Decay>(this.prefabID);
     this.decayPoints   = PrefabAttribute.server.FindAll <DecayPoint>(this.prefabID);
     this.upkeep        = PrefabAttribute.server.Find <Upkeep>(this.prefabID);
     BuildingManager.server.Add(this);
     if (Application.isLoadingSave == null)
     {
         BuildingManager.server.CheckMerge(this);
     }
     this.lastDecayTick = Time.get_time();
 }
Esempio n. 13
0
        private void Update(EvaluationContext context)
        {
            var pointLights = context.PointLights;
            var light       = new PointLight(Position.GetValue(context),
                                             Intensity.GetValue(context),
                                             Color.GetValue(context),
                                             Range.GetValue(context),
                                             Decay.GetValue(context));

            pointLights.Push(light);

            Command.GetValue(context); // Evaluate sub-tree

            pointLights.Pop();
        }
Esempio n. 14
0
            void CheckCollisions()
            {
                foreach (Collider col in Physics.OverlapSphere(info.Location.GetPosition(), info.Location.GetRadius(), zoneMask))
                {
                    if (!buildingblocks.Contains(col))
                    {
                        buildingblocks.Add(col);
                        BaseCombatEntity basecombat = col.GetComponentInParent <BaseCombatEntity>();

                        ResourceDispenser baseresource = col.GetComponentInParent <ResourceDispenser>();
                        if (baseresource != null)
                        {
                            if (baseresource == null)
                            {
                                return;
                            }
                            if (resourceZones[baseresource] == null)
                            {
                                resourceZones[baseresource] = new List <Zone>();
                            }
                            if (!resourceZones[baseresource].Contains(this))
                            {
                                resourceZones[baseresource].Add(this);
                            }
                        }
                        else if (basecombat != null)
                        {
                            if (buildingZones[basecombat] == null)
                            {
                                buildingZones[basecombat] = new List <Zone>();
                            }
                            if (!buildingZones[basecombat].Contains(this))
                            {
                                buildingZones[basecombat].Add(this);
                            }
                        }
                        if (info.nodecay != null)
                        {
                            Decay decay = col.GetComponentInParent <Decay>();
                            if (decay != null)
                            {
                                GameObject.Destroy(col.GetComponentInParent <Decay>());
                            }
                        }
                    }
                }
            }
Esempio n. 15
0
    // Use this for initialization
    void Start()
    {
        Decay decayScript = this.GetComponent <Decay> ();

        if (decayScript != null)
        {
            decayScript.decaySeconds = decayTime;
        }

        if (hasRandomMovement)
        {
            this.gameObject.AddComponent <MoveInRandomDirection> ();
        }
        Image imageScript = this.GetComponent <Image> ();

        imageScript.sprite = spriteToUse;
    }
Esempio n. 16
0
    // Use this for initialization
    void Start()
    {
        Decay decay_script = this.GetComponent <Decay> ();

        if (decay_script != null)
        {
            decay_script.decay_sec = decay_time;
        }

        if (has_rdm_mov)
        {
            this.gameObject.AddComponent <MoveInRdmDir> ();
        }

        Image image_script = this.GetComponent <Image> ();

        image_script.sprite = sprite_to_use;
    }
Esempio n. 17
0
        // Door.RPC_CloseDoor()/RPC_OpenDoor()
        public static void On_DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open)
        {
            if ((open && door.IsOpen()) || (!open && !door.IsOpen()))
            {
                return;
            }

            DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open);

            OnNext("On_DoorUse", due);

            if (!due.Allow)
            {
                if (due.DenyReason != "")
                {
                    rpc.player.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), due.DenyReason));
                }
                return;
            }

            bool doaction = true;

            BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

            if (!due.IgnoreLock && baseLock != null)
            {
                doaction = open ? baseLock.OnTryToOpen(rpc.player) : baseLock.OnTryToClose(rpc.player);

                if (doaction && open && (baseLock.IsLocked() && Time.realtimeSinceStartup - (float)door.GetFieldValue("decayResetTimeLast") > 60))
                {
                    Decay.RadialDecayTouch(door.transform.position, 40, 270532608);
                    door.SetFieldValue("decayResetTimeLast", Time.realtimeSinceStartup);
                }
            }

            if (doaction)
            {
                door.SetFlag(BaseEntity.Flags.Open, open);
                door.SendNetworkUpdateImmediate(false);
                door.CallMethod("UpdateDoorAnimationParameters", false);
            }
        }
Esempio n. 18
0
 public override void WriteLayerProperties(System.Xml.XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteAttributeString("TimeSeries", TimeSeries.ToString());
     xmlWriter.WriteAttributeString("BeginRange", BeginRange.ToString());
     xmlWriter.WriteAttributeString("EndRange", EndRange.ToString());
     xmlWriter.WriteAttributeString("Decay", Decay.ToString());
     xmlWriter.WriteAttributeString("CoordinatesType", CoordinatesType.ToString());
     xmlWriter.WriteAttributeString("LatColumn", LatColumn.ToString());
     xmlWriter.WriteAttributeString("LngColumn", LngColumn.ToString());
     xmlWriter.WriteAttributeString("GeometryColumn", GeometryColumn.ToString());
     xmlWriter.WriteAttributeString("AltType", AltType.ToString());
     xmlWriter.WriteAttributeString("MarkerMix", MarkerMix.ToString());
     xmlWriter.WriteAttributeString("ColorMap", ColorMap.ToString());
     xmlWriter.WriteAttributeString("MarkerColumn", MarkerColumn.ToString());
     xmlWriter.WriteAttributeString("ColorMapColumn", ColorMapColumn.ToString());
     xmlWriter.WriteAttributeString("PlotType", PlotType.ToString());
     xmlWriter.WriteAttributeString("MarkerIndex", MarkerIndex.ToString());
     xmlWriter.WriteAttributeString("MarkerScale", MarkerScale.ToString());
     xmlWriter.WriteAttributeString("AltUnit", AltUnit.ToString());
     xmlWriter.WriteAttributeString("AltColumn", AltColumn.ToString());
     xmlWriter.WriteAttributeString("StartDateColumn", StartDateColumn.ToString());
     xmlWriter.WriteAttributeString("EndDateColumn", EndDateColumn.ToString());
     xmlWriter.WriteAttributeString("SizeColumn", SizeColumn.ToString());
     xmlWriter.WriteAttributeString("HyperlinkFormat", HyperlinkFormat.ToString());
     xmlWriter.WriteAttributeString("HyperlinkColumn", HyperlinkColumn.ToString());
     xmlWriter.WriteAttributeString("ScaleFactor", ScaleFactor.ToString());
     xmlWriter.WriteAttributeString("PointScaleType", PointScaleType.ToString());
     xmlWriter.WriteAttributeString("ShowFarSide", ShowFarSide.ToString());
     xmlWriter.WriteAttributeString("RaUnits", RaUnits.ToString());
     xmlWriter.WriteAttributeString("HoverTextColumn", NameColumn.ToString());
     xmlWriter.WriteAttributeString("XAxisColumn", XAxisColumn.ToString());
     xmlWriter.WriteAttributeString("XAxisReverse", XAxisReverse.ToString());
     xmlWriter.WriteAttributeString("YAxisColumn", YAxisColumn.ToString());
     xmlWriter.WriteAttributeString("YAxisReverse", YAxisReverse.ToString());
     xmlWriter.WriteAttributeString("ZAxisColumn", ZAxisColumn.ToString());
     xmlWriter.WriteAttributeString("ZAxisReverse", ZAxisReverse.ToString());
     xmlWriter.WriteAttributeString("CartesianScale", CartesianScale.ToString());
     xmlWriter.WriteAttributeString("CartesianCustomScale", CartesianCustomScale.ToString());
     xmlWriter.WriteAttributeString("DynamicData", DynamicData.ToString());
     xmlWriter.WriteAttributeString("AutoUpdate", AutoUpdate.ToString());
     xmlWriter.WriteAttributeString("DataSourceUrl", DataSourceUrl.ToString());
 }
Esempio n. 19
0
        /// <summary>Create a radioactive isotope.</summary>
        /// <param name="z">Proton count.</param>
        /// <param name="a">Nucleon count.</param>
        /// <param name="abundance">Percentage of the isotope to all the element's isotopes or <b>null</b> for synthetics.</param>
        /// <param name="decayMode">Ored bitflags of possible isotope mutations.</param>
        /// <param name="halflife">Time to decay by half scaler.</param>
        /// <param name="timeUnit">Time to decay by half scale.</param>
        /// <exception cref="ArgumentException">When <em>timeUnit</em> not valid.</exception>
        public Isotope(int z, int a, double?abundance, Decay decayMode, double halflife, char timeUnit)
        {
            if (TimeUnitCodes.IndexOf(timeUnit) < 0)
            {
                throw new ArgumentException("Invalid code.", nameof(timeUnit));
            }

            Z         = z;
            A         = a;
            Abundance = abundance;
            DecayMode = decayMode;
            Halflife  = halflife;
            TimeUnit  = timeUnit;
            var hls = HalflifeSeconds;

            StabilityIndex = hls >= 2000000.0 * Nuclide.SecondsPerYear ? 1
                           : hls >= 800.0 * Nuclide.SecondsPerYear ? 2
                           : hls >= 24.0 * 60.0 * 60.0 ? 3
                           : hls >= 10.0 * 60.0 ? 4 : 5;
        }
Esempio n. 20
0
        public override int Read(float[] buffer, int offset, int count)
        {
            float[] input  = new float[buffer.Length];
            float[] decay  = new float[buffer.Length];
            float[] delay  = new float[buffer.Length];
            float[] cutoff = new float[buffer.Length];
            Source.Read(input, offset, count);
            Decay.Read(decay, offset, count);

            for (int i = offset; i < count; i++)
            {
                int   sample_delay = (int)Math.Floor(Math.Min(Math.Max(delay[i], 0.0f), 1.0f) * _waveFormat.SampleRate);
                int   delay_index  = (_buffer_index - sample_delay) % _buffer.Length;
                float x            = input[i] + (_buffer[delay_index] * decay[i]);
                buffer[i] = x;
                _buffer[_buffer_index] = x;
                _buffer_index          = (_buffer_index + 1) % _buffer.Length;
            }
            return(count);
        }
Esempio n. 21
0
        private void Update(EvaluationContext context)
        {
            var bang = Trigger.GetValue(context);

            if (bang != _lastBang)
            {
                if (bang)
                {
                    _lastTriggerTime = (float)EvaluationContext.BeatTime;
                }
                _lastBang = bang;
            }

            var timeSinceTrigger = (float)EvaluationContext.BeatTime - _lastTriggerTime;

            if (timeSinceTrigger < 0)
            {
                timeSinceTrigger = 0;
            }
            Result.Value = Math.Max(Amplitude.GetValue(context) - timeSinceTrigger * Decay.GetValue(context), 0);
        }
Esempio n. 22
0
        private void Update(EvaluationContext context)
        {
            var runTime = context.Playback.FxTimeInBars;

            var wasEvaluatedThisFrame = Math.Abs(runTime - _lastEvalTime) < 0.001f;

            if (wasEvaluatedThisFrame)
            {
                Value.DirtyFlag.Clear();
                Decay.DirtyFlag.Clear();
                return;
            }

            _lastEvalTime = runTime;

            var value = Value.GetValue(context);

            _dampedValue = _dampedValue > value
                               ? MathUtils.Lerp(_dampedValue, value, Decay.GetValue(context))
                               : value;

            Result.Value = _dampedValue;
        }
Esempio n. 23
0
        public DecayInfoView(Decay decay)
        {
            Decay = decay;
            InitializeComponent();
            DecayTypeLabel.Text = decay.Name;
            var dim  = " ev";
            var ener = Decay.DecayEnergy;

            if (decay.DecayEnergy >= 1.0E3)
            {
                dim = " keV"; ener = Decay.DecayEnergy / 1.0E3;
            }
            if (decay.DecayEnergy >= 1.0E6)
            {
                dim = " MeV"; ener = Decay.DecayEnergy / 1.0E6;
            }
            if (decay.DecayEnergy >= 1.0E12)
            {
                dim = " GeV"; ener = Decay.DecayEnergy / 1.0E12;
            }
            EnergyLabel.Text = ener + dim;
            Probability.Text = decay.DecayProbPerc + " %";
        }
Esempio n. 24
0
        private void Update(EvaluationContext context)
        {
            var runTime = EvaluationContext.BeatTime;

            var wasEvaluatedThisFrame = runTime <= _lastEvalTime;

            if (wasEvaluatedThisFrame)
            {
                Value.DirtyFlag.Clear();
                Decay.DirtyFlag.Clear();
                return;
            }

            _lastEvalTime = runTime;

            var value = Value.GetValue(context);

            _dampedValue = _dampedValue > value
                               ? MathUtils.Lerp(_dampedValue, value, Decay.GetValue(context))
                               : value;

            Result.Value = _dampedValue;
        }
Esempio n. 25
0
    private void RPC_OpenDoor(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract() || !this.canHandOpen || (this.IsOpen() || this.IsBusy()) || this.IsLocked())
        {
            return;
        }
        BaseLock slot = this.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (Object.op_Inequality((Object)slot, (Object)null))
        {
            if (!slot.OnTryToOpen(rpc.player))
            {
                return;
            }
            if (slot.IsLocked() && (double)Time.get_realtimeSinceStartup() - (double)this.decayResetTimeLast > 60.0)
            {
                BuildingBlock linkedEntity = this.FindLinkedEntity <BuildingBlock>();
                if (Object.op_Implicit((Object)linkedEntity))
                {
                    Decay.BuildingDecayTouch(linkedEntity);
                }
                else
                {
                    Decay.RadialDecayTouch(((Component)this).get_transform().get_position(), 40f, 2097408);
                }
                this.decayResetTimeLast = Time.get_realtimeSinceStartup();
            }
        }
        this.SetFlag(BaseEntity.Flags.Open, true, false, true);
        this.SendNetworkUpdateImmediate(false);
        if (this.isSecurityDoor && Object.op_Inequality((Object)this.NavMeshLink, (Object)null))
        {
            this.SetNavMeshLinkEnabled(true);
        }
        Interface.CallHook("OnDoorOpened", (object)this, (object)rpc.player);
    }
Esempio n. 26
0
 public static E TriggerAttack(double t0, double e0, double attack, double decay, Amplitude sustainLevel)
 => (t)
 => !HasElapsed(t0, t, attack) ? Attack(t0, e0, attack)(t)
         : !HasElapsed(t0 + attack, t, decay) ? Decay(t0 + attack, e0, decay, sustainLevel)(t)
         : Sustain(sustainLevel)(t);
Esempio n. 27
0
 public void UpdateEpoch(int epoch)
 {
     epochLr = Decay?.Compute(LearningRate, epoch) ?? LearningRate;
 }
Esempio n. 28
0
        public override string ToString()
        {
            string res = "";

            if (MaxHP != 1)
            {
                res += "\n" + Core.SignValue(MaxHP - 1, "P0") + " max HP";
            }
            if (MaxHPBonus != 0)
            {
                res += "\n" + Core.SignValue(MaxHPBonus, "F0") + "x max HP";
            }
            if (ExhaustedStart != 1)
            {
                res += "\n" + ExhaustedStart.ToString("F2") + "x Exhausted condition start HP";
            }
            if (ExhaustedEnd != 1)
            {
                res += "\n" + ExhaustedEnd.ToString("F2") + "x Exhausted condition end HP";
            }
            if (Exposure != 1)
            {
                res += "\n" + Exposure.ToString("F2") + "x Radiation Exposure";
            }

            if (HPChangePerDay != 0)
            {
                res = "\n" + Core.SignValue(HPChangePerDay, "F1") + " HP/day";
            }
            if (Recuperation != 0)
            {
                res += "\n" + Recuperation.ToString("F1") + "%/day Recuperation";
            }
            if (Decay != 0)
            {
                res += "\n" + Decay.ToString("F1") + "%/day Health Decay";
            }
            if (Multiplier != 1)
            {
                res += "\n" + Multiplier.ToString("F2") + "x " + MultiplyFactor + " factor";
            }
            if (Space != 0)
            {
                res += "\n" + Core.SignValue(Space, "F1") + " Living Space";
            }
            if (Shielding != 0)
            {
                res += "\n" + Core.SignValue(Shielding, "F1") + " Shielding";
            }
            if (Radioactivity != 0)
            {
                res += "\n" + Core.SignValue(Radioactivity, "N0") + " banana/day radioactive emission";
            }

            if (AccidentChance != 1)
            {
                res += "\n" + AccidentChance.ToString("F2") + "x Accident chance";
            }
            if (PanicAttackChance != 1)
            {
                res += "\n" + PanicAttackChance.ToString("F2") + "x Panic attack chance";
            }
            if (SicknessChance != 1)
            {
                res += "\n" + SicknessChance.ToString("F2") + "x Sickness chance";
            }
            if (CureChance != 1)
            {
                res += "\n" + CureChance.ToString("F2") + "x Cure chance";
            }
            if (LoseImmunityChance != 1)
            {
                res += "\n" + LoseImmunityChance.ToString("F2") + "x Lose immunity chance";
            }

            string l = Logic.ToString();

            if (l != "")
            {
                res += "\nLogic:\n" + l;
            }

            return(res.Trim());
        }
 public virtual void CompletePendingOrder()
 {
     this.DoTransaction(this.vend_Player, this.vend_sellOrderID, this.vend_numberOfTransactions);
     this.ClearPendingOrder();
     Decay.RadialDecayTouch(base.transform.position, 40f, 2097408);
 }
Esempio n. 30
0
        private void Update(EvaluationContext context)
        {
            var band   = (FrequencyBands)Band.GetValue(context);
            var mode   = (Modes)Mode.GetValue(context);
            var decay  = Decay.GetValue(context);
            var modulo = UseModulo.GetValue(context);

            var t = context.LocalFxTime;

            if (Math.Abs(t - _lastEvalTime) < 0.001f)
            {
                return;
            }

            _lastEvalTime = t;

            //var a = _SetAudioAnalysis.AudioAnalysisResult;

            var results = band == FrequencyBands.Bass
                              ? AudioAnalysisResult.Bass
                              : AudioAnalysisResult.HiHats;

            var peakDetected = results.PeakCount > _lastPeakCount;

            var usingModulo  = modulo > 0;
            var isModuloPeak = peakDetected && (!usingModulo || results.PeakCount % modulo == 0);

            if (peakDetected && isModuloPeak)
            {
                _lastModuloPeakTime = context.Playback.FxTimeInBars;
            }
            var timeSinceModuloPeak = (float)(context.Playback.FxTimeInBars - _lastModuloPeakTime);
            var timeSincePeak       = usingModulo
                                    ? timeSinceModuloPeak
                                    : results.TimeSincePeak;

            float value = 0;

            switch (mode)
            {
            case Modes.TimeSincePeak:

                value = timeSincePeak;
                break;

            case Modes.Count:
                value = usingModulo
                        ? results.PeakCount / modulo
                        : results.PeakCount;
                break;

            case Modes.Peaks:
                value = (float)Math.Max(0, 1 - timeSincePeak * decay);
                break;

            case Modes.PeaksDecaying:
                value = (float)Math.Pow(decay + 1, -timeSincePeak);
                break;

            case Modes.Level:
                value = (float)results.AccumulatedEnergy;
                break;

            case Modes.MovingSum:
                if (double.IsNaN(_movingSum))
                {
                    _movingSum = 0;
                }

                var step = Math.Pow(results.AccumulatedEnergy, decay);
                if (!double.IsNaN(step))
                {
                    _movingSum += step;
                }

                value = (float)(_movingSum % 10000);
                break;

            case Modes.RandomValue:
                if (isModuloPeak)
                {
                    _lastRandomValue = (float)_random.NextDouble();
                }
                value = _lastRandomValue;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Level.Value = value * Amplitude.GetValue(context);

            PeakCount.Value = results.PeakCount;

            PeakDetected.Value = isModuloPeak;
            _lastPeakCount     = results.PeakCount;

            Level.DirtyFlag.Clear();
            PeakCount.DirtyFlag.Clear();
            PeakDetected.DirtyFlag.Clear();
        }