Beispiel #1
0
 public static void RecalculateGroupFor(MegaMeshComponent component)
 {
     if (component.Group == null)
     {
         return;
     }
     component.Group.RecalculateNextFrame();
 }
    private void Removal(MegaMeshComponent component)
    {
        Components.Remove(component);
        component.Group            = null;
        component.Renderer.enabled = true;

        TotalVertexCount -= component.Mesh.vertexCount;
        DetermineFullness();
    }
Beispiel #3
0
    public static void RemoveComponentImmediatelyOf(GameObject boner)
    {
        MegaMeshComponent cum = boner.GetComponent <MegaMeshComponent>();

        if (cum != null)
        {
            RemoveComponentImmediately(cum);
        }
    }
Beispiel #4
0
    public static void AddComponentOf(GameObject boner)
    {
        MegaMeshComponent cum = boner.GetComponent <MegaMeshComponent>();

        if (cum != null)
        {
            AddComponent(cum);
        }
    }
Beispiel #5
0
    protected void Awake()
    {
        Renderer          = GetComponent <Renderer>();
        MeshFilter        = GetComponent <MeshFilter>();
        MegaMeshComponent = GetComponent <MegaMeshComponent>();

        QueueVisualUpdate();

        AfterAwake();
    }
    public void Initialize()
    {
        transform.parent = StuffConnector.AppropriateConnectionParent(this);

        MegaMeshComponent MMC = gameObject.AddComponent <MegaMeshComponent>();

        MMC.MaterialType = MaterialType.SnappingPeg;
        MegaMeshManager.AddComponent(MMC);

        SetThisAsSnappedConnectionOfPegs();
    }
Beispiel #7
0
 public static void RemoveComponentStaggered(MegaMeshComponent component)
 {
     if (component == null)
     {
         return;
     }
     if (component.Group == null)
     {
         return;
     }
     component.Group.RemoveComponentStaggered(component);
 }
Beispiel #8
0
 public static void RemoveComponentImmediately(MegaMeshComponent component)
 {
     if (component == null)
     {
         return;
     }
     if (component.Group == null)
     {
         return;
     }
     component.Group.RemoveComponentImmediately(component);
 }
Beispiel #9
0
    private static void AddComponentTo(MegaMeshComponent component, HashSet <MegaMeshGroup> GroupList, bool AddAllImmediate = false)
    {
        if (GroupList != null)
        {
            foreach (MegaMeshGroup group in GroupList)
            {
                if (!group.full)
                {
                    group.AddComponent(component, AddAllImmediate); // if any non-full groups are found, add the component to the first one found
                    return;
                }
            }
        }

        // if all groups are full, or if there are no groups, create a new group for the component
        CreateNewGroupFor(component, AddAllImmediate);
    }
Beispiel #10
0
    public static int MaxVerticesPerDynamicMesh = Settings.Get("MaxVerticesPerDynamicMegaMesh", 20000); // dynamic meshes are ones that change while circuitry is running; circuitry itself, displays

    public static void AddComponent(MegaMeshComponent component, bool AddAllImmediate = false)
    {
        if (component == null)
        {
            return;
        }
        if (component.MaterialType == MaterialType.Unknown)
        {
            return;
        }                                                               // don't do this if we don't know what kind of mega mesh to add it to
        if (component.Group != null)
        {
            return;
        }

        HashSet <MegaMeshGroup> grouplist;

        if (component.MaterialType == MaterialType.CircuitBoard)             // the enum check is faster than doing if(component is BoardMegaMeshComponent) according to Stack Overflow
        {
            BoardMegaMeshGroups.TryGetValue(component.Color, out grouplist); // my first time using TryGetValue! grouplist will be set to null if the key doesn't exist
        }
        else if (component.MaterialType == MaterialType.SolidColor)
        {
            SolidColorMegaMeshGroups.TryGetValue(component.Color, out grouplist);
        }
        else // boards are a special case, since we don't know what colors they'll be. Everything else can be handled generically
        {
            if (component.Mesh == null)
            {
                return;
            }
            if (component.Mesh.vertexCount > MaxVerticesPerDynamicMesh)
            {
                return;
            }                                                                       // if a cluster or output has exceeded the complexity allowed for a mega mesh group, not much point adding it to the group...

            StandardizedMegaMeshGroups.TryGetValue(component.MaterialType, out grouplist);
        }

        AddComponentTo(component, grouplist);
    }
    public void AddComponent(MegaMeshComponent component, bool AlwaysAddImmediate = false)
    {
        if (component.MaterialType != MaterialType)
        {
            Debug.LogError("component material type does not match group"); return;
        }

        Components.Add(component);
        component.Group = this;

        if (MegaMeshManager.IsDynamicMaterialType(this) && !AlwaysAddImmediate)
        {
            RecalculateNextOpportunity();
        }
        else
        {
            RecalculateNextFrame();
        }

        TotalVertexCount += component.Mesh.vertexCount;
        DetermineFullness();
    }
Beispiel #12
0
    private static void CreateNewGroupFor(MegaMeshComponent component, bool AddImmediate = false)
    {
        MegaMeshGroup newgroup = Object.Instantiate(Prefabs.CombinedMeshGroup, Transforms.MegaMeshParent).AddComponent <MegaMeshGroup>();

        newgroup.MaterialType = component.MaterialType;

        // add newgroup to the appropriate list inside the appropriate dictionary. If the appropriate list doesn't exist, create it
        if (component.MaterialType == MaterialType.CircuitBoard)
        {
            if (!BoardMegaMeshGroups.ContainsKey(component.Color))
            {
                BoardMegaMeshGroups.Add(component.Color, new HashSet <MegaMeshGroup>());
            }
            BoardMegaMeshGroups[component.Color].Add(newgroup);

            newgroup.Renderer.material = Materials.BoardOfColor(component.Color);
        }
        else if (component.MaterialType == MaterialType.SolidColor)
        {
            if (!SolidColorMegaMeshGroups.ContainsKey(component.Color))
            {
                SolidColorMegaMeshGroups.Add(component.Color, new HashSet <MegaMeshGroup>());
            }
            SolidColorMegaMeshGroups[component.Color].Add(newgroup);

            newgroup.Renderer.material = Materials.SolidColor(component.Color);
        }
        else
        {
            SetNonColorableGroupMaterial(newgroup);
            if (!StandardizedMegaMeshGroups.ContainsKey(component.MaterialType))
            {
                StandardizedMegaMeshGroups.Add(component.MaterialType, new HashSet <MegaMeshGroup>());
            }
            StandardizedMegaMeshGroups[component.MaterialType].Add(newgroup);
        }

        newgroup.AddComponent(component, AddImmediate); // add the component to the new group
    }
 public void RemoveComponentImmediately(MegaMeshComponent component)
 {
     Removal(component);
     RecalculateNextFrame();
 }
 public void RemoveComponentStaggered(MegaMeshComponent component)
 {
     Removal(component);
     RecalculateNextOpportunity();
 }
 private void Awake()
 {
     ThisCollider      = GetComponent <BoxCollider>();
     Renderer          = GetComponent <Renderer>();
     MegaMeshComponent = GetComponent <MegaMeshComponent>();
 }
Beispiel #16
0
 public static bool IsDynamicMaterialType(MegaMeshComponent component)
 {
     return(IsDynamicMaterialType(component.MaterialType));
 }