public ResourceClassTests() { money = new Money(); prototype = new Prototypes(); usecase = new UseCases(); userstory = new UserStories(); }
protected void ReadPrototypeEntry(BinaryStream stream) { long uid = 0; if (Use64Bit) { uid = stream.ReadInt64(); } else { uid = stream.ReadUInt32(); } var buffer = (Use64Bit) ? BitConverter.GetBytes(uid) : BitConverter.GetBytes((uint)uid); var lookup = new EntityPrototypeInfo(stream, 8); var obj = Context.GetRefByPtr(lookup.Offset) as NomadObject; if (obj == null) { throw new InvalidDataException($"Couldn't find library '{uid:X8}' at offset {lookup.Offset:X8}!"); } // remove before writing var libId = new NomadValue("UID", DataType.BinHex, buffer); obj.Attributes.Add(libId); Prototypes.Add(uid, obj); }
/// <summary> /// Perform all the actions needed to spawn a new station /// </summary> /// <param name="shape">Shape index</param> /// <param name="position">World position</param> private void SpawnNewStation(int shape, Vector3 position) { Station station = Prototypes.CreateStation(shape, position, shapeGraphicMap[shape]); stations.Add(station); OnStationCreate?.Invoke(station); }
/// <summary> /// Perform all the actions needed to spawn a new airplane /// </summary> /// <param name="shape">Shape index</param> /// <param name="position">World position</param> private void SpawnNewAirplane(Vector3 position) { Airplane airplane = Prototypes.CreateAirplane(position, shapeGraphicMap[4]); airplanes.Add(airplane); OnAirplaneCreate?.Invoke(airplane); }
protected override void Awake( ) { base.Awake( ); foreach (var kv in _prototypes) { Prototypes.Add(kv.Key, kv.Value); } }
public static void registerPrototype(System.String className) { Prototypes.addString(className); try { //UPGRADE_TODO: The differences in the format of parameters for method 'java.lang.Class.forName' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" PrototypeFactory.getInstance(System.Type.GetType(className)); } //UPGRADE_NOTE: Exception 'java.lang.ClassNotFoundException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'" catch (System.Exception e) { throw new CannotCreateObjectException(className + ": not found"); } rebuild(); }
private Dictionary <Station, TextMeshProUGUI> stationTextMap; // Does not support deleting stations private void Awake() { canvas = Prototypes.CreateCanvas(); RectTransform canvasRectTransform = canvas.GetComponent <RectTransform>(); canvasSizeDelta = canvasRectTransform.sizeDelta; canvasOffset = new Vector2(canvasSizeDelta.x * 0.5f, canvasSizeDelta.y * 0.5f); airplaneTextMap = new Dictionary <Airplane, TextMeshProUGUI>(); stationTextMap = new Dictionary <Station, TextMeshProUGUI>(); GameMaster.Instance.OnAirplaneCreate += OnAirplaneCreate; GameMaster.Instance.OnAirplaneDelete += OnAirplaneDelete; GameMaster.Instance.OnStationCreate += OnStationCreate; }
/// <summary> /// Sets the GameMaster up with only essentials. No game data involved. /// </summary> private void ConstructEmptyWorld() { uiManager = gameObject.AddComponent <UiManager>(); inputManager = gameObject.AddComponent <InputManager>(); LinePool = Prototypes.CreateLineFactory(); MainCamera = Prototypes.CreateMainCamera(); stations = new List <Station>(); airplanes = new List <Airplane>(); shapeGraphicMap = new Dictionary <int, RuntimeAnimatorController>() { { 0, Resources.Load <RuntimeAnimatorController> ("Animations/new_box_animator") }, { 1, Resources.Load <RuntimeAnimatorController> ("Animations/new_cross_animator") }, { 2, Resources.Load <RuntimeAnimatorController> ("Animations/triangle_animator") }, { 3, Resources.Load <RuntimeAnimatorController> ("Animations/octagon_animator") }, { 4, Resources.Load <RuntimeAnimatorController> ("Animations/airplane_animator") } }; }
public override Symbol CreateModel(string key) { return(new SymbolCreate() { Path = key, Import = Import, Type = Type, Prototypes = Prototypes.Select((e) => new SymbolCreate.Prototype { Description = e.Description, Proto = e.Proto, Parameters = e.Parameters.Select((p) => new SymbolCreate.Prototype.Parameter() { Description = p.Description, Proto = p.Proto, Ref = p.Ref }).ToArray() }).ToArray(), Symbols = Symbols }.CreateModel()); }
/// <summary> /// This is used to create the object prototype. Use <see cref="Furniture.Placeinstance(Furniture, Tile)"/> /// to place an object onto a tile. /// </summary> /// <param name="type">Identifies the object's type.</param> /// <param name="movementCost">A multiplier that (inversely) modifies the effective movement speed across the tile. /// Can be combined with others. Set to 0 for an impassable tile.</param> /// <param name="width">The width of the object from the upper left.</param> /// <param name="height">The height of the object from the upper left.</param> /// <returns>A reference to the prototype. Returns null if a prototype of the same name already exists.</returns> public static Furniture CreatePrototype(string type, float movementCost = 1f, int width = 1, int height = 1, bool linksToNeighbours = false) { Furniture obj = new Furniture(); obj.Type = type; obj.movementCost = movementCost; obj.width = width; obj.height = height; obj.LinksToNeighbours = linksToNeighbours; obj.funcValidatePosition = obj.IsPositionValid; if (Prototypes.ContainsKey(type)) { GD.Print("Unable to create prototype " + type + "."); return(null); } else { Prototypes.Add(type, obj); return(obj); } }
public static void Init() { prototypes.Add(Prototypes.Tile()); prototypes.Add(Prototypes.Conveyor()); prototypes.Add(Prototypes.Parcel()); }
/// <exception cref="System.Exception"></exception> public virtual void SetUp() { _prototypes = new Prototypes(Prototypes.DefaultReflector(), RecursionDepth, IgnoreTransientFields ); }
private void OnStationCreate(Station station) { stationTextMap[station] = Prototypes.CreateText(canvas.transform, Vector3.zero, "yo"); }
private void OnAirplaneCreate(Airplane airplane) { airplaneTextMap[airplane] = Prototypes.CreateText(canvas.transform, Vector3.zero, "yo"); }
public void CallFunction(List <object> Stack, Registers registers) { Delegate FuncDelegate = Prototypes.GetDelegate(lib, func); if (FuncDelegate != null) { object[] tmp = Stack.ToArray(); Array.Reverse(tmp); List <Type> Types = new List <Type>(); List <object> ReversedStack = new List <object>(tmp); tmp = null; ParameterInfo[] param = FuncDelegate.Method.GetParameters(); if (param.Length != ReversedStack.Count) { throw new Exception("Parameter count does not match"); } List <IntPtr> Allocations = new List <IntPtr>(); for (int i = 0; i < param.Length; i++) { Types.Add(ReversedStack[i].GetType()); if (param[i].ParameterType != ReversedStack[i].GetType()) { //ReversedStack[i] = EasyConvert.Convert<IntPtr>(ReversedStack[i]); unsafe { if (ReversedStack[i].GetType() == typeof(byte[])) fixed(byte *p = (byte[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(short[])) fixed(short *p = (short[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(ushort[])) fixed(ushort *p = (ushort[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(int[])) fixed(int *p = (int[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(uint[])) fixed(uint *p = (uint[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(long[])) fixed(long *p = (long[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(ulong[])) fixed(ulong *p = (ulong[])ReversedStack[i]) ReversedStack[i] = new IntPtr(p); else if (ReversedStack[i].GetType() == typeof(byte)) { if (param[i].ParameterType.ToString().Contains("*")) { ReversedStack[i] = new IntPtr((byte *)((byte)ReversedStack[i])); } } else if (ReversedStack[i].GetType() == typeof(short)) { if (param[i].ParameterType.ToString().Contains("*")) { ReversedStack[i] = new IntPtr((short *)((short)ReversedStack[i])); } } else if (ReversedStack[i].GetType() == typeof(int)) { if (param[i].ParameterType.ToString().Contains("*")) { ReversedStack[i] = new IntPtr((int *)((int)ReversedStack[i])); } } else if (ReversedStack[i].GetType() == typeof(uint)) { if (param[i].ParameterType.ToString().Contains("*")) { ReversedStack[i] = new IntPtr((uint *)((uint)ReversedStack[i])); } } else if (ReversedStack[i].GetType() == typeof(long)) { if (param[i].ParameterType.ToString().Contains("*")) { ReversedStack[i] = new IntPtr((long *)((long)ReversedStack[i])); } } else if (ReversedStack[i].GetType() == typeof(ulong)) { if (param[i].ParameterType.ToString().Contains("*")) { ReversedStack[i] = new IntPtr((ulong *)((ulong)ReversedStack[i])); } } else { //throw new Exception("CALL could not be executed because this type is not supported yet, " + param[i].ParameterType.ToString()); } } } } Delegate del = Marshal.GetDelegateForFunctionPointer(new IntPtr(FuncAddress), FuncDelegate.GetType()); if (del.Method.ReturnType == typeof(bool)) { registers.EAX = (bool)del.DynamicInvoke(ReversedStack.ToArray()) ? 1 : 0; } else if (del.Method.ReturnType == typeof(byte) || del.Method.ReturnType == typeof(Int16) || del.Method.ReturnType == typeof(Int32) || del.Method.ReturnType == typeof(Int64) || del.Method.ReturnType == typeof(UInt16) || del.Method.ReturnType == typeof(UInt32) || del.Method.ReturnType == typeof(UInt64)) { registers.EAX = Convert.ToInt32(del.DynamicInvoke(ReversedStack.ToArray())); } else if (del.Method.ReturnType == typeof(IntPtr)) { registers.EAX = ((IntPtr)del.DynamicInvoke(ReversedStack.ToArray())).ToInt32(); } else if (del.Method.ReturnType == typeof(UIntPtr)) { registers.EAX = (int)((UIntPtr)del.DynamicInvoke(ReversedStack.ToArray())).ToUInt32(); } else //more types need to be added here { del.DynamicInvoke(ReversedStack.ToArray()); } } else { //Execute function at Address throw new Exception("Unable to execute function, Delegate not found for " + lib + "." + func); } Stack.Clear(); }
/// <summary> /// Searches for prototypes with following prefix /// </summary> /// <param name="prefix"></param> /// <returns></returns> public IEnumerable <AgentPrototype> GetPrototypesWithPrefix(string prefix) { return(Prototypes.Where(prototype => prototype.NamePrefix == prefix)); }