Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/RNGAction.cs
T
Juan Pablo Arce 0002ad2c50 v0.10.5.1
2020-09-22 11:31:56 -03:00

28 lines
768 B
C#

using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma
{
class RNGAction : BinaryOptionAction
{
[Serialize(0.0f, true)]
public float Chance { get; set; }
public RNGAction(ScriptedEvent parentEvent, XElement element) : base(parentEvent, element) { }
private bool isFinished;
protected override bool? DetermineSuccess()
{
isFinished = true;
return Rand.Range(0.0, 1.0) <= Chance;
}
public override string ToDebugString()
{
return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(RNGAction)} -> (Chance: {Chance.ColorizeObject()}, "+
$"Succeeded: {succeeded.ColorizeObject()})";
}
}
}