Exemplo n.º 1
0
 private void PrintData(SmartObject smo)
 {
     Game.Logger.Write(Log.FromPool(PlaceableConfigData(smo.placeableObject.Config)));
     Game.Logger.Write(Log.FromPool(SmartObjectData(smo)));
     Game.Logger.Write(Log.FromPool(PlaceableObjectData(smo.placeableObject)));
     Game.Logger.Write(Log.FromPool($"smo.GetType(): {smo.GetType()}"));
     Game.Logger.Write(Log.FromPool($"isassignable to IJsonSaveable?: {typeof(IJsonSaveable).IsAssignableFrom(smo.GetType())}"));
     //  Game.Logger.Write(Log.FromPool((smo as ToiletUtility)?.leavePosition.ToString()));
 }
Exemplo n.º 2
0
    private RunStatus StartTask(string name, SmartObject user)
    {
        if (this.activeTasks.ContainsKey(name) == true)
            throw new ApplicationException(
                "Attempting to clobber existing active task");

        DebugUtil.Assert(
            this.affordances.ContainsKey(name), "Not found: " + name);
        Affordance affordance = this.affordances[name];

        if (affordance == null)
            throw new ApplicationException(
                "Attempting to activate nonexistent affordance");
        if (affordance.requiredType.IsAssignableFrom(user.GetType()) == false)
            throw new ApplicationException(
                "Wrong user type for affordance execution -- "
                + "Owner: " + this
                + ", User: "******", Affordance: " + name);
        Node node = affordance.BakeTask(this, user);
        this.activeTasks[name] = node;
        node.Start();
        return RunStatus.Running;
    }
Exemplo n.º 3
0
 //Helper Function for SmartObject content string
 public static GUIContent ObjectContentString(SmartObject obj)
 {
     return new GUIContent(obj.gameObject.name + "\n" + obj.GetType().ToString());
 }
Exemplo n.º 4
0
 /// <summary>
 /// Checks whether the given object can be added. Also returns the list of indices where the roles
 /// match the given object's roles.
 /// </summary>
 private bool CanSet(SmartObject obj, out List<int> matching)
 {
     bool matchesRole = false;
     matching = new List<int>();
     for (int i = 0; i < Roles.Length; i++)
     {
         if (CanSet(obj, i))
         {
             matching.Add(i);
             matchesRole = true;
         }
     }
     return obj == null || (NeededType.IsAssignableFrom(obj.GetType()) && matchesRole);
 }