Skip to content
Dmitry Mitrofanov edited this page Jun 20, 2020 · 1 revision

📗 Pixeye Style Guide (PCS)

💡 Note that there can be exceptions to these rules. These rules are forced only for Pixeye Games members or contributors that want to make official tutorials, samples.

The PCS favors a coding-centric approach and is designed for coders, not designers.

Naming rules

  • Use <TYPE><NAME> for classes and structs:

    • ProcessorAI
    • LayerGame
    • ActorAlpaca
    • ComponentHealth
    • MonoDoor
    • SignalAttack
    • TaskMove
  • Use <TYPE><NAME>_<SPECIFICATION> for partial classes:

    • ActorPlayer_DB.cs
    • ActorPlayer_ActionShoot.cs
    • ActorPlayer_AnimationGuide.cs
  • Use plural names for ECS groups.

    • Group<ComponentBehavior> pawns;
  • Use Hungarian Notation for local components you received.

    • var cbehavior = entity.ComponentBehavior();

Indent style

  • Spaces
  • Size: 2

Actor Setup Order

  • Bind Data
  • Bind Tags
  • Bind Components
  • Setup Components
public class ActorStonePiles : Actor
  {
    public DataObject data;
  
    protected override void Setup()
    {
      entity.Bind(data);
      entity.Set(tags.interact);
     
      var cobject      = entity.Set<ComponentObject>();
      var ccolider     = entity.Set<ComponentCollider>();
      var cwork        = entity.Set<ComponentWork>();
 
      // component object
      cobject.position = transform.position;

      // component collider
      ccolider.source.offset = Vector3.zero;
      ccolider.source.size   = 0.65f;

      // component work
      cwork.SetSlots(transform, 0.25f);
      cwork.jobTypes = new[] {tags.pawn_digger};
      cwork.handle    = TaskWorkBreak.Execute;  
    }
  }

💡 There is no DataObject or Data bind in the framework. It's custom example based on the real code of our project.

Ecs Groups

Get all components you are going to work with in one place.

     foreach (var blocker in blockers)
      {
        var cobject  = blocker.ComponentObject();
        var cblocker = blocker.ComponentBlocker();
        var xmin     = cobject.position.x - cblocker.range / 2f;
        var xmax     = cobject.position.x + cblocker.range / 2f;
        // other code 
      }