-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public class GraphBox : IGraphBox { | ||
public float LocalPositionX { get; private set; } | ||
public float LocalPositionY { get; private set; } | ||
|
||
public float GlobalPositionX { get; private set; } | ||
public float GlobalPositionY { get; private set; } | ||
|
||
public float Width { get; private set; } | ||
public float Height { get; private set; } | ||
|
||
public void SetSize (float width, float height) { | ||
Width = width; | ||
Height = height; | ||
} | ||
|
||
public void SetLocalPosition (float x, float y) { | ||
LocalPositionX = x; | ||
LocalPositionY = y; | ||
} | ||
|
||
public void AddGlobalPosition (float x, float y) { | ||
GlobalPositionX += x; | ||
GlobalPositionY += y; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public class GraphContainerHorizontal : IGraphContainer { | ||
protected readonly List<IGraphBox> _childContainers = new List<IGraphBox>(); | ||
|
||
public float LocalPositionX { get; private set; } | ||
public float LocalPositionY { get; private set; } | ||
public float GlobalPositionX { get; private set; } | ||
public float GlobalPositionY { get; private set; } | ||
public float Width { get; protected set; } | ||
public float Height { get; protected set; } | ||
public List<IGraphBox> ChildContainers => _childContainers; | ||
|
||
public void SetLocalPosition (float x, float y) { | ||
LocalPositionX = x; | ||
LocalPositionY = y; | ||
} | ||
|
||
public virtual void AddBox (IGraphBox child) { | ||
CalculateChild(child); | ||
_childContainers.Add(child); | ||
} | ||
|
||
private void CalculateChild (IGraphBox child) { | ||
child.SetLocalPosition(Width, 0); | ||
child.AddGlobalPosition(GlobalPositionX + child.LocalPositionX, GlobalPositionY + child.LocalPositionY); | ||
|
||
Width += child.Width; | ||
if (child.Height > Height) Height = child.Height; | ||
} | ||
|
||
public void SetSize (float width, float height) { | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public void SetGlobalPosition (float x, float y) { | ||
GlobalPositionX = x; | ||
GlobalPositionY = y; | ||
} | ||
|
||
public void AddGlobalPosition (float x, float y) { | ||
GlobalPositionX += x; | ||
GlobalPositionY += y; | ||
|
||
foreach (var child in ChildContainers) { | ||
child.AddGlobalPosition(x, y); | ||
} | ||
} | ||
|
||
public override string ToString () { | ||
return | ||
$"Size: {Width}, {Height}; Local: {LocalPositionX}, {LocalPositionY}; Global: {GlobalPositionX}, {GlobalPositionY};"; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public class GraphContainerVertical : GraphContainerHorizontal { | ||
public override void AddBox (IGraphBox child) { | ||
CalculateChild(child); | ||
_childContainers.Add(child); | ||
} | ||
|
||
private void CalculateChild (IGraphBox child) { | ||
child.SetLocalPosition(0, Height); | ||
child.AddGlobalPosition(GlobalPositionX + child.LocalPositionX, GlobalPositionY + child.LocalPositionY); | ||
|
||
Height += child.Height; | ||
if (child.Width > Width) Width = child.Width; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public interface IGraphBox { | ||
float LocalPositionX { get; } | ||
float LocalPositionY { get; } | ||
float GlobalPositionX { get; } | ||
float GlobalPositionY { get; } | ||
|
||
float Width { get; } | ||
float Height { get; } | ||
|
||
void SetSize (float width, float height); | ||
void SetLocalPosition (float x, float y); | ||
void AddGlobalPosition (float x, float y); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public interface IGraphContainer : IGraphBox { | ||
void AddBox (IGraphBox container); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.