Пример #1
0
 public void AddComponent(BindableComponent component, ICollection <Type> binds)
 {
     foreach (var bind in binds)
     {
         component.AddBinding(bind);
     }
     AddComponent(component);
 }
 private void ApplyKnockback(ProjectileComponent actor, BindableComponent target)
 {
     if (actor.Bindings.TryGetValue(typeof(MovementComponent), out var actorBinding))
     {
         if (target.Bindings.TryGetValue(typeof(MovementComponent), out var targetBinding))
         {
             MovementComponent actorMovement  = actorBinding as MovementComponent;
             MovementComponent targetMovement = targetBinding as MovementComponent;
             targetMovement.Speed.SetVector2(new Coord2(actorMovement.Speed.Cartesian).ChangePolarLength(actor.Knockback).Cartesian);
         }
     }
 }
Пример #3
0
 private void FinalizeBindableComponent(BindableComponent component)
 {
     for (int i = 0; i < component.Bindings.Count; i++)
     {
         Type type = component.Bindings.ElementAt(i).Key;
         if (Components.TryGetValue(type, out var binding))
         {
             component.Bindings[type] = binding;
         }
         else
         {
             throw new ArgumentException("Entity does not contain binding type");
         }
     }
 }
Пример #4
0
 public void AddComponent(BindableComponent component, Type bind)
 {
     component.AddBinding(bind);
     AddComponent(component);
 }