Ejemplo n.º 1
0
    public override void flowFrom(ResourceType resourceType, float quantity, int sourceFlowIteration)
    {
        if (sourceFlowIteration <= flowIteration)
        {
            return;
        }
        flowIteration = sourceFlowIteration;

        storage.resources[resourceType] += quantity;
        var falloff      = resourceFalloff[resourceType];
        var nextQuantity = quantity * falloff;

        if (!ResourceConsumer.isFunctioning(gameObject))
        {
            return;
        }

        foreach (var conduit in Placeable.FindConnectedTo <ResourceReceiver>(GetComponent <Placeable>()))
        {
            conduit.flowFrom(resourceType, nextQuantity, flowIteration);
        }
    }
Ejemplo n.º 2
0
    public void Tick()
    {
        if (!ResourceConsumer.isFunctioning(gameObject))
        {
            return;
        }

        var storage   = GetComponent <ResourceStorage>();
        var placeable = GetComponent <Placeable>();

        foreach (var pair in resourceGeneration)
        {
            if (pair.Value <= 0)
            {
                continue;
            }
            storage.resources[pair.Key] = pair.Value;
            foreach (var conduit in Placeable.FindConnectedTo <ResourceReceiver>(placeable))
            {
                Debug.Log("Flowing " + pair.Key + " to " + conduit.gameObject.name);
                conduit.flowFrom(pair.Key, pair.Value, Ticker.FindTicker().NextFlow());
            }
        }
    }