Restore the stable legacy Unity project
This commit is contained in:
parent
56a156ee87
commit
7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions
|
|
@ -5,8 +5,9 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using Ink;
|
||||
using Ink.Parsed;
|
||||
using MessagePack;
|
||||
using Path = System.IO.Path;
|
||||
using Random = CultMath.Random;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
using Story = Ink.Runtime.Story;
|
||||
|
||||
public class StoryProcessor : IZoneResolver, IFactionResolver
|
||||
|
|
@ -33,11 +34,11 @@ public class StoryProcessor : IZoneResolver, IFactionResolver
|
|||
public DirectoryInfo NarrativeDirectory { get; }
|
||||
private Random _random;
|
||||
public Galaxy Galaxy { get; }
|
||||
public RuntimePlayerSettings Settings { get; }
|
||||
public PlayerSettings Settings { get; }
|
||||
|
||||
private Action<string> Log { get; }
|
||||
|
||||
public StoryProcessor(RuntimePlayerSettings settings, DirectoryInfo narrativeDirectory, Galaxy galaxy, ref Random random, Action<string> log)
|
||||
public StoryProcessor(PlayerSettings settings, DirectoryInfo narrativeDirectory, Galaxy galaxy, ref Random random, Action<string> log)
|
||||
{
|
||||
NarrativeDirectory = narrativeDirectory;
|
||||
Galaxy = galaxy;
|
||||
|
|
@ -105,6 +106,20 @@ public class StoryProcessor : IZoneResolver, IFactionResolver
|
|||
// If the story has already been read / compiled, return it directly
|
||||
if (_processedStories.ContainsKey(fileName)) return _processedStories[fileName];
|
||||
|
||||
// var compiledFileName = Path.Combine(inkFile.Directory.FullName, $"{fileName}.json");
|
||||
//
|
||||
// // Calculate a hash of the ink file
|
||||
// var hash = File.ReadAllBytes(inkFile.FullName).GetHashSHA1();
|
||||
//
|
||||
// if (File.Exists(compiledFileName) && // If a compiled version of the ink file exists
|
||||
// Settings.HashedStoryFiles.ContainsKey(fileName) && // And its hash has been saved
|
||||
// hash == Settings.HashedStoryFiles[fileName]) // And the saved hash matches the current hash
|
||||
// {
|
||||
// // Load the story from the existing compiled JSON representation
|
||||
// return new Story(File.ReadAllText(compiledFileName));
|
||||
// }
|
||||
//
|
||||
// Settings.HashedStoryFiles[fileName] = hash;
|
||||
var compiler = new Compiler(File.ReadAllText(inkFile.FullName), new Compiler.Options
|
||||
{
|
||||
countAllVisits = true,
|
||||
|
|
@ -113,6 +128,7 @@ public class StoryProcessor : IZoneResolver, IFactionResolver
|
|||
var story = compiler.Compile();
|
||||
var knots = compiler.parsedStory.FindAll<Knot>().Select(k=>k.runtimePath.ToString()).ToArray();
|
||||
_storyKnotPaths[story] = knots;
|
||||
//File.WriteAllText(compiledFileName, story.ToJson());
|
||||
_processedStories[fileName] = story;
|
||||
return story;
|
||||
}
|
||||
|
|
@ -239,4 +255,4 @@ public class StoryProcessor : IZoneResolver, IFactionResolver
|
|||
|
||||
return contentTags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ public class FactionPresenceConstraint : ZoneConstraint
|
|||
|
||||
protected override bool TestZone(GalaxyZone zone)
|
||||
{
|
||||
return zone.Factions.Any(f => f.HasSameKey(TargetFaction));
|
||||
return zone.Factions.Any(f=>f.ID == TargetFaction?.ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ public class FactionOwnerConstraint : ZoneConstraint
|
|||
|
||||
protected override bool TestZone(GalaxyZone zone)
|
||||
{
|
||||
return zone.Owner?.HasSameKey(TargetFaction) ?? false;
|
||||
return zone.Owner.ID == TargetFaction?.ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,4 +86,4 @@ public class DistanceConstraint : ZoneConstraint
|
|||
{
|
||||
return _targetZone != null && _test(zone.Distance[_targetZone]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Random = CultMath.Random;
|
||||
using MessagePack;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
|
||||
public abstract class ZoneSelector
|
||||
{
|
||||
|
|
@ -47,4 +48,4 @@ public class RandomSelector : ZoneSelector
|
|||
{
|
||||
return candidates[Random.NextInt(candidates.Count)];
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue