Unsure of how to convert c# public class to javascript

I am working on a tutorial series and recoding everything in Javascript from C#. I am only doing this as the tutorial is perfect for me but not in Javascript. I know enough C# to read some of the lines of code, but not enough to write it from scratch. This particular part makes objects “Living Entities” and allows them to take damage if hit by a projectile.

I have a script called IDamageable.js and so far it only contains the following:

function TakeHit(damage:float,hit:RaycastHit){

}

In C# a script called LivingEntity.cs uses the following lines to somehow connect the IDamageable part:

public class LivingEntity : MonoBehaviour, IDamageable {

}

I am unsure of what the comma does. Like the IDamageable part in that line. So I am unable to ask the question directly of how to implement an [Extend? Value? Whatever?] in Javascript. So my question is, what is the IDamageable parameter called… and how do I do the same thing in Javascript. My apologies in advance, I think my question could be a lot more straight forward if I knew the terminology of the position IDamageable occupies in the C# code.

It’s common practice in coding to name interfaces ISomething so most probably IDamageable is an interface (look up the difference between class and interface if you don’t know already). Any class can have only 1 parent class (MonoBehavioiur in your case) but it can also implement infinite number of interfaces.

Interface is a collection of method headers without body. When implementing an interface in a class you have to write body for all the methods (or it will not compile). Using interface is good for casting different objects in same method, or iterating through them.

For example, in your case you may have an explosion in your scene so you’d write something like:

foreach(IDamagable d in ExplosionZone){
    d.TakeHit(10f);
}

So in this way you can take any class implementing IDamageable like Tiger and DeathStar and cast them in this loop and they will both take hit even though they don’t have a common parent class.

So, for now, in your LivingEntity class you have to implement all the methods that are declared in IDamageable to let your stuff compile.