public void RefreshGraph(IGraphOwner graphOwner) { mGraph = new Graph(); mGraph.Directed = true; mGraph.LayoutAlgorithmSettings = new SugiyamaLayoutSettings(); if (mCurrentGraphRoot != null) { HashSet <GameMasterNode> campaignNodes = new HashSet <GameMasterNode>(); mCurrentGraphRoot.NodeData.GetRelatedNodes(campaignNodes); foreach (GameMasterNode node in campaignNodes) { GameMasterNodeType nodeType = node.NodeType; if (nodeType == GameMasterNodeType.CAMP_PIECE || nodeType == GameMasterNodeType.UNKNOWN) { // Do not add camp pieces or unknown node types. continue; } if (node.NodeData != null) { node.NodeData.UpdateGraph(mGraph); } } graphOwner.SetGraph(mGraph); } }
public override void Initialize(IGraphOwner _graphOwner) { base.Initialize(_graphOwner); GOAPAgent agent = _graphOwner as GOAPAgent; if (AvailableActions == null) { AvailableActions = new List <GOAPAction>(); } else { AvailableActions.Clear(); } foreach (var node in Nodes) { if (node.Value is GOAPAction action) { AvailableActions.Add(action); } } AvailableActions.QuickSort((a, center) => { if (a.Position.y > center.Position.y) { return(true); } return(false); }); foreach (var action in AvailableActions) { action.Initialize(agent); } }
public void OnCampaignSelected(IGraphOwner graphOwner, TreeNode selectedNode) { if (selectedNode.Parent != null && !selectedNode.Parent.Text.Equals("campaigns")) { string module = selectedNode.Parent.Text; SelectCampaign(graphOwner, selectedNode.Parent.Text, selectedNode.Text); } }
public void TryModifyJson(IGraphOwner graphOwner, GameMasterNode node, string newJsonString) { if (node.TryModifyJson(newJsonString)) { node.OnFileChanged(mGameMasterNodes); RefreshGraph(graphOwner); } }
void ReloadGraph() { IGraphOwner tempGraphOwner = GraphOwner; SetUp((GraphAsset as IGraphAsset).Graph); GraphOwner = tempGraphOwner; if (Graph != null && GraphOwner != null) { GraphView.Model.InitializePropertyMapping(GraphOwner); } }
public void SelectCampaign(IGraphOwner graphOwner, string module, string name) { foreach (GameMasterNode node in mCampaignNodes) { if (name.Equals(node.Name) && node.Module.Equals(module)) { mCurrentGraphRoot = node; RefreshGraph(graphOwner); } } }
public bool CloneNode(IGraphOwner graphOwner, GameMasterNode original, string cloneName) { GameMasterNode newNode = original.Clone(cloneName); mGameMasterNodes.Add(newNode.Path, newNode); if (newNode.Owner == null) { CampaignNodeData campaignNodeData = mCurrentGraphRoot.NodeData as CampaignNodeData; campaignNodeData.OrphanedNodes.Add(newNode); newNode.Owner = mCurrentGraphRoot; } RefreshGraph(graphOwner); return(false); }
public bool AddNewGenericScriptNode(IGraphOwner owner, string scriptNodeName, string filePath) { if (mCurrentGraphRoot == null) { return(false); } EncounterScriptFile scriptFile = mGenericScriptNodes[scriptNodeName]; scriptFile.WriteDefaultToFile(filePath); GameMasterNode newNode = new GameMasterNode(mCurrentGraphRoot.Module, filePath); mGameMasterNodes.Add(newNode.Path, newNode); newNode.Load(mGameMasterNodes); string nodeName = Path.GetFileNameWithoutExtension(filePath); CampaignNodeData campaignNodeData = mCurrentGraphRoot.NodeData as CampaignNodeData; string arcsDir = Path.GetFullPath(Path.Combine(campaignNodeData.NodeFile.Path, "..", "arcs")).ToUpperInvariant(); string filePathUpper = Path.GetFullPath(filePath).ToUpperInvariant(); bool foundMatchingArc = false; foreach (var arcNode in campaignNodeData.GetAllArcs()) { string arcDir = Path.GetFullPath(Path.Combine(arcNode.Path, "..")).ToUpperInvariant(); if (filePathUpper.StartsWith(arcDir)) { // Add new node to arc's index file (ex. game_events_arc) using nodeName as the key (arcNode.NodeData as ArcNodeData).AddEncounter(newNode.NodeData as EncounterNodeData); newNode.Owner = arcNode; foundMatchingArc = true; break; } } if (!foundMatchingArc) { (mCurrentGraphRoot.NodeData as CampaignNodeData).OrphanedNodes.Add(newNode); newNode.Owner = mCurrentGraphRoot; } newNode.IsModified = true; newNode.SaveIfNecessary(); RefreshGraph(owner); return(true); }
public bool AddNewGenericScriptNode(IGraphOwner owner, string scriptNodeName, string filePath) { if (mCurrentGraphRoot == null) { return false; } EncounterScriptFile scriptFile = mGenericScriptNodes[scriptNodeName]; scriptFile.WriteDefaultToFile(filePath); GameMasterNode newNode = new GameMasterNode(mCurrentGraphRoot.Module, filePath); mGameMasterNodes.Add(newNode.Path, newNode); newNode.Load(mGameMasterNodes); string nodeName = Path.GetFileNameWithoutExtension(filePath); CampaignNodeData campaignNodeData = mCurrentGraphRoot.NodeData as CampaignNodeData; string arcsDir = Path.GetFullPath(Path.Combine(campaignNodeData.NodeFile.Path, "..", "arcs")).ToUpperInvariant(); string filePathUpper = Path.GetFullPath(filePath).ToUpperInvariant(); bool foundMatchingArc = false; foreach (var arcNode in campaignNodeData.GetAllArcs()) { string arcDir = Path.GetFullPath(Path.Combine(arcNode.Path, "..")).ToUpperInvariant(); if (filePathUpper.StartsWith(arcDir)) { // Add new node to arc's index file (ex. game_events_arc) using nodeName as the key (arcNode.NodeData as ArcNodeData).AddEncounter(newNode.NodeData as EncounterNodeData); newNode.Owner = arcNode; foundMatchingArc = true; break; } } if (!foundMatchingArc) { (mCurrentGraphRoot.NodeData as CampaignNodeData).OrphanedNodes.Add(newNode); newNode.Owner = mCurrentGraphRoot; } newNode.IsModified = true; newNode.SaveIfNecessary(); RefreshGraph(owner); return true; }
public void RefreshGraph(IGraphOwner graphOwner) { mGraph = new Graph(); mGraph.Directed = true; mGraph.LayoutAlgorithmSettings = new SugiyamaLayoutSettings(); if (mCurrentGraphRoot != null) { HashSet<GameMasterNode> campaignNodes = new HashSet<GameMasterNode>(); mCurrentGraphRoot.NodeData.GetRelatedNodes(campaignNodes); foreach (GameMasterNode node in campaignNodes) { GameMasterNodeType nodeType = node.NodeType; if (nodeType == GameMasterNodeType.CAMP_PIECE || nodeType == GameMasterNodeType.UNKNOWN) { // Do not add camp pieces or unknown node types. continue; } if (node.NodeData != null) { node.NodeData.UpdateGraph(mGraph); } } graphOwner.SetGraph(mGraph); } }
public CloneDialogCallback(IGraphOwner viewer, GameMasterNode node) { mViewer = viewer; mNode = node; }
public virtual void Initialize(IGraphOwner _graphOwner) { }
public override void Initialize(IGraphOwner _graphOwner) { Agent = _graphOwner as GOAPAgent; OnInitialized(); }
public virtual void Initialize(IGraphOwner _graphOwner) { InitializePropertyMapping(_graphOwner); }
public bool CloneNode(IGraphOwner graphOwner, GameMasterNode original, string cloneName) { GameMasterNode newNode = original.Clone(cloneName); mGameMasterNodes.Add(newNode.Path, newNode); if (newNode.Owner == null) { CampaignNodeData campaignNodeData = mCurrentGraphRoot.NodeData as CampaignNodeData; campaignNodeData.OrphanedNodes.Add(newNode); newNode.Owner = mCurrentGraphRoot; } RefreshGraph(graphOwner); return false; }